Index.js 69 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591
  1. MWF.xApplication.CRM = MWF.xApplication.CRM || {};
  2. MWF.xDesktop.requireApp("Template", "MForm", null, false);
  3. MWF.xDesktop.requireApp("CRM", "Template", null,false);
  4. MWF.xDesktop.requireApp("Template", "Explorer", null,false);
  5. MWF.require("MWF.widget.O2Identity", null, false);
  6. MWF.xDesktop.requireApp("Selector", "package", null, false);
  7. MWF.xDesktop.requireApp("CRM", "ClueEdit", null,false);
  8. MWF.xDesktop.requireApp("CRM", "Customer", null,false);
  9. MWF.xDesktop.requireApp("CRM", "CustomerEdit", null,false);
  10. MWF.xDesktop.requireApp("CRM", "Contacts", null,false);
  11. MWF.xDesktop.requireApp("CRM", "ContactsEdit", null,false);
  12. MWF.xDesktop.requireApp("CRM", "Chance", null,false);
  13. MWF.xDesktop.requireApp("CRM", "ChanceEdit", null,false);
  14. MWF.xApplication.CRM.AddressExplorer={};
  15. /*MWF.xApplication.CRM.Chance={};*/
  16. /*MWF.require("MWF.widget.Identity", null,false);
  17. MWF.xDesktop.requireApp("Forum", "Actions.RestActions", null, false);*/
  18. MWF.xApplication.CRM.Index = new Class({
  19. Extends: MWF.widget.Common,
  20. Implements: [Options, Events],
  21. options: {
  22. "style": "default"
  23. },
  24. initialize: function (node, app, actions, options) {
  25. this.setOptions(options);
  26. this.app = app;
  27. this.lp = app.lp.index;
  28. this.path = "../x_component_CRM/$Index/";
  29. this.loadCss();
  30. this.actions = actions;
  31. //this.node = $(node);
  32. this.node = node;
  33. this.configData = [];
  34. var now = new Date(); //当前日期
  35. var nowYear = now.getYear();
  36. nowYear += (nowYear < 2000) ? 1900 : 0; //
  37. this.nowDayOfWeek = now.getDay(); //今天本周的第几天
  38. this.nowDay = now.getDate(); //当前日
  39. this.nowMonth = now.getMonth(); //当前月
  40. this.nowYear = nowYear;//当前年
  41. this.now = now;
  42. },
  43. loadCss: function () {
  44. this.cssPath = "../x_component_CRM/$Index/" + this.options.style + "/css.wcss";
  45. this._loadCss();
  46. },
  47. load: function () {
  48. //this.testActions = new MWF.xApplication.Forum.Actions.RestActions();
  49. if(this.formContentArr)this.formContentArr.empty();
  50. this.formContentArr = [];
  51. if(this.formMarkArr)this.formMarkArr.empty();
  52. this.formMarkArr = [];
  53. /*MWF.xDesktop.requireApp("CRM", "$Chance.default."+o2.language, {
  54. "failure": function(){
  55. MWF.xDesktop.requireApp("CRM", "$Chance.default.zh-cn", null, false);
  56. }.bind(this)
  57. }, false);*/
  58. this.rightContentDiv = this.rightContentDiv || this.app.rightContentDiv;
  59. this.loadResource(function(){
  60. this.appArea = jQuery("body").children(":first");
  61. this.createHeadContent();
  62. this.createIndexContent();
  63. }.bind(this))
  64. /*this.resizeWindow();
  65. console.log("x7777");
  66. this.app.addEvent("resize", function(){
  67. this.resizeWindow();
  68. }.bind(this));*/
  69. },
  70. reload:function(){
  71. this.createIndexContent();
  72. //this.resizeWindow();
  73. },
  74. loadResource: function ( callback ) {
  75. var baseUrls = [
  76. "../x_component_CRM/$Template/plugins/jquery.min.js",
  77. ];
  78. var fullcalendarUrl = "../x_component_CRM/$Template/plugins/layui/layui.js";
  79. var langUrl = "../x_component_CRM/$Template/plugins/table2/table2.js";
  80. COMMON.AjaxModule.loadCss("../x_component_CRM/$Template/plugins/table2/css/table2.css",function(){
  81. COMMON.AjaxModule.load(baseUrls, function(){
  82. jQuery.noConflict();
  83. COMMON.AjaxModule.load(fullcalendarUrl, function(){
  84. COMMON.AjaxModule.load(langUrl, function(){
  85. COMMON.AjaxModule.loadCss("../x_component_CRM/$Template/assets/css/notifyme.css", function(){
  86. COMMON.AjaxModule.loadCss("../x_component_CRM/$Template/date/css/jquery-ui.css", function(){
  87. COMMON.AjaxModule.load("../x_component_CRM/$Template/date/jquery-ym-datePlugin-0.1.js", function(){
  88. COMMON.AjaxModule.load("../x_component_CRM/$Template/assets/js/notifyme.js", function(){
  89. COMMON.AjaxModule.load("../x_component_CRM/$Template/assets/js/showBo.js", function(){
  90. COMMON.AjaxModule.load("../x_component_CRM/$Template/assets/js/echarts.min.js", function(){
  91. COMMON.AjaxModule.load("../x_component_CRM/$Template/assets/js/china.js", function(){
  92. if(callback)callback();
  93. }.bind(this));
  94. }.bind(this));
  95. }.bind(this));
  96. }.bind(this));
  97. }.bind(this));
  98. }.bind(this))
  99. }.bind(this))
  100. }.bind(this));
  101. }.bind(this));
  102. }.bind(this))
  103. }.bind(this))
  104. },
  105. createHeadContent:function(){
  106. _self = this;
  107. if(jQuery(".openDiv").length > 0) jQuery(".openDiv").remove();
  108. jQuery(_self.appArea).after("<div class='openDiv'></div>")
  109. jQuery(".openDiv").before("<div></div>");
  110. if(jQuery("#layout").length > 0)jQuery(_self.appArea).find(".MWF_dialod_title_action").find("div").eq(1).hide();
  111. if(this.headContentDiv) this.headContentDiv.destroy();
  112. this.headContentDiv = new Element("div.headContentDiv",{"styles":this.css.headContentDiv}).inject(this.rightContentDiv);
  113. this.headHomeDiv = new Element("div.headHomeDiv",{"styles":this.css.headHomeDiv}).inject(this.headContentDiv);
  114. this.headHomeImg = new Element("img.headHomeImg",{
  115. "styles":this.css.headHomeImg,
  116. "src": this.path+"default/icons/homePage.png"
  117. }).inject(this.headHomeDiv);
  118. this.headTitleDiv = new Element("div.headTitleDiv",{
  119. "styles":this.css.headTitleDiv,
  120. }).inject(this.headContentDiv);
  121. this.headTitleinDiv = new Element("div.headTitleinDiv",{
  122. "styles":this.css.mark_header,
  123. "text":this.lp.head.headTitle
  124. }).inject(this.headTitleDiv);
  125. this.user_lineDiv = new Element("div.user_line",{
  126. "styles":this.css.user_line
  127. }).inject(this.headContentDiv);
  128. this.user_changeDiv = new Element("div.user_change",{
  129. "styles":this.css.user_change,
  130. "text":"切换"
  131. }).inject(this.headContentDiv);
  132. //select
  133. this.selectDiv = new Element("div.se-select",{"styles":this.css.selectDiv}).inject(this.headContentDiv);
  134. this.selectnameDiv = new Element("div.se-select-name",{
  135. "styles":this.css.selectname,
  136. "text":"本年"
  137. }).inject(this.selectDiv);
  138. this.arrowdownDiv = new Element("div.el-icon-arrow-down", {"styles":this.css.arrowdown}).inject(this.selectDiv);
  139. this.selectImg = new Element("img.selectImg",{
  140. "styles":this.css.selectImg,
  141. "src": this.path+"default/icons/arrow.png"
  142. }).inject(this.arrowdownDiv);
  143. //var selecthtml = '<ul class="el-dropdown-type" style="display: none;top:115px;left:398px;width:220px;" id="searchDate"></ul>'
  144. var selecthtml = '<ul class="el-dropdown-type" style="display: none;width:220px;" id="searchDate"></ul>'
  145. jQuery(".headContentDiv").after(selecthtml);
  146. var ulHtml = "";
  147. var valueList = this.lp.searchDate.value;
  148. var valueArr = valueList.split(",");
  149. for(var n=0;n<valueArr.length;n++){
  150. ulHtml = ulHtml+'<li class="el-dropdown-menu__item" style="font-size:15px;">'+valueArr[n]+'</li>'
  151. }
  152. jQuery("#searchDate").append(ulHtml+'<div class="popper__arrow" style="left:99px;box-sizing: border-box !important;"></div>');
  153. this.dropdown = jQuery("body")[0].getElement(".el-dropdown-type");
  154. if(this.dropdown) this.dropdown.setStyles({"top":(jQuery(".user_change").offset().top+52)+"px","left":jQuery(".user_change").offset().left+2});
  155. jQuery(".headTitleDiv").append('<div id="selectheadName" style="display: none;"></div><div id="selectheadId" personList="" departList="" style="display: none;"></div>');
  156. jQuery(".se-select").click(function(){
  157. jQuery(".el-dropdown-type").toggle(100);
  158. });
  159. jQuery('.el-dropdown-menu__item').click(function(){
  160. if(jQuery(this).text()=="自定义"){
  161. var dateHtml = '<div class="timeDiv"><div class="timeItemDiv"><input name="starttime" class="inputtime" id="starttime" type="text" readonly="readonly"></div>'+
  162. '<div class="timeItemDiv"><input name="endtime" class="inputtime" id="endtime" type="text" readonly="readonly"></div>'+
  163. '<div class="timeOk">确定</div></div>';
  164. if(jQuery(".timeDiv").length>0){
  165. jQuery(".inputtime").val("");
  166. jQuery(".timeDiv").toggle(100);
  167. }else{
  168. jQuery(this).parent().append(dateHtml);
  169. }
  170. _self.loadTimeContainer("starttime");
  171. _self.loadTimeContainer("endtime");
  172. jQuery('.timeOk').click(function(){
  173. if(jQuery("#starttime").val()!="" && jQuery("#endtime").val()!=""){
  174. jQuery(_self.rightContentDiv).find(".se-select-name").text(jQuery("#starttime").val()+"--"+jQuery("#endtime").val());
  175. _self.loadDataContent();
  176. jQuery(this).parent().parent().hide();
  177. }else{
  178. Showbo.Msg.alert('请选择开始日期和结束日期!');
  179. }
  180. });
  181. }else{
  182. jQuery(_self.rightContentDiv).find(".se-select-name").text(jQuery(this).text());
  183. _self.loadDataContent();
  184. jQuery(this).parent().toggle(100);
  185. }
  186. });
  187. jQuery(".user_change").click(function(){
  188. _self.selectPerson(jQuery(_self.appArea)[0],"selectheadName","selectheadId",0);
  189. });
  190. //if(jQuery(".quickNew").length > 0) jQuery(".quickNew").remove();
  191. if(jQuery(".quickNew").length < 1){
  192. var quickNewHtml='<div class="quickNew"><div class="quickNew_conent">'+
  193. '<div class="quickNew_item"><span class="sImg"><img class="naviItemImg" src="../x_component_CRM/$Main/default/icons/clue-fill.png"></span><span class="sName" stype="clue">线索</span></div>'+
  194. '<div class="quickNew_item"><span class="sImg"><img class="naviItemImg" src="../x_component_CRM/$Main/default/icons/customer-fill.png"></span><span class="sName" stype="customer">客户</span></div>'+
  195. '<div class="quickNew_item"><span class="sImg"><img class="naviItemImg" src="../x_component_CRM/$Main/default/icons/contact-fill.png"></span><span class="sName" stype="contact">联系人</span></div>'+
  196. '<div class="quickNew_item"><span class="sImg"><img class="naviItemImg" src="../x_component_CRM/$Main/default/icons/chance-fill.png"></span><span class="sName" stype="chance">商机</span></div></div></div>';
  197. jQuery(".middleContentDiv").append(quickNewHtml);
  198. jQuery(".quickStartDiv").click(function(){
  199. jQuery(".quickNew").toggle(100);
  200. });
  201. jQuery(".quickNew").mouseleave(function(){
  202. jQuery(this).toggle(100);
  203. });
  204. _thatnew = _self;
  205. jQuery(".quickNew_item").click(function(){
  206. _thatnew.openNew(jQuery(this).children().eq(1).attr("stype"));
  207. });
  208. }
  209. jQuery("body").click(function(e){
  210. if (jQuery(e.target).closest(".se-select").length <1){
  211. if(jQuery(".el-dropdown-type").css('display')=='block'){
  212. jQuery(".el-dropdown-type").hide();
  213. }
  214. }
  215. });
  216. _self.app.leftContentDiv.getElements(".naviItemLi").addEvents({
  217. "click":function(){
  218. jQuery(".notify").remove();
  219. }.bind(this)
  220. });
  221. },
  222. createToolBarContent:function(){
  223. },
  224. createIndexContent:function(){
  225. debugger
  226. if(this.contentListDiv) this.contentListDiv.destroy();
  227. this.contentListDiv = new Element("div.contentListDiv",{"styles":this.css.contentListDiv}).inject(this.rightContentDiv);
  228. if(this.contentListInDiv) this.contentListInDiv.destroy();
  229. this.contentListInDiv = new Element("div.contentListInDiv",{"styles":this.css.contentListInDiv}).inject(this.contentListDiv);
  230. //var size = this.rightContentDiv.getSize();
  231. //if(this.contentListDiv)this.contentListDiv.setStyles({"height":(size.y-this.headContentDiv.getHeight()-8)+"px"});
  232. //if(this.contentListInDiv)this.contentListInDiv.setStyles({"height":this.contentListDiv.getHeight()+"px","width":"100%"});
  233. this.loadDataContent();
  234. },
  235. loadDataContent:function(){
  236. _self = this;
  237. if(this.contentListInDiv) this.contentListInDiv.destroy();
  238. this.contentListInDiv = new Element("div.contentListInDiv",{"styles":this.css.contentListInDiv}).inject(this.contentListDiv);
  239. this.vux_flexbox_item = new Element("div.vux_flexbox_item",{
  240. "id":"jianbao",
  241. "styles":this.css.vux_flexbox_item
  242. }).inject(this.contentListInDiv);
  243. this.cardDiv = new Element("div.cardDiv",{"styles":this.css.cardDiv}).inject(this.vux_flexbox_item);
  244. this.mark_headerDiv = new Element("div.mark_header",{
  245. "styles":this.css.mark_header,
  246. "text":"销售简报"
  247. }).inject(this.cardDiv);
  248. this.markImg = new Element("img.img_mark",{
  249. "styles":this.css.img_mark,
  250. "src": this.path+"default/icons/jianbao.png"
  251. }).inject(this.mark_headerDiv);
  252. this.vux_flex_rowDiv = new Element("div.vux_flex_row",{"styles":this.css.vux_flex_row}).inject(this.cardDiv);
  253. this.vux_flexbox_item_right = new Element("div.vux_flexbox_item_right",{
  254. "id":"fenbu",
  255. "styles":this.css.vux_flexbox_item_right
  256. }).inject(this.contentListInDiv);
  257. this.cardDiv = new Element("div.cardDiv",{"styles":this.css.cardDiv}).inject(this.vux_flexbox_item_right);
  258. this.mark_headerDiv = new Element("div.mark_header",{
  259. "styles":this.css.mark_header,
  260. "text":"客户分布"
  261. }).inject(this.cardDiv);
  262. this.markImg = new Element("img.img_mark",{
  263. "styles":this.css.img_mark,
  264. "src": this.path+"default/icons/fenbu.png"
  265. }).inject(this.mark_headerDiv);
  266. this.vux_flex_rowDiv = new Element("div.vux_flex_row",{
  267. "id":"cityMap",
  268. "styles":this.css.vux_flex_rowDiv
  269. }).inject(this.cardDiv);
  270. this.vux_flexbox_item2 = new Element("div.vux_flexbox_item",{
  271. "id":"loudou",
  272. "styles":this.css.vux_flexbox_item
  273. }).inject(this.contentListInDiv);
  274. this.cardDiv3 = new Element("div.cardDiv",{"styles":this.css.cardDiv}).inject(this.vux_flexbox_item2);
  275. this.mark_headerDiv = new Element("div.mark_header",{
  276. "styles":this.css.mark_header,
  277. "text":"客户总量"
  278. }).inject(this.cardDiv3);
  279. this.markImg = new Element("img.img_mark",{
  280. "styles":this.css.img_mark,
  281. "src": this.path+"default/icons/loudou.png"
  282. }).inject(this.mark_headerDiv);
  283. this.vux_flex_rowDiv = new Element("div.vux_flex_row",{
  284. "styles":this.css.vux_flex_rowDiv,
  285. "id":"costomerCount"
  286. }).inject(this.cardDiv3);
  287. this.vux_flexbox_item_right2 = new Element("div.vux_flexbox_item_right",{
  288. "id":"qushi",
  289. "styles":this.css.vux_flexbox_item_right
  290. }).inject(this.contentListInDiv);
  291. this.cardDiv = new Element("div.cardDiv",{"styles":this.css.cardDiv}).inject(this.vux_flexbox_item_right2);
  292. this.mark_headerDiv = new Element("div.mark_header",{
  293. "styles":this.css.mark_header,
  294. "text":"客户行业"
  295. }).inject(this.cardDiv);
  296. this.markImg = new Element("img.img_mark",{
  297. "styles":this.css.img_mark,
  298. "src": this.path+"default/icons/qushi.png"
  299. }).inject(this.mark_headerDiv);
  300. this.vux_flex_rowDiv = new Element("div.vux_flex_row",{
  301. "styles":this.css.vux_flex_rowDiv,
  302. "id":"costomerIndustryCount"
  303. }).inject(this.cardDiv);
  304. var personList = jQuery("#selectheadId").attr("personList")==""?[]:jQuery("#selectheadId").attr("personList").split(",");
  305. var departList = jQuery("#selectheadId").attr("departList")==""?[]:jQuery("#selectheadId").attr("departList").split(",");
  306. var dateList = this.getDateList(jQuery(_self.rightContentDiv).find(".se-select-name").text()).split(",");
  307. var filter = {};
  308. filter = {
  309. begintime:dateList[0]+" 00:00:00",
  310. endtime:dateList[1]+" 23:59:59",
  311. key:"",
  312. personNameList:personList,
  313. unitList:departList
  314. };
  315. this.getJianbaoList(filter);
  316. this.getFenBuMap();
  317. this.getCustomerCount(filter);
  318. this.getCustomerByIndustry(filter);
  319. },
  320. openNew: function(stype){
  321. _self = this;
  322. if(stype=="clue"){
  323. MWF.xDesktop.requireApp("CRM", "ClueEdit", function(){
  324. _self.clueModule = new MWF.xApplication.CRM.ClueEdit(_self, _self.actions,{},{
  325. "isEdited":true,
  326. "isNew":true,
  327. "onReloadView" : function(){
  328. //this.load();
  329. }.bind(_self)
  330. });
  331. _self.clueModule.load();
  332. }.bind(_self))
  333. }
  334. if(stype=="customer"){
  335. MWF.xDesktop.requireApp("CRM", "CustomerEdit", function(){
  336. _self.customerModule = new MWF.xApplication.CRM.CustomerEdit(_self, _self.actions,{},{
  337. "isEdited":true,
  338. "isNew":true,
  339. "onReloadView" : function(){
  340. //this.load();
  341. }.bind(_self)
  342. });
  343. _self.customerModule.load();
  344. }.bind(_self))
  345. }
  346. if(stype=="contact"){
  347. MWF.xDesktop.requireApp("CRM", "ContactsEdit", function(){
  348. _self.contactModule = new MWF.xApplication.CRM.ContactsEdit(_self, _self.actions,{},{
  349. "isEdited":true,
  350. "isNew":true,
  351. "onReloadView" : function(){
  352. //this.load();
  353. }.bind(_self)
  354. });
  355. _self.contactModule.load();
  356. }.bind(_self))
  357. }
  358. if(stype=="chance"){
  359. MWF.xDesktop.requireApp("CRM", "ChanceEdit", function(){
  360. var editForm = new MWF.xApplication.CRM.ChanceEdit(null,{},null, {
  361. app: _self.app,
  362. container : _self.app.content,
  363. lp : _self.app.lp.chance,
  364. actions : _self.actions,
  365. css : {},
  366. /*customer :{"id":that.options.openCustomerId},*/
  367. callback : function () {
  368. //editForm.create();
  369. }
  370. });
  371. editForm.create();
  372. }.bind(_self));
  373. }
  374. },
  375. getJianbaoList: function(filter){
  376. _self = this;
  377. //获取简报数字列表
  378. _self.actions.countLike( filter, function (json) {
  379. debugger
  380. if(json.type=="success"){
  381. var customerHtml ='';
  382. json.data.each(function (data ) {
  383. var moduleId = data.moduleId
  384. var count = data.count
  385. var moduleName = "";
  386. switch (moduleId) {
  387. case "customer":
  388. moduleName = "新增客户";
  389. break;
  390. case "contacts":
  391. moduleName = "新增联系人";
  392. break;
  393. case "opportunity":
  394. moduleName = "新增商机";
  395. break;
  396. case "record":
  397. moduleName = "跟进记录";
  398. break;
  399. }
  400. customerHtml = customerHtml+ '<div class="vux-flexbox-item" id="'+moduleId+'"><div class="vux-flexbox jianbao-icon-content" style="cursor: pointer;">'+
  401. '<img src="../x_component_CRM/$Index/default/icons/'+moduleId+'.png" class="jianbao-icon"><div class="jianbao-title">'+moduleName+'</div><div class="jianbao-value">'+count+'</div></div></div>'
  402. }.bind(this));
  403. jQuery("#jianbao").find(".vux_flex_row").append(customerHtml);
  404. jQuery("#jianbao").find(".vux-flexbox-item").each(function(index,element){
  405. jQuery(this).click(function(){
  406. var mid = jQuery(this).attr("id");
  407. /*var filter = {};*/
  408. if(jQuery(".openDiv").length > 0){
  409. jQuery(".openDiv").empty();
  410. }
  411. switch (mid) {
  412. case "customer":
  413. if(_self.index_customerView) delete _self.index_customerView;
  414. /*filter = {
  415. begintime:dateList[0],
  416. endtime:dateList[1],
  417. key:"",
  418. personNameList:personList,
  419. unitList:departList
  420. };*/
  421. _self.index_customerView = new MWF.xApplication.CRM.Index.View(
  422. jQuery(".openDiv")[0],
  423. _self.app,
  424. _self.app,
  425. _self,
  426. { templateUrl : "../x_component_CRM/$Customer/customerView.json",filterData:{}},
  427. {
  428. lp:_self.app.lp.customerView,
  429. isAdmin:_self.options.isAdmin
  430. }
  431. );
  432. _self.index_customerView.load();
  433. jQuery(".openDiv").show();
  434. break;
  435. case "contacts":
  436. if(_self.index_contactsView) delete _self.index_contactsView;
  437. _self.index_contactsView = new MWF.xApplication.CRM.Index.ContactsView(
  438. jQuery(".openDiv")[0],
  439. _self.app,
  440. _self.app,
  441. _self,
  442. { templateUrl : "../x_component_CRM/$Contacts/contactsView.json",filterData:{}},
  443. {
  444. lp:_self.app.lp.contactsView,
  445. isAdmin:_self.options.isAdmin
  446. }
  447. );
  448. _self.index_contactsView.load();
  449. jQuery(".openDiv").show();
  450. break;
  451. case "opportunity":
  452. if(_self.index_opportunityView) delete _self.index_opportunityView;
  453. _self.index_opportunityView = new MWF.xApplication.CRM.Index.ChanceView(
  454. jQuery(".openDiv")[0],
  455. {},
  456. _self.app,
  457. _self,
  458. { templateUrl : "../x_component_CRM/$Chance/chanceView.json",filterData:{}},
  459. {
  460. lp:_self.app.lp.chance,
  461. isAdmin:_self.options.isAdmin
  462. }
  463. );
  464. _self.index_opportunityView.load();
  465. jQuery(".openDiv").show();
  466. break;
  467. case "record":
  468. _self.getRecordCount(filter);
  469. break;
  470. }
  471. });
  472. });
  473. }
  474. }.bind(_self));
  475. },
  476. getFenBuMap: function(){
  477. var myChart = echarts.init(document.getElementById('cityMap'));
  478. debugger
  479. var provinces = ['shanghai', 'hebei', 'shanxi', 'neimenggu', 'liaoning', 'jilin', 'heilongjiang', 'jiangsu', 'zhejiang', 'anhui', 'fujian', 'jiangxi', 'shandong', 'henan', 'hubei', 'hunan', 'guangdong', 'guangxi', 'hainan', 'sichuan', 'guizhou', 'yunnan', 'xizang', 'shanxi1', 'gansu', 'qinghai', 'ningxia', 'xinjiang', 'beijing', 'tianjin', 'chongqing', 'xianggang', 'aomen'];
  480. var provincesText = ['上海', '河北', '山西', '内蒙古', '辽宁', '吉林', '黑龙江', '江苏', '浙江', '安徽', '福建', '江西', '山东', '河南', '湖北', '湖南', '广东', '广西', '海南', '四川', '贵州', '云南', '西藏', '陕西', '甘肃', '青海', '宁夏', '新疆', '北京', '天津', '重庆', '香港', '澳门'];
  481. // 全国省份数据
  482. var toolTipData =[];
  483. /*var toolTipData = [{
  484. "provinceName": "北京",
  485. "count": 58
  486. }, {
  487. "provinceName": "内蒙古",
  488. "count": 0
  489. }, {
  490. "provinceName": "宁夏",
  491. "count": 14
  492. }, {
  493. "provinceName": "新疆",
  494. "count": 4
  495. }]*/
  496. this.actions.countCustomerByProvince(function (json) {
  497. if(json.type=="success"){
  498. toolTipData = json.data;
  499. }
  500. });
  501. var seriesData = [];
  502. for (var j = 0; j < provincesText.length; j++) {
  503. var provinceName = provincesText[j];
  504. var pcount = 0;
  505. for (var i = 0; i < toolTipData.length; i++) {
  506. if(provinceName==toolTipData[i].provinceName){
  507. pcount = toolTipData[i].count;
  508. }
  509. }
  510. seriesData[j] = {};
  511. seriesData[j].name = provinceName;
  512. seriesData[j].value = pcount;
  513. }
  514. var max = Math.max.apply(Math, seriesData.map(function(o) {
  515. return o.value
  516. })),
  517. min = 0; // 侧边最大值最小值
  518. var maxSize4Pin = 40,
  519. minSize4Pin = 30;
  520. var pName = "china";
  521. var Chinese_ = "中国";
  522. var tmpSeriesData = pName === "china" ? seriesData : seriesData;
  523. //var tmp = pName === "china" ? toolTipData : provinceData;
  524. var tmp = pName === "china" ? seriesData : toolTipData;
  525. var option = {
  526. /*title: {
  527. text: Chinese_ || pName,
  528. left: 'center'
  529. },*/
  530. tooltip: {
  531. trigger: 'item',
  532. formatter: function(params) { // 鼠标滑过显示的数据
  533. if (pName === "china") {
  534. var toolTiphtml = ''
  535. for (var i = 0; i < tmp.length; i++) {
  536. if (params.name == tmp[i].name) {
  537. toolTiphtml += tmp[i].name + '<br>客户数:' + tmp[i].value;
  538. }
  539. }
  540. return toolTiphtml;
  541. } else {
  542. var toolTiphtml = ''
  543. for (var i = 0; i < tmp.length; i++) {
  544. if (params.name == tmp[i].cityName) {
  545. toolTiphtml += tmp[i].cityName + '<br>客户数:' + tmp[i].value;
  546. }
  547. }
  548. return toolTiphtml;
  549. }
  550. }
  551. },
  552. visualMap: { //视觉映射组件
  553. show: true,
  554. min: min,
  555. max: max, // 侧边滑动的最大值,从数据中获取
  556. left: '5%',
  557. top: '70%',
  558. inverse: true, //是否反转 visualMap 组件
  559. // itemHeight:200, //图形的高度,即长条的高度
  560. text: ['高', '低'], // 文本,默认为数值文本
  561. calculable: false, //是否显示拖拽用的手柄(手柄能拖拽调整选中范围)
  562. seriesIndex: 1, //指定取哪个系列的数据,即哪个系列的 series.data,默认取所有系列
  563. orient: "horizontal",
  564. inRange: {
  565. color: ['#dbfefe', '#1066d5'] // 蓝绿
  566. }
  567. },
  568. geo: {
  569. show: true,
  570. map: pName,
  571. roam: false,
  572. top:"0%",
  573. //aspectScale: 0.75, //长宽比
  574. label: {
  575. normal: {
  576. show: false
  577. },
  578. emphasis: {
  579. show: false,
  580. }
  581. },
  582. itemStyle: {
  583. normal: {
  584. areaColor: '#f5f7fa', // 没有值得时候颜色
  585. borderColor: '#097bba',
  586. },
  587. emphasis: {
  588. areaColor: '#fbd456', // 鼠标滑过选中的颜色
  589. }
  590. }
  591. },
  592. series: [
  593. {
  594. name: '散点',
  595. type: 'scatter',
  596. coordinateSystem: 'geo',
  597. data: tmpSeriesData,
  598. symbolSize: '1',
  599. label: {
  600. normal: {
  601. show: true,
  602. formatter: '{b}',
  603. position: 'right'
  604. },
  605. emphasis: {
  606. show: true
  607. }
  608. },
  609. itemStyle: {
  610. normal: {
  611. color: '#895139' // 字体颜色
  612. }
  613. }
  614. },
  615. {
  616. name: Chinese_ || pName,
  617. type: 'map',
  618. mapType: pName,
  619. roam: false, //是否开启鼠标缩放和平移漫游
  620. data: tmpSeriesData,
  621. top: "0%",//组件距离容器的距离
  622. // geoIndex: 0,
  623. //aspectScale: 0.75, //长宽比
  624. // showLegendSymbol: false, // 存在legend时显示
  625. selectedMode: 'single',
  626. label: {
  627. normal: {
  628. show: true, //显示省份标签
  629. textStyle: {
  630. color: "#895139"
  631. } //省份标签字体颜色
  632. },
  633. emphasis: { //对应的鼠标悬浮效果
  634. show: true,
  635. textStyle: {
  636. color: "#323232"
  637. }
  638. }
  639. },
  640. itemStyle: {
  641. normal: {
  642. borderWidth: .5, //区域边框宽度
  643. borderColor: '#0550c3', //区域边框颜色
  644. areaColor: "#0b7e9e", //区域颜色
  645. },
  646. emphasis: {
  647. borderWidth: .5,
  648. borderColor: '#4b0082',
  649. areaColor: "#ece39e",
  650. }
  651. }
  652. },
  653. ]
  654. };
  655. myChart.setOption(option);
  656. /* 响应式 */
  657. jQuery(window).resize(function() {
  658. myChart.resize();
  659. });
  660. myChart.off("click");
  661. },
  662. getCustomerCount: function(filter){
  663. _self = this;
  664. var xdata = [];
  665. var ydata = [];
  666. _self.actions.countCustomerByMonth( filter, function (json) {
  667. debugger
  668. if(json.type=="success"){
  669. json.data.each(function (data ) {
  670. xdata.push(data.month);
  671. ydata.push(data.count);
  672. });
  673. }
  674. });
  675. var myChart = echarts.init(jQuery("#costomerCount")[0]);
  676. var option = {
  677. calculable: true,
  678. grid: {
  679. y: 115,
  680. y2: 115
  681. },
  682. // ------ X轴 ------
  683. xAxis: {
  684. show: true, // 是否显示
  685. position: 'bottom', // x轴的位置
  686. offset: 0, // x轴相对于默认位置的偏移
  687. type: 'category', // 轴类型, 默认为 'category'
  688. //name: '月份', // 轴名称
  689. nameLocation: 'end', // 轴名称相对位置
  690. nameTextStyle: { // 坐标轴名称样式
  691. color: '#333',
  692. padding: [5, 0, 0, -5]
  693. },
  694. nameGap: 5, // 坐标轴名称与轴线之间的距离
  695. nameRotate: 0, // 坐标轴名字旋转
  696. axisLine: { // 坐标轴 轴线
  697. show: true, // 是否显示
  698. // ------ 线 ---------
  699. lineStyle: {
  700. color: '#333',//blue
  701. width: 1,
  702. type: 'solid'
  703. }
  704. },
  705. axisTick: { // 坐标轴 刻度
  706. show: false, // 是否显示
  707. inside: true, // 是否朝内
  708. length: 3, // 长度
  709. lineStyle: { // 默认取轴线的样式
  710. color: '#333',//red
  711. width: 1,
  712. type: 'solid'
  713. }
  714. },
  715. axisLabel: { // 坐标轴标签
  716. show: true, // 是否显示
  717. inside: false, // 是否朝内
  718. rotate: 0, // 旋转角度
  719. margin: 5, // 刻度标签与轴线之间的距离
  720. color: '#333' // 默认取轴线的颜色red
  721. },
  722. splitLine: { // gird区域中的分割线
  723. show: false, // 是否显示
  724. lineStyle: {
  725. // color: 'red',
  726. // width: 1,
  727. // type: 'solid'
  728. }
  729. },
  730. splitArea: { // 网格区域
  731. show: false // 是否显示,默认为false
  732. },
  733. data:xdata
  734. //data: ['1月', '2月', '3月', '4月', '5月', '6月', '7月', '8月', '9月', '10月', '11月', '12月']
  735. },
  736. // ------ y轴 ----------
  737. yAxis: {
  738. show: true, // 是否显示
  739. position: 'left', // y轴位置
  740. offset: 0, // y轴相对于默认位置的偏移
  741. type: 'value', // 轴类型,默认为 ‘category’
  742. name: '客户数', // 轴名称
  743. nameLocation: 'end', // 轴名称相对位置value
  744. nameTextStyle: { // 坐标轴名称样式
  745. color: '#333',
  746. padding: [5, 0, 0, 5] // 坐标轴名称相对位置
  747. },
  748. nameGap: 15, // 坐标轴名称与轴线之间的距离
  749. nameRotate: 360, // 坐标轴名字旋转
  750. axisLine: { // 坐标轴 轴线
  751. show: true, // 是否显示
  752. // ----- 线 -------
  753. lineStyle: {
  754. color: '#333',
  755. width: 1,
  756. type: 'solid'
  757. }
  758. },
  759. axisTick: { // 坐标轴的刻度
  760. show: false, // 是否显示
  761. inside: true, // 是否朝内
  762. length: 3, // 长度
  763. lineStyle: {
  764. color: '#333', // 默认取轴线的颜色
  765. width: 1,
  766. type: 'solid'
  767. }
  768. },
  769. axisLabel: { // 坐标轴的标签
  770. show: true, // 是否显示
  771. inside: false, // 是否朝内
  772. rotate: 0, // 旋转角度
  773. margin: 8, // 刻度标签与轴线之间的距离
  774. color: '#333', // 默认轴线的颜色
  775. },
  776. splitLine: { // gird 区域中的分割线
  777. show: false, // 是否显示
  778. lineStyle: {
  779. color: '#666',
  780. width: 1,
  781. type: 'dashed'
  782. }
  783. },
  784. splitArea: { // 网格区域
  785. show: false // 是否显示,默认为false
  786. }
  787. },
  788. // ------- 内容数据 -------
  789. series: [
  790. {
  791. name: '客户数', // 序列名称
  792. type: 'bar', //类型
  793. legendHoverLink: true, // 是否启用图列 hover 时的联动高亮
  794. label: { // 图形上的文本标签
  795. show: false,
  796. position: 'insideTop', // 相对位置
  797. rotate: 0, // 旋转角度
  798. color: '#eee'
  799. },
  800. itemStyle: { // 图形的形状
  801. color: '#A3C7F7',
  802. barBorderRadius: [0, 0, 0 ,0]
  803. },
  804. barWidth: 20, // 柱形的宽度
  805. barCategoryGap: '20%', // 柱形的间距
  806. data: ydata
  807. //data: [3000, 4000, 4200, 4500, 6000, 5600, 8500, 5020, 4500, 5400, 4300, 1200]
  808. }
  809. ]
  810. };
  811. myChart.setOption(option);
  812. },
  813. getCustomerByIndustry: function(filter){
  814. _self = this;
  815. var xdata = [];
  816. var ydata = [];
  817. var typeList = this.app.lp.customer.industry.value;
  818. var typeArr = typeList.split(",");
  819. var otherCount = 0;
  820. _self.actions.countCustomerByIndustry( filter, function (json) {
  821. debugger
  822. if(json.type=="success"){
  823. json.data.each(function (data ) {
  824. var industry = data.industry;
  825. if(typeArr.contains(industry)){
  826. xdata.push(industry);
  827. ydata.push({value:data.count,name:industry})
  828. }else{
  829. otherCount = otherCount+(data.count).toInt();
  830. }
  831. });
  832. if(otherCount>0){
  833. xdata.push('未知');
  834. ydata.push({value:otherCount,name:'未知'})
  835. }
  836. }
  837. });
  838. var myChart = echarts.init(jQuery("#costomerIndustryCount")[0]);
  839. var option = {
  840. /* title: {//标题组件
  841. text: '故障',
  842. left:'50px',//标题的位置 默认是left,其余还有center、right属性
  843. textStyle: {
  844. color: "#436EEE",
  845. fontSize: 17,
  846. }
  847. },*/
  848. tooltip : { //提示框组件
  849. trigger: 'item', //触发类型(饼状图片就是用这个)
  850. //formatter: "{a} <br/>{b} : {c} ({d}%)" //提示框浮层内容格式器
  851. formatter: "{b} : {c}" //提示框浮层内容格式器
  852. },
  853. color:['#48cda6','#ffa500','#11abff','#ffdf6f','#968ade','#C9C9C9','#7CFC00','#BF600D','#96E2F5'], //手动设置每个图例的颜色
  854. legend: { //图例组件
  855. //right:100, //图例组件离右边的距离
  856. orient : 'horizontal', //布局 纵向布局 图例标记居文字的左边 vertical则反之
  857. width:40, //图行例组件的宽度,默认自适应
  858. x : 'right', //图例显示在右边
  859. y: 'center', //图例在垂直方向上面显示居中
  860. itemWidth:10, //图例标记的图形宽度
  861. itemHeight:10, //图例标记的图形高度
  862. //data:['正常','一般','提示','较急','特急'],
  863. data:xdata,
  864. textStyle:{ //图例文字的样式
  865. color:'#333', //文字颜色
  866. fontSize:12 //文字大小
  867. }
  868. },
  869. series : [ //系列列表
  870. {
  871. name:'设备状态', //系列名称
  872. type:'pie', //类型 pie表示饼图
  873. center:['35%','45%'], //设置饼的原心坐标 不设置就会默认在中心的位置
  874. radius : ['40%', '55%'], //饼图的半径,第一项是内半径,第二项是外半径,内半径为0就是真的饼,不是环形
  875. itemStyle : { //图形样式
  876. normal : { //normal 是图形在默认状态下的样式;emphasis 是图形在高亮状态下的样式,比如在鼠标悬浮或者图例联动高亮时。
  877. label : { //饼图图形上的文本标签
  878. show : true, //平常不显示
  879. textStyle:{color:'#3c4858',fontSize:"18"},
  880. formatter:function(val){
  881. return '{b|' + val.name + '}'
  882. },
  883. rich: {
  884. b: {fontSize: 15}
  885. }
  886. },
  887. labelLine:{
  888. show:true
  889. //lineStyle:{color:'#45bcf2'}
  890. }
  891. },
  892. emphasis : { //normal 是图形在默认状态下的样式;emphasis 是图形在高亮状态下的样式,比如在鼠标悬浮或者图例联动高亮时。
  893. label : { //饼图图形上的文本标签
  894. show : true,
  895. position : 'center',
  896. textStyle : {
  897. fontSize : '10',
  898. fontWeight : 'bold'
  899. }
  900. }
  901. }
  902. },
  903. data:ydata
  904. /*data:[
  905. {value:1, name:'正常'},
  906. {value:10, name:'一般'},
  907. {value:30, name:'提示'},
  908. {value:20, name:'较急'},
  909. {value:25, name:'特急'}
  910. ]*/
  911. }
  912. ]
  913. };
  914. myChart.setOption(option);
  915. },
  916. getDateList: function(stime){
  917. _self = this;
  918. var dateList = "";
  919. switch (stime) {
  920. case "今天":
  921. dateList = this.formatDate(this.now)+","+this.formatDate(this.now);
  922. break;
  923. case "本周":
  924. dateList = this.getWeekStartDate()+","+this.getWeekEndDate();
  925. break;
  926. case "本月":
  927. dateList = this.getMonthStartDate()+","+this.getMonthEndDate();
  928. break;
  929. case "本季度":
  930. dateList = this.getQuarterStartDate()+","+this.getQuarterEndDate();
  931. break;
  932. case "本年":
  933. dateList = this.nowYear+"-01-01,"+this.nowYear+"-12-31";
  934. break;
  935. default:
  936. dateList = jQuery(_self.rightContentDiv).find(".se-select-name").text().replace("--",",");
  937. }
  938. return dateList;
  939. },
  940. //格局化日期:yyyy-MM-dd
  941. formatDate:function(date) {
  942. var myyear = date.getFullYear();
  943. var mymonth = date.getMonth()+1;
  944. var myweekday = date.getDate();
  945. if(mymonth < 10){
  946. mymonth = "0" + mymonth;
  947. }
  948. if(myweekday < 10){
  949. myweekday = "0" + myweekday;
  950. }
  951. return (myyear+"-"+mymonth + "-" + myweekday);
  952. },
  953. //获得某月的天数
  954. getMonthDays:function(myMonth){
  955. var monthStartDate = new Date(this.nowYear, myMonth, 1);
  956. var monthEndDate = new Date(this.nowYear, myMonth + 1, 1);
  957. var days = (monthEndDate - monthStartDate)/(1000 * 60 * 60 * 24);
  958. return days;
  959. },
  960. //获得本季度的开端月份
  961. getQuarterStartMonth:function(){
  962. var quarterStartMonth = 0;
  963. if(this.nowMonth<3){
  964. quarterStartMonth = 0;
  965. }
  966. if(2<this.nowMonth && this.nowMonth<6){
  967. quarterStartMonth = 3;
  968. }
  969. if(5<this.nowMonth && this.nowMonth<9){
  970. quarterStartMonth = 6;
  971. }
  972. if(this.nowMonth>8){
  973. quarterStartMonth = 9;
  974. }
  975. return quarterStartMonth;
  976. },
  977. //获得本周的开端日期
  978. getWeekStartDate:function() {
  979. var weekStartDate = new Date(this.nowYear, this.nowMonth, (this.nowDay - this.nowDayOfWeek)+1);
  980. return this.formatDate(weekStartDate);
  981. },
  982. //获得本周的停止日期
  983. getWeekEndDate:function() {
  984. var weekEndDate = new Date(this.nowYear, this.nowMonth, this.nowDay + (7 - this.nowDayOfWeek));
  985. return this.formatDate(weekEndDate);
  986. },
  987. //获得本月的开端日期
  988. getMonthStartDate:function(){
  989. var monthStartDate = new Date(this.nowYear, this.nowMonth, 1);
  990. return this.formatDate(monthStartDate);
  991. },
  992. //获得本月的停止日期
  993. getMonthEndDate:function(){
  994. var monthEndDate = new Date(this.nowYear, this.nowMonth, this.getMonthDays(this.nowMonth));
  995. return this.formatDate(monthEndDate);
  996. },
  997. //获得本季度的开端日期
  998. getQuarterStartDate:function(){
  999. var quarterStartDate = new Date(this.nowYear, this.getQuarterStartMonth(), 1);
  1000. return this.formatDate(quarterStartDate);
  1001. },
  1002. //或的本季度的停止日期
  1003. getQuarterEndDate:function(){
  1004. var quarterEndMonth = this.getQuarterStartMonth() + 2;
  1005. var quarterStartDate = new Date(this.nowYear, quarterEndMonth, this.getMonthDays(quarterEndMonth));
  1006. return this.formatDate(quarterStartDate);
  1007. },
  1008. loadTimeContainer: function(stime){
  1009. jQuery("#"+stime).ymdateplugin({
  1010. showTimePanel: false
  1011. });
  1012. },
  1013. selectPerson: function (showContainer,nameId,fullNameId,count) {
  1014. var options = {
  1015. "type" : "",
  1016. "types": ["person","unit"],
  1017. "values": this.configData,
  1018. "count": count,
  1019. "zIndex": 50000,
  1020. "onComplete": function(items){
  1021. MWF.require("MWF.widget.O2Identity", function(){
  1022. var invitePersonList = [];
  1023. var fullPersonList = [];
  1024. this.configData = [];
  1025. this.process = null;
  1026. items.each(function(item){
  1027. var _self = this;
  1028. if( item.data.distinguishedName.split("@").getLast().toLowerCase() == "i" ){
  1029. var person = new MWF.widget.O2Identity(item.data, it.form.getItem("invitePersonList").container, {"style": "room"});
  1030. invitePersonList.push( item.data.distinguishedName );
  1031. }else{
  1032. //var person = new MWF.widget.O2Person(item.data, it.form.getItem("invitePersonList").container, {"style": "room"});
  1033. invitePersonList.push(item.data.name);
  1034. fullPersonList.push(item.data.distinguishedName);
  1035. var personJson = {
  1036. "name": item.data.name,
  1037. "distinguishedName": item.data.distinguishedName,
  1038. "employee":item.data.employee
  1039. }
  1040. this.configData.push(personJson);
  1041. }
  1042. }.bind(this));
  1043. if(items.length==0){
  1044. //document.getElementById(nameId).innerHTML = "+点击选择"
  1045. if(jQuery(".headTitleinDiv").text()!="本人及下属"){
  1046. document.getElementById(nameId).innerHTML = "";
  1047. document.getElementById(fullNameId).innerHTML = "";
  1048. jQuery(".headTitleinDiv").text("本人及下属");
  1049. _self.loadDataContent();
  1050. }
  1051. }else{
  1052. document.getElementById(nameId).innerHTML = invitePersonList.join(",");
  1053. if(fullNameId!=""){
  1054. document.getElementById(fullNameId).innerHTML = fullPersonList.join(",");
  1055. var personCount = [];
  1056. var departCount = [];
  1057. var puhtml = "";
  1058. for(var n=0;n<fullPersonList.length;n++){
  1059. if(fullPersonList[n].contains("@P")){
  1060. personCount.push(fullPersonList[n])
  1061. }
  1062. if(fullPersonList[n].contains("@U")){
  1063. departCount.push(fullPersonList[n])
  1064. }
  1065. }
  1066. if(personCount.length>0){
  1067. puhtml = personCount.length+"个员工";
  1068. jQuery("#"+fullNameId).attr("personList",personCount.join(","));
  1069. }
  1070. if(departCount.length>0){
  1071. if(personCount.length>0){
  1072. puhtml = puhtml+","+departCount.length+"个部门"
  1073. }else{
  1074. puhtml = departCount.length+"个部门"
  1075. }
  1076. jQuery("#"+fullNameId).attr("departList",departCount.join(","));
  1077. }
  1078. if(puhtml!=""){
  1079. jQuery(".headTitleinDiv").text(puhtml);
  1080. _self.loadDataContent();
  1081. if(_self.dropdown) _self.dropdown.setStyles({"top":(jQuery(".user_change").offset().top+52)+"px","left":jQuery(".user_change").offset().left+2});
  1082. }
  1083. }
  1084. }
  1085. }.bind(this));
  1086. }.bind(this)
  1087. };
  1088. var selector = new MWF.O2Selector(showContainer, options);
  1089. },
  1090. getRecordCount:function(filter){
  1091. _self = this;
  1092. jQuery(".openDiv").show();
  1093. jQuery(".openDiv").append('<div class="headNode"><span class="title">销售简报-新增跟进记录</span><img class="close" src="../x_component_CRM/$Template/close.png"></div>');
  1094. var listCountHtml = '<div class="lsitBody"><table class="el-table__bd" style="width:100%;border-collapse: collapse;"><tbody><tr class="el-table__row current-row">'+
  1095. '<td class="firstCol"><div class="cell">模块</div></td><td><div class="cell">新增跟进记录</div></td></tr></tbody></table></div>'
  1096. jQuery(".openDiv").append(listCountHtml);
  1097. var addTR = '';
  1098. _self.actions.countGroupByTypes( filter, function (json) {
  1099. if(json.type=="success"){
  1100. json.data.each(function (data ) {
  1101. var typesname = data.typesname;
  1102. if(typesname!=""){
  1103. addTR = addTR+'<tr class="el-table__row"><td class="firstCol"><div class="cell">'+typesname+'</div></td><td mid="'+data.types+'"><div class="cell el-tooltip">'+data.count+'</div></td></tr>'
  1104. }
  1105. });
  1106. }
  1107. });
  1108. jQuery(".lsitBody").find("tbody").append(addTR);
  1109. jQuery(".headNode").find(".close").click(function(){
  1110. jQuery(".openDiv").empty();
  1111. jQuery(".openDiv").hide();
  1112. });
  1113. jQuery("td[mid]").css("cursor","pointer");
  1114. jQuery("td[mid]").click(function(){
  1115. var openId = jQuery(this).attr("mid");
  1116. if(jQuery(".notify").length > 0){
  1117. jQuery(".notify").remove();
  1118. }
  1119. MWF.xDesktop.requireApp("CRM", "Record", function(){
  1120. _self.explorer = new MWF.xApplication.CRM.Record(_self, _self.actions,{},{
  1121. "openId":openId,
  1122. "openName":"跟进记录",
  1123. "filter":filter,
  1124. "onReloadView" : function(){
  1125. }.bind(_self)
  1126. });
  1127. _self.explorer.load();
  1128. }.bind(_self))
  1129. });
  1130. },
  1131. resizeWindow:function(){
  1132. var size = this.rightContentDiv.getSize();
  1133. /*var rSize = this.headTitleDiv.getSize();
  1134. var lSize = this.headBottonDiv.getSize();
  1135. if(this.headSearchDiv){
  1136. var x = this.headSearchDiv.getSize().x;
  1137. this.headSearchDiv.setStyles({"margin-left":(size.x-rSize.x-lSize.x)/2-(x/2)+"px"});
  1138. }*/
  1139. //if(this.contentListDiv)this.contentListDiv.setStyles({"height":(size.y-this.headContentDiv.getHeight()-8)+"px"});
  1140. //if(this.contentListInDiv)this.contentListInDiv.setStyles({"height":this.contentListDiv.getHeight()+"px"});
  1141. }
  1142. });
  1143. MWF.xApplication.CRM.Index.View = new Class({
  1144. Extends: MWF.xApplication.CRM.Template.ComplexViewOpen,
  1145. _getCurrentPageData: function(callback, count, page, searchText,searchType){
  1146. //var category = this.category = this.options.category;
  1147. if (!count)count = 15;
  1148. if (!page)page = 1;
  1149. var id = (this.items.length) ? this.items[this.items.length - 1].data.id : "(0)";
  1150. //if(id=="(0)")this.app.createShade();
  1151. var filter = this.options.filterData || {};
  1152. filter={key: searchText?searchText.trim():"",
  1153. orderFieldName: "updateTime",
  1154. orderType: "desc"
  1155. };
  1156. if (!searchType)searchType = "全部客户";
  1157. if(!this.isAdmin){
  1158. debugger
  1159. if(searchType=="我负责的客户"){
  1160. this.actions.ListMyDuty_customer(page, count, filter, function (json) {
  1161. if (callback)callback(json);
  1162. }.bind(this));
  1163. }
  1164. if(searchType=="下属负责的客户"){
  1165. this.actions.ListNestedSubPerson_customer(page, count, filter, function (json) {
  1166. if (callback)callback(json);
  1167. }.bind(this));
  1168. }
  1169. if(searchType=="我参与的客户"){
  1170. this.actions.ListMyParticipate_customer(page, count, filter, function (json) {
  1171. if (callback)callback(json);
  1172. }.bind(this));
  1173. }
  1174. if(searchType=="全部客户"){
  1175. this.actions.ListAllMy_customer(page, count, filter, function (json) {
  1176. if (callback)callback(json);
  1177. }.bind(this));
  1178. }
  1179. }else{
  1180. debugger
  1181. this.actions.getCustomerListPage(page, count, filter, function (json) {
  1182. if (callback)callback(json);
  1183. }.bind(this));
  1184. }
  1185. },
  1186. _create: function(){
  1187. },
  1188. _openDocument: function(openId ,openName){
  1189. /*MWF.xDesktop.requireApp("CRM", "ClueEdit", function(){
  1190. this.explorer = new MWF.xApplication.CRM.ClueEdit(this, this.actions,{},{
  1191. "clueId":clueId,
  1192. "onReloadView" : function( ){
  1193. //alert(JSON.stringify(data))
  1194. this.reload();
  1195. }.bind(this)
  1196. });
  1197. this.explorer.load();
  1198. }.bind(this))*/
  1199. MWF.xDesktop.requireApp("CRM", "CustomerOpen", function(){
  1200. this.explorer = new MWF.xApplication.CRM.CustomerOpen(this, this.actions,{},{
  1201. "openId":openId,
  1202. "openName":openName,
  1203. "onReloadView" : function( ){
  1204. //alert(JSON.stringify(data))
  1205. this.reload();
  1206. }.bind(this)
  1207. });
  1208. this.explorer.load();
  1209. }.bind(this))
  1210. },
  1211. _queryCreateViewNode: function(){
  1212. },
  1213. _postCreateViewNode: function( viewNode ){
  1214. },
  1215. _queryCreateViewHead:function(){
  1216. },
  1217. _postCreateViewHead: function( headNode ){
  1218. }
  1219. });
  1220. MWF.xApplication.CRM.Index.ContactsView = new Class({
  1221. Extends: MWF.xApplication.CRM.Template.ComplexViewOpen,
  1222. _createDocument: function(data){
  1223. return new MWF.xApplication.CRM.Clue.Document(this.viewNode, data, this.explorer, this);
  1224. },
  1225. _getCurrentPageData: function(callback, count, page, searchText){
  1226. var category = this.category = this.options.category;
  1227. if (!count)count = 15;
  1228. if (!page)page = 1;
  1229. var id = (this.items.length) ? this.items[this.items.length - 1].data.id : "(0)";
  1230. //if(id=="(0)")this.app.createShade();
  1231. var filter = this.options.filterData || {};
  1232. if(searchText){
  1233. filter = {
  1234. key:searchText
  1235. };
  1236. }
  1237. debugger
  1238. this.actions.getContactsListPage(page, count, filter, function (json) {
  1239. debugger
  1240. if (callback)callback(json);
  1241. }.bind(this));
  1242. },
  1243. _create: function(){
  1244. },
  1245. _openDocument: function(openId ,openName){
  1246. /*MWF.xDesktop.requireApp("CRM", "ClueEdit", function(){
  1247. this.explorer = new MWF.xApplication.CRM.ClueEdit(this, this.actions,{},{
  1248. "clueId":clueId,
  1249. "onReloadView" : function( ){
  1250. //alert(JSON.stringify(data))
  1251. this.reload();
  1252. }.bind(this)
  1253. });
  1254. this.explorer.load();
  1255. }.bind(this))*/
  1256. MWF.xDesktop.requireApp("CRM", "ContactsOpen", function(){
  1257. this.explorer = new MWF.xApplication.CRM.ContactsOpen(this, this.actions,{},{
  1258. "openId":openId,
  1259. "openName":openName,
  1260. "onReloadView" : function( ){
  1261. //alert(JSON.stringify(data))
  1262. this.reload();
  1263. }.bind(this)
  1264. });
  1265. this.explorer.load();
  1266. }.bind(this))
  1267. },
  1268. _openOtherDocument: function(openId ,openName){
  1269. MWF.xDesktop.requireApp("CRM", "CustomerOpen", function(){
  1270. this.explorer = new MWF.xApplication.CRM.CustomerOpen(this, this.actions,{},{
  1271. "openId":openId,
  1272. "openName":openName,
  1273. "onReloadView" : function( ){
  1274. //alert(JSON.stringify(data))
  1275. this.reload();
  1276. }.bind(this)
  1277. });
  1278. this.explorer.load();
  1279. }.bind(this))
  1280. },
  1281. _queryCreateViewNode: function(){
  1282. },
  1283. _postCreateViewNode: function( viewNode ){
  1284. },
  1285. _queryCreateViewHead:function(){
  1286. },
  1287. _postCreateViewHead: function( headNode ){
  1288. }
  1289. });
  1290. MWF.xApplication.CRM.Index.ChanceView = new Class({
  1291. Extends: MWF.xApplication.CRM.Template.ComplexViewOpen,
  1292. initialize: function (container, data, app, explorer, options, para) {
  1293. this.container = container;
  1294. this.data = data||{};
  1295. this.explorer = explorer;
  1296. if( para ){
  1297. this.app = app || para.app || this.explorer.app;
  1298. this.lp = para.lp || this.explorer.lp || this.app.lp;
  1299. this.css = para.css || this.explorer.css || this.app.css;
  1300. this.actions = para.actions || this.explorer.actions || this.app.actions || this.app.restActions;
  1301. }else{
  1302. this.app = app || this.explorer.app;
  1303. this.lp = this.explorer.lp || this.app.lp;
  1304. this.css = this.explorer.css || this.app.css;
  1305. this.actions = this.explorer.actions || this.app.actions || this.app.restActions;
  1306. }
  1307. /*template 外边传进来*/
  1308. if (!options.templateUrl) {
  1309. options.templateUrl = this.explorer.path + "listItem.json"
  1310. } else if (options.templateUrl.indexOf("/") == -1) {
  1311. options.templateUrl = this.explorer.path + options.templateUrl;
  1312. }
  1313. this.setOptions(options);
  1314. },
  1315. _createDocument: function(data){
  1316. return new MWF.xApplication.CRM.Chance.Document(this.viewNode, data, this.explorer, this);
  1317. },
  1318. ayalyseTemplate: function () {
  1319. MWF.getJSON(this.options.templateUrl, function (json) {
  1320. this.template = json;
  1321. console.log("this is template,",json);
  1322. }.bind(this), false)
  1323. },
  1324. _getCurrentPageData: function(callback, count, page, searchText){
  1325. var category = this.category = this.options.category;
  1326. if (!count)count = 10;
  1327. if (!page)page = 1;
  1328. var id = (this.items.length) ? this.items[this.items.length - 1].data.id : "(0)";
  1329. //if(id=="(0)")this.app.createShade();
  1330. var filter = this.options.filterData || {};
  1331. if(searchText){
  1332. filter = {
  1333. key:searchText
  1334. };
  1335. }
  1336. this.actions.getChanceByPage(page, count, filter, function (json) {
  1337. if (callback)callback(json);
  1338. //this.app.destroyShade();
  1339. }.bind(this));
  1340. },
  1341. useTablePlugins: function (cpage,searchText) {
  1342. console.log("this is useTablePlugins page:"+cpage+";;;;text:"+searchText);
  1343. if(jQuery(".laytable-box").length > 0) jQuery(".laytable-box").remove();
  1344. var that = this;
  1345. var cdata = [];
  1346. var cols = [];
  1347. var col = [];
  1348. var sortField = "";
  1349. var sortType = "";
  1350. var chanceViewObject = this.template;
  1351. var count = 10;
  1352. sortField = chanceViewObject.sortField;
  1353. sortType = chanceViewObject.sortType;
  1354. if (!cpage)cpage = 1;
  1355. /*for ( i in chanceListObject){
  1356. cols.push(chanceListObject[i]);
  1357. }*/
  1358. cols = chanceViewObject.field;
  1359. //cols.push(col);
  1360. this._getCurrentPageData(function (json) {
  1361. /*json.data.each(function (data ) {
  1362. this.actions.getCustomerInfo(data.customerid, function(customer){
  1363. var newData = data;
  1364. newData.customername = customer.data.customername;
  1365. cdata.push(newData);
  1366. }, function(){
  1367. cdata.push(data);
  1368. }, true)
  1369. }.bind(this));*/
  1370. cdata = json.data;
  1371. layui.config({
  1372. base: '../x_component_CRM/$Template/plugins/table2/'
  1373. }).use(['table2', "table2"], function () {
  1374. var table = layui.table2;
  1375. console.log(cols);
  1376. var tableIns = table.render({
  1377. elem: "#contentTable",
  1378. data: cdata,
  1379. height: 600,
  1380. width: '100%',
  1381. page: {
  1382. align: 'right',
  1383. groups: 5,//显示连续页码数量
  1384. curr:1,
  1385. count: json.count,//总条数
  1386. limit:10,
  1387. limits:[10, 20, 30, 40, 50, 60, 70, 80, 90]
  1388. },
  1389. initSort: {
  1390. sortField: sortField,
  1391. sortType: sortType
  1392. },
  1393. cols:[cols]
  1394. });
  1395. that.container.getElements(".chanceId").forEach(
  1396. function (e,i) {
  1397. //console.log("this is chanceId click fun:::::",e,i);
  1398. e.addEvent("click",function(){
  1399. console.log(this);
  1400. that._openDocument(this.get("id"),this.text);
  1401. }.bind(e))
  1402. }
  1403. );
  1404. that.container.getElements(".customerId").forEach(
  1405. function (e,i) {
  1406. //console.log("this is customerid click fun:::::",e,i);
  1407. e.addEvent("click",function(){
  1408. console.log(this);
  1409. that._openCustomer(this.get("id"),this.text);
  1410. }.bind(e))
  1411. }
  1412. );
  1413. jQuery(".laytable-page-pagination").find("a").each(function(index,element){
  1414. jQuery(element).on("click", function () {
  1415. //cpage = parseInt(jQuery(element).attr("value"))+cpage;
  1416. var topage = 1;
  1417. if(jQuery(element).attr("value")=="-1" || jQuery(element).attr("value")=="+1"){
  1418. topage = parseInt(jQuery(element).attr("value"))+topage;
  1419. }else{
  1420. topage = parseInt(jQuery(element).text());
  1421. }
  1422. if(jQuery(element).attr("class")!="page-item page-last rayui-disabled" && jQuery(element).attr("class")!="page-item page-prev rayui-disabled"){
  1423. //that.useTablePlugins(topage);
  1424. var searchText = jQuery(".headSearchInput").val();
  1425. if(searchText!=""){
  1426. that.useTablePlugins(topage,searchText);
  1427. }else{
  1428. that.useTablePlugins(topage);
  1429. }
  1430. }
  1431. });
  1432. }
  1433. );
  1434. jQuery(".laytable-page-btnok").on("click", function () {
  1435. var cpage = parseInt(jQuery(".laytable-page-input").val());
  1436. var searchText = jQuery(".headSearchInput").val();
  1437. if(searchText!=""){
  1438. that.useTablePlugins(cpage,searchText);
  1439. }else{
  1440. that.useTablePlugins(cpage);
  1441. }
  1442. //that.useTablePlugins(cpage);
  1443. });
  1444. jQuery(".page-item").each(function(index,element){
  1445. if(jQuery(element).attr("value")==(cpage+"")){
  1446. jQuery(element).attr("class","page-item page-active");
  1447. }else{
  1448. if(jQuery(element).attr("value")!="-1" && jQuery(element).attr("value")!="+1"){
  1449. jQuery(element).attr("class","page-item");
  1450. }
  1451. }
  1452. });
  1453. var cCount = jQuery(".page-active").attr("value");
  1454. var firstObj = jQuery(".page-prev").parent().next().find("a")[0];
  1455. var lastObj = jQuery(".page-last").parent().prev().find("a")[0];
  1456. if(parseInt(cCount)>parseInt(jQuery(firstObj).attr("value"))){
  1457. jQuery(".page-prev").attr("class","page-item page-prev");
  1458. }else{
  1459. jQuery(".page-prev").attr("class","page-item page-prev rayui-disabled");
  1460. }
  1461. if(parseInt(cCount)==parseInt(jQuery(lastObj).attr("value"))){
  1462. jQuery(".page-last").attr("class","page-item page-last rayui-disabled");/////
  1463. }else{
  1464. jQuery(".page-last").attr("class","page-item page-last");
  1465. }
  1466. jQuery(".laytable-page-input").attr("value",cpage+"");
  1467. });
  1468. }.bind(this),count, cpage,searchText);
  1469. },
  1470. _openDocument: function( id , name ){
  1471. //if(this.customerRead){
  1472. // this.customerRead.load(documentData)
  1473. //}else{
  1474. MWF.xDesktop.requireApp("CRM", "ChanceOpen", function(){
  1475. this.explorer = new MWF.xApplication.CRM.ChanceOpen(this, this.actions,{},{
  1476. "openId":id,
  1477. "openName":name,
  1478. "lp":this.lp,
  1479. "onReloadView" : function( ){
  1480. //alert(JSON.stringify(data))
  1481. this.reload();
  1482. }.bind(this)
  1483. });
  1484. this.explorer.load();
  1485. }.bind(this))
  1486. },
  1487. _openCustomer: function(openId ,openName){
  1488. MWF.xDesktop.requireApp("CRM", "CustomerOpen", function(){
  1489. this.explorer = new MWF.xApplication.CRM.CustomerOpen(this, this.actions,{},{
  1490. "openId":openId,
  1491. "openName":openName,
  1492. "onReloadView" : function( ){
  1493. //alert(JSON.stringify(data))
  1494. this.reload();
  1495. }.bind(this)
  1496. });
  1497. this.explorer.load();
  1498. }.bind(this))
  1499. },
  1500. });