CustomerOpen.js 112 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193
  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.CustomerOpen = 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.customer.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"><div class="headMoveBottonDiv">转移</div><div class="headEditBottonDiv">编辑</div>' +
  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><li class="el-dropdown-menu__item">锁定</li><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 = '<div ><div class="mix-container"><div class="i-cont"><div class="el-textarea el-input--suffix">'+
  121. '<textarea autocomplete="off" placeholder="请输入内容" class="el-textarea__inner" style="resize: none; min-height: 57px; height: 57px;"></textarea></div></div>'+
  122. '<div class="vux-flexbox bar-cont vux-flex-row">'+
  123. '<div class="vux-flexbox bar-item vux-flex-row"><input type="file" accept="image/*" multiple="multiple" class="bar-input"><img src="../x_component_CRM/$Template/img.png" class="bar-img"><div class="bar-title">图片</div></div>'+
  124. '<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>'+
  125. '</div>';
  126. var indexSendHtml = '<div class="vux-flexbox se-section vux-flex-row"><div class="se-name">记录类型</div>'+
  127. '<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>'+
  128. '<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>'+
  129. '<button type="button" class="el-button se-send el-button--primary"><span>发布</span></button></div>'+
  130. '<ul class="el-dropdown-type" style="display: none;" tid = "recordType"><li class="el-dropdown-menu__item">邮箱</li><li class="el-dropdown-menu__item">电话</li>'+
  131. '<li class="el-dropdown-menu__item">地址</li><li class="el-dropdown-menu__item">微信</li><div class="popper__arrow"></div></ul>';
  132. var indexContentHtml = '<div class="log-cont"><div class="log-inner1"><div class="log-inner2"><div class="log-items">'+
  133. '<div class="load"><button type="button" class="el-button el-button--text"><span>没有更多了</span></button></div></div>'+
  134. '<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>'+
  135. '<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>'+
  136. '</div></div>';
  137. //jQuery("#"+sectionId).find("#tab-follow").html(indexHtml+indexSendHtml+indexContentHtml);
  138. this.sectionArea.getElement("#tab-follow").set("html",indexHtml+indexSendHtml+indexContentHtml);
  139. that.loadTimeContainer('stime');
  140. that.loadRecord();
  141. }.bind(this));
  142. },
  143. createTypeHtml: function () {
  144. var createType = jQuery(this.sectionArea).find(".hit").text();
  145. debugger
  146. if(createType == "基本信息") {
  147. this.getCustomerInfo();
  148. }
  149. if(createType == "联系人") {
  150. this.loadContacts();
  151. }
  152. if(createType == "相关团队") {
  153. this.loadTeam();
  154. }
  155. if(createType == "商机") {
  156. this.loadBusiness();
  157. }
  158. if(createType == "附件") {
  159. this.loadAttachment();
  160. }
  161. if(createType == "操作记录") {
  162. this.loadOptions();
  163. }
  164. },
  165. loadTimeContainer: function(stime){
  166. jQuery("#"+stime).ymdateplugin({
  167. showTimePanel: true
  168. });
  169. },
  170. getCustomerInfo: function () {
  171. _self = this;
  172. this.actions.getCustomerInfo(this.options.openId, function (json) {
  173. var jsonObj = json.data;
  174. var section_header = '<div class="section-header"><div class="section-mark" style="border-left-color: rgb(70, 205, 207);"></div> '+
  175. '<div data-v-ec8f8850="" class="section-title">基本信息</div></div>'
  176. var itemTemplateObject = _self.lp;
  177. var section_conent = '<div class="section-conent">';
  178. for ( i in itemTemplateObject){
  179. section_conent = section_conent+'<div class="conent-inline"><div class="conent-title">'+itemTemplateObject[i].text+'</div>' +
  180. '<div class="conent-value">'+((typeof(jsonObj[i])=="undefined")?"" : jsonObj[i])+'</div></div>';
  181. }
  182. section_conent = section_conent + '</div>';
  183. //jQuery("#tab-basicinfo").html(section_header+section_conent);
  184. jQuery(_self.sectionArea).find("#tab-basicinfo").html(section_header+section_conent);
  185. //this.contentHtml = briefDiv+tabPanel+tabConent;
  186. }.bind(this));
  187. },
  188. loadAttachment: function() {
  189. that = this;
  190. var attHtml = '<div class="rc-cont">';
  191. 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>';
  192. 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">'+
  193. '<div class="el-table__header-wrapper"><table class="el-table__header" style="width: 100%;" cellspacing="0" cellpadding="0" border="0"><thead class="has-gutter">'+
  194. '<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>'+
  195. '<th colspan="1" rowspan="1" class="el-table_3_column_28 is-leaf" style="width: 10%;"><div class="cell">附件大小</div></th>'+
  196. '<th colspan="1" rowspan="1" class="el-table_3_column_29 is-leaf" style="width: 20%;"><div class="cell">上传人</div></th>'+
  197. '<th colspan="1" rowspan="1" class="el-table_3_column_30 is-leaf" style="width: 20%;"><div class="cell">上传时间</div></th>'+
  198. '<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>';
  199. var attBody = '<div class="el-table__body-wrapper is-scrolling-none" style="height: 450px;">'+
  200. '<table class="el-table__body" style="width: 100%;" cellspacing="0" cellpadding="0" border="0"><tbody></tbody></table>'+
  201. '<div class="el-table__empty-block" style="width: 100%;"><span class="el-table__empty-text">暂无数据</span></div></div></div>';
  202. attHtml = attHtml+attButton+attHeader+attBody+'</div>';
  203. jQuery(that.sectionArea).find("#tab-att").html(attHtml);
  204. jQuery(that.sectionArea).find('#afile').change(function(event) {
  205. var objFile = jQuery(that.sectionArea).find('#afile')[0].files;
  206. jQuery(objFile).each(function(index,file){
  207. var filter = {};
  208. filter = {
  209. file:file,
  210. fileName:file.name
  211. };
  212. var formdata=new FormData();
  213. formdata.append("fileName",file.name);
  214. formdata.append("file",file);
  215. that.actions.updateAttachment("att", that.options.openId, "customer", formdata,file, function (json) {
  216. if(json.type=="success"){
  217. //Showbo.Msg.alert('附件上传成功!');
  218. that.getAttachment();
  219. }
  220. }.bind(that));
  221. }
  222. );
  223. });
  224. that.getAttachment();
  225. },
  226. getAttachment: function(){
  227. that = this;
  228. this.actions.getAttachment(this.options.openId, function (json) {
  229. debugger
  230. if(json.type=="success"){
  231. var attDatas = json.data;
  232. var tbodyHtml = "";
  233. for ( i in attDatas){
  234. if(i<attDatas.length){
  235. var attData = attDatas[i];
  236. var fsize = attData.length/1024;
  237. var lastUpdatePerson = attData.lastUpdatePerson;
  238. lastUpdatePerson = lastUpdatePerson.split("@")[0];
  239. 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>'+
  240. '<td style="width: 20%;">'+lastUpdatePerson+'</td><td style="width: 20%;">'+attData.updateTime+'</td><td class="attOption">删除</td></tr>';
  241. }
  242. }
  243. if(tbodyHtml!=""){
  244. jQuery(that.sectionArea).find(".el-table__body").children().html(tbodyHtml);
  245. jQuery(that.sectionArea).find(".el-table__empty-block").hide();
  246. jQuery(that.sectionArea).find(".attOption").click(function(){
  247. self = this;
  248. Showbo.Msg.confirm('提示','确定删除该附件吗?',function(){
  249. var aid = jQuery(self).parent().children(":first").attr("aid");
  250. if(aid && aid !=""){
  251. that.actions.delAttachment(aid, function (ajson) {
  252. if(ajson.type=="success"){
  253. that.getAttachment();
  254. }
  255. }.bind(self));
  256. }
  257. },function(){
  258. });
  259. });
  260. jQuery(that.sectionArea).find(".aname").click(function(){
  261. var attUrl = 'http://172.16.92.55:20020/x_wcrm_assemble_control/jaxrs/attachment/download/'+jQuery(this).attr("aid")+'/work/'+jQuery(this).attr("wcrm")
  262. window.open(attUrl);
  263. /*that.actions.downloadAttachment(jQuery(this).attr("aid"),jQuery(this).attr("wcrm"), function (wjson) {
  264. }.bind(that));*/
  265. });
  266. }
  267. }
  268. }.bind(that));
  269. },
  270. loadContacts: function() {
  271. that = this;
  272. var attHtml = '<div class="rc-cont">';
  273. var attButton = '<div class="vux-flexbox rc-head vux-flex-row" style="flex-direction: row-reverse;"><div class="rc-head-item" style="width: 75px;"><span>新建联系人</span></div></div>';
  274. 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">'+
  275. '<div class="el-table__header-wrapper"><table class="el-table__header" style="width: 100%;" cellspacing="0" cellpadding="0" border="0"><thead class="has-gutter">'+
  276. '<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>'+
  277. '<th colspan="1" rowspan="1" class="el-table_3_column_29 is-leaf" style="width: 34%;"><div class="cell">手机</div></th>'+
  278. '<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>';
  279. var attBody = '<div class="el-table__body-wrapper is-scrolling-none" style="height: 450px;">'+
  280. '<table class="el-table__body" style="width: 100%;" cellspacing="0" cellpadding="0" border="0"><tbody></tbody></table>'+
  281. '<div class="el-table__empty-block" style="width: 100%;"><span class="el-table__empty-text">暂无数据</span></div></div></div>';
  282. attHtml = attHtml+attButton+attHeader+attBody+'</div>';
  283. jQuery(that.sectionArea).find("#tab-contacts").html(attHtml);
  284. this.actions.getContacts(this.options.openId, function (json) {
  285. if(json.type=="success"){
  286. var attDatas = json.data;
  287. var tbodyHtml = "";
  288. for ( i in attDatas){
  289. if(i<attDatas.length){
  290. var attData = attDatas[i];
  291. tbodyHtml = tbodyHtml+'<tr><td style="width: 34%;height:40px;" class="aname" aid="'+attData.id+'">'+attData.contactsname+'</td>'+
  292. '<td style="width: 33%;">'+attData.cellphone+'</td><td style="width: 33%;">'+attData.post+'</td></tr>';
  293. }
  294. }
  295. if(tbodyHtml!=""){
  296. jQuery(that.sectionArea).find(".el-table__body").children().html(tbodyHtml);
  297. jQuery(that.sectionArea).find(".el-table__empty-block").hide();
  298. }
  299. }
  300. }.bind(that));
  301. jQuery(that.sectionArea).find("#tab-contacts").find(".rc-head-item").click(function(){
  302. that.contactsCreate();
  303. });
  304. jQuery(that.sectionArea).find("#tab-contacts").find(".aname").click(function(){
  305. //that.contactsEdit(jQuery(this).attr("aid"));
  306. });
  307. },
  308. loadTeam: function() {
  309. that = this;
  310. var attHtml = '<div class="rc-cont">';
  311. var attButton = '<div class="vux-flexbox rc-head vux-flex-row" style="flex-direction: row-reverse;"><div class="rc-head-item" style="width: 75px;"><span>移除</span></div>'+
  312. '<div class="rc-head-item" style="width: 75px;"><span>编辑</span></div><div class="rc-head-item" style="width: 95px;"><span>添加团队成员</span></div></div>';
  313. 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">'+
  314. '<div class="el-table__header-wrapper"><table class="el-table__header" style="width: 100%;" cellspacing="0" cellpadding="0" border="0"><thead class="has-gutter">'+
  315. '<tr class=""><th colspan="1" rowspan="1" class="el-table_3_column_27"><div class="cell">'+
  316. '<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>'+
  317. '<th colspan="1" rowspan="1" class="el-table_3_column_27 is-leaf" style="width: 30%;height:40px;"><div class="cell">姓名</div></th>'+
  318. '<th colspan="1" rowspan="1" class="el-table_3_column_29 is-leaf" style="width: 20%;"><div class="cell">职位</div></th>'+
  319. '<th colspan="1" rowspan="1" class="el-table_3_column_29 is-leaf" style="width: 20%;"><div class="cell">团队角色</div></th>'+
  320. '<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>'+
  321. '<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>';
  322. var attBody = '<div class="el-table__body-wrapper is-scrolling-none" style="height: 450px;">'+
  323. '<table class="el-table__body" style="width: 100%;" cellspacing="0" cellpadding="0" border="0"><tbody></tbody></table>'+
  324. '<div class="el-table__empty-block" style="width: 100%;"><span class="el-table__empty-text">暂无数据</span></div></div></div>';
  325. attHtml = attHtml+attButton+attHeader+attBody+'</div>';
  326. jQuery(that.sectionArea).find("#tab-team").html(attHtml);
  327. this.actions.getTeamMemberListById(this.options.openId, function (json) {
  328. if(json.type=="success"){
  329. var attDatas = json.data;
  330. var tbodyHtml = "";
  331. for ( i in attDatas){
  332. if(i<attDatas.length){
  333. var attData = attDatas[i];
  334. var unit = (attData.units.length>0)?((attData.units[0]).split("@")[0]):"";
  335. var id = 'all'+i;
  336. var cdiv = '<div class="cell">'+
  337. '<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>'
  338. if(attData.teamRole && attData.teamRole=="负责人"){
  339. cdiv = '<div class="cell">'+
  340. '<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>'
  341. }
  342. if(attData.teamRole && attData.teamRole!=""){
  343. tbodyHtml = tbodyHtml+'<tr><td style="width: 10%;height:40px;">'+cdiv+'</td><td style="width: 30%;" class="aname" aid="'+attData.person.distinguishedName+'">'+attData.person.name+
  344. '</td><td style="width: 20%;">'+unit+'</td><td style="width: 20%;">'+attData.teamRole+'</td><td style="width: 20%;">'+attData.dispaly_permission+'</td></tr>';
  345. }
  346. }
  347. }
  348. if(tbodyHtml!=""){
  349. jQuery(that.sectionArea).find(".el-table__body").children().html(tbodyHtml);
  350. jQuery(that.sectionArea).find(".el-table__empty-block").hide();
  351. }
  352. }
  353. }.bind(that));
  354. jQuery("[for='all']").click(function(){
  355. //var cobj = jQuery("[for='all1']");
  356. var cobj = jQuery(that.sectionArea).find(".cbxx").not("[for='all']");
  357. if (jQuery(this).prev().is(':checked')) {
  358. cobj.each(function(index,element){
  359. jQuery(element).prev().prop("checked", false);
  360. });
  361. } else {
  362. cobj.each(function(index,element){
  363. jQuery(element).prev().prop("checked", true);
  364. });
  365. }
  366. });
  367. jQuery(that.sectionArea).find(".rc-head-item").click(function() {
  368. if(jQuery(this).children().text()=="添加团队成员"){
  369. that.addTeam();
  370. }
  371. if(jQuery(this).children().text()=="编辑"){
  372. var nameList = [];
  373. jQuery(".el-table__body").find("input:checked").each(function(index,element){
  374. var nobj = jQuery(element).parent().parent().next();
  375. nameList.push(jQuery(nobj).attr("aid"));
  376. });
  377. that.editTeam(nameList);
  378. }
  379. if(jQuery(this).children().text()=="移除"){
  380. that.deleteTeam();
  381. }
  382. });
  383. },
  384. loadBusiness: function() {
  385. that = this;
  386. var attHtml = '<div class="rc-cont">';
  387. var attButton = '<div class="vux-flexbox rc-head vux-flex-row" style="flex-direction: row-reverse;"><div class="rc-head-item" style="width: 75px;"><span>新建商机</span></div></div>';
  388. 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">'+
  389. '<div class="el-table__header-wrapper"><table class="el-table__header" style="width: 100%;" cellspacing="0" cellpadding="0" border="0"><thead class="has-gutter">'+
  390. '<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>'+
  391. '<th colspan="1" rowspan="1" class="el-table_3_column_29 is-leaf" style="width: 20%;"><div class="cell">商品金额</div></th>'+
  392. '<th colspan="1" rowspan="1" class="el-table_3_column_29 is-leaf" style="width: 30%;"><div class="cell">客户名称</div></th>'+
  393. '<th colspan="1" rowspan="1" class="el-table_3_column_29 is-leaf" style="width: 20%;"><div class="cell">商机状态组</div></th>'+
  394. '<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>';
  395. var attBody = '<div class="el-table__body-wrapper is-scrolling-none" style="height: 450px;">'+
  396. '<table class="el-table__body" style="width: 100%;" cellspacing="0" cellpadding="0" border="0"><tbody></tbody></table>'+
  397. '<div class="el-table__empty-block" style="width: 100%;"><span class="el-table__empty-text">暂无数据</span></div></div></div>';
  398. attHtml = attHtml+attButton+attHeader+attBody+'</div>';
  399. jQuery(that.sectionArea).find("#tab-business").html(attHtml);
  400. this.actions.getOpportunityListByCustomerId(this.options.openId, function (json) {
  401. if(json.type=="success"){
  402. var attDatas = json.data;
  403. var tbodyHtml = "";
  404. for ( i in attDatas){
  405. if(i<attDatas.length){
  406. var attData = attDatas[i];
  407. tbodyHtml = tbodyHtml+'<tr><td style="width: 30%;height:40px;" class="aname" aid="'+attData.id+'">'+attData.opportunityname+
  408. '</td><td style="width: 20%;">'+attData.money+'</td><td style="width: 30%;">'+attData.customer.customername+
  409. '</td><td style="width: 20%;">'+attData.opportunityType.opportunitytypename+'</td><td style="width: 20%;">'+attData.opportunityStatus.opportunitystatusname+'</td></tr>';
  410. }
  411. }
  412. if(tbodyHtml!=""){
  413. jQuery(that.sectionArea).find(".el-table__body").children().html(tbodyHtml);
  414. jQuery(that.sectionArea).find(".el-table__empty-block").hide();
  415. }
  416. }
  417. }.bind(that));
  418. jQuery(that.sectionArea).find("#tab-business").find(".rc-head-item").click(function(){
  419. that.businessCreate();
  420. });
  421. jQuery(that.sectionArea).find("#tab-business").find(".aname").click(function(){
  422. //that.contactsEdit(jQuery(this).attr("aid"));
  423. });
  424. },
  425. loadOptions: function() {
  426. that = this;
  427. var optionsHtml = '<div class="rc-cont">'+
  428. '<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>'
  429. jQuery(that.sectionArea).find("#tab-options").html(optionsHtml);
  430. this.actions.getOptionsRecord(this.options.openId, function (json) {
  431. if(json.type=="success"){
  432. var recordDatas = json.data;
  433. jQuery(that.sectionArea).find(".rc-cont").find(".vux-flexbox").remove();
  434. var logItemHtml = "";
  435. for ( i in recordDatas){
  436. if(i<recordDatas.length){
  437. var recordData = recordDatas[i];
  438. var personImg = 'http://172.16.92.55../x_component_CRM/$Template/portrait.png';
  439. var updatetime = recordData.updateTime;
  440. logItemHtml = logItemHtml+'<div class="vux-flexbox ha-cont vux-flex-row" style="justify-content: flex-start; align-items: stretch;">'+
  441. '<div class="ha-week">'+recordData.DateCN+'</div>'+
  442. '<div class="ha-circle"></div> '+
  443. '<div class="ha-time">'+updatetime.substring(11,16)+'</div>'+
  444. '<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>' +
  445. '<div class="ha-name">'+recordData.person.name+'</div>'+
  446. '<div class="ha-content">'+recordData.content+'</div>'+
  447. '<div class="ha-line"></div></div>'
  448. }
  449. }
  450. if(logItemHtml!=""){
  451. jQuery(that.sectionArea).find(".rc-cont").append(logItemHtml);
  452. }
  453. if(recordDatas.length<1){
  454. jQuery(that.sectionArea).find(".empty-mask").show();
  455. }
  456. }
  457. }.bind(this));
  458. },
  459. transformCustomerDealstatus: function () {
  460. _self = this;
  461. 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:90px;">成交状态:</div><div class="el-select handle-item-content" style="margin-top: 8px;">'+
  462. '<div class="se-select-name" style="display: inline-block;">已成交</div><div style="display: inline-block;float:right;" class="el-icon-arrow-down el-icon--right"><img src="../x_component_CRM/$Clue/default/icons/arrow.png"></div></div></div>'
  463. contentHtml = contentHtml+'<ul class="el-dropdown-confirm"><li class="el-dropdown-menu__item">已成交</li><li class="el-dropdown-menu__item">未成交</li><div class="popper__arrow"></div></ul>'
  464. Showbo.Msg.confirm('客户成交状态',contentHtml,function(){
  465. _self.confirmCustomerDealstatus();
  466. },function(){
  467. });
  468. jQuery('.handle-item-content').click(function(){
  469. jQuery(".ct").find(".el-dropdown-confirm").toggle(100);
  470. });
  471. jQuery('.el-dropdown-menu__item').click(function(){
  472. if(jQuery(this).parent().attr("class")=="el-dropdown-confirm"){
  473. jQuery(".ct").find(".se-select-name").text(jQuery(this).text());
  474. jQuery(this).parent().toggle(100);
  475. }
  476. });
  477. },
  478. lockCustomer: function () {
  479. _self = this;
  480. var contentHtml = '确定要锁定此客户吗?锁定后将不会掉入公海。'
  481. Showbo.Msg.confirm('提示',contentHtml,function(){
  482. _self.confirmLockCustomer();
  483. },function(){
  484. });
  485. jQuery('.handle-item-content').click(function(){
  486. jQuery(".ct").find(".el-dropdown-confirm").toggle(100);
  487. });
  488. },
  489. unLockCustomer: function () {
  490. _self = this;
  491. var contentHtml = '确定要解锁此客户吗?'
  492. Showbo.Msg.confirm('提示',contentHtml,function(){
  493. _self.confirmUnLockCustomer();
  494. },function(){
  495. });
  496. jQuery('.handle-item-content').click(function(){
  497. jQuery(".ct").find(".el-dropdown-confirm").toggle(100);
  498. });
  499. },
  500. putToCustomerPool: function () {
  501. _self = this;
  502. var contentHtml = '确定转移到公海吗?'
  503. Showbo.Msg.confirm('提示',contentHtml,function(){
  504. _self.actions.putToCustomerPool(_self.options.openId, function (json) {
  505. debugger
  506. if(json.type == "success"){
  507. Showbo.Msg.alert('操作成功!');
  508. }
  509. }.bind(this));
  510. },function(){
  511. });
  512. jQuery('.handle-item-content').click(function(){
  513. jQuery(".ct").find(".el-dropdown-confirm").toggle(100);
  514. });
  515. },
  516. confirmCustomerDealstatus: function () {
  517. _self = this;
  518. if(jQuery(".ct").find(".se-select-name").text()=="已成交"){
  519. this.actions.customerDealStatus_completed(this.options.openId, function (json) {
  520. if(json.type == "success"){
  521. Showbo.Msg.alert('操作成功!');
  522. }
  523. }.bind(this));
  524. }
  525. if(jQuery(".ct").find(".se-select-name").text()=="未成交"){
  526. this.actions.customerDealStatus_processing(this.options.openId, function (json) {
  527. if(json.type == "success"){
  528. Showbo.Msg.alert('操作成功!');
  529. }
  530. }.bind(this));
  531. }
  532. },
  533. confirmLockCustomer: function () {
  534. this.actions.lockCustomer(this.options.openId, function (json) {
  535. if(json.type == "success"){
  536. Showbo.Msg.alert('操作成功!');
  537. }
  538. }.bind(this));
  539. },
  540. confirmUnLockCustomer: function () {
  541. this.actions.unLockCustomer(this.options.openId, function (json) {
  542. if(json.type == "success"){
  543. Showbo.Msg.alert('操作成功!');
  544. }
  545. }.bind(this));
  546. },
  547. transfer: function () {
  548. //转移负责人
  549. _self = this;
  550. var contentHtml = '<div class="vux-flexbox handle-item vux-flex-row" style="align-items: stretch;padding: 30px 20px 0px 20px;line-height:30px;">'+
  551. '<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>'+
  552. '<div class="vux-flexbox handle-item vux-flex-row" style="align-items: stretch;padding: 10px 20px 0px 20px;line-height:30px;">'+
  553. '<div class="handle-item-name" style="margin-top: 8px;width:130px;">将原负责人:</div><div role="radiogroup" class="el-radio-group">'+
  554. '<label role="radio" tabindex="0" class="el-radio"><span class="el-radio__input"><span class="el-radio__inner"></span><input type="radio" aria-hidden="true" tabindex="-1" class="el-radio__original" value="1"></span><span class="el-radio__label">移出</span></label>'+
  555. '<label role="radio" tabindex="-1" class="el-radio"><span class="el-radio__input"><span class="el-radio__inner"></span><input type="radio" aria-hidden="true" tabindex="-1" class="el-radio__original" value="2"></span><span class="el-radio__label">转为团队成员</span></label></div></div></div>'+
  556. '<div class="vux-flexbox handle-item vux-flex-row" style="align-items: stretch;padding: 10px 20px 0px 20px;line-height:30px;display: none">'+
  557. '<div class="handle-item-name" style="margin-top: 8px;width:130px;">权限:</div><div role="radiogroup" class="el-radio-group">'+
  558. '<label role="radio" aria-checked="true" tabindex="0" class="el-radio is-checked"><span class="el-radio__input is-checked"><span class="el-radio__inner"></span><input type="radio" aria-hidden="true" tabindex="-1" class="el-radio__original" value="1"></span><span class="el-radio__label">只读</span></label>'+
  559. '<label role="radio" tabindex="-1" class="el-radio"><span class="el-radio__input"><span class="el-radio__inner"></span><input type="radio" aria-hidden="true" tabindex="-1" class="el-radio__original" value="2"></span><span class="el-radio__label">读写</span></label></div></div></div>'+
  560. '<div class="vux-flexbox handle-item vux-flex-row" style="align-items: stretch;padding: 10px 20px 80px 20px;line-height:30px;">'+
  561. '<div class="handle-item-name" style="margin-top: 8px;width:130px;">同时变更负责人至:</div><div role="group" aria-label="checkbox-group" class="el-checkbox-group">'+
  562. '<label role="checkbox" class="el-checkbox"><span aria-checked="mixed" class="el-checkbox__input"><span class="el-checkbox__inner"></span><input type="checkbox" aria-hidden="true" class="el-checkbox__original" value="contacts"></span><span class="el-checkbox__label">联系人</span></label>'+
  563. '<label role="checkbox" class="el-checkbox"><span aria-checked="mixed" class="el-checkbox__input"><span class="el-checkbox__inner"></span><input type="checkbox" aria-hidden="true" class="el-checkbox__original" value="business"></span><span class="el-checkbox__label">商机</span></label></div></div></div>'
  564. Showbo.Msg.confirm('客户转移',contentHtml,function(){
  565. //_self.confirmCustomerDealstatus();
  566. var transferType = "";
  567. var readOrWrite = "";
  568. var checkFlag = true;
  569. var relationTypeList = [];
  570. jQuery(".ct").find(".is-checked").each(function(i,obj){
  571. var typeStr = jQuery(obj).children(".el-radio__label").text();
  572. if(typeStr=="移出"){
  573. transferType = "1"
  574. }
  575. if(typeStr=="转为团队成员"){
  576. transferType = "2"
  577. }
  578. if(typeStr=="只读"){
  579. readOrWrite = "readonly"
  580. }
  581. if(typeStr=="读写"){
  582. readOrWrite = "readandwrite"
  583. }
  584. })
  585. jQuery(".ct").find(".el-checkbox__original").each(function(i,obj){
  586. debugger
  587. if(jQuery(obj).is(':checked')){
  588. debugger
  589. relationTypeList.push(jQuery(obj).val());
  590. }
  591. })
  592. if(jQuery("#selectId").text() == ""){
  593. checkFlag = false;
  594. Showbo.Msg.alert('请选择负责人!');
  595. }
  596. if(transferType == ""){
  597. checkFlag = false;
  598. Showbo.Msg.alert('请选择将负责人移出或转为团队成员!');
  599. }
  600. if(checkFlag){
  601. var filter = {};
  602. filter = {
  603. distinguishName: jQuery('#selectId').text(),
  604. transferType: transferType,
  605. readOrWrite: readOrWrite,
  606. relationTypeList:relationTypeList
  607. }
  608. debugger
  609. _self.actions.customerTransfer(_self.options.openId, filter, function (json) {
  610. if(json.type=="success"){
  611. Showbo.Msg.alert('操作成功!');
  612. }
  613. setTimeout(function(){
  614. jQuery("#notifyEdit").remove();
  615. if(jQuery(".mask").length>0){
  616. jQuery(".mask").attr("style",'left: 0px; top: 0px; width: 100%; overflow: hidden; position: absolute; z-index: 500000; background-color: rgb(255, 255, 255)');
  617. jQuery(".mask").attr("class","");
  618. }
  619. },200);
  620. }.bind(_self));
  621. }
  622. },function(){
  623. });
  624. jQuery(".ct").find(".se-select-name").click(function(){
  625. _self.selectPerson(jQuery(_self.appArea)[0],"selectName","selectId",0);
  626. });
  627. jQuery(".ct").find(".el-radio").click(function(){
  628. jQuery(this).siblings().attr("class","el-radio");
  629. jQuery(this).siblings().find("input:radio").attr("checked",false)
  630. jQuery(this).attr("class","el-radio is-checked");
  631. jQuery(this).find("input:radio").attr("checked",true);
  632. var typeName = jQuery(this).find(".el-radio__label").text();
  633. if(typeName == "转为团队成员"){
  634. jQuery(this).parent().parent().next().show();
  635. }
  636. if(typeName == "移出"){
  637. jQuery(this).parent().parent().next().hide();
  638. }
  639. });
  640. },
  641. customerEdit: function () {
  642. //编辑线索
  643. _self = this;
  644. this.actions.getCustomerInfo(this.options.openId, function (json) {
  645. jQuery(_self.appArea).next().attr("style","");
  646. jQuery(_self.appArea).next().attr("class","mask");
  647. var jsonObj = json.data;
  648. var section_header = '<div class="section-header"><div class="section-mark" style="border-left-color: rgb(70, 205, 207);"></div> '+
  649. '<div data-v-ec8f8850="" class="section-title">基本信息</div></div>'
  650. var itemTemplateObject = _self.lp;
  651. debugger
  652. var section_conent = '<div class="section-conent">';
  653. for ( i in itemTemplateObject){
  654. var stype = itemTemplateObject[i].type;
  655. var notEmpty = itemTemplateObject[i].notEmpty?itemTemplateObject[i].notEmpty:"false";
  656. var innerHtml = '<input type="text" class="inline-input" name="'+i+'" id="'+i+'" notEmpty="'+notEmpty+'" stype="'+stype+'" value="'+((typeof(jsonObj[i])=="undefined")?"" : jsonObj[i])+'">';
  657. if(stype=="textarea"){
  658. innerHtml = '<textarea rows="6" class="el-textarea__inner" id="'+i+'" notEmpty="'+notEmpty+'" stype="'+stype+'" style="resize: none; min-height: 30.6px;">'+jsonObj[i]+'</textarea>';
  659. }
  660. if(stype=="select"){
  661. 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>';
  662. }
  663. if(stype=="map"){
  664. innerHtml = '<div class="setMap" id="setMap"' +' stype="'+stype+'"></div>';
  665. }
  666. if(i=="detailaddress"){
  667. var location = ((typeof(jsonObj["location"])=="undefined")?"" : jsonObj["location"]);
  668. var lng = ((typeof(jsonObj["lng"])=="undefined")?"" : jsonObj["lng"]);
  669. var lat = ((typeof(jsonObj["lat"])=="undefined")?"" : jsonObj["lat"]);
  670. innerHtml = '<input type="text" class="inline-input" name="'+i+'" id="'+i+'" notEmpty="'+notEmpty+'" stype="'+stype+'" lat="'+lat+'" lng="'+lng+'" location="'+location+'" value="'+((typeof(jsonObj[i])=="undefined")?"" : jsonObj[i])+'">';
  671. }
  672. if(stype!="hide"){
  673. section_conent = section_conent+'<div class="conent-inline"><div class="conent-title" lable="'+i+'">'+itemTemplateObject[i].text+'</div>' +
  674. '<div class="conent-value">'+innerHtml+'</div></div>';
  675. }
  676. }
  677. section_conent = section_conent + '</div>';
  678. var section_button = '<div class="section_button"><div><button class="el-button handle-button el-button-cancle"><span>取消</span></button>'+
  679. '<button class="el-button handle-button el-button-primary"><span>保存</span></button></div></div>';
  680. var htmlstr = section_header+section_conent+section_button;
  681. jQuery(".headMoreImg").notifyMe(
  682. 'left',
  683. 'default',
  684. '编辑客户',
  685. '',
  686. '',
  687. htmlstr,
  688. 'notifyEdit',
  689. 50
  690. );
  691. jQuery(".conent-value").each(function(index,element){
  692. var cobj = jQuery(element).children().eq(0)
  693. var stype = jQuery(cobj).attr("stype");
  694. if(stype=="datetime"){
  695. _self.loadTimeContainer(jQuery(cobj).attr("id"));
  696. }
  697. if(stype=="select"){
  698. var selectObjects = _self.app.lp.customer;
  699. for ( j in selectObjects){
  700. if(j==jQuery(cobj).attr("id")){
  701. var clp = itemTemplateObject[j];
  702. var valueList = clp.value;
  703. var valueArr = valueList.split(",");
  704. if(valueArr.length>0){
  705. var selectHtml = '<ul class="el-dropdown-type" style="display: none;" tid="'+jQuery(cobj).attr("id")+'">'
  706. for(var n=0;n<valueArr.length;n++){
  707. selectHtml = selectHtml+'<li class="el-dropdown-menu__item">'+valueArr[n]+'</li>'
  708. }
  709. jQuery(".notify-content").append(selectHtml+'<div class="popper__arrow"></div></ul>');
  710. jQuery(cobj).click(function(){
  711. jQuery("[tid='"+jQuery(cobj).attr("id")+"']").css({"left":jQuery(cobj).offset().left-50,"top":jQuery(cobj).offset().top+30,"width":282})
  712. jQuery("[tid='"+jQuery(cobj).attr("id")+"']").toggle(100);
  713. });
  714. jQuery("[tid='"+jQuery(cobj).attr("id")+"']").children().click(function(){
  715. debugger
  716. jQuery(cobj).text(jQuery(this).text());
  717. jQuery("[tid='"+jQuery(cobj).attr("id")+"']").toggle(100);
  718. });
  719. }
  720. }
  721. }
  722. }
  723. if(stype=="map"){
  724. debugger
  725. _self.loadMap();
  726. }
  727. }
  728. );
  729. jQuery('.el-button-cancle').click(function(){
  730. setTimeout(function(){
  731. jQuery("#notifyEdit").remove();
  732. if(jQuery(".mask").length>0){
  733. jQuery(".mask").attr("style",'left: 0px; top: 0px; width: 100%; overflow: hidden; position: absolute; z-index: 500000; background-color: rgb(255, 255, 255)');
  734. jQuery(".mask").attr("class","");
  735. }
  736. },200);
  737. });
  738. jQuery('.el-button-primary').click(function(){
  739. var sflag = true;
  740. jQuery(".inline-input[notempty='true']").each(function(index,element){
  741. if(jQuery(element).val()=="" && jQuery(element).text()==""){
  742. sflag = false;
  743. var nameStr = jQuery(element).parent().prev().text()+'不能为空';
  744. if(jQuery(element).nextAll(".empError").length>0)jQuery(element).nextAll(".empError").remove();
  745. jQuery(element).parent().append('<div class="empError" style="color:#f56c6c;padding: 0;line-height: 1;">'+nameStr+'</div>');
  746. }else{
  747. if(jQuery(element).nextAll(".empError").length>0)jQuery(element).nextAll(".empError").remove();
  748. }
  749. });
  750. if(sflag){
  751. var filter = {};
  752. filter = {
  753. customername:jQuery('div[lable="customername"]').next().children().eq(0).val(),
  754. level:jQuery('div[lable="level"]').next().children().eq(0).text(),
  755. industry:jQuery('div[lable="industry"]').next().children().eq(0).text(),
  756. source:jQuery('div[lable="source"]').next().children().eq(0).text(),
  757. telephone:jQuery('div[lable="telephone"]').next().children().eq(0).val(),
  758. cellphone:jQuery('div[lable="cellphone"]').next().children().eq(0).val(),
  759. website:jQuery('div[lable="website"]').next().children().eq(0).val(),
  760. location:jQuery('div[lable="detailaddress"]').next().children().eq(0).attr("location"),
  761. lng:jQuery('div[lable="detailaddress"]').next().children().eq(0).attr("lng"),
  762. lat:jQuery('div[lable="detailaddress"]').next().children().eq(0).attr("lat"),
  763. province:jQuery('div[lable="detailaddress"]').next().children().eq(0).attr("province"),
  764. city:jQuery('div[lable="detailaddress"]').next().children().eq(0).attr("city"),
  765. detailaddress:jQuery('div[lable="detailaddress"]').next().children().eq(0).val(),
  766. nexttime:jQuery('div[lable="nexttime"]').next().children().eq(0).val(),
  767. remark:jQuery('div[lable="remark"]').next().children().eq(0).val(),
  768. pinyin:((typeof(jsonObj["pinyin"])=="undefined")?"" : jsonObj["pinyin"]),
  769. pinyinInitial:((typeof(jsonObj["pinyinInitial"])=="undefined")?"" : jsonObj["pinyinInitial"]),
  770. islock:((typeof(jsonObj["islock"])=="undefined")?"" : jsonObj["islock"]),
  771. dealstatus:((typeof(jsonObj["dealstatus"])=="undefined")?"" : jsonObj["dealstatus"]),
  772. readerUserIds:((typeof(jsonObj["readerUserIds"])=="undefined")?"" : jsonObj["readerUserIds"]),
  773. writerUserIds:((typeof(jsonObj["writerUserIds"])=="undefined")?"" : jsonObj["writerUserIds"]),
  774. createuser:((typeof(jsonObj["createuser"])=="undefined")?"" : jsonObj["createuser"]),
  775. owneruser:((typeof(jsonObj["owneruser"])=="undefined")?"" : jsonObj["owneruser"])
  776. };
  777. _self.actions.updateCustomer(_self.options.openId, filter, function (json) {
  778. if(json.type=="success"){
  779. Showbo.Msg.alert('保存成功!');
  780. }
  781. setTimeout(function(){
  782. jQuery("#notifyEdit").remove();
  783. if(jQuery(".mask").length>0){
  784. jQuery(".mask").attr("style",'left: 0px; top: 0px; width: 100%; overflow: hidden; position: absolute; z-index: 500000; background-color: rgb(255, 255, 255)');
  785. jQuery(".mask").attr("class","");
  786. }
  787. },200);
  788. }.bind(_self));
  789. }
  790. });
  791. jQuery(".inline-input[notempty='true']").blur( function () {
  792. if(jQuery(this).attr("stype")!="datetime"){
  793. if(jQuery(this).val()=="" && jQuery(this).text()==""){
  794. var nameStr = jQuery(this).parent().prev().text()+'不能为空';
  795. if(jQuery(this).nextAll(".empError").length>0)jQuery(this).nextAll(".empError").remove();
  796. jQuery(this).parent().append('<div class="empError" style="color:#f56c6c;padding: 0;line-height: 1;">'+nameStr+'</div>');
  797. }else{
  798. if(jQuery(this).nextAll(".empError").length>0)jQuery(this).nextAll(".empError").remove();
  799. }
  800. }
  801. });
  802. }.bind(this));
  803. },
  804. contactsCreate: function () {
  805. //编辑联系人
  806. _self = this;
  807. var htmlstr = "";
  808. jQuery(_self.appArea).next().attr("style","");
  809. jQuery(_self.appArea).next().attr("class","mask");
  810. var section_header = '<div class="section-header"><div class="section-mark" style="border-left-color: rgb(70, 205, 207);"></div> '+
  811. '<div data-v-ec8f8850="" class="section-title">基本信息</div></div>';
  812. var itemTemplateObject = _self.app.lp.contact.contactEdit;
  813. var section_conent = '<div class="section-conent">';
  814. for ( i in itemTemplateObject){
  815. var stype = itemTemplateObject[i].type;
  816. var notEmpty = itemTemplateObject[i].notEmpty?itemTemplateObject[i].notEmpty:"false";
  817. var innerHtml = '<input type="text" class="inline-input" name="'+i+'" id="'+i+'" notEmpty="'+notEmpty+'" stype="'+stype+'">';
  818. if(stype=="textarea"){
  819. innerHtml = '<textarea rows="6" class="el-textarea__inner" id="'+i+'" stype="'+stype+'" style="resize: none; min-height: 30.6px;"></textarea>';
  820. }
  821. if(stype=="select"){
  822. innerHtml = '<div class="inline-input" style="display: inline-block;cursor:pointer;" id="'+i+'" notEmpty="'+notEmpty+'" stype="'+stype+'" ></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>';
  823. }
  824. if(stype=="openSelect"){
  825. innerHtml = '<input type="text" class="inline-input" disabled="disabled" style="background-color:#e2ebf9;" name="'+i+'" id="'+i+'" value="'+jQuery("#notify").find("h3").text()+'" cid="'+_self.options.openId+'" stype="'+stype+'">';
  826. }
  827. section_conent = section_conent+'<div class="conent-inline"><div class="conent-title" lable="'+i+'">'+itemTemplateObject[i].text+'</div>' +
  828. '<div class="conent-value">'+innerHtml+'</div></div>';
  829. }
  830. section_conent = section_conent + '</div>';
  831. var section_button = '<div class="section_button"><div><button class="el-button handle-button el-button-cancle"><span>取消</span></button>'+
  832. '<button class="el-button handle-button el-button-primary"><span>保存</span></button></div></div>';
  833. htmlstr = section_header+section_conent+section_button;
  834. jQuery(".headMoreImg").notifyMe(
  835. 'left',
  836. 'default',
  837. "新建联系人",
  838. '',
  839. '',
  840. htmlstr,
  841. 'notifyEdit',
  842. 50
  843. );
  844. jQuery(".conent-value").each(function(index,element){
  845. var cobj = jQuery(element).children().eq(0)
  846. var stype = jQuery(cobj).attr("stype");
  847. if(stype=="datetime"){
  848. _self.loadTimeContainer(jQuery(cobj).attr("id"));
  849. }
  850. if(stype=="select"){
  851. var selectObjects = _self.app.lp.contact;
  852. for ( j in selectObjects){
  853. if(j==jQuery(cobj).attr("id")){
  854. var clp = itemTemplateObject[j];
  855. var valueList = clp.value;
  856. var valueArr = valueList.split(",");
  857. if(valueArr.length>0){
  858. var selectHtml = '<ul class="el-dropdown-type" style="display: none;" tid="'+jQuery(cobj).attr("id")+'">'
  859. for(var n=0;n<valueArr.length;n++){
  860. selectHtml = selectHtml+'<li class="el-dropdown-menu__item">'+valueArr[n]+'</li>'
  861. }
  862. jQuery(".notify-content").append(selectHtml+'<div class="popper__arrow"></div></ul>');
  863. jQuery(cobj).click(function(){
  864. jQuery("[tid='"+jQuery(cobj).attr("id")+"']").css({"left":jQuery(cobj).offset().left-50,"top":jQuery(cobj).offset().top+30,"width":282})
  865. jQuery("[tid='"+jQuery(cobj).attr("id")+"']").toggle(100);
  866. });
  867. jQuery("[tid='"+jQuery(cobj).attr("id")+"']").children().click(function(){
  868. debugger
  869. jQuery(cobj).text(jQuery(this).text());
  870. jQuery("[tid='"+jQuery(cobj).attr("id")+"']").toggle(100);
  871. });
  872. }
  873. }
  874. }
  875. }
  876. }
  877. );
  878. jQuery('.el-button-cancle').click(function(){
  879. setTimeout(function(){
  880. jQuery("#notifyEdit").remove();
  881. if(jQuery(".mask").length>0){
  882. jQuery(".mask").attr("style",'left: 0px; top: 0px; width: 100%; overflow: hidden; position: absolute; z-index: 500000; background-color: rgb(255, 255, 255)');
  883. jQuery(".mask").attr("class","");
  884. }
  885. },200);
  886. });
  887. jQuery('.el-button-primary').click(function(){
  888. var sflag = true;
  889. jQuery(".inline-input[notempty='true']").each(function(index,element){
  890. if(jQuery(element).val()=="" && jQuery(element).text()==""){
  891. sflag = false;
  892. var nameStr = jQuery(element).parent().prev().text()+'不能为空';
  893. if(jQuery(element).nextAll(".empError").length>0)jQuery(element).nextAll(".empError").remove();
  894. jQuery(element).parent().append('<div class="empError" style="color:#f56c6c;padding: 0;line-height: 1;">'+nameStr+'</div>');
  895. }else{
  896. if(jQuery(element).nextAll(".empError").length>0)jQuery(element).nextAll(".empError").remove();
  897. }
  898. });
  899. if(sflag) {
  900. var filter = {};
  901. filter = {
  902. contactsname: jQuery('div[lable="contactsname"]').next().children().eq(0).val(),
  903. customerid: jQuery('#customername').attr("cid"),
  904. telephone: jQuery('div[lable="telephone"]').next().children().eq(0).val(),
  905. cellphone: jQuery('div[lable="cellphone"]').next().children().eq(0).val(),
  906. email: jQuery('div[lable="email"]').next().children().eq(0).val(),
  907. decision: jQuery('div[lable="decision"]').next().children().eq(0).text(),
  908. sex: jQuery('div[lable="sex"]').next().children().eq(0).text(),
  909. post: jQuery('div[lable="post"]').next().children().eq(0).val(),
  910. detailaddress: jQuery('div[lable="detailaddress"]').next().children().eq(0).val(),
  911. nexttime: jQuery('div[lable="nexttime"]').next().children().eq(0).val(),
  912. remark: jQuery('div[lable="remark"]').next().children().eq(0).val()
  913. };
  914. debugger
  915. _self.actions.saveContacts(filter, function (json) {
  916. debugger
  917. if (json.type == "success") {
  918. Showbo.Msg.alert('保存成功!');
  919. _self.loadContacts();
  920. }
  921. setTimeout(function () {
  922. jQuery("#notifyEdit").remove();
  923. if (jQuery(".mask").length > 0) {
  924. jQuery(".mask").attr("style", 'left: 0px; top: 0px; width: 100%; overflow: hidden; position: absolute; z-index: 500000; background-color: rgb(255, 255, 255)');
  925. jQuery(".mask").attr("class", "");
  926. }
  927. }, 200);
  928. }.bind(_self));
  929. }
  930. });
  931. jQuery(".inline-input[notempty='true']").blur( function () {
  932. if(jQuery(this).attr("stype")!="datetime" || jQuery(this).attr("stype")!="openSelect"){
  933. if(jQuery(this).val()=="" && jQuery(this).text()==""){
  934. var nameStr = jQuery(this).parent().prev().text()+'不能为空';
  935. if(jQuery(this).nextAll(".empError").length>0)jQuery(this).nextAll(".empError").remove();
  936. jQuery(this).parent().append('<div class="empError" style="color:#f56c6c;padding: 0;line-height: 1;">'+nameStr+'</div>');
  937. }else{
  938. if(jQuery(this).nextAll(".empError").length>0)jQuery(this).nextAll(".empError").remove();
  939. }
  940. }
  941. });
  942. },
  943. businessCreate: function(){
  944. that = this;
  945. MWF.xDesktop.requireApp("CRM", "ChanceEdit", function(){
  946. //console.log("this.lp",this.lp);
  947. var editForm = new MWF.xApplication.CRM.ChanceEdit(null,{},null, {
  948. app: this.app,
  949. container : this.app.content,
  950. lp : this.app.lp.chance,
  951. actions : this.actions,
  952. css : {},
  953. customer :{"id":that.options.openCustomerId},
  954. callback : function () {
  955. //editForm.create();
  956. }
  957. });
  958. editForm.create();
  959. }.bind(this));
  960. that.app.content.getElement("#customer").setProperty("value",that.options.openCustomerName);
  961. },
  962. editTeam: function(nameList){
  963. _self = this;
  964. var contentHtml = '<div class="vux-flexbox handle-item vux-flex-row" style="align-items: stretch;padding: 10px 20px 50px 20px;line-height:30px;font-size:16px;">'+
  965. '<div class="handle-item-name" style="margin-top: 8px;width:60px;">权限:</div><div role="radiogroup" class="el-radio-group">'+
  966. '<label role="radio" tabindex="0" class="el-radio"><span class="el-radio__input"><span class="el-radio__inner"></span><input type="radio" checked aria-hidden="true" tabindex="-1" class="el-radio__original" value="1"></span><span class="el-radio__label">只读</span></label>'+
  967. '<label role="radio" tabindex="-1" class="el-radio"><span class="el-radio__input"><span class="el-radio__inner"></span><input type="radio" aria-hidden="true" tabindex="-1" class="el-radio__original" value="2"></span><span class="el-radio__label">读写</span></label></div></div></div>'
  968. Showbo.Msg.confirm('编辑权限',contentHtml,function(){
  969. var filter = {};
  970. filter = {
  971. distinguishName: nameList,
  972. }
  973. var val=jQuery(".ct").find('input:radio:checked').val();
  974. if(val==1){
  975. _self.actions.setTeamReader(_self.options.openId, filter, function (json) {
  976. if(json.type=="success"){
  977. Showbo.Msg.alert('操作成功!');
  978. _self.loadTeam();
  979. }
  980. setTimeout(function(){
  981. jQuery("#notifyEdit").remove();
  982. if(jQuery(".mask").length>0){
  983. jQuery(".mask").attr("style",'left: 0px; top: 0px; width: 100%; overflow: hidden; position: absolute; z-index: 500000; background-color: rgb(255, 255, 255)');
  984. jQuery(".mask").attr("class","");
  985. }
  986. },200);
  987. }.bind(_self));
  988. }else{
  989. _self.actions.setTeamWriter(_self.options.openId, filter, function (json) {
  990. if(json.type=="success"){
  991. Showbo.Msg.alert('操作成功!');
  992. _self.loadTeam();
  993. }
  994. setTimeout(function(){
  995. jQuery("#notifyEdit").remove();
  996. if(jQuery(".mask").length>0){
  997. jQuery(".mask").attr("style",'left: 0px; top: 0px; width: 100%; overflow: hidden; position: absolute; z-index: 500000; background-color: rgb(255, 255, 255)');
  998. jQuery(".mask").attr("class","");
  999. }
  1000. },200);
  1001. }.bind(_self));
  1002. }
  1003. },function(){
  1004. });
  1005. jQuery(".el-radio").click(function(){
  1006. var robj = jQuery(this).find("input");
  1007. jQuery(this).siblings().find("input[type=radio]").removeAttr('checked');
  1008. });
  1009. },
  1010. addTeam: function () {
  1011. //添加team成员
  1012. _self = this;
  1013. var contentHtml = '<div class="vux-flexbox handle-item vux-flex-row" style="align-items: stretch;padding: 30px 20px 0px 20px;line-height:30px;">'+
  1014. '<div class="handle-item-name" style="margin-top: 8px;width:100px;">选择团队成员:</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>'+
  1015. '<div class="vux-flexbox handle-item vux-flex-row" style="align-items: stretch;padding: 10px 20px 0px 20px;line-height:30px;">'+
  1016. '<div class="handle-item-name" style="margin-top: 8px;width:100px;">权限:</div><div role="radiogroup" class="el-radio-group">'+
  1017. '<label role="radio" aria-checked="true" tabindex="0" class="el-radio is-checked"><span class="el-radio__input is-checked"><span class="el-radio__inner"></span><input type="radio" aria-hidden="true" tabindex="-1" class="el-radio__original" value="1"></span><span class="el-radio__label">只读</span></label>'+
  1018. '<label role="radio" tabindex="-1" class="el-radio"><span class="el-radio__input"><span class="el-radio__inner"></span><input type="radio" aria-hidden="true" tabindex="-1" class="el-radio__original" value="2"></span><span class="el-radio__label">读写</span></label></div></div></div>'+
  1019. '<div class="vux-flexbox handle-item vux-flex-row" style="align-items: stretch;padding: 10px 20px 80px 20px;line-height:30px;">'+
  1020. '<div class="handle-item-name" style="margin-top: 8px;width:100px;">同时添加至:</div><div role="group" aria-label="checkbox-group" class="el-checkbox-group">'+
  1021. '<label role="checkbox" class="el-checkbox"><span aria-checked="mixed" class="el-checkbox__input"><span class="el-checkbox__inner"></span><input type="checkbox" aria-hidden="true" class="el-checkbox__original" value="opportunity"></span><span class="el-checkbox__label">商机</span></label>'+
  1022. '</div></div></div>'
  1023. Showbo.Msg.confirm('添加团队成员',contentHtml,function(){
  1024. //_self.confirmCustomerDealstatus();
  1025. var readOrWrite = "";
  1026. var checkFlag = true;
  1027. var relationTypeList = [];
  1028. jQuery(".ct").find(".is-checked").each(function(i,obj){
  1029. var typeStr = jQuery(obj).children(".el-radio__label").text();
  1030. if(typeStr=="只读"){
  1031. readOrWrite = "read"
  1032. }
  1033. if(typeStr=="读写"){
  1034. readOrWrite = "write"
  1035. }
  1036. })
  1037. jQuery(".ct").find(".el-checkbox__original").each(function(i,obj){
  1038. if(jQuery(obj).is(':checked')){
  1039. relationTypeList.push(jQuery(obj).val());
  1040. }
  1041. })
  1042. if(jQuery("#selectId").text() == ""){
  1043. checkFlag = false;
  1044. Showbo.Msg.alert('选择团队成员!');
  1045. }
  1046. if(readOrWrite == ""){
  1047. checkFlag = false;
  1048. Showbo.Msg.alert('请权限!');
  1049. }
  1050. if(checkFlag){
  1051. var filter = {};
  1052. filter = {
  1053. personList: (jQuery('#selectId').text()).split(","),
  1054. relationTypeList: relationTypeList
  1055. }
  1056. _self.actions.addRelevantPerson(_self.options.openId,readOrWrite, filter, function (json) {
  1057. if(json.type=="success"){
  1058. Showbo.Msg.alert('操作成功!');
  1059. _self.loadTeam();
  1060. }
  1061. setTimeout(function(){
  1062. jQuery("#notifyEdit").remove();
  1063. if(jQuery(".mask").length>0){
  1064. jQuery(".mask").attr("style",'left: 0px; top: 0px; width: 100%; overflow: hidden; position: absolute; z-index: 500000; background-color: rgb(255, 255, 255)');
  1065. jQuery(".mask").attr("class","");
  1066. }
  1067. },200);
  1068. }.bind(_self));
  1069. }
  1070. },function(){
  1071. });
  1072. jQuery(".ct").find(".se-select-name").click(function(){
  1073. _self.selectPerson(jQuery(_self.appArea)[0],"selectName","selectId",0);
  1074. });
  1075. jQuery(".ct").find(".el-radio").click(function(){
  1076. jQuery(this).siblings().attr("class","el-radio");
  1077. jQuery(this).siblings().find("input:radio").attr("checked",false)
  1078. jQuery(this).attr("class","el-radio is-checked");
  1079. jQuery(this).find("input:radio").attr("checked",true);
  1080. var typeName = jQuery(this).find(".el-radio__label").text();
  1081. });
  1082. },
  1083. deleteTeam: function(){
  1084. _self = this;
  1085. Showbo.Msg.confirm('提示','此操作将移除这些团队成员是否继续?',function(){
  1086. var nameList = [];
  1087. jQuery(".el-table__body").find("input:checked").each(function(index,element){
  1088. var nobj = jQuery(element).parent().parent().next();
  1089. nameList.push(jQuery(nobj).attr("aid"));
  1090. });
  1091. if(nameList.length<1){
  1092. Showbo.Msg.alert('请选择要删除的相关团队成员!');
  1093. }else{
  1094. var filter = {};
  1095. filter = {
  1096. distinguishName: nameList
  1097. }
  1098. _self.actions.removeTeamMember(_self.options.openId,filter, function (json) {
  1099. if(json.type=="success"){
  1100. Showbo.Msg.alert('操作成功!');
  1101. _self.loadTeam();
  1102. }
  1103. }.bind(self));
  1104. }
  1105. setTimeout(function(){
  1106. jQuery("#notifyEdit").remove();
  1107. if(jQuery(".mask").length>0){
  1108. jQuery(".mask").attr("style",'left: 0px; top: 0px; width: 100%; overflow: hidden; position: absolute; z-index: 500000; background-color: rgb(255, 255, 255)');
  1109. jQuery(".mask").attr("class","");
  1110. }
  1111. },200);
  1112. },function(){
  1113. });
  1114. },
  1115. loadEvent: function(){
  1116. that = this;
  1117. jQuery(that.sectionArea).find('.tabPanel div').click(function(){
  1118. debugger
  1119. jQuery(this).addClass('hit').siblings().removeClass('hit');
  1120. jQuery(that.sectionArea).find('.panes>div:eq('+jQuery(this).index()+')').show().siblings().hide();
  1121. that.createTypeHtml();
  1122. });
  1123. jQuery(that.sectionArea).find('.headMoreBottonDiv').click(function(){
  1124. jQuery(that.sectionArea).find(".el-dropdown-menu").toggle(100);
  1125. });
  1126. jQuery(that.sectionArea).find('.el-dropdown-menu__item').click(function(){
  1127. debugger
  1128. if(jQuery(this).text()=="放入公海"){
  1129. that.putToCustomerPool();
  1130. }
  1131. if(jQuery(this).text()=="更改成交状态"){
  1132. that.transformCustomerDealstatus();
  1133. }
  1134. if(jQuery(this).text()=="锁定"){
  1135. that.lockCustomer();
  1136. }
  1137. if(jQuery(this).text()=="解锁"){
  1138. that.unLockCustomer();
  1139. }
  1140. if(jQuery(this).text()=="删除"){
  1141. }
  1142. //---for记录类型
  1143. if(jQuery(this).parent().attr("tid")=="recordType"){
  1144. jQuery(that.sectionArea).find(".se-select-name").text(jQuery(this).text());
  1145. jQuery(this).parent().toggle(100);
  1146. }
  1147. });
  1148. jQuery(that.sectionArea).find('.headMoveBottonDiv').click(function(){
  1149. that.transfer();
  1150. });
  1151. jQuery(that.sectionArea).find('.headEditBottonDiv').click(function(){
  1152. that.customerEdit();
  1153. });
  1154. jQuery(that.sectionArea).find('#bar-file').change(function(event) {
  1155. var files = event.target.files;
  1156. debugger
  1157. jQuery(that.sectionArea).find('.fileList').empty();
  1158. if (files && files.length > 0) {
  1159. // 获取目前上传的文件
  1160. var fileListHtml = '<div class="fileList">';
  1161. for(var i=0;i<files.length;i++){
  1162. var file = files[i];
  1163. var fsize = file.size/1024;
  1164. var lastModifiedDate = file.lastModifiedDate;
  1165. 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>';
  1166. }
  1167. fileListHtml = fileListHtml+'</div>';
  1168. jQuery(that.sectionArea).find('.mix-container').append(fileListHtml);
  1169. /*
  1170. file = files[0];
  1171. // 来在控制台看看到底这个对象是什么
  1172. console.log(file);
  1173. var filter = {};
  1174. filter = {
  1175. file:file,
  1176. fileName:file.name
  1177. };
  1178. debugger
  1179. var formdata=new FormData();
  1180. formdata.append("fileName",file.name);
  1181. formdata.append("file",file);
  1182. that.actions.updateAttachment(that.options.clueId, "leads", formdata,file, function (json) {
  1183. debugger
  1184. if(json.type=="success"){
  1185. Showbo.Msg.alert('附件上传成功!');
  1186. }
  1187. }.bind(that));
  1188. /!*!// 那么我们可以做一下诸如文件大小校验的动作
  1189. if(file.size > 1024 * 1024 * 2) {
  1190. alert('图片大小不能超过 2MB!');
  1191. return false;
  1192. }*!/
  1193. // 下面是关键的关键,通过这个 file 对象生成一个可用的图像 URL
  1194. // 获取 window 的 URL 工具
  1195. var URL = window.URL || window.webkitURL;
  1196. // 通过 file 生成目标 url
  1197. var imgURL = URL.createObjectURL(file);
  1198. // 用这个 URL 产生一个 <img> 将其显示出来
  1199. //jQuery('.fbpj .container').prev().find("img").attr('src', imgURL);
  1200. jQuery('.mix-container').append('<div><img src="'+imgURL+'"></div>');
  1201. // 使用下面这句可以在内存中释放对此 url 的伺服,跑了之后那个 URL 就无效了
  1202. //URL.revokeObjectURL(imgURL);
  1203. */
  1204. }
  1205. });
  1206. jQuery(that.sectionArea).find('.se-send').click(function(){
  1207. that.sendRecord();
  1208. });
  1209. jQuery(that.sectionArea).find('.el-dropdown-selfdefine').click(function(){
  1210. jQuery(that.sectionArea).find("[tid='recordType']").toggle(100);
  1211. });
  1212. },
  1213. sendRecord: function () {
  1214. that = this;
  1215. //var objFile = document.getElementById("bar-file");
  1216. var filters = {};
  1217. filters = {
  1218. types:"customer",
  1219. typesid:that.options.openId,
  1220. content:jQuery(that.sectionArea).find('.el-textarea__inner').val(),
  1221. category:jQuery(that.sectionArea).find('.se-select-name').text(),
  1222. nexttime:jQuery(that.sectionArea).find('.hasDatepicker').val(),
  1223. businessids:"",
  1224. contactsids:"",
  1225. createuser:""
  1226. };
  1227. that.actions.createRecord(filters,function(json){
  1228. if(json.type=="success"){
  1229. Showbo.Msg.alert('跟进记录发布成功!');
  1230. var objFile = jQuery(that.sectionArea).find('#bar-file')[0].files;
  1231. jQuery(objFile).each(function(index,file){
  1232. var filter = {};
  1233. filter = {
  1234. file:file,
  1235. fileName:file.name
  1236. };
  1237. debugger
  1238. var formdata=new FormData();
  1239. formdata.append("fileName",file.name);
  1240. formdata.append("file",file);
  1241. that.actions.updateAttachment("att",json.data.id, "record", formdata,file, function (attjson) {
  1242. debugger
  1243. /*if(json.type=="success"){
  1244. Showbo.Msg.alert('附件上传成功!');
  1245. }*/
  1246. }.bind(that));
  1247. }
  1248. );
  1249. that.loadRecord();
  1250. }
  1251. }.bind(that),function(xhr,text,error){
  1252. }.bind(that));
  1253. },
  1254. loadRecord: function(){
  1255. that = this;
  1256. this.actions.getRecord(this.options.openId, function (json) {
  1257. if(json.type=="success"){
  1258. var recordDatas = json.data;
  1259. jQuery(that.sectionArea).find(".fl-c").remove();
  1260. var logItemHtml = "";
  1261. for ( i in recordDatas){
  1262. if(i<recordDatas.length){
  1263. var recordData = recordDatas[i];
  1264. var personImg = '../x_component_CRM/$Template/portrait.png';
  1265. if(recordData.ICONBase64 && recordData.ICONBase64!=""){
  1266. personImg = recordData.ICONBase64;
  1267. }
  1268. var attHtml = '';
  1269. var relationHtml = '';
  1270. if(recordData.attachmentListPreview.length>0){
  1271. attHtml = attHtml+'<div class="vux-flexbox fl-b-images vux-flex-row" style="flex-wrap: wrap;"></div>'
  1272. }
  1273. if(recordData.attachmentList.length>0){
  1274. attHtml = attHtml+'<div class="fl-b-files">';
  1275. var attList = recordData.attachmentList;
  1276. for(j in attList){
  1277. if(j<attList.length){
  1278. var attData = attList[j];
  1279. attHtml = attHtml+'<div class="vux-flexbox cell vux-flex-row">'+
  1280. '<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>'+
  1281. '<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>'
  1282. }
  1283. }
  1284. attHtml = attHtml+'</div>';
  1285. }
  1286. logItemHtml = logItemHtml+'<div class="fl-c"><div class="vux-flexbox fl-h vux-flex-row">'+
  1287. '<div class="div-photo fl-h-img" style="background-image: url(&quot;'+personImg+'&quot;);" lazy="loaded"></div> '+
  1288. '<div class="fl-h-b"><div class="fl-h-name">'+recordData.person.name+'</div><div class="fl-h-time">'+recordData.updateTime+'</div></div></div>'+
  1289. '<div class="fl-b"><div class="fl-b-content">'+recordData.content+'</div>'+attHtml+
  1290. '<div class="follow"><span class="follow-info">'+recordData.category+'</span></div></div>'+
  1291. '<div class="full-container" style="display: none;"></div></div>'
  1292. }
  1293. }
  1294. if(logItemHtml!=""){
  1295. jQuery(that.sectionArea).find(".load").before(logItemHtml);
  1296. }
  1297. if(recordDatas.length<1){
  1298. jQuery(that.sectionArea).find(".load").hide();
  1299. jQuery(that.sectionArea).find(".empty-mask").show();
  1300. }
  1301. jQuery(".aname").click(function(){
  1302. var attUrl = 'http://172.16.92.55:20020/x_wcrm_assemble_control/jaxrs/attachment/download/'+jQuery(this).attr("aid")+'/work/'+jQuery(this).attr("wcrm")
  1303. window.open(attUrl);
  1304. });
  1305. }
  1306. }.bind(this));
  1307. },
  1308. open: function (e) {
  1309. this.fireEvent("queryOpen");
  1310. this._open();
  1311. this.fireEvent("postOpen");
  1312. },
  1313. create: function () {
  1314. this.fireEvent("queryCreate");
  1315. this.isNew = true;
  1316. this._open();
  1317. this.fireEvent("postCreate");
  1318. },
  1319. edit: function () {
  1320. this.fireEvent("queryEdit");
  1321. this.isEdited = true;
  1322. this._open();
  1323. this.fireEvent("postEdit");
  1324. },
  1325. _open: function () {
  1326. if( this.options.hasMask ){
  1327. this.formMaskNode = new Element("div.formMaskNode", {
  1328. "styles": this.css.formMaskNode,
  1329. "events": {
  1330. "mouseover": function (e) {
  1331. e.stopPropagation();
  1332. },
  1333. "mouseout": function (e) {
  1334. e.stopPropagation();
  1335. },
  1336. "click": function (e) {
  1337. e.stopPropagation();
  1338. }
  1339. }
  1340. }).inject( this.container || this.app.content);
  1341. }
  1342. this.formAreaNode = new Element("div.formAreaNode", {
  1343. "styles": this.css.formAreaNode
  1344. });
  1345. this.createFormNode();
  1346. this.formAreaNode.inject(this.formMaskNode || this.container || this.app.content, "after");
  1347. this.formAreaNode.fade("in");
  1348. this.setFormNodeSize();
  1349. this.setFormNodeSizeFun = this.setFormNodeSize.bind(this);
  1350. if( this.app )this.app.addEvent("resize", this.setFormNodeSizeFun);
  1351. if (this.options.draggable && this.formTopNode) {
  1352. var size = (this.container || this.app.content).getSize();
  1353. var nodeSize = this.formAreaNode.getSize();
  1354. this.formAreaNode.makeDraggable({
  1355. "handle": this.formTopNode,
  1356. "limit": {
  1357. "x": [0, size.x - nodeSize.x],
  1358. "y": [0, size.y - nodeSize.y]
  1359. }
  1360. });
  1361. }
  1362. },
  1363. createFormNode: function () {
  1364. var _self = this;
  1365. this.formNode = new Element("div.formNode", {
  1366. "styles": this.css.formNode
  1367. }).inject(this.formAreaNode);
  1368. if (this.options.hasTop) {
  1369. this.createTopNode();
  1370. }
  1371. if (this.options.hasIcon) {
  1372. this.formIconNode = new Element("div.formIconNode", {
  1373. "styles": this.isNew ? this.css.formNewNode : this.css.formIconNode
  1374. }).inject(this.formNode);
  1375. }
  1376. this.createContent();
  1377. //formContentNode.set("html", html);
  1378. if (this.options.hasBottom) {
  1379. this.createBottomNode();
  1380. }
  1381. this._setCustom();
  1382. if( this.options.hasScroll ){
  1383. //this.setScrollBar(this.formTableContainer)
  1384. MWF.require("MWF.widget.ScrollBar", function () {
  1385. new MWF.widget.ScrollBar(this.formTableContainer, {
  1386. "indent": false,
  1387. "style": "default",
  1388. "where": "before",
  1389. "distance": 30,
  1390. "friction": 4,
  1391. "axis": {"x": false, "y": true},
  1392. "onScroll": function (y) {
  1393. //var scrollSize = _self.viewContainerNode.getScrollSize();
  1394. //var clientSize = _self.viewContainerNode.getSize();
  1395. //var scrollHeight = scrollSize.y - clientSize.y;
  1396. //if (y + 200 > scrollHeight && _self.view && _self.view.loadElementList) {
  1397. // if (!_self.view.isItemsLoaded) _self.view.loadElementList();
  1398. //}
  1399. }
  1400. });
  1401. }.bind(this));
  1402. }
  1403. },
  1404. createContent: function () {
  1405. this.formContentNode = new Element("div.formContentNode", {
  1406. "styles": this.css.formContentNode
  1407. }).inject(this.formNode);
  1408. this.formTableContainer = new Element("div.formTableContainer", {
  1409. "styles": this.css.formTableContainer
  1410. }).inject(this.formContentNode);
  1411. this.formTableArea = new Element("div.formTableArea", {
  1412. "styles": this.css.formTableArea,
  1413. "text":"loading..."
  1414. }).inject(this.formTableContainer);
  1415. this._createTableContent();
  1416. },
  1417. createBottomNode: function () {
  1418. this.formBottomNode = new Element("div.formBottomNode", {
  1419. "styles": this.css.formBottomNode
  1420. }).inject(this.formNode);
  1421. this._createBottomContent()
  1422. },
  1423. createTopNode: function () {
  1424. if (!this.formTopNode) {
  1425. this.formTopNode = new Element("div.formTopNode", {
  1426. "styles": this.css.formTopNode
  1427. }).inject(this.formNode);
  1428. this.formTopIconNode = new Element("div", {
  1429. "styles": this.css.formTopIconNode
  1430. }).inject(this.formTopNode);
  1431. this.formTopTextNode = new Element("div", {
  1432. "styles": this.css.formTopTextNode,
  1433. "text": this.options.title + ( this.data.title ? ("-" + this.data.title ) : "" )
  1434. }).inject(this.formTopNode);
  1435. if (this.options.closeAction) {
  1436. this.formTopCloseActionNode = new Element("div", {"styles": this.css.formTopCloseActionNode}).inject(this.formTopNode);
  1437. this.formTopCloseActionNode.addEvent("click", function () {
  1438. this.close();
  1439. }.bind(this))
  1440. }
  1441. this.formTopContentNode = new Element("div", {
  1442. "styles": this.css.formTopContentNode
  1443. }).inject(this.formTopNode);
  1444. this._createTopContent();
  1445. }
  1446. },
  1447. _createTopContent: function () {
  1448. },
  1449. _createTableContent: function () {
  1450. this.loadFormData();
  1451. /*
  1452. var Ttype = "clue";
  1453. this.actions.getProfiles(Ttype,function(json){
  1454. this.profileData = json.data;
  1455. if(this.data.id){
  1456. this.actions.getCustomerInfo(this.data.id,function(json){
  1457. this.customerData = json.data;
  1458. this.loadFormData();
  1459. this.createCustomBottom();
  1460. }.bind(this));
  1461. }else{
  1462. this.loadFormData();
  1463. this.createCustomBottom();
  1464. }
  1465. }.bind(this));
  1466. */
  1467. },
  1468. _createBottomContent: function () {
  1469. this.cancelActionNode = new Element("div.formCancelActionNode", {
  1470. "styles": this.css.formCancelActionNode,
  1471. "text": this.lp.actionCancel
  1472. }).inject(this.formBottomNode);
  1473. if (this.options.isNew || this.options.isEdited) {
  1474. //this.ok();
  1475. this.okActionNode = new Element("div.formOkActionNode", {
  1476. "styles": this.css.formOkActionNode,
  1477. "text": this.lp.actionConfirm
  1478. }).inject(this.formBottomNode);
  1479. this.okActionNode.addEvent("click", function (e) {
  1480. this.ok(e);
  1481. }.bind(this));
  1482. }
  1483. this.cancelActionNode.addEvent("click", function (e) {
  1484. this.cancel(e);
  1485. }.bind(this));
  1486. },
  1487. loadFormData:function(){
  1488. var tmpData={};
  1489. this.loadForm();
  1490. /*
  1491. var html = "<table width='100%' bordr='0' cellpadding='5' cellspacing='0' styles='formTable'>" +
  1492. "<tr>" +
  1493. " <td styles='formTableTitle'><span lable='TCustomerName'></span><span style='color:#f00'>*</span></td>" +
  1494. " <td styles='formTableValue' item='TCustomerName'></td>" +
  1495. "</tr><tr>" +
  1496. " <td styles='formTableTitle' lable='TCustomerType'></td>" +
  1497. " <td styles='formTableValue'><div id='TCustomerType'></div></td>" +
  1498. "</tr><tr>" +
  1499. " <td styles='formTableTitle' lable='TCustomerLevel'></td>" +
  1500. " <td styles='formTableValue'><div id='TCustomerLevel'></div></td>" +
  1501. "</tr><tr>" +
  1502. " <td styles='formTableTitle' lable='TSource'></td>" +
  1503. " <td styles='formTableValue'><div id='TSource'></div></td>" +
  1504. "</tr><tr>" +
  1505. " <td styles='formTableTitle' lable='TIndustryFirst'></td>" +
  1506. " <td styles='formTableValue'><div id='TIndustryFirst'></div><div id='TIndustrySecond'></div></td>" +
  1507. "</tr><tr>" +
  1508. " <td styles='formTableTitle' lable='TDistrict'></td>" +
  1509. " <td styles='formTableValue'><div id='TProvince'></div><div id='TCity'></div><div id='TArea'></div></td>" +
  1510. "</tr><tr>" +
  1511. " <td styles='formTableTitle' lable='TStreet'></td>" +
  1512. " <td styles='formTableValue' item='TStreet'></td>" +
  1513. "</tr><tr>" +
  1514. " <td styles='formTableTitle' lable='TLocation'></td>" +
  1515. " <td styles='formTableValue'><div style='width:100%;height:30px;'><input type='text' placeholder='"+this.lp.TLocationNotice+"' id='mapLocation' disabled/></div></td>" +
  1516. "</tr><tr>" +
  1517. " <td styles='formTableTitle'></td>" +
  1518. " <td styles='formTableValue'><div id='mapDiv' styles='mapDiv'></div></td>" +
  1519. "</tr><tr>" +
  1520. " <td styles='formTableTitle' lable='TTelphone'></td>" +
  1521. " <td styles='formTableValue' item='TTelphone'></td>" +
  1522. "</tr><tr>" +
  1523. " <td styles='formTableTitle' lable='TFax'></td>" +
  1524. " <td styles='formTableValue' item='TFax'></td>" +
  1525. "</tr><tr>" +
  1526. " <td styles='formTableTitle' lable='TRemark'></td>" +
  1527. " <td styles='formTableValue' item='TRemark'></td>" +
  1528. "</tr><tr>" +
  1529. " <td styles='formTableTitle' lable='TWebSite'></td>" +
  1530. " <td styles='formTableValue' item='TWebSite'></td>" +
  1531. "</tr><tr>" +
  1532. " <td styles='formTableTitle' lable='TEmail'></td>" +
  1533. " <td styles='formTableValue' item='TEmail'></td>" +
  1534. "</tr><tr>" +
  1535. " <td styles='formTableTitle' lable='TCustomerStatus'></td>" +
  1536. " <td styles='formTableValue'><div id='TCustomerStatus'></div></td>" +
  1537. "</tr><tr>" +
  1538. " <td styles='formTableTitle' lable='TCustomerGrade'></td>" +
  1539. " <td styles='formTableValue'><div id='TCustomerGrade'></div></td>" +
  1540. "</tr>" +
  1541. "</table>"
  1542. this.formTableArea.set("html", html);
  1543. this.TCustomerType = this.formTableArea.getElement("#TCustomerType");
  1544. this.TCustomerLevel = this.formTableArea.getElement("#TCustomerLevel");
  1545. this.TSource = this.formTableArea.getElement("#TSource");
  1546. this.TIndustryFirst = this.formTableArea.getElement("#TIndustryFirst");
  1547. this.TIndustrySecond = this.formTableArea.getElement("#TIndustrySecond");
  1548. this.TProvince = this.formTableArea.getElement("#TProvince");
  1549. this.TCity = this.formTableArea.getElement("#TCity");
  1550. this.TArea = this.formTableArea.getElement("#TArea");
  1551. this.TCustomerStatus = this.formTableArea.getElement("#TCustomerStatus");
  1552. this.TCustomerGrade = this.formTableArea.getElement("#TCustomerGrade");
  1553. var size = {"width":230,"height":30};
  1554. this.TIndustryFirst.setStyles({"float":"left"});
  1555. this.TIndustrySecond.setStyles({"float":"left","margin-left":"10px"});
  1556. //客户类型
  1557. this.TCustomerTypeSelector = new MWF.xApplication.CRM.Template.Select(this.TCustomerType,this, this.actions, size);
  1558. this.TCustomerTypeSelector.load();
  1559. alert(JSON.stringify(this.profileData.customertype_config))
  1560. this.TCustomerTypeSelector.setList(this.profileData.customertype_config);
  1561. if(this.customerData && this.customerData.customertype){
  1562. this.TCustomerTypeSelector.selectValueDiv.set({"text":this.customerData.customertype});
  1563. this.TCustomerTypeSelector.node.set("value",this.customerData.customertype);
  1564. }
  1565. //客户级别
  1566. this.TCustomerLevelSelector = new MWF.xApplication.CRM.Template.Select(this.TCustomerLevel,this, this.actions, size);
  1567. this.TCustomerLevelSelector.load();
  1568. this.TCustomerLevelSelector.setList(this.profileData.level_config);
  1569. if(this.customerData && this.customerData.level){
  1570. this.TCustomerLevelSelector.selectValueDiv.set({"text":this.customerData.level});
  1571. this.TCustomerLevelSelector.node.set("value",this.customerData.level);
  1572. }
  1573. //来源
  1574. this.TSourceSelector = new MWF.xApplication.CRM.Template.Select(this.TSource,this, this.actions, size);
  1575. this.TSourceSelector.load();
  1576. this.TSourceSelector.setList(this.profileData.source_config);
  1577. if(this.customerData && this.customerData.source){
  1578. this.TSourceSelector.selectValueDiv.set({"text":this.customerData.source});
  1579. this.TSourceSelector.node.set("value",this.customerData.source);
  1580. }
  1581. //行业
  1582. this.TIndustryFirstSelector = new MWF.xApplication.CRM.Template.Select(this.TIndustryFirst,this, this.actions, {"width":230,"height":30});
  1583. this.TIndustrySecondSelector = new MWF.xApplication.CRM.Template.Select(this.TIndustrySecond,this, this.actions, {"width":230,"height":30,"available":"no"});
  1584. this.TIndustrySecondSelector.load();
  1585. this.TIndustryFirstSelector.load();
  1586. if(this.customerData && this.customerData.industryfirst){
  1587. this.TIndustryFirstSelector.selectValueDiv.set({"text":this.customerData.industryfirst});
  1588. this.TIndustryFirstSelector.node.set("value",this.customerData.industryfirst);
  1589. this.profileData.industry_config.childNodes.each(function(d){
  1590. if(d.configname == this.customerData.industryfirst){
  1591. tmpData = d;
  1592. }
  1593. }.bind(this));
  1594. this.TIndustrySecondSelector.setList(tmpData);
  1595. this.TIndustrySecond.set("available","yes");
  1596. this.TIndustrySecond.setStyles({"background-color":""});
  1597. }
  1598. if(this.customerData && this.customerData.industrysecond){
  1599. this.TIndustrySecondSelector.selectValueDiv.set({"text":this.customerData.industrysecond});
  1600. this.TIndustrySecondSelector.node.set("value",this.customerData.industrysecond);
  1601. this.profileData.industry_config.childNodes.each(function(d){
  1602. if(d.configname == this.customerData.industryfirst){
  1603. tmpData = d;
  1604. }
  1605. }.bind(this));
  1606. this.TIndustrySecondSelector.setList(tmpData);
  1607. this.TIndustrySecond.set("available","yes");
  1608. this.TIndustrySecond.setStyles({"background-color":""});
  1609. }
  1610. this.TIndustryFirstSelector.setList(this.profileData.industry_config,function(d){
  1611. if(this.TIndustryFirst.get("value") == this.lp.defaultSelect){
  1612. this.TIndustrySecondSelector.createDefault();
  1613. this.TIndustrySecondSelector.setList();
  1614. this.TIndustrySecond.set("available","no");
  1615. this.TIndustrySecond.setStyles({"background-color":"#eeeeee"})
  1616. }else{
  1617. this.TIndustrySecondSelector.createDefault();
  1618. this.TIndustrySecondSelector.setList(d);
  1619. this.TIndustrySecond.set("available","yes");
  1620. this.TIndustrySecond.setStyles({"background-color":""});
  1621. }
  1622. }.bind(this));
  1623. //省、市、区
  1624. this.TProvinceSelector = new MWF.xApplication.CRM.Template.Select(this.TProvince,this, this.actions, {"width":150,"height":30});
  1625. this.TProvinceSelector.load({},function(){
  1626. this.actions.getProvinceList(function(json){
  1627. this.TProvinceSelector.setAddress(json.data,function(d){
  1628. //city
  1629. if(this.TProvince.get("value") == this.lp.defaultSelect){
  1630. this.TCitySelector.createDefault();
  1631. this.TCitySelector.setAddress();
  1632. this.TCity.set("available","no");
  1633. this.TCity.setStyles({"background-color":"#eeeeee"});
  1634. }else{
  1635. this.actions.getCityList({pid: d.cityid},function(json){
  1636. this.TCitySelector.createDefault();
  1637. this.TCitySelector.setAddress(json.data,function(dd){
  1638. //area
  1639. if(this.TCity.get("value") == this.lp.defaultSelect){
  1640. this.TAreaSelector.createDefault();
  1641. this.TAreaSelector.setAddress();
  1642. this.TArea.set("available","no");
  1643. this.TArea.setStyles({"background-color":"#eeeeee"});
  1644. }else{
  1645. this.actions.getAreaList({pid:dd.cityid},function(json){
  1646. this.TAreaSelector.createDefault();
  1647. this.TAreaSelector.setAddress(json.data);
  1648. this.TArea.set("available","yes");
  1649. this.TArea.setStyles({"background-color":""});
  1650. }.bind(this));
  1651. }
  1652. }.bind(this));
  1653. this.TCity.set("available","yes");
  1654. this.TCity.setStyles({"background-color":""});
  1655. }.bind(this));
  1656. }
  1657. this.TAreaSelector.createDefault();
  1658. this.TAreaSelector.setAddress();
  1659. this.TArea.set("available","no");
  1660. this.TArea.setStyles({"background-color":"#eeeeee"});
  1661. }.bind(this))
  1662. }.bind(this))
  1663. }.bind(this));
  1664. this.TCitySelector = new MWF.xApplication.CRM.Template.Select(this.TCity,this, this.actions, {"width":150,"height":30,"available":"no"});
  1665. this.TCitySelector.load();
  1666. this.TAreaSelector = new MWF.xApplication.CRM.Template.Select(this.TArea,this, this.actions, {"width":150,"height":30,"available":"no"});
  1667. this.TAreaSelector.load();
  1668. if(this.customerData && this.customerData.province){ //省
  1669. this.TProvinceSelector.selectValueDiv.set({"text":this.customerData.province});
  1670. this.TProvinceSelector.node.set("value",this.customerData.province);
  1671. }
  1672. if(this.customerData && this.customerData.city){ //市
  1673. if(this.customerData && this.customerData.province){
  1674. this.actions.getCityListByName({"regionname":this.customerData.province},
  1675. function(json){
  1676. this.TCitySelector.setAddress(json.data,function(dd){
  1677. //area
  1678. if(this.TCity.get("value") == this.lp.defaultSelect){
  1679. this.TAreaSelector.createDefault();
  1680. this.TAreaSelector.setAddress();
  1681. this.TArea.set("available","no");
  1682. this.TArea.setStyles({"background-color":"#eeeeee"});
  1683. }else{
  1684. this.actions.getAreaList({pid:dd.cityid},function(json){
  1685. this.TAreaSelector.createDefault();
  1686. this.TAreaSelector.setAddress(json.data);
  1687. this.TArea.set("available","yes");
  1688. this.TArea.setStyles({"background-color":""});
  1689. }.bind(this));
  1690. }
  1691. }.bind(this));
  1692. }.bind(this));
  1693. }
  1694. this.TCitySelector.selectValueDiv.set({"text":this.customerData.city});
  1695. this.TCitySelector.node.set("value",this.customerData.city);
  1696. this.TCity.set("available","yes");
  1697. this.TCity.setStyles({"background-color":""});
  1698. }
  1699. if(this.customerData && this.customerData.county){ //区
  1700. if(this.customerData && this.customerData.city){
  1701. this.actions.getAreaListByName({"regionname":this.customerData.city},
  1702. function(json){
  1703. this.TAreaSelector.setAddress(json.data);
  1704. }.bind(this));
  1705. }
  1706. this.TAreaSelector.selectValueDiv.set({"text":this.customerData.county});
  1707. this.TAreaSelector.node.set("value",this.customerData.county);
  1708. this.TArea.set("available","yes");
  1709. this.TArea.setStyles({"background-color":""});
  1710. }
  1711. this.TProvince.setStyles({"float":"left"});
  1712. this.TCity.setStyles({"float":"left","margin-left":"10px"});
  1713. this.TArea.setStyles({"float":"left","margin-left":"10px"});
  1714. this.TCustomerStatusSelector = new MWF.xApplication.CRM.Template.Select(this.TCustomerStatus,this, this.actions, size);
  1715. this.TCustomerStatusSelector.load();
  1716. this.TCustomerStatusSelector.setList(this.profileData.state_config);
  1717. if(this.customerData && this.customerData.state){
  1718. this.TCustomerStatusSelector.selectValueDiv.set({"text":this.customerData.state});
  1719. this.TCustomerStatusSelector.node.set("value",this.customerData.state);
  1720. }
  1721. this.TCustomerGradeSelector = new MWF.xApplication.CRM.Template.Select(this.TCustomerGrade,this, this.actions, size);
  1722. this.TCustomerGradeSelector.load();
  1723. this.TCustomerGradeSelector.setList(this.profileData.customerrank_config);
  1724. this.TMap = this.formTableArea.getElement("#mapDiv");
  1725. this.TMap.addEvents({
  1726. "mousewheel":function(e){
  1727. e.stopPropagation();
  1728. }
  1729. });
  1730. this.mapLocation = this.formTableArea.getElement("#mapLocation");
  1731. this.mapLocation.setStyles({
  1732. "width": "99%",
  1733. "text-indent":"5px",
  1734. "border":"1px solid #999",
  1735. "background-color":"#eee",
  1736. "border-radius": "3px",
  1737. "box-shadow": "0px 0px 6px #eee",
  1738. "height": "26px"
  1739. });
  1740. MWF.xDesktop.requireApp("CRM", "BaiduMap", function(){
  1741. this.bMap = new MWF.xApplication.CRM.BaiduMap(this.TMap,this.app,this,this.actions,{"from":"newCustomer"});
  1742. var mapData = {};
  1743. if(this.customerData && this.customerData.addresslatitude){
  1744. mapData.latitude = this.customerData.addresslatitude
  1745. }
  1746. if(this.customerData && this.customerData.addresslongitude){
  1747. mapData.longitude = this.customerData.addresslongitude
  1748. }
  1749. this.bMap.load(mapData);
  1750. }.bind(this));
  1751. */
  1752. },
  1753. ok: function (e) {
  1754. this.fireEvent("queryOk");
  1755. var data = this.form.getResult(true, ",", true, false, true);
  1756. debugger;
  1757. if (data) {
  1758. this._ok(data, function (json) {
  1759. if (json.type == "error") {
  1760. if( this.app )this.app.notice(json.message, "error");
  1761. } else {
  1762. if( this.formMaskNode )this.formMaskNode.destroy();
  1763. this.formAreaNode.destroy();
  1764. if (this.explorer && this.explorer.view)this.explorer.view.reload();
  1765. if( this.app )this.app.notice(this.isNew ? this.lp.createSuccess : this.lp.updateSuccess, "success");
  1766. this.fireEvent("postOk");
  1767. }
  1768. }.bind(this))
  1769. }
  1770. },
  1771. loadForm: function(){
  1772. _self = this;
  1773. this.form = new MForm(this.formTableArea, this.data, {
  1774. style: "default",
  1775. isEdited: this.isEdited || this.isNew,
  1776. itemTemplate: this.lp
  1777. },this.app,this.css);
  1778. var html = "<table width='100%' bordr='0' cellpadding='5' cellspacing='0' styles='formTable'>";
  1779. var itemTemplateObject = this.form.itemTemplate;
  1780. debugger
  1781. for ( i in itemTemplateObject){
  1782. html = html+"<tr>" +
  1783. " <td styles='formTableTitle'><span lable='"+i+"'>"+itemTemplateObject[i].text+"</td>" +
  1784. " <td styles='formTableValue' item='"+i+"'></td>" +
  1785. "</tr>";
  1786. }
  1787. html = html+"</table>";
  1788. debugger
  1789. this.formTableArea.set("html", html);
  1790. this.form.load();
  1791. if(!this.isNew){
  1792. this.actions.getCustomerInfo(this.options.openId, function (json) {
  1793. debugger
  1794. var jsonObj = json.data;
  1795. var spanObject = this.formTableArea.getElements("span");
  1796. for ( j in spanObject){
  1797. if(j < spanObject.length){
  1798. debugger
  1799. if(spanObject[j].get("name")!=null){
  1800. var fieldName = spanObject[j].get("name");
  1801. for (var prop in jsonObj){
  1802. if(prop == fieldName){
  1803. spanObject[j].set("text",jsonObj[prop]);
  1804. }
  1805. }
  1806. }
  1807. }
  1808. }
  1809. }.bind(this));
  1810. }
  1811. //this.nexttime = this.formTableArea.getElement("#nexttime");
  1812. //this.nexttime.addEvent("click",function(){
  1813. //_self.selectCalendar(this);
  1814. //});
  1815. this.formTableArea.getElements("textarea").setStyles({"height":"100px","overflow":"auto","color":"#666666"});
  1816. this.formTableArea.getElements("input").setStyles({"color":"#666666"});
  1817. },
  1818. loadMap: function(){
  1819. debugger
  1820. _self = this;
  1821. _self.mapDiv = jQuery("#setMap")[0];
  1822. jQuery(".section-conent").css("height","700px");
  1823. if(_self.mapDiv)_self.mapDiv.empty();
  1824. if(_self.addressModule) delete _self.addressModule;
  1825. MWF.xDesktop.requireApp("CRM", "AddressExplorer", function(){
  1826. _self.addressModule = new MWF.xApplication.CRM.AddressExplorer(_self.mapDiv,_self,_self.actions,{});
  1827. _self.addressModule.load();
  1828. }.bind(_self))
  1829. },
  1830. getItemTemplate: function( lp ){
  1831. _self = this;
  1832. return {
  1833. customername: {
  1834. text: lp.customername,
  1835. type: "text",
  1836. //attr : {placeholder:lp.name},
  1837. notEmpty:true,
  1838. value:this.customerData && this.customerData.customername?this.customerData.customername:""
  1839. },
  1840. level:{
  1841. type: "select",
  1842. text: lp.level,
  1843. notEmpty:true,
  1844. value:this.app.lp.customer.level.value
  1845. },
  1846. industry: {
  1847. type: "select",
  1848. notEmpty:true,
  1849. text: lp.industry,
  1850. value:this.app.lp.customer.industry.value
  1851. },
  1852. source: {
  1853. type: "select",
  1854. text: lp.source,
  1855. notEmpty:true,
  1856. value:this.app.lp.customer.source.value
  1857. },
  1858. /*dealstatus:{
  1859. type: "hide",
  1860. text: lp.dealstatus,
  1861. value:this.app.lp.customer.dealstatus.value
  1862. },*/
  1863. telephone:{
  1864. type: "text",
  1865. notEmpty:true,
  1866. text: lp.telephone,
  1867. value:this.app.lp.clue.level.value
  1868. },
  1869. website: {
  1870. text:lp.website,
  1871. type: "text"
  1872. },
  1873. nexttime: {
  1874. text:lp.nexttime,
  1875. notEmpty:true,
  1876. attr : {id:"nexttime"},
  1877. type: "datetime"
  1878. },
  1879. cellphone: {
  1880. text:lp.cellphone,
  1881. type: "text"
  1882. },
  1883. detailaddress: {
  1884. text:lp.detailaddress,
  1885. type: "text"
  1886. },
  1887. remark: {
  1888. text:lp.remark,
  1889. type: "textarea"
  1890. },
  1891. location: {
  1892. text:lp.location,
  1893. type: "map"
  1894. }
  1895. }
  1896. },
  1897. getContactTemplate: function( lp ){
  1898. _self = this;
  1899. return {
  1900. contactsname: {
  1901. text: lp.contactsname,
  1902. type: "text",
  1903. notEmpty:true
  1904. },
  1905. customername: {
  1906. text: lp.customername,
  1907. type: "openSelect",
  1908. notEmpty:true
  1909. },
  1910. telephone:{
  1911. type: "text",
  1912. text: lp.telephone,
  1913. },
  1914. cellphone: {
  1915. text:lp.cellphone,
  1916. type: "text"
  1917. },
  1918. email:{
  1919. type: "text",
  1920. text: lp.email
  1921. },
  1922. decision: {
  1923. type: "select",
  1924. text: lp.decision,
  1925. value:this.app.lp.contact.decision.value
  1926. },
  1927. post: {
  1928. text:lp.post,
  1929. type: "text"
  1930. },
  1931. sex: {
  1932. type: "select",
  1933. text: lp.sex,
  1934. value:this.app.lp.contact.sex.value
  1935. },
  1936. detailaddress: {
  1937. text:lp.detailaddress,
  1938. type: "text"
  1939. },
  1940. nexttime: {
  1941. text:lp.nexttime,
  1942. attr : {id:"nexttime"},
  1943. type: "datetime"
  1944. },
  1945. remark: {
  1946. text:lp.remark,
  1947. type: "textarea"
  1948. }
  1949. }
  1950. },
  1951. selectPerson: function (showContainer,nameId,fullNameId,count) {
  1952. var options = {
  1953. "type" : "",
  1954. "types": ["person"],
  1955. "values": this.configData,
  1956. "count": count,
  1957. "zIndex": 50000,
  1958. "onComplete": function(items){
  1959. MWF.require("MWF.widget.O2Identity", function(){
  1960. var invitePersonList = [];
  1961. var fullPersonList = [];
  1962. this.configData = [];
  1963. this.process = null;
  1964. items.each(function(item){
  1965. var _self = this;
  1966. if( item.data.distinguishedName.split("@").getLast().toLowerCase() == "i" ){
  1967. var person = new MWF.widget.O2Identity(item.data, it.form.getItem("invitePersonList").container, {"style": "room"});
  1968. invitePersonList.push( item.data.distinguishedName );
  1969. }else{
  1970. //var person = new MWF.widget.O2Person(item.data, it.form.getItem("invitePersonList").container, {"style": "room"});
  1971. invitePersonList.push(item.data.name);
  1972. fullPersonList.push(item.data.distinguishedName);
  1973. var personJson = {
  1974. "name": item.data.name,
  1975. "distinguishedName": item.data.distinguishedName,
  1976. "employee":item.data.employee
  1977. }
  1978. debugger
  1979. this.configData.push(personJson);
  1980. }
  1981. }.bind(this));
  1982. if(items.length==0){
  1983. document.getElementById(nameId).innerHTML = "+点击选择"
  1984. }else{
  1985. document.getElementById(nameId).innerHTML = invitePersonList.join(",");
  1986. if(fullNameId!=""){
  1987. document.getElementById(fullNameId).innerHTML = fullPersonList.join(",");
  1988. }
  1989. }
  1990. }.bind(this));
  1991. }.bind(this)
  1992. };
  1993. var selector = new MWF.O2Selector(showContainer, options);
  1994. },
  1995. getFormateTime: function( timeStr ){
  1996. _self = this;
  1997. var date= new Date(timeStr);
  1998. return date.getFullYear()+'-'+_self.checkTime(date.getMonth()+1)+'-'+_self.checkTime(date.getDate())+ ' ' + _self.checkTime(date.getHours()) + ':' + _self.checkTime(date.getMinutes()) + ':' + _self.checkTime(date.getSeconds());
  1999. },
  2000. checkTime: function( i ){
  2001. if(i<10){
  2002. i = '0'+i
  2003. }
  2004. return i;
  2005. },
  2006. toDecimal: function(x){
  2007. if(x==""){
  2008. return "";
  2009. }else{
  2010. var f = parseFloat(x);
  2011. if (isNaN(f)) {
  2012. return x;
  2013. }
  2014. f = Math.round(x*100)/100;
  2015. return f;
  2016. }
  2017. },
  2018. /*selectCalendar : function( calendarNode ){
  2019. MWF.require("MWF.widget.Calendar", function(){
  2020. var calendar = new MWF.widget.Calendar( calendarNode, {
  2021. "style": "xform",
  2022. "isTime": false
  2023. "target": this.app.content
  2024. });
  2025. calendar.show();
  2026. }.bind(this));
  2027. },*/
  2028. createCustomBottom:function(){
  2029. this.okActionNode = new Element("div.formOkActionNode", {
  2030. "styles": this.css.formOkActionNode,
  2031. "text": this.lp.actionConfirm
  2032. }).inject(this.formBottomNode);
  2033. this.okActionNode.addEvent("click", function (e) {
  2034. this.ok(e);
  2035. }.bind(this));
  2036. },
  2037. _ok: function (data, callback) {
  2038. var saveDataStr = "";
  2039. for ( i in this.data){
  2040. saveDataStr = saveDataStr+"'"+i+"':'"+this.data[i]+"',";
  2041. }
  2042. debugger;
  2043. saveDataStr = "'{"+saveDataStr.replace(/'/g, '"')+"}'";
  2044. debugger;
  2045. //var saveData = JSON.parse(saveDataStr);
  2046. var saveData = eval('(' + saveDataStr.substring(1,saveDataStr.length - 1) + ')');
  2047. debugger;
  2048. //alert(JSON.stringify(saveData))
  2049. this.app.createShade();
  2050. this.actions.saveClue(saveData,function(json){
  2051. this.app.destroyShade();
  2052. this.app.notice(this.lp.saveSuccess,"success");
  2053. this.close();
  2054. this.fireEvent("reloadView",json);
  2055. }.bind(this),function(xhr,text,error){
  2056. this.app.showErrorMessage(xhr,text,error);
  2057. this.app.destroyShade();
  2058. }.bind(this));
  2059. }
  2060. });