ContactsOpen.js 95 KB

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