ClueOpen.js 69 KB

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