PublicseasOpen.js 68 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471
  1. MWF.xApplication.CRM.AddressExplorer={};
  2. MWF.require("MWF.widget.O2Identity", null, false);
  3. MWF.xDesktop.requireApp("Selector", "package", null, false);
  4. MWF.xApplication.CRM.PublicseasOpen = new Class({
  5. Extends: MWF.xApplication.CRM.Template.PopupForm,
  6. Implements: [Options, Events],
  7. options: {
  8. "style": "default",
  9. "width": "800",
  10. "height": "100%",
  11. "top" : 0,
  12. "left" : 0,
  13. "hasTop": true,
  14. "hasIcon": false,
  15. "hasBottom": true,
  16. "title": "",
  17. "draggable": false,
  18. "closeAction": true
  19. },
  20. initialize: function (explorer, actions, data, options) {
  21. this.setOptions(options);
  22. this.explorer = explorer;
  23. this.app = explorer.app;
  24. this.lp = this.app.lp.publicseas.customerEdit;
  25. this.path = "../x_component_CRM/$ClueEdit/";
  26. this.cssPath = this.path + this.options.style + "/css.wcss";
  27. this._loadCss();
  28. this.options.title = this.lp.title;
  29. this.data = data || {};
  30. this.actions = actions;
  31. this.configData = [];
  32. debugger
  33. },
  34. load: function () {
  35. that = this;
  36. this.loadResource(function(){
  37. this.appArea = jQuery("body").children(":first");
  38. this.createForm();
  39. this.loadEvent();
  40. }.bind(this))
  41. },
  42. loadResource: function ( callback ) {
  43. if(callback)callback();
  44. },
  45. createForm:function(){
  46. that = this;
  47. var clueName = this.options.openName;
  48. /*this.createContentHtml(this.options.clueId);*/
  49. var buttonHtml = '<div class = "headBottonDiv">' +
  50. '<div class="headMoreBottonDiv"><span>更多</span><img class="headMoreImg" src="../x_component_CRM/$Clue/default/icons/arrow.png"></div></div>';
  51. var moreHtml = '<ul class="el-dropdown-menu"><li class="el-dropdown-menu__item">分配</li>'+
  52. '<li class="el-dropdown-menu__item">领取</li>'+
  53. '<li class="el-dropdown-menu__item">删除</li><div class="popper__arrow"></div></ul>';
  54. var sectionId = that.getNotifyMax();
  55. var sjson = this.options.openStyle?this.options.openStyle:this.xxx;
  56. jQuery(".headMoreImg").notifyMe(
  57. 'right',
  58. 'default',
  59. clueName,
  60. buttonHtml,
  61. moreHtml,
  62. '',
  63. sectionId,
  64. 500,
  65. sjson
  66. );
  67. that.createContentHtml(sectionId);
  68. },
  69. getNotifyMax : function () {
  70. var sectionId = 'notify';
  71. var sectionNum = 0;
  72. if(!(this.options.openType) || (this.options.openType !="single")) {
  73. jQuery(".notify").each(function (index, element) {
  74. var notifyId = jQuery(element).attr("id");
  75. var notifyNum = 0;
  76. if (notifyId.indexOf("_") > 0) {
  77. notifyNum = parseInt(notifyId.split("_")[1]);
  78. if (notifyNum > sectionNum) {
  79. sectionNum = notifyNum;
  80. }
  81. } else {
  82. if (sectionNum == 0) {
  83. sectionNum = 1;
  84. }
  85. }
  86. });
  87. if (sectionNum > 0) {
  88. sectionId = sectionId + '_' + sectionNum;
  89. }
  90. }
  91. return sectionId;
  92. },
  93. createContentHtml: function (sectionId) {
  94. that = this;
  95. this.sectionArea = jQuery("body")[0].getElement("#"+sectionId);
  96. debugger
  97. this.actions.getCustomerInfo(this.options.openId, function (json) {
  98. var jsonObj = json.data;
  99. var owneruser = (jsonObj.owneruser=="" || (typeof(jsonObj.owneruser)=="undefined"))?"--":(jsonObj.owneruser).split("@")[0];
  100. var briefDiv = "<div class = 'briefdiv'>"+
  101. "<div class='div-inline'><div class='div-title'>客户级别</div><div class='div-value'>"+jsonObj.level+"</div></div>"+
  102. "<div class='div-inline'><div class='div-title'>成交状态</div><div class='div-value'>"+jsonObj.dealstatus+"</div></div>"+
  103. "<div class='div-inline'><div class='div-title'>负责人</div><div class='div-value'>"+owneruser+"</div></div>"+
  104. "<div class='div-inline'><div class='div-title'>更新时间</div><div class='div-value'>"+jsonObj.updateTime+"</div></div>"+
  105. "</div>"
  106. var tabPanel = "<div class='tabPanel'><div class='hit'>跟进记录</div><div style='width:30px'></div><div>基本信息</div><div style='width:30px'></div>"+
  107. "<div>联系人</div><div style='width:30px'></div><div>相关团队</div><div style='width:30px'></div><div>商机</div><div style='width:30px'></div>"+
  108. "<div>附件</div><div style='width:30px'></div><div>操作记录</div></div>"
  109. var tabConent ="<div class='panes'><div class='pane' id='tab-follow' style='display:block;'><p>First tab content</p></div><div></div>"+
  110. "<div class='pane' id='tab-basicinfo'><p>Secend tab content</p></div><div></div>"+
  111. "<div class='pane' id='tab-contacts'><p>contacts tab content</p></div><div></div>"+
  112. "<div class='pane' id='tab-team'><p>team tab content</p></div><div></div>"+
  113. "<div class='pane' id='tab-business'><p>business tab content</p></div><div></div>"+
  114. "<div class='pane' id='tab-att'><p>Third tab content</p></div><div></div>"+
  115. "<div class='pane' id='tab-options'><p>Four tab content</p></div></div>"
  116. //jQuery("#"+sectionId).find(".notify-content").html( briefDiv+tabPanel+tabConent);
  117. this.sectionArea.getElement(".notify-content").set("html",briefDiv+tabPanel+tabConent);
  118. var size = this.sectionArea.getSize();
  119. this.sectionArea.getElement(".panes").setStyles({"height":(size.y-250)+"px"});
  120. var indexHtml = '';
  121. var indexSendHtml = '';
  122. var indexContentHtml = '<div class="log-cont"><div class="log-inner1"><div class="log-inner2"><div class="log-items">'+
  123. '<div class="load"><button type="button" class="el-button el-button--text"><span>没有更多了</span></button></div></div>'+
  124. '<div class="empty-mask" style="display: none;"><div class="empty-content"><img src="../x_component_CRM/$Template/empty.png" class="empty-icon"> <p class="empty-text">没有找到数据</p></div></div></div>'+
  125. '<div class="el-loading-mask" style="display: none;"><div class="el-loading-spinner"><svg viewBox="25 25 50 50" class="circular"><circle cx="50" cy="50" r="20" fill="none" class="path"></circle></svg></div></div>'+
  126. '</div></div>';
  127. //jQuery("#"+sectionId).find("#tab-follow").html(indexHtml+indexSendHtml+indexContentHtml);
  128. this.sectionArea.getElement("#tab-follow").set("html",indexHtml+indexSendHtml+indexContentHtml);
  129. that.loadTimeContainer('stime');
  130. that.loadRecord();
  131. }.bind(this));
  132. },
  133. createTypeHtml: function () {
  134. var createType = jQuery(this.sectionArea).find(".hit").text();
  135. debugger
  136. if(createType == "基本信息") {
  137. this.getPublicseasInfo();
  138. }
  139. if(createType == "联系人") {
  140. this.loadContacts();
  141. }
  142. if(createType == "相关团队") {
  143. this.loadTeam();
  144. }
  145. if(createType == "商机") {
  146. this.loadBusiness();
  147. }
  148. if(createType == "附件") {
  149. this.loadAttachment();
  150. }
  151. if(createType == "操作记录") {
  152. this.loadOptions();
  153. }
  154. },
  155. loadTimeContainer: function(stime){
  156. jQuery("#"+stime).ymdateplugin({
  157. showTimePanel: true
  158. });
  159. },
  160. getPublicseasInfo: function () {
  161. _self = this;
  162. this.actions.getCustomerInfo(this.options.openId, function (json) {
  163. var jsonObj = json.data;
  164. var section_header = '<div class="section-header"><div class="section-mark" style="border-left-color: rgb(70, 205, 207);"></div> '+
  165. '<div data-v-ec8f8850="" class="section-title">基本信息</div></div>'
  166. var itemTemplateObject = _self.getItemTemplate(_self.lp );
  167. var section_conent = '<div class="section-conent">';
  168. for ( i in itemTemplateObject){
  169. section_conent = section_conent+'<div class="conent-inline"><div class="conent-title">'+itemTemplateObject[i].text+'</div>' +
  170. '<div class="conent-value">'+((typeof(jsonObj[i])=="undefined")?"" : jsonObj[i])+'</div></div>';
  171. }
  172. section_conent = section_conent + '</div>';
  173. //jQuery("#tab-basicinfo").html(section_header+section_conent);
  174. jQuery(_self.sectionArea).find("#tab-basicinfo").html(section_header+section_conent);
  175. //this.contentHtml = briefDiv+tabPanel+tabConent;
  176. }.bind(this));
  177. },
  178. loadAttachment: function() {
  179. that = this;
  180. var attHtml = '<div class="rc-cont">';
  181. var attButton = '';
  182. var attHeader = '<div class="el-table el-table--fit el-table--striped el-table--enable-row-hover" header-align="center" style="width: 100%; border: 1px solid rgb(230, 230, 230); height: 500px;" align="center">'+
  183. '<div class="el-table__header-wrapper"><table class="el-table__header" style="width: 100%;" cellspacing="0" cellpadding="0" border="0"><thead class="has-gutter">'+
  184. '<tr class=""><th colspan="1" rowspan="1" class="el-table_3_column_27 is-leaf" style="width: 40%;height:40px;"><div class="cell">附件名称</div></th>'+
  185. '<th colspan="1" rowspan="1" class="el-table_3_column_28 is-leaf" style="width: 10%;"><div class="cell">附件大小</div></th>'+
  186. '<th colspan="1" rowspan="1" class="el-table_3_column_29 is-leaf" style="width: 20%;"><div class="cell">上传人</div></th>'+
  187. '<th colspan="1" rowspan="1" class="el-table_3_column_30 is-leaf" style="width: 20%;"><div class="cell">上传时间</div></th></tr></thead></table></div>';
  188. var attBody = '<div class="el-table__body-wrapper is-scrolling-none" style="height: 450px;">'+
  189. '<table class="el-table__body" style="width: 100%;" cellspacing="0" cellpadding="0" border="0"><tbody></tbody></table>'+
  190. '<div class="el-table__empty-block" style="width: 100%;"><span class="el-table__empty-text">暂无数据</span></div></div></div>';
  191. attHtml = attHtml+attButton+attHeader+attBody+'</div>';
  192. jQuery(that.sectionArea).find("#tab-att").html(attHtml);
  193. jQuery(that.sectionArea).find('#afile').change(function(event) {
  194. var objFile = jQuery(that.sectionArea).find('#afile')[0].files;
  195. jQuery(objFile).each(function(index,file){
  196. var filter = {};
  197. filter = {
  198. file:file,
  199. fileName:file.name
  200. };
  201. var formdata=new FormData();
  202. formdata.append("fileName",file.name);
  203. formdata.append("file",file);
  204. that.actions.updateAttachment("att", that.options.openId, "customer", formdata,file, function (json) {
  205. if(json.type=="success"){
  206. //Showbo.Msg.alert('附件上传成功!');
  207. that.getAttachment();
  208. }
  209. }.bind(that));
  210. }
  211. );
  212. });
  213. that.getAttachment();
  214. },
  215. getAttachment: function(){
  216. that = this;
  217. this.actions.getAttachment(this.options.openId, function (json) {
  218. debugger
  219. if(json.type=="success"){
  220. var attDatas = json.data;
  221. var tbodyHtml = "";
  222. for ( i in attDatas){
  223. if(i<attDatas.length){
  224. var attData = attDatas[i];
  225. var fsize = attData.length/1024;
  226. var lastUpdatePerson = attData.lastUpdatePerson;
  227. lastUpdatePerson = lastUpdatePerson.split("@")[0];
  228. tbodyHtml = tbodyHtml+'<tr><td style="width: 40%;height:40px;" class="aname" aid="'+attData.id+'" wcrm="'+attData.wcrm+'">'+attData.name+'</td><td style="width: 10%;">'+that.toDecimal(fsize)+'kb</td>'+
  229. '<td style="width: 20%;">'+lastUpdatePerson+'</td><td style="width: 20%;">'+attData.updateTime+'</td></tr>';
  230. }
  231. }
  232. if(tbodyHtml!=""){
  233. jQuery(that.sectionArea).find(".el-table__body").children().html(tbodyHtml);
  234. jQuery(that.sectionArea).find(".el-table__empty-block").hide();
  235. jQuery(that.sectionArea).find(".aname").click(function(){
  236. var attUrl = 'http://172.16.92.55:20020/x_wcrm_assemble_control/jaxrs/attachment/download/'+jQuery(this).attr("aid")+'/work/'+jQuery(this).attr("wcrm")
  237. window.open(attUrl);
  238. /*that.actions.downloadAttachment(jQuery(this).attr("aid"),jQuery(this).attr("wcrm"), function (wjson) {
  239. }.bind(that));*/
  240. });
  241. }
  242. }
  243. }.bind(that));
  244. },
  245. loadContacts: function() {
  246. that = this;
  247. var attHtml = '<div class="rc-cont">';
  248. var attButton = '';
  249. var attHeader = '<div class="el-table el-table--fit el-table--striped el-table--enable-row-hover" header-align="center" style="width: 100%; border: 1px solid rgb(230, 230, 230); height: 500px;" align="center">'+
  250. '<div class="el-table__header-wrapper"><table class="el-table__header" style="width: 100%;" cellspacing="0" cellpadding="0" border="0"><thead class="has-gutter">'+
  251. '<tr class=""><th colspan="1" rowspan="1" class="el-table_3_column_27 is-leaf" style="width: 33%;height:40px;"><div class="cell">姓名</div></th>'+
  252. '<th colspan="1" rowspan="1" class="el-table_3_column_29 is-leaf" style="width: 34%;"><div class="cell">手机</div></th>'+
  253. '<th colspan="1" rowspan="1" class="el-table_3_column_26 is-leaf" style="width: 33%;"><div class="cell">职务</div></th></tr></thead></table></div>';
  254. var attBody = '<div class="el-table__body-wrapper is-scrolling-none" style="height: 450px;">'+
  255. '<table class="el-table__body" style="width: 100%;" cellspacing="0" cellpadding="0" border="0"><tbody></tbody></table>'+
  256. '<div class="el-table__empty-block" style="width: 100%;"><span class="el-table__empty-text">暂无数据</span></div></div></div>';
  257. attHtml = attHtml+attButton+attHeader+attBody+'</div>';
  258. jQuery(that.sectionArea).find("#tab-contacts").html(attHtml);
  259. this.actions.getContacts(this.options.openId, function (json) {
  260. if(json.type=="success"){
  261. var attDatas = json.data;
  262. var tbodyHtml = "";
  263. for ( i in attDatas){
  264. if(i<attDatas.length){
  265. var attData = attDatas[i];
  266. tbodyHtml = tbodyHtml+'<tr><td style="width: 34%;height:40px;" class="aname" aid="'+attData.id+'">'+attData.contactsname+'</td>'+
  267. '<td style="width: 33%;">'+attData.cellphone+'</td><td style="width: 33%;">'+attData.post+'</td></tr>';
  268. }
  269. }
  270. if(tbodyHtml!=""){
  271. jQuery(that.sectionArea).find(".el-table__body").children().html(tbodyHtml);
  272. jQuery(that.sectionArea).find(".el-table__empty-block").hide();
  273. }
  274. }
  275. }.bind(that));
  276. jQuery(that.sectionArea).find("#tab-contacts").find(".rc-head-item").click(function(){
  277. that.contactsCreate();
  278. });
  279. jQuery(that.sectionArea).find("#tab-contacts").find(".aname").click(function(){
  280. //that.contactsEdit(jQuery(this).attr("aid"));
  281. });
  282. },
  283. loadTeam: function() {
  284. that = this;
  285. var attHtml = '<div class="rc-cont">';
  286. var attButton = '';
  287. var attHeader = '<div class="el-table el-table--fit el-table--striped el-table--enable-row-hover" header-align="center" style="width: 100%; border: 1px solid rgb(230, 230, 230); height: 500px;" align="center">'+
  288. '<div class="el-table__header-wrapper"><table class="el-table__header" style="width: 100%;" cellspacing="0" cellpadding="0" border="0"><thead class="has-gutter">'+
  289. '<tr class=""><th colspan="1" rowspan="1" class="el-table_3_column_27"><div class="cell">'+
  290. '<input class="inp-cbx" id="all" type="checkbox" style="display: none;"/><label class="cbx cbxx" for="all"><span><svg width="12px" height="10px"><use xlink:href="#check"></use></svg></span><span></span></label></div></th>'+
  291. '<th colspan="1" rowspan="1" class="el-table_3_column_27 is-leaf" style="width: 30%;height:40px;"><div class="cell">姓名</div></th>'+
  292. '<th colspan="1" rowspan="1" class="el-table_3_column_29 is-leaf" style="width: 20%;"><div class="cell">职位</div></th>'+
  293. '<th colspan="1" rowspan="1" class="el-table_3_column_29 is-leaf" style="width: 20%;"><div class="cell">团队角色</div></th>'+
  294. '<th colspan="1" rowspan="1" class="el-table_3_column_26 is-leaf" style="width: 20%;"><div class="cell">权限</div></th></tr></thead></table></div>'+
  295. '<svg class="inline-svg"><symbol id="check" viewbox="0 0 12 10"><polyline points="1.5 6 4.5 9 10.5 1" ></polyline></symbol></svg>';
  296. var attBody = '<div class="el-table__body-wrapper is-scrolling-none" style="height: 450px;">'+
  297. '<table class="el-table__body" style="width: 100%;" cellspacing="0" cellpadding="0" border="0"><tbody></tbody></table>'+
  298. '<div class="el-table__empty-block" style="width: 100%;"><span class="el-table__empty-text">暂无数据</span></div></div></div>';
  299. attHtml = attHtml+attButton+attHeader+attBody+'</div>';
  300. jQuery(that.sectionArea).find("#tab-team").html(attHtml);
  301. this.actions.getTeamMemberListById(this.options.openId, function (json) {
  302. if(json.type=="success"){
  303. var attDatas = json.data;
  304. var tbodyHtml = "";
  305. for ( i in attDatas){
  306. if(i<attDatas.length){
  307. var attData = attDatas[i];
  308. var unit = (attData.units.length>0)?((attData.units[0]).split("@")[0]):"";
  309. var id = 'all'+i;
  310. var cdiv = '<div class="cell">'+
  311. '<input class="inp-cbx" id="'+id+'" type="checkbox" style="display: none;"/><label class="cbx cbxx" for="'+id+'"><span><svg width="12px" height="10px"><use xlink:href="#check"></use></svg></span><span></span></label></div>'
  312. if(attData.teamRole && attData.teamRole=="负责人"){
  313. cdiv = '<div class="cell">'+
  314. '<input class="inp-cbx" id="'+id+'" type="checkbox" style="display: none;"/><label class="cbx" for="xx"><span style="background: #e6e6e6;"><svg width="12px" height="0px"><use xlink:href="#check"></use></svg></span><span></span></label></div>'
  315. }
  316. if(attData.teamRole && attData.teamRole!=""){
  317. tbodyHtml = tbodyHtml+'<tr><td style="width: 10%;height:40px;">'+cdiv+'</td><td style="width: 30%;" class="aname" aid="'+attData.person.distinguishedName+'">'+attData.person.name+
  318. '</td><td style="width: 20%;">'+unit+'</td><td style="width: 20%;">'+attData.teamRole+'</td><td style="width: 20%;">'+attData.dispaly_permission+'</td></tr>';
  319. }
  320. }
  321. }
  322. if(tbodyHtml!=""){
  323. jQuery(that.sectionArea).find(".el-table__body").children().html(tbodyHtml);
  324. jQuery(that.sectionArea).find(".el-table__empty-block").hide();
  325. }
  326. }
  327. }.bind(that));
  328. jQuery("[for='all']").click(function(){
  329. //var cobj = jQuery("[for='all1']");
  330. var cobj = jQuery(that.sectionArea).find(".cbxx").not("[for='all']");
  331. if (jQuery(this).prev().is(':checked')) {
  332. cobj.each(function(index,element){
  333. jQuery(element).prev().prop("checked", false);
  334. });
  335. } else {
  336. cobj.each(function(index,element){
  337. jQuery(element).prev().prop("checked", true);
  338. });
  339. }
  340. });
  341. },
  342. loadBusiness: function() {
  343. that = this;
  344. var attHtml = '<div class="rc-cont">';
  345. var attButton = '';
  346. var attHeader = '<div class="el-table el-table--fit el-table--striped el-table--enable-row-hover" header-align="center" style="width: 100%; border: 1px solid rgb(230, 230, 230); height: 500px;" align="center">'+
  347. '<div class="el-table__header-wrapper"><table class="el-table__header" style="width: 100%;" cellspacing="0" cellpadding="0" border="0"><thead class="has-gutter">'+
  348. '<tr class=""><th colspan="1" rowspan="1" class="el-table_3_column_27 is-leaf" style="width: 30%;height:40px;"><div class="cell">商机名称</div></th>'+
  349. '<th colspan="1" rowspan="1" class="el-table_3_column_29 is-leaf" style="width: 20%;"><div class="cell">商品金额</div></th>'+
  350. '<th colspan="1" rowspan="1" class="el-table_3_column_29 is-leaf" style="width: 30%;"><div class="cell">客户名称</div></th>'+
  351. '<th colspan="1" rowspan="1" class="el-table_3_column_29 is-leaf" style="width: 20%;"><div class="cell">商机状态组</div></th>'+
  352. '<th colspan="1" rowspan="1" class="el-table_3_column_26 is-leaf" style="width: 20%;"><div class="cell">状态</div></th></tr></thead></table></div>';
  353. var attBody = '<div class="el-table__body-wrapper is-scrolling-none" style="height: 450px;">'+
  354. '<table class="el-table__body" style="width: 100%;" cellspacing="0" cellpadding="0" border="0"><tbody></tbody></table>'+
  355. '<div class="el-table__empty-block" style="width: 100%;"><span class="el-table__empty-text">暂无数据</span></div></div></div>';
  356. attHtml = attHtml+attButton+attHeader+attBody+'</div>';
  357. jQuery(that.sectionArea).find("#tab-business").html(attHtml);
  358. this.actions.getOpportunityListByCustomerId(this.options.openId, function (json) {
  359. if(json.type=="success"){
  360. var attDatas = json.data;
  361. var tbodyHtml = "";
  362. for ( i in attDatas){
  363. if(i<attDatas.length){
  364. var attData = attDatas[i];
  365. tbodyHtml = tbodyHtml+'<tr><td style="width: 30%;height:40px;" class="aname" aid="'+attData.id+'">'+attData.opportunityname+
  366. '</td><td style="width: 20%;">'+attData.money+'</td><td style="width: 30%;">'+attData.customer.customername+
  367. '</td><td style="width: 20%;">'+attData.opportunityType.opportunitytypename+'</td><td style="width: 20%;">'+attData.opportunityStatus.opportunitystatusname+'</td></tr>';
  368. }
  369. }
  370. if(tbodyHtml!=""){
  371. jQuery(that.sectionArea).find(".el-table__body").children().html(tbodyHtml);
  372. jQuery(that.sectionArea).find(".el-table__empty-block").hide();
  373. }
  374. }
  375. }.bind(that));
  376. jQuery(that.sectionArea).find("#tab-business").find(".rc-head-item").click(function(){
  377. that.businessCreate();
  378. });
  379. jQuery(that.sectionArea).find("#tab-business").find(".aname").click(function(){
  380. //that.contactsEdit(jQuery(this).attr("aid"));
  381. });
  382. },
  383. loadOptions: function() {
  384. that = this;
  385. var optionsHtml = '<div class="rc-cont">'+
  386. '<div class="empty-mask" style="display:none;height:370px;"><div class="empty-content" style="margin-top:0px;"><img src="../x_component_CRM/$Template/empty.png" class="empty-icon"> <p class="empty-text">没有找到数据</p></div></div></div>'
  387. jQuery(that.sectionArea).find("#tab-options").html(optionsHtml);
  388. this.actions.getOptionsRecord(this.options.openId, function (json) {
  389. if(json.type=="success"){
  390. var recordDatas = json.data;
  391. jQuery(that.sectionArea).find(".rc-cont").find(".vux-flexbox").remove();
  392. var logItemHtml = "";
  393. for ( i in recordDatas){
  394. if(i<recordDatas.length){
  395. var recordData = recordDatas[i];
  396. var personImg = 'http://172.16.92.55../x_component_CRM/$Template/portrait.png';
  397. var updatetime = recordData.updateTime;
  398. logItemHtml = logItemHtml+'<div class="vux-flexbox ha-cont vux-flex-row" style="justify-content: flex-start; align-items: stretch;">'+
  399. '<div class="ha-week">'+recordData.DateCN+'</div>'+
  400. '<div class="ha-circle"></div> '+
  401. '<div class="ha-time">'+updatetime.substring(11,16)+'</div>'+
  402. '<div class="div-photo ha-img xs-photo-parent--relative" style="background-image: url(&quot;'+personImg+'&quot;);" lazy="error"><div class="photo-wrap"></div></div>' +
  403. '<div class="ha-name">'+recordData.person.name+'</div>'+
  404. '<div class="ha-content">'+recordData.content+'</div>'+
  405. '<div class="ha-line"></div></div>'
  406. }
  407. }
  408. if(logItemHtml!=""){
  409. jQuery(that.sectionArea).find(".rc-cont").append(logItemHtml);
  410. }
  411. if(recordDatas.length<1){
  412. jQuery(that.sectionArea).find(".empty-mask").show();
  413. }
  414. }
  415. }.bind(this));
  416. },
  417. receiveCustomer: function () {
  418. _self = this;
  419. var contentHtml = '确定要领取此客户吗?领取后将在公海移除。'
  420. Showbo.Msg.confirm('提示',contentHtml,function(){
  421. _self.confirmReceiveCustomer();
  422. },function(){
  423. });
  424. jQuery('.handle-item-content').click(function(){
  425. jQuery(".ct").find(".el-dropdown-confirm").toggle(100);
  426. });
  427. },
  428. confirmReceiveCustomer: function () {
  429. this.actions.receiveCustomer(this.options.openId, function (json) {
  430. if(json.type == "success"){
  431. Showbo.Msg.alert('操作成功!');
  432. }
  433. }.bind(this));
  434. },
  435. distributeCustomer: function () {
  436. //转移负责人
  437. _self = this;
  438. var contentHtml = '<div class="vux-flexbox handle-item vux-flex-row" style="align-items: stretch;padding: 30px 20px 0px 20px;line-height:30px;">'+
  439. '<div class="handle-item-name" style="margin-top: 8px;width:130px;">分配给:</div><div class="el-select handle-item-content" style="margin-top: 8px;"><div class="se-select-name" id="selectName" style="display: inline-block;">+点击选择</div><div id="selectId" style="display:none;"></div></div></div>'+
  440. '<div class="vux-flexbox handle-item vux-flex-row" style="align-items: stretch;padding: 10px 20px 80px 20px;line-height:30px;"></div></div>'
  441. Showbo.Msg.confirm('公海分配',contentHtml,function(){
  442. //_self.confirmCustomerDealstatus();
  443. var transferType = "";
  444. var readOrWrite = "";
  445. var checkFlag = true;
  446. var relationTypeList = [];
  447. if(jQuery("#selectId").text() == ""){
  448. checkFlag = false;
  449. Showbo.Msg.alert('请选择负责人!');
  450. }
  451. if(checkFlag){
  452. var filter = {};
  453. filter = {
  454. distinguishName: jQuery('#selectId').text()
  455. }
  456. debugger
  457. _self.actions.distributeCustomer(_self.options.openId, filter, function (json) {
  458. if(json.type=="success"){
  459. Showbo.Msg.alert('操作成功!');
  460. }
  461. setTimeout(function(){
  462. jQuery("#notifyEdit").remove();
  463. if(jQuery(".mask").length>0){
  464. jQuery(".mask").attr("style",'left: 0px; top: 0px; width: 100%; overflow: hidden; position: absolute; z-index: 500000; background-color: rgb(255, 255, 255)');
  465. jQuery(".mask").attr("class","");
  466. }
  467. },200);
  468. }.bind(_self));
  469. }
  470. },function(){
  471. });
  472. jQuery(".ct").find(".se-select-name").click(function(){
  473. _self.selectPerson(jQuery(_self.appArea)[0],"selectName","selectId",0);
  474. });
  475. },
  476. loadEvent: function(){
  477. that = this;
  478. jQuery(that.sectionArea).find('.tabPanel div').click(function(){
  479. debugger
  480. jQuery(this).addClass('hit').siblings().removeClass('hit');
  481. jQuery(that.sectionArea).find('.panes>div:eq('+jQuery(this).index()+')').show().siblings().hide();
  482. that.createTypeHtml();
  483. });
  484. jQuery(that.sectionArea).find('.headMoreBottonDiv').click(function(){
  485. jQuery(that.sectionArea).find(".el-dropdown-menu").toggle(100);
  486. });
  487. jQuery(that.sectionArea).find('.el-dropdown-menu__item').click(function(){
  488. debugger
  489. if(jQuery(this).text()=="分配"){
  490. that.distributeCustomer();
  491. }
  492. if(jQuery(this).text()=="领取"){
  493. that.receiveCustomer();
  494. }
  495. if(jQuery(this).text()=="删除"){
  496. }
  497. //---for记录类型
  498. if(jQuery(this).parent().attr("tid")=="recordType"){
  499. jQuery(that.sectionArea).find(".se-select-name").text(jQuery(this).text());
  500. jQuery(this).parent().toggle(100);
  501. }
  502. });
  503. jQuery(that.sectionArea).find('#bar-file').change(function(event) {
  504. var files = event.target.files;
  505. debugger
  506. jQuery(that.sectionArea).find('.fileList').empty();
  507. if (files && files.length > 0) {
  508. // 获取目前上传的文件
  509. var fileListHtml = '<div class="fileList">';
  510. for(var i=0;i<files.length;i++){
  511. var file = files[i];
  512. var fsize = file.size/1024;
  513. var lastModifiedDate = file.lastModifiedDate;
  514. fileListHtml = fileListHtml+'<div class="fileItem"><div class="fname">'+file.name+'</div><div class="fsize">'+that.toDecimal(fsize)+'kb</div><div class="ftime">'+that.getFormateTime(lastModifiedDate)+'</div></div>';
  515. }
  516. fileListHtml = fileListHtml+'</div>';
  517. jQuery(that.sectionArea).find('.mix-container').append(fileListHtml);
  518. /*
  519. file = files[0];
  520. // 来在控制台看看到底这个对象是什么
  521. console.log(file);
  522. var filter = {};
  523. filter = {
  524. file:file,
  525. fileName:file.name
  526. };
  527. debugger
  528. var formdata=new FormData();
  529. formdata.append("fileName",file.name);
  530. formdata.append("file",file);
  531. that.actions.updateAttachment(that.options.clueId, "leads", formdata,file, function (json) {
  532. debugger
  533. if(json.type=="success"){
  534. Showbo.Msg.alert('附件上传成功!');
  535. }
  536. }.bind(that));
  537. /!*!// 那么我们可以做一下诸如文件大小校验的动作
  538. if(file.size > 1024 * 1024 * 2) {
  539. alert('图片大小不能超过 2MB!');
  540. return false;
  541. }*!/
  542. // 下面是关键的关键,通过这个 file 对象生成一个可用的图像 URL
  543. // 获取 window 的 URL 工具
  544. var URL = window.URL || window.webkitURL;
  545. // 通过 file 生成目标 url
  546. var imgURL = URL.createObjectURL(file);
  547. // 用这个 URL 产生一个 <img> 将其显示出来
  548. //jQuery('.fbpj .container').prev().find("img").attr('src', imgURL);
  549. jQuery('.mix-container').append('<div><img src="'+imgURL+'"></div>');
  550. // 使用下面这句可以在内存中释放对此 url 的伺服,跑了之后那个 URL 就无效了
  551. //URL.revokeObjectURL(imgURL);
  552. */
  553. }
  554. });
  555. jQuery(that.sectionArea).find('.el-dropdown-selfdefine').click(function(){
  556. jQuery(that.sectionArea).find("[tid='recordType']").toggle(100);
  557. });
  558. },
  559. loadRecord: function(){
  560. that = this;
  561. this.actions.getRecord(this.options.openId, function (json) {
  562. if(json.type=="success"){
  563. var recordDatas = json.data;
  564. jQuery(that.sectionArea).find(".fl-c").remove();
  565. var logItemHtml = "";
  566. for ( i in recordDatas){
  567. if(i<recordDatas.length){
  568. var recordData = recordDatas[i];
  569. var personImg = '../x_component_CRM/$Template/portrait.png';
  570. if(recordData.ICONBase64 && recordData.ICONBase64!=""){
  571. personImg = recordData.ICONBase64;
  572. }
  573. var attHtml = '';
  574. var relationHtml = '';
  575. if(recordData.attachmentListPreview.length>0){
  576. attHtml = attHtml+'<div class="vux-flexbox fl-b-images vux-flex-row" style="flex-wrap: wrap;"></div>'
  577. }
  578. if(recordData.attachmentList.length>0){
  579. attHtml = attHtml+'<div class="fl-b-files">';
  580. var attList = recordData.attachmentList;
  581. for(j in attList){
  582. if(j<attList.length){
  583. var attData = attList[j];
  584. attHtml = attHtml+'<div class="vux-flexbox cell vux-flex-row">'+
  585. '<img src="../x_component_CRM/$Record/default/icons/att.png" class="cell-head"> <div class="cell-body">'+attData.name+'<span style="color: rgb(204, 204, 204);">('+that.toDecimal(attData.length)+'KB)</span></div>'+
  586. '<button type="button" class="el-button el-button--primary aname" aid="'+attData.id+'" wcrm="'+attData.wcrm+'"><img src="../x_component_CRM/$Record/default/icons/down.png" style="margin-bottom:-3px;"><span>下载</span></button></div>'
  587. }
  588. }
  589. attHtml = attHtml+'</div>';
  590. }
  591. logItemHtml = logItemHtml+'<div class="fl-c"><div class="vux-flexbox fl-h vux-flex-row">'+
  592. '<div class="div-photo fl-h-img" style="background-image: url(&quot;'+personImg+'&quot;);" lazy="loaded"></div> '+
  593. '<div class="fl-h-b"><div class="fl-h-name">'+recordData.person.name+'</div><div class="fl-h-time">'+recordData.updateTime+'</div></div></div>'+
  594. '<div class="fl-b"><div class="fl-b-content">'+recordData.content+'</div>'+attHtml+
  595. '<div class="follow"><span class="follow-info">'+recordData.category+'</span></div></div>'+
  596. '<div class="full-container" style="display: none;"></div></div>'
  597. }
  598. }
  599. if(logItemHtml!=""){
  600. jQuery(that.sectionArea).find(".load").before(logItemHtml);
  601. }
  602. if(recordDatas.length<1){
  603. jQuery(that.sectionArea).find(".load").hide();
  604. jQuery(that.sectionArea).find(".empty-mask").show();
  605. }
  606. jQuery(".aname").click(function(){
  607. var attUrl = 'http://172.16.92.55:20020/x_wcrm_assemble_control/jaxrs/attachment/download/'+jQuery(this).attr("aid")+'/work/'+jQuery(this).attr("wcrm")
  608. window.open(attUrl);
  609. });
  610. }
  611. }.bind(this));
  612. },
  613. open: function (e) {
  614. this.fireEvent("queryOpen");
  615. this._open();
  616. this.fireEvent("postOpen");
  617. },
  618. create: function () {
  619. this.fireEvent("queryCreate");
  620. this.isNew = true;
  621. this._open();
  622. this.fireEvent("postCreate");
  623. },
  624. edit: function () {
  625. this.fireEvent("queryEdit");
  626. this.isEdited = true;
  627. this._open();
  628. this.fireEvent("postEdit");
  629. },
  630. _open: function () {
  631. if( this.options.hasMask ){
  632. this.formMaskNode = new Element("div.formMaskNode", {
  633. "styles": this.css.formMaskNode,
  634. "events": {
  635. "mouseover": function (e) {
  636. e.stopPropagation();
  637. },
  638. "mouseout": function (e) {
  639. e.stopPropagation();
  640. },
  641. "click": function (e) {
  642. e.stopPropagation();
  643. }
  644. }
  645. }).inject( this.container || this.app.content);
  646. }
  647. this.formAreaNode = new Element("div.formAreaNode", {
  648. "styles": this.css.formAreaNode
  649. });
  650. this.createFormNode();
  651. this.formAreaNode.inject(this.formMaskNode || this.container || this.app.content, "after");
  652. this.formAreaNode.fade("in");
  653. this.setFormNodeSize();
  654. this.setFormNodeSizeFun = this.setFormNodeSize.bind(this);
  655. if( this.app )this.app.addEvent("resize", this.setFormNodeSizeFun);
  656. if (this.options.draggable && this.formTopNode) {
  657. var size = (this.container || this.app.content).getSize();
  658. var nodeSize = this.formAreaNode.getSize();
  659. this.formAreaNode.makeDraggable({
  660. "handle": this.formTopNode,
  661. "limit": {
  662. "x": [0, size.x - nodeSize.x],
  663. "y": [0, size.y - nodeSize.y]
  664. }
  665. });
  666. }
  667. },
  668. createFormNode: function () {
  669. var _self = this;
  670. this.formNode = new Element("div.formNode", {
  671. "styles": this.css.formNode
  672. }).inject(this.formAreaNode);
  673. if (this.options.hasTop) {
  674. this.createTopNode();
  675. }
  676. if (this.options.hasIcon) {
  677. this.formIconNode = new Element("div.formIconNode", {
  678. "styles": this.isNew ? this.css.formNewNode : this.css.formIconNode
  679. }).inject(this.formNode);
  680. }
  681. this.createContent();
  682. //formContentNode.set("html", html);
  683. if (this.options.hasBottom) {
  684. this.createBottomNode();
  685. }
  686. this._setCustom();
  687. if( this.options.hasScroll ){
  688. //this.setScrollBar(this.formTableContainer)
  689. MWF.require("MWF.widget.ScrollBar", function () {
  690. new MWF.widget.ScrollBar(this.formTableContainer, {
  691. "indent": false,
  692. "style": "default",
  693. "where": "before",
  694. "distance": 30,
  695. "friction": 4,
  696. "axis": {"x": false, "y": true},
  697. "onScroll": function (y) {
  698. //var scrollSize = _self.viewContainerNode.getScrollSize();
  699. //var clientSize = _self.viewContainerNode.getSize();
  700. //var scrollHeight = scrollSize.y - clientSize.y;
  701. //if (y + 200 > scrollHeight && _self.view && _self.view.loadElementList) {
  702. // if (!_self.view.isItemsLoaded) _self.view.loadElementList();
  703. //}
  704. }
  705. });
  706. }.bind(this));
  707. }
  708. },
  709. createContent: function () {
  710. this.formContentNode = new Element("div.formContentNode", {
  711. "styles": this.css.formContentNode
  712. }).inject(this.formNode);
  713. this.formTableContainer = new Element("div.formTableContainer", {
  714. "styles": this.css.formTableContainer
  715. }).inject(this.formContentNode);
  716. this.formTableArea = new Element("div.formTableArea", {
  717. "styles": this.css.formTableArea,
  718. "text":"loading..."
  719. }).inject(this.formTableContainer);
  720. this._createTableContent();
  721. },
  722. createBottomNode: function () {
  723. this.formBottomNode = new Element("div.formBottomNode", {
  724. "styles": this.css.formBottomNode
  725. }).inject(this.formNode);
  726. this._createBottomContent()
  727. },
  728. createTopNode: function () {
  729. if (!this.formTopNode) {
  730. this.formTopNode = new Element("div.formTopNode", {
  731. "styles": this.css.formTopNode
  732. }).inject(this.formNode);
  733. this.formTopIconNode = new Element("div", {
  734. "styles": this.css.formTopIconNode
  735. }).inject(this.formTopNode);
  736. this.formTopTextNode = new Element("div", {
  737. "styles": this.css.formTopTextNode,
  738. "text": this.options.title + ( this.data.title ? ("-" + this.data.title ) : "" )
  739. }).inject(this.formTopNode);
  740. if (this.options.closeAction) {
  741. this.formTopCloseActionNode = new Element("div", {"styles": this.css.formTopCloseActionNode}).inject(this.formTopNode);
  742. this.formTopCloseActionNode.addEvent("click", function () {
  743. this.close();
  744. }.bind(this))
  745. }
  746. this.formTopContentNode = new Element("div", {
  747. "styles": this.css.formTopContentNode
  748. }).inject(this.formTopNode);
  749. this._createTopContent();
  750. }
  751. },
  752. _createTopContent: function () {
  753. },
  754. _createTableContent: function () {
  755. this.loadFormData();
  756. /*
  757. var Ttype = "clue";
  758. this.actions.getProfiles(Ttype,function(json){
  759. this.profileData = json.data;
  760. if(this.data.id){
  761. this.actions.getPublicseasInfo(this.data.id,function(json){
  762. this.customerData = json.data;
  763. this.loadFormData();
  764. this.createCustomBottom();
  765. }.bind(this));
  766. }else{
  767. this.loadFormData();
  768. this.createCustomBottom();
  769. }
  770. }.bind(this));
  771. */
  772. },
  773. _createBottomContent: function () {
  774. this.cancelActionNode = new Element("div.formCancelActionNode", {
  775. "styles": this.css.formCancelActionNode,
  776. "text": this.lp.actionCancel
  777. }).inject(this.formBottomNode);
  778. if (this.options.isNew || this.options.isEdited) {
  779. //this.ok();
  780. this.okActionNode = new Element("div.formOkActionNode", {
  781. "styles": this.css.formOkActionNode,
  782. "text": this.lp.actionConfirm
  783. }).inject(this.formBottomNode);
  784. this.okActionNode.addEvent("click", function (e) {
  785. this.ok(e);
  786. }.bind(this));
  787. }
  788. this.cancelActionNode.addEvent("click", function (e) {
  789. this.cancel(e);
  790. }.bind(this));
  791. },
  792. loadFormData:function(){
  793. var tmpData={};
  794. this.loadForm();
  795. /*
  796. var html = "<table width='100%' bordr='0' cellpadding='5' cellspacing='0' styles='formTable'>" +
  797. "<tr>" +
  798. " <td styles='formTableTitle'><span lable='TCustomerName'></span><span style='color:#f00'>*</span></td>" +
  799. " <td styles='formTableValue' item='TCustomerName'></td>" +
  800. "</tr><tr>" +
  801. " <td styles='formTableTitle' lable='TCustomerType'></td>" +
  802. " <td styles='formTableValue'><div id='TCustomerType'></div></td>" +
  803. "</tr><tr>" +
  804. " <td styles='formTableTitle' lable='TCustomerLevel'></td>" +
  805. " <td styles='formTableValue'><div id='TCustomerLevel'></div></td>" +
  806. "</tr><tr>" +
  807. " <td styles='formTableTitle' lable='TSource'></td>" +
  808. " <td styles='formTableValue'><div id='TSource'></div></td>" +
  809. "</tr><tr>" +
  810. " <td styles='formTableTitle' lable='TIndustryFirst'></td>" +
  811. " <td styles='formTableValue'><div id='TIndustryFirst'></div><div id='TIndustrySecond'></div></td>" +
  812. "</tr><tr>" +
  813. " <td styles='formTableTitle' lable='TDistrict'></td>" +
  814. " <td styles='formTableValue'><div id='TProvince'></div><div id='TCity'></div><div id='TArea'></div></td>" +
  815. "</tr><tr>" +
  816. " <td styles='formTableTitle' lable='TStreet'></td>" +
  817. " <td styles='formTableValue' item='TStreet'></td>" +
  818. "</tr><tr>" +
  819. " <td styles='formTableTitle' lable='TLocation'></td>" +
  820. " <td styles='formTableValue'><div style='width:100%;height:30px;'><input type='text' placeholder='"+this.lp.TLocationNotice+"' id='mapLocation' disabled/></div></td>" +
  821. "</tr><tr>" +
  822. " <td styles='formTableTitle'></td>" +
  823. " <td styles='formTableValue'><div id='mapDiv' styles='mapDiv'></div></td>" +
  824. "</tr><tr>" +
  825. " <td styles='formTableTitle' lable='TTelphone'></td>" +
  826. " <td styles='formTableValue' item='TTelphone'></td>" +
  827. "</tr><tr>" +
  828. " <td styles='formTableTitle' lable='TFax'></td>" +
  829. " <td styles='formTableValue' item='TFax'></td>" +
  830. "</tr><tr>" +
  831. " <td styles='formTableTitle' lable='TRemark'></td>" +
  832. " <td styles='formTableValue' item='TRemark'></td>" +
  833. "</tr><tr>" +
  834. " <td styles='formTableTitle' lable='TWebSite'></td>" +
  835. " <td styles='formTableValue' item='TWebSite'></td>" +
  836. "</tr><tr>" +
  837. " <td styles='formTableTitle' lable='TEmail'></td>" +
  838. " <td styles='formTableValue' item='TEmail'></td>" +
  839. "</tr><tr>" +
  840. " <td styles='formTableTitle' lable='TCustomerStatus'></td>" +
  841. " <td styles='formTableValue'><div id='TCustomerStatus'></div></td>" +
  842. "</tr><tr>" +
  843. " <td styles='formTableTitle' lable='TCustomerGrade'></td>" +
  844. " <td styles='formTableValue'><div id='TCustomerGrade'></div></td>" +
  845. "</tr>" +
  846. "</table>"
  847. this.formTableArea.set("html", html);
  848. this.TCustomerType = this.formTableArea.getElement("#TCustomerType");
  849. this.TCustomerLevel = this.formTableArea.getElement("#TCustomerLevel");
  850. this.TSource = this.formTableArea.getElement("#TSource");
  851. this.TIndustryFirst = this.formTableArea.getElement("#TIndustryFirst");
  852. this.TIndustrySecond = this.formTableArea.getElement("#TIndustrySecond");
  853. this.TProvince = this.formTableArea.getElement("#TProvince");
  854. this.TCity = this.formTableArea.getElement("#TCity");
  855. this.TArea = this.formTableArea.getElement("#TArea");
  856. this.TCustomerStatus = this.formTableArea.getElement("#TCustomerStatus");
  857. this.TCustomerGrade = this.formTableArea.getElement("#TCustomerGrade");
  858. var size = {"width":230,"height":30};
  859. this.TIndustryFirst.setStyles({"float":"left"});
  860. this.TIndustrySecond.setStyles({"float":"left","margin-left":"10px"});
  861. //客户类型
  862. this.TCustomerTypeSelector = new MWF.xApplication.CRM.Template.Select(this.TCustomerType,this, this.actions, size);
  863. this.TCustomerTypeSelector.load();
  864. alert(JSON.stringify(this.profileData.customertype_config))
  865. this.TCustomerTypeSelector.setList(this.profileData.customertype_config);
  866. if(this.customerData && this.customerData.customertype){
  867. this.TCustomerTypeSelector.selectValueDiv.set({"text":this.customerData.customertype});
  868. this.TCustomerTypeSelector.node.set("value",this.customerData.customertype);
  869. }
  870. //客户级别
  871. this.TCustomerLevelSelector = new MWF.xApplication.CRM.Template.Select(this.TCustomerLevel,this, this.actions, size);
  872. this.TCustomerLevelSelector.load();
  873. this.TCustomerLevelSelector.setList(this.profileData.level_config);
  874. if(this.customerData && this.customerData.level){
  875. this.TCustomerLevelSelector.selectValueDiv.set({"text":this.customerData.level});
  876. this.TCustomerLevelSelector.node.set("value",this.customerData.level);
  877. }
  878. //来源
  879. this.TSourceSelector = new MWF.xApplication.CRM.Template.Select(this.TSource,this, this.actions, size);
  880. this.TSourceSelector.load();
  881. this.TSourceSelector.setList(this.profileData.source_config);
  882. if(this.customerData && this.customerData.source){
  883. this.TSourceSelector.selectValueDiv.set({"text":this.customerData.source});
  884. this.TSourceSelector.node.set("value",this.customerData.source);
  885. }
  886. //行业
  887. this.TIndustryFirstSelector = new MWF.xApplication.CRM.Template.Select(this.TIndustryFirst,this, this.actions, {"width":230,"height":30});
  888. this.TIndustrySecondSelector = new MWF.xApplication.CRM.Template.Select(this.TIndustrySecond,this, this.actions, {"width":230,"height":30,"available":"no"});
  889. this.TIndustrySecondSelector.load();
  890. this.TIndustryFirstSelector.load();
  891. if(this.customerData && this.customerData.industryfirst){
  892. this.TIndustryFirstSelector.selectValueDiv.set({"text":this.customerData.industryfirst});
  893. this.TIndustryFirstSelector.node.set("value",this.customerData.industryfirst);
  894. this.profileData.industry_config.childNodes.each(function(d){
  895. if(d.configname == this.customerData.industryfirst){
  896. tmpData = d;
  897. }
  898. }.bind(this));
  899. this.TIndustrySecondSelector.setList(tmpData);
  900. this.TIndustrySecond.set("available","yes");
  901. this.TIndustrySecond.setStyles({"background-color":""});
  902. }
  903. if(this.customerData && this.customerData.industrysecond){
  904. this.TIndustrySecondSelector.selectValueDiv.set({"text":this.customerData.industrysecond});
  905. this.TIndustrySecondSelector.node.set("value",this.customerData.industrysecond);
  906. this.profileData.industry_config.childNodes.each(function(d){
  907. if(d.configname == this.customerData.industryfirst){
  908. tmpData = d;
  909. }
  910. }.bind(this));
  911. this.TIndustrySecondSelector.setList(tmpData);
  912. this.TIndustrySecond.set("available","yes");
  913. this.TIndustrySecond.setStyles({"background-color":""});
  914. }
  915. this.TIndustryFirstSelector.setList(this.profileData.industry_config,function(d){
  916. if(this.TIndustryFirst.get("value") == this.lp.defaultSelect){
  917. this.TIndustrySecondSelector.createDefault();
  918. this.TIndustrySecondSelector.setList();
  919. this.TIndustrySecond.set("available","no");
  920. this.TIndustrySecond.setStyles({"background-color":"#eeeeee"})
  921. }else{
  922. this.TIndustrySecondSelector.createDefault();
  923. this.TIndustrySecondSelector.setList(d);
  924. this.TIndustrySecond.set("available","yes");
  925. this.TIndustrySecond.setStyles({"background-color":""});
  926. }
  927. }.bind(this));
  928. //省、市、区
  929. this.TProvinceSelector = new MWF.xApplication.CRM.Template.Select(this.TProvince,this, this.actions, {"width":150,"height":30});
  930. this.TProvinceSelector.load({},function(){
  931. this.actions.getProvinceList(function(json){
  932. this.TProvinceSelector.setAddress(json.data,function(d){
  933. //city
  934. if(this.TProvince.get("value") == this.lp.defaultSelect){
  935. this.TCitySelector.createDefault();
  936. this.TCitySelector.setAddress();
  937. this.TCity.set("available","no");
  938. this.TCity.setStyles({"background-color":"#eeeeee"});
  939. }else{
  940. this.actions.getCityList({pid: d.cityid},function(json){
  941. this.TCitySelector.createDefault();
  942. this.TCitySelector.setAddress(json.data,function(dd){
  943. //area
  944. if(this.TCity.get("value") == this.lp.defaultSelect){
  945. this.TAreaSelector.createDefault();
  946. this.TAreaSelector.setAddress();
  947. this.TArea.set("available","no");
  948. this.TArea.setStyles({"background-color":"#eeeeee"});
  949. }else{
  950. this.actions.getAreaList({pid:dd.cityid},function(json){
  951. this.TAreaSelector.createDefault();
  952. this.TAreaSelector.setAddress(json.data);
  953. this.TArea.set("available","yes");
  954. this.TArea.setStyles({"background-color":""});
  955. }.bind(this));
  956. }
  957. }.bind(this));
  958. this.TCity.set("available","yes");
  959. this.TCity.setStyles({"background-color":""});
  960. }.bind(this));
  961. }
  962. this.TAreaSelector.createDefault();
  963. this.TAreaSelector.setAddress();
  964. this.TArea.set("available","no");
  965. this.TArea.setStyles({"background-color":"#eeeeee"});
  966. }.bind(this))
  967. }.bind(this))
  968. }.bind(this));
  969. this.TCitySelector = new MWF.xApplication.CRM.Template.Select(this.TCity,this, this.actions, {"width":150,"height":30,"available":"no"});
  970. this.TCitySelector.load();
  971. this.TAreaSelector = new MWF.xApplication.CRM.Template.Select(this.TArea,this, this.actions, {"width":150,"height":30,"available":"no"});
  972. this.TAreaSelector.load();
  973. if(this.customerData && this.customerData.province){ //省
  974. this.TProvinceSelector.selectValueDiv.set({"text":this.customerData.province});
  975. this.TProvinceSelector.node.set("value",this.customerData.province);
  976. }
  977. if(this.customerData && this.customerData.city){ //市
  978. if(this.customerData && this.customerData.province){
  979. this.actions.getCityListByName({"regionname":this.customerData.province},
  980. function(json){
  981. this.TCitySelector.setAddress(json.data,function(dd){
  982. //area
  983. if(this.TCity.get("value") == this.lp.defaultSelect){
  984. this.TAreaSelector.createDefault();
  985. this.TAreaSelector.setAddress();
  986. this.TArea.set("available","no");
  987. this.TArea.setStyles({"background-color":"#eeeeee"});
  988. }else{
  989. this.actions.getAreaList({pid:dd.cityid},function(json){
  990. this.TAreaSelector.createDefault();
  991. this.TAreaSelector.setAddress(json.data);
  992. this.TArea.set("available","yes");
  993. this.TArea.setStyles({"background-color":""});
  994. }.bind(this));
  995. }
  996. }.bind(this));
  997. }.bind(this));
  998. }
  999. this.TCitySelector.selectValueDiv.set({"text":this.customerData.city});
  1000. this.TCitySelector.node.set("value",this.customerData.city);
  1001. this.TCity.set("available","yes");
  1002. this.TCity.setStyles({"background-color":""});
  1003. }
  1004. if(this.customerData && this.customerData.county){ //区
  1005. if(this.customerData && this.customerData.city){
  1006. this.actions.getAreaListByName({"regionname":this.customerData.city},
  1007. function(json){
  1008. this.TAreaSelector.setAddress(json.data);
  1009. }.bind(this));
  1010. }
  1011. this.TAreaSelector.selectValueDiv.set({"text":this.customerData.county});
  1012. this.TAreaSelector.node.set("value",this.customerData.county);
  1013. this.TArea.set("available","yes");
  1014. this.TArea.setStyles({"background-color":""});
  1015. }
  1016. this.TProvince.setStyles({"float":"left"});
  1017. this.TCity.setStyles({"float":"left","margin-left":"10px"});
  1018. this.TArea.setStyles({"float":"left","margin-left":"10px"});
  1019. this.TCustomerStatusSelector = new MWF.xApplication.CRM.Template.Select(this.TCustomerStatus,this, this.actions, size);
  1020. this.TCustomerStatusSelector.load();
  1021. this.TCustomerStatusSelector.setList(this.profileData.state_config);
  1022. if(this.customerData && this.customerData.state){
  1023. this.TCustomerStatusSelector.selectValueDiv.set({"text":this.customerData.state});
  1024. this.TCustomerStatusSelector.node.set("value",this.customerData.state);
  1025. }
  1026. this.TCustomerGradeSelector = new MWF.xApplication.CRM.Template.Select(this.TCustomerGrade,this, this.actions, size);
  1027. this.TCustomerGradeSelector.load();
  1028. this.TCustomerGradeSelector.setList(this.profileData.customerrank_config);
  1029. this.TMap = this.formTableArea.getElement("#mapDiv");
  1030. this.TMap.addEvents({
  1031. "mousewheel":function(e){
  1032. e.stopPropagation();
  1033. }
  1034. });
  1035. this.mapLocation = this.formTableArea.getElement("#mapLocation");
  1036. this.mapLocation.setStyles({
  1037. "width": "99%",
  1038. "text-indent":"5px",
  1039. "border":"1px solid #999",
  1040. "background-color":"#eee",
  1041. "border-radius": "3px",
  1042. "box-shadow": "0px 0px 6px #eee",
  1043. "height": "26px"
  1044. });
  1045. MWF.xDesktop.requireApp("CRM", "BaiduMap", function(){
  1046. this.bMap = new MWF.xApplication.CRM.BaiduMap(this.TMap,this.app,this,this.actions,{"from":"newCustomer"});
  1047. var mapData = {};
  1048. if(this.customerData && this.customerData.addresslatitude){
  1049. mapData.latitude = this.customerData.addresslatitude
  1050. }
  1051. if(this.customerData && this.customerData.addresslongitude){
  1052. mapData.longitude = this.customerData.addresslongitude
  1053. }
  1054. this.bMap.load(mapData);
  1055. }.bind(this));
  1056. */
  1057. },
  1058. ok: function (e) {
  1059. this.fireEvent("queryOk");
  1060. var data = this.form.getResult(true, ",", true, false, true);
  1061. debugger;
  1062. if (data) {
  1063. this._ok(data, function (json) {
  1064. if (json.type == "error") {
  1065. if( this.app )this.app.notice(json.message, "error");
  1066. } else {
  1067. if( this.formMaskNode )this.formMaskNode.destroy();
  1068. this.formAreaNode.destroy();
  1069. if (this.explorer && this.explorer.view)this.explorer.view.reload();
  1070. if( this.app )this.app.notice(this.isNew ? this.lp.createSuccess : this.lp.updateSuccess, "success");
  1071. this.fireEvent("postOk");
  1072. }
  1073. }.bind(this))
  1074. }
  1075. },
  1076. loadForm: function(){
  1077. _self = this;
  1078. this.form = new MForm(this.formTableArea, this.data, {
  1079. style: "default",
  1080. isEdited: this.isEdited || this.isNew,
  1081. itemTemplate: this.getItemTemplate(this.lp )
  1082. },this.app,this.css);
  1083. var html = "<table width='100%' bordr='0' cellpadding='5' cellspacing='0' styles='formTable'>";
  1084. var itemTemplateObject = this.form.itemTemplate;
  1085. debugger
  1086. for ( i in itemTemplateObject){
  1087. html = html+"<tr>" +
  1088. " <td styles='formTableTitle'><span lable='"+i+"'>"+itemTemplateObject[i].text+"</td>" +
  1089. " <td styles='formTableValue' item='"+i+"'></td>" +
  1090. "</tr>";
  1091. }
  1092. html = html+"</table>";
  1093. debugger
  1094. this.formTableArea.set("html", html);
  1095. this.form.load();
  1096. if(!this.isNew){
  1097. this.actions.geCustomerInfo(this.options.openId, function (json) {
  1098. debugger
  1099. var jsonObj = json.data;
  1100. var spanObject = this.formTableArea.getElements("span");
  1101. for ( j in spanObject){
  1102. if(j < spanObject.length){
  1103. debugger
  1104. if(spanObject[j].get("name")!=null){
  1105. var fieldName = spanObject[j].get("name");
  1106. for (var prop in jsonObj){
  1107. if(prop == fieldName){
  1108. spanObject[j].set("text",jsonObj[prop]);
  1109. }
  1110. }
  1111. }
  1112. }
  1113. }
  1114. }.bind(this));
  1115. }
  1116. //this.nexttime = this.formTableArea.getElement("#nexttime");
  1117. //this.nexttime.addEvent("click",function(){
  1118. //_self.selectCalendar(this);
  1119. //});
  1120. this.formTableArea.getElements("textarea").setStyles({"height":"100px","overflow":"auto","color":"#666666"});
  1121. this.formTableArea.getElements("input").setStyles({"color":"#666666"});
  1122. },
  1123. loadMap: function(){
  1124. debugger
  1125. _self = this;
  1126. this.mapDiv = jQuery("#setMap")[0];
  1127. jQuery(".section-conent").css("height","700px");
  1128. if(this.mapDiv)this.mapDiv.empty();
  1129. if(this.addressModule) delete this.addressModule;
  1130. MWF.xDesktop.requireApp("CRM", "AddressExplorer", function(){
  1131. this.addressModule = new MWF.xApplication.CRM.AddressExplorer(this.mapDiv,this,this.actions,{});
  1132. this.addressModule.load();
  1133. }.bind(this))
  1134. },
  1135. getItemTemplate: function( lp ){
  1136. _self = this;
  1137. return {
  1138. customername: {
  1139. text: lp.customername,
  1140. type: "text",
  1141. //attr : {placeholder:lp.name},
  1142. notEmpty:true,
  1143. value:this.customerData && this.customerData.customername?this.customerData.customername:""
  1144. },
  1145. level:{
  1146. type: "select",
  1147. text: lp.level,
  1148. value:this.app.lp.customer.level.value
  1149. },
  1150. industry: {
  1151. type: "select",
  1152. text: lp.industry,
  1153. value:this.app.lp.customer.industry.value
  1154. },
  1155. source: {
  1156. type: "select",
  1157. text: lp.source,
  1158. value:this.app.lp.customer.source.value
  1159. },
  1160. /*dealstatus:{
  1161. type: "hide",
  1162. text: lp.dealstatus,
  1163. value:this.app.lp.customer.dealstatus.value
  1164. },*/
  1165. telephone:{
  1166. type: "text",
  1167. text: lp.telephone,
  1168. value:this.app.lp.clue.level.value
  1169. },
  1170. website: {
  1171. text:lp.website,
  1172. type: "text"
  1173. },
  1174. nexttime: {
  1175. text:lp.nexttime,
  1176. attr : {id:"nexttime"},
  1177. type: "datetime"
  1178. },
  1179. cellphone: {
  1180. text:lp.cellphone,
  1181. type: "text"
  1182. },
  1183. detailaddress: {
  1184. text:lp.detailaddress,
  1185. type: "text"
  1186. },
  1187. remark: {
  1188. text:lp.remark,
  1189. type: "textarea"
  1190. },
  1191. location: {
  1192. text:lp.location,
  1193. type: "map"
  1194. }
  1195. }
  1196. },
  1197. getContactTemplate: function( lp ){
  1198. _self = this;
  1199. return {
  1200. contactsname: {
  1201. text: lp.contactsname,
  1202. type: "text",
  1203. notEmpty:true
  1204. },
  1205. customername: {
  1206. text: lp.customername,
  1207. type: "readonly",
  1208. notEmpty:true
  1209. },
  1210. telephone:{
  1211. type: "text",
  1212. text: lp.telephone,
  1213. },
  1214. cellphone: {
  1215. text:lp.cellphone,
  1216. type: "text"
  1217. },
  1218. email:{
  1219. type: "text",
  1220. text: lp.email
  1221. },
  1222. decision: {
  1223. type: "select",
  1224. text: lp.decision,
  1225. value:this.app.lp.contact.decision.value
  1226. },
  1227. post: {
  1228. text:lp.post,
  1229. type: "text"
  1230. },
  1231. sex: {
  1232. type: "select",
  1233. text: lp.sex,
  1234. value:this.app.lp.contact.sex.value
  1235. },
  1236. detailaddress: {
  1237. text:lp.detailaddress,
  1238. type: "text"
  1239. },
  1240. nexttime: {
  1241. text:lp.nexttime,
  1242. attr : {id:"nexttime"},
  1243. type: "datetime"
  1244. },
  1245. remark: {
  1246. text:lp.remark,
  1247. type: "textarea"
  1248. }
  1249. }
  1250. },
  1251. selectPerson: function (showContainer,nameId,fullNameId,count) {
  1252. var options = {
  1253. "type" : "",
  1254. "types": ["person"],
  1255. "values": this.configData,
  1256. "count": count,
  1257. "zIndex": 50000,
  1258. "onComplete": function(items){
  1259. MWF.require("MWF.widget.O2Identity", function(){
  1260. var invitePersonList = [];
  1261. var fullPersonList = [];
  1262. this.configData = [];
  1263. this.process = null;
  1264. items.each(function(item){
  1265. var _self = this;
  1266. if( item.data.distinguishedName.split("@").getLast().toLowerCase() == "i" ){
  1267. var person = new MWF.widget.O2Identity(item.data, it.form.getItem("invitePersonList").container, {"style": "room"});
  1268. invitePersonList.push( item.data.distinguishedName );
  1269. }else{
  1270. //var person = new MWF.widget.O2Person(item.data, it.form.getItem("invitePersonList").container, {"style": "room"});
  1271. invitePersonList.push(item.data.name);
  1272. fullPersonList.push(item.data.distinguishedName);
  1273. var personJson = {
  1274. "name": item.data.name,
  1275. "distinguishedName": item.data.distinguishedName,
  1276. "employee":item.data.employee
  1277. }
  1278. debugger
  1279. this.configData.push(personJson);
  1280. }
  1281. }.bind(this));
  1282. if(items.length==0){
  1283. document.getElementById(nameId).innerHTML = "+点击选择"
  1284. }else{
  1285. document.getElementById(nameId).innerHTML = invitePersonList.join(",");
  1286. if(fullNameId!=""){
  1287. document.getElementById(fullNameId).innerHTML = fullPersonList.join(",");
  1288. }
  1289. }
  1290. }.bind(this));
  1291. }.bind(this)
  1292. };
  1293. var selector = new MWF.O2Selector(showContainer, options);
  1294. },
  1295. getFormateTime: function( timeStr ){
  1296. _self = this;
  1297. var date= new Date(timeStr);
  1298. return date.getFullYear()+'-'+_self.checkTime(date.getMonth()+1)+'-'+_self.checkTime(date.getDate())+ ' ' + _self.checkTime(date.getHours()) + ':' + _self.checkTime(date.getMinutes()) + ':' + _self.checkTime(date.getSeconds());
  1299. },
  1300. checkTime: function( i ){
  1301. if(i<10){
  1302. i = '0'+i
  1303. }
  1304. return i;
  1305. },
  1306. toDecimal: function(x){
  1307. if(x==""){
  1308. return "";
  1309. }else{
  1310. var f = parseFloat(x);
  1311. if (isNaN(f)) {
  1312. return x;
  1313. }
  1314. f = Math.round(x*100)/100;
  1315. return f;
  1316. }
  1317. },
  1318. /*selectCalendar : function( calendarNode ){
  1319. MWF.require("MWF.widget.Calendar", function(){
  1320. var calendar = new MWF.widget.Calendar( calendarNode, {
  1321. "style": "xform",
  1322. "isTime": false
  1323. "target": this.app.content
  1324. });
  1325. calendar.show();
  1326. }.bind(this));
  1327. },*/
  1328. createCustomBottom:function(){
  1329. this.okActionNode = new Element("div.formOkActionNode", {
  1330. "styles": this.css.formOkActionNode,
  1331. "text": this.lp.actionConfirm
  1332. }).inject(this.formBottomNode);
  1333. this.okActionNode.addEvent("click", function (e) {
  1334. this.ok(e);
  1335. }.bind(this));
  1336. },
  1337. _ok: function (data, callback) {
  1338. var saveDataStr = "";
  1339. for ( i in this.data){
  1340. saveDataStr = saveDataStr+"'"+i+"':'"+this.data[i]+"',";
  1341. }
  1342. debugger;
  1343. saveDataStr = "'{"+saveDataStr.replace(/'/g, '"')+"}'";
  1344. debugger;
  1345. //var saveData = JSON.parse(saveDataStr);
  1346. var saveData = eval('(' + saveDataStr.substring(1,saveDataStr.length - 1) + ')');
  1347. debugger;
  1348. //alert(JSON.stringify(saveData))
  1349. this.app.createShade();
  1350. this.actions.saveClue(saveData,function(json){
  1351. this.app.destroyShade();
  1352. this.app.notice(this.lp.saveSuccess,"success");
  1353. this.close();
  1354. this.fireEvent("reloadView",json);
  1355. }.bind(this),function(xhr,text,error){
  1356. this.app.showErrorMessage(xhr,text,error);
  1357. this.app.destroyShade();
  1358. }.bind(this));
  1359. }
  1360. });