ChanceOpen.js 76 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569
  1. MWF.require("MWF.widget.O2Identity", null, false);
  2. MWF.xDesktop.requireApp("Selector", "package", null, false);
  3. MWF.xApplication.CRM.ChanceOpen = 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 = options.lp;
  24. this.path = "/x_component_CRM/$ChanceEdit/";
  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. //console.log("this is initialize all parm:",explorer, actions, data, options);
  32. },
  33. load: function () {
  34. that = this;
  35. this.loadResource(function(){
  36. this.createForm();
  37. this.loadEvent();
  38. }.bind(this))
  39. },
  40. loadResource: function ( callback ) {
  41. callback();
  42. /* var baseUrls = [
  43. "/x_component_CRM/$Template/assets/js/jquery.min.js",
  44. ];
  45. var fullcalendarUrl = "/x_component_CRM/$Template/assets/js/notifyme.js";
  46. var confirmUrl = "/x_component_CRM/$Template/assets/js/showBo.js";
  47. //var confirmUrl = "/x_component_CRM/$Main/laydate/laydate.js";
  48. COMMON.AjaxModule.loadCss("/x_component_CRM/$Template/assets/css/notifyme.css",function(){
  49. COMMON.AjaxModule.load(baseUrls, function(){
  50. jQuery.noConflict();
  51. COMMON.AjaxModule.load(fullcalendarUrl, function(){
  52. COMMON.AjaxModule.load(confirmUrl, function(){
  53. if(callback)callback();
  54. }.bind(this))
  55. }.bind(this));
  56. }.bind(this))
  57. }.bind(this));
  58. COMMON.AjaxModule.loadCss("/x_component_CRM/$Template/date/css/jquery-ui.css",function(){
  59. COMMON.AjaxModule.load(baseUrls, function(){
  60. jQuery.noConflict();
  61. COMMON.AjaxModule.load("/x_component_CRM/$Template/date/jquery-ym-datePlugin-0.1.js", function(){
  62. if(callback)callback();
  63. /!* COMMON.AjaxModule.load("/x_component_CRM/$Template/date/js/datepicker.all.js", function(){
  64. if(callback)callback();
  65. }.bind(this))*!/
  66. }.bind(this));
  67. }.bind(this))
  68. }.bind(this));*/
  69. },
  70. createForm:function(){
  71. var that = this;
  72. var openName = this.options.openName;
  73. /*this.createContentHtml(this.options.openId);*/
  74. var buttonHtml = '<div class = "headBottonDiv"><div class="headMoveBottonDiv">转移</div><div class="headEditBottonDiv">编辑</div>' +
  75. '<div class="headMoreBottonDiv"><span>更多</span><img class="headMoreImg" src="/x_component_CRM/$Clue/default/icons/arrow.png"></div></div>';
  76. var moreHtml = '<ul class="el-dropdown-menu"><li class="el-dropdown-menu__item">删除</li><div class="popper__arrow"></div></ul>';
  77. var sectionId = that.getNotifyMax();
  78. var sjson = this.options.openStyle?this.options.openStyle:this.xxx;
  79. jQuery(".headMoreImg").notifyMe(
  80. 'right',
  81. 'default',
  82. openName,
  83. buttonHtml,
  84. moreHtml,
  85. '',
  86. sectionId,
  87. 500,
  88. sjson
  89. );
  90. this.createContentHtml(sectionId);
  91. },
  92. getNotifyMax : function () {
  93. var sectionId = 'notify';
  94. var sectionNum = 0;
  95. if(!(this.options.openType) || (this.options.openType !="single")) {
  96. jQuery(".notify").each(function (index, element) {
  97. var notifyId = jQuery(element).attr("id");
  98. var notifyNum = 0;
  99. if (notifyId.indexOf("_") > 0) {
  100. notifyNum = parseInt(notifyId.split("_")[1]);
  101. if (notifyNum > sectionNum) {
  102. sectionNum = notifyNum;
  103. }
  104. } else {
  105. if (sectionNum == 0) {
  106. sectionNum = 1;
  107. }
  108. }
  109. });
  110. if (sectionNum > 0) {
  111. sectionId = sectionId + '_' + sectionNum;
  112. }
  113. }
  114. return sectionId;
  115. },
  116. createContentHtml: function (sectionId) {
  117. that = this;
  118. this.sectionArea = jQuery("body")[0].getElement("#"+sectionId);
  119. this.actions.getChanceInfo(this.options.openId, function (json) {
  120. //需要定制页面
  121. this.data = json.data;
  122. console.log("this is data :",this.data);
  123. var jsonObj = json.data;
  124. var owneruser = (jsonObj.owneruser=="" || (typeof(jsonObj.owneruser)=="undefined"))?"--":(jsonObj.owneruser).split("@")[0];
  125. var briefDiv = "<div class = 'briefdiv'>"+
  126. "<div class='div-inline'><div class='div-title'>客户名称</div><div class='div-value'>"+jsonObj.customer.customername+"</div></div>"+
  127. "<div class='div-inline'><div class='div-title'>商机金额(元)</div><div class='div-value'>"+jsonObj.money+"</div></div>"+
  128. "<div class='div-inline'><div class='div-title'>商机状态</div><div class='div-value'>"+jsonObj.opportunityStatus.opportunitystatusname+"</div></div>"+
  129. "<div class='div-inline'><div class='div-title'>负责人</div><div class='div-value'>"+owneruser+"</div></div>"+
  130. "<div class='div-inline'><div class='div-title'>更新时间\n</div><div class='div-value'>"+jsonObj.updateTime+"</div></div>"+
  131. "</div>"
  132. var tabPanel = "<div class='tabPanel'><div class='hit'>跟进记录</div><div style='width:30px'></div><div>基本信息</div><div style='width:30px'></div>"+
  133. "<div>联系人</div><div style='width:30px'></div><div>相关团队</div><div style='width:30px'></div>"+
  134. "<div>附件</div><div style='width:30px'></div><div>操作记录</div></div>"
  135. var tabConent ="<div class='panes'><div class='pane' id='tab-follow' style='display:block;'><p>First tab content</p></div><div></div>"+
  136. "<div class='pane' id='tab-basicinfo'><p>Secend tab content</p></div><div></div>"+
  137. "<div class='pane' id='tab-contacts'><p>contacts tab content</p></div><div></div>"+
  138. "<div class='pane' id='tab-team'><p>team tab content</p></div><div></div>"+
  139. "<div class='pane' id='tab-att'><p>Third tab content</p></div><div></div>"+
  140. "<div class='pane' id='tab-options'><p>Four tab content</p></div></div>"
  141. //jQuery(".notify-content").html( briefDiv+tabPanel+tabConent);
  142. this.sectionArea.getElement(".notify-content").set("html",briefDiv+tabPanel+tabConent);
  143. var size = this.sectionArea.getSize();
  144. this.sectionArea.getElement(".panes").setStyles({"height":(size.y-250)+"px"});
  145. var indexHtml = '<div ><div class="mix-container"><div class="i-cont"><div class="el-textarea el-input--suffix">'+
  146. '<textarea autocomplete="off" placeholder="请输入内容" class="el-textarea__inner" style="resize: none; min-height: 57px; height: 57px;"></textarea></div></div>'+
  147. '<div class="vux-flexbox bar-cont vux-flex-row">'+
  148. '<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>'+
  149. '<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>'+
  150. '</div>';
  151. var indexSendHtml = '<div class="vux-flexbox se-section vux-flex-row"><div class="se-name">记录类型</div>'+
  152. '<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>'+
  153. '<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>'+
  154. '<button type="button" class="el-button se-send el-button--primary"><span>发布</span></button></div>'+
  155. '<ul class="el-dropdown-type" style="display: none;" tid = "recordType"><li class="el-dropdown-menu__item">邮箱</li><li class="el-dropdown-menu__item">电话</li>'+
  156. '<li class="el-dropdown-menu__item">地址</li><li class="el-dropdown-menu__item">微信</li><div class="popper__arrow"></div></ul>';
  157. var indexContentHtml = '<div class="log-cont"><div class="log-inner1"><div class="log-inner2"><div class="log-items">'+
  158. '<div class="load"><button type="button" class="el-button el-button--text"><span>没有更多了</span></button></div></div>'+
  159. '<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>'+
  160. '<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>'+
  161. '</div></div>';
  162. //jQuery("#tab-follow").html(indexHtml+indexSendHtml+indexContentHtml);
  163. this.sectionArea.getElement("#tab-follow").set("html",indexHtml+indexSendHtml+indexContentHtml);
  164. that.loadTimeContainer('stime');
  165. that.loadRecord();
  166. }.bind(this));
  167. },
  168. createTypeHtml: function () {
  169. //var createType = jQuery(".hit").text();
  170. var createType = jQuery(this.sectionArea).find(".hit").text();
  171. if(createType == "基本信息") {
  172. this.getChanceInfo();
  173. }
  174. if(createType == "联系人") {
  175. this.loadContacts();
  176. }
  177. if(createType == "相关团队") {
  178. this.loadTeam();
  179. }
  180. if(createType == "附件") {
  181. this.loadAttachment();
  182. }
  183. if(createType == "操作记录") {
  184. this.loadOptions();
  185. }
  186. },
  187. loadTimeContainer: function(stime){
  188. jQuery("#"+stime).ymdateplugin({
  189. showTimePanel: true
  190. });
  191. },
  192. getChanceInfo: function () {
  193. _self = this;
  194. this.actions.getChanceInfo(this.options.openId, function (json) {
  195. //var jsonObj = json.data;
  196. _self.data = json.data;
  197. var section_header = '<div class="section-header"><div class="section-mark" style="border-left-color: rgb(70, 205, 207);"></div> '+
  198. '<div data-v-ec8f8850="" class="section-title">基本信息</div></div>'
  199. var itemTemplateObject = _self.getItemTemplate(_self.lp.chanceEdit);
  200. var section_conent = '<div class="section-conent">';
  201. debugger
  202. for ( i in itemTemplateObject){
  203. debugger
  204. section_conent = section_conent+'<div class="conent-inline"><div class="conent-title">'+itemTemplateObject[i].text+'</div>' +
  205. '<div class="conent-value">'+((typeof(itemTemplateObject[i].value)=="undefined")?"" :itemTemplateObject[i].value)+'</div></div>';
  206. }
  207. section_conent = section_conent + '</div>';
  208. //jQuery("#tab-basicinfo").html(section_header+section_conent);
  209. jQuery(_self.sectionArea).find("#tab-basicinfo").html(section_header+section_conent);
  210. //this.contentHtml = briefDiv+tabPanel+tabConent;
  211. }.bind(this));
  212. },
  213. loadAttachment: function() {
  214. that = this;
  215. var attHtml = '<div class="rc-cont">';
  216. 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>';
  217. 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">'+
  218. '<div class="el-table__header-wrapper"><table class="el-table__header" style="width: 866px;height:40px;" cellspacing="0" cellpadding="0" border="0"><thead class="has-gutter">'+
  219. '<tr class=""><th colspan="1" rowspan="1" class="el-table_3_column_27 is-leaf" style="width: 40%;"><div class="cell">附件名称</div></th>'+
  220. '<th colspan="1" rowspan="1" class="el-table_3_column_28 is-leaf" style="width: 10%;"><div class="cell">附件大小</div></th>'+
  221. '<th colspan="1" rowspan="1" class="el-table_3_column_29 is-leaf" style="width: 20%;"><div class="cell">上传人</div></th>'+
  222. '<th colspan="1" rowspan="1" class="el-table_3_column_30 is-leaf" style="width: 20%;"><div class="cell">上传时间</div></th>'+
  223. '<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>';
  224. var attBody = '<div class="el-table__body-wrapper is-scrolling-none" style="height: 450px;">'+
  225. '<table class="el-table__body" style="width: 866px;" cellspacing="0" cellpadding="0" border="0"><tbody></tbody></table>'+
  226. '<div class="el-table__empty-block" style="width: 866px;"><span class="el-table__empty-text">暂无数据</span></div></div></div>';
  227. attHtml = attHtml+attButton+attHeader+attBody+'</div>';
  228. jQuery(that.sectionArea).find("#tab-att").html(attHtml);
  229. jQuery(that.sectionArea).find('#afile').change(function(event) {
  230. var objFile = jQuery(that.sectionArea).find('#afile')[0].files;
  231. jQuery(objFile).each(function(index,file){
  232. var filter = {};
  233. filter = {
  234. file:file,
  235. fileName:file.name
  236. };
  237. debugger
  238. var formdata=new FormData();
  239. formdata.append("fileName",file.name);
  240. formdata.append("file",file);
  241. that.actions.updateAttachment("att",that.options.openId, "chance", formdata,file, function (json) {//
  242. if(json.type=="success"){
  243. //Showbo.Msg.alert('附件上传成功!');
  244. that.getAttachment();
  245. }
  246. }.bind(that));
  247. }
  248. );
  249. });
  250. that.getAttachment();
  251. },
  252. getAttachment: function(){
  253. that = this;
  254. this.actions.getAttachment(this.options.openId, function (json) {
  255. debugger
  256. if(json.type=="success"){
  257. var attDatas = json.data;
  258. var tbodyHtml = "";
  259. for ( i in attDatas){
  260. if(i<attDatas.length){
  261. var attData = attDatas[i];
  262. var fsize = attData.length/1024;
  263. var lastUpdatePerson = attData.lastUpdatePerson;
  264. lastUpdatePerson = lastUpdatePerson.split("@")[0];
  265. tbodyHtml = tbodyHtml+'<tr><td style="width: 40%;" class="aname" aid="'+attData.id+'" wcrm="'+attData.wcrm+'">'+attData.name+'</td><td style="width: 10%;">'+that.toDecimal(fsize)+'kb</td>'+
  266. '<td style="width: 20%;">'+lastUpdatePerson+'</td><td style="width: 20%;">'+attData.updateTime+'</td><td class="attOption">删除</td></tr>';
  267. }
  268. }
  269. if(tbodyHtml!=""){
  270. jQuery(that.sectionArea).find(".el-table__body").children().html(tbodyHtml);
  271. jQuery(that.sectionArea).find(".el-table__empty-block").hide();
  272. jQuery(that.sectionArea).find(".attOption").click(function(){
  273. self = this;
  274. Showbo.Msg.confirm('提示','确定删除该附件吗?',function(){
  275. var aid = jQuery(self).parent().children(":first").attr("aid");
  276. if(aid && aid !=""){
  277. that.actions.delAttachment(aid, function (ajson) {
  278. if(ajson.type=="success"){
  279. that.getAttachment();
  280. }
  281. }.bind(self));
  282. }
  283. },function(){
  284. });
  285. });
  286. jQuery(that.sectionArea).find(".aname").click(function(){
  287. var attUrl = 'http://172.16.92.55:20020/x_wcrm_assemble_control/jaxrs/attachment/download/'+jQuery(this).attr("aid")+'/work/'+jQuery(this).attr("wcrm")
  288. window.open(attUrl);
  289. /*that.actions.downloadAttachment(jQuery(this).attr("aid"),jQuery(this).attr("wcrm"), function (wjson) {
  290. }.bind(that));*/
  291. });
  292. }
  293. }
  294. }.bind(that));
  295. },
  296. loadContacts: function() {
  297. that = this;
  298. var attHtml = '<div class="rc-cont">';
  299. var attButton = '<div class="vux-flexbox rc-head vux-flex-row" style="flex-direction: row-reverse;">'+
  300. '<div class="rc-head-item" style="width: 75px;"><span>新建联系人</span></div>'+
  301. '<div class="rc-head-item" style="width: 75px;"><span>解除关联</span></div>'+
  302. '<div class="rc-head-item" style="width: 75px;"><span>关联</span></div></div>';
  303. 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">'+
  304. '<div class="el-table__header-wrapper"><table class="el-table__header" style="width: 100%;height:40px;" cellspacing="0" cellpadding="0" border="0"><thead class="has-gutter">'+
  305. '<tr class="">' +
  306. '<th colspan="1" rowspan="1" class="el-table_3_column_27"><div class="cell">'+
  307. '<input class="inp-cbx" id="allContacts" type="checkbox" style="display: none;"/><label class="cbx cbxx" for="allContacts"><span><svg width="12px" height="10px"><use xlink:href="#checkContact"></use></svg></span><span></span></label></div></th>'+
  308. '<th colspan="1" rowspan="1" class="el-table_3_column_27 is-leaf" style="width: 30%;"><div class="cell">姓名</div></th>'+
  309. '<th colspan="1" rowspan="1" class="el-table_3_column_29 is-leaf" style="width: 30%;"><div class="cell">手机</div></th>'+
  310. '<th colspan="1" rowspan="1" class="el-table_3_column_26 is-leaf" style="width: 30%;"><div class="cell">职务</div></th></tr></thead></table></div>'+
  311. '<svg class="inline-svg"><symbol id="checkContact" viewbox="0 0 12 10"><polyline points="1.5 6 4.5 9 10.5 1" ></polyline></symbol></svg>';
  312. var attBody = '<div class="el-table__body-wrapper is-scrolling-none" style="height: 450px;">'+
  313. '<table class="el-table__body_contact" style="width: 100%;" cellspacing="0" cellpadding="0" border="0"><tbody></tbody></table>'+
  314. '<div class="el-table__empty-block_contact" style="width: 100%;"><span class="el-table__empty-text">暂无数据</span></div></div></div>';
  315. attHtml = attHtml+attButton+attHeader+attBody+'</div>';
  316. jQuery(that.sectionArea).find("#tab-contacts").html(attHtml);
  317. this.actions.getContactsByChanceId(this.options.openId, function (json) {
  318. if(json.type=="success"){
  319. var attDatas = json.data;
  320. var tbodyHtml = "";
  321. for ( i in attDatas){
  322. if(i<attDatas.length){
  323. var attData = attDatas[i];
  324. var id = 'allContacts'+i;
  325. var cdiv = '<div class="cell">'+
  326. '<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="#checkContact"></use></svg></span><span></span></label></div>'
  327. tbodyHtml = tbodyHtml+'<tr><td style="width: 10%;">'+cdiv+'</td><td style="width: 30%;" class="aname" aid="'+attData.id+'">'+attData.contactsname+'</td>'+
  328. '<td style="width: 30%;">'+attData.cellphone+'</td><td style="width: 30%;">'+attData.post+'</td></tr>';
  329. }
  330. }
  331. if(tbodyHtml!=""){
  332. jQuery(that.sectionArea).find(".el-table__body_contact").children().html(tbodyHtml);
  333. jQuery(that.sectionArea).find(".el-table__empty-block_contact").hide();
  334. }
  335. }
  336. }.bind(that));
  337. jQuery(that.sectionArea).find("[for='allContacts']").click(function(){
  338. //var cobj = jQuery("[for='all1']");
  339. var cobj = jQuery(that.sectionArea).find(".cbxx").not("[for='allContacts']");
  340. if (jQuery(this).prev().is(':checked')) {
  341. cobj.each(function(index,element){
  342. jQuery(element).prev().prop("checked", false);
  343. });
  344. } else {
  345. cobj.each(function(index,element){
  346. jQuery(element).prev().prop("checked", true);
  347. });
  348. }
  349. });
  350. jQuery(that.sectionArea).find("#tab-contacts").find(".rc-head-item").click(function(){
  351. if(jQuery(this).children().text()=="新建联系人"){
  352. that.contactsCreate();
  353. }
  354. if(jQuery(this).children().text()=="关联"){
  355. that.relateChanceAndContact();
  356. }
  357. if(jQuery(this).children().text()=="解除关联"){
  358. that.terminatedRelation();
  359. }
  360. });
  361. jQuery(that.sectionArea).find("#tab-contacts").find(".aname").click(function(){
  362. //that.contactsEdit(jQuery(this).attr("aid"));
  363. });
  364. },
  365. loadTeam: function() {
  366. that = this;
  367. var attHtml = '<div class="rc-cont">';
  368. 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>'+
  369. '<div class="rc-head-item" style="width: 75px;"><span>编辑</span></div><div class="rc-head-item" style="width: 95px;"><span>添加团队成员</span></div></div>';
  370. 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">'+
  371. '<div class="el-table__header-wrapper"><table class="el-table__header" style="width: 100%;height:40px;" cellspacing="0" cellpadding="0" border="0"><thead class="has-gutter">'+
  372. '<tr class=""><th colspan="1" rowspan="1" class="el-table_3_column_27"><div class="cell">'+
  373. '<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>'+
  374. '<th colspan="1" rowspan="1" class="el-table_3_column_27 is-leaf" style="width: 30%;"><div class="cell">姓名</div></th>'+
  375. '<th colspan="1" rowspan="1" class="el-table_3_column_29 is-leaf" style="width: 20%;"><div class="cell">职位</div></th>'+
  376. '<th colspan="1" rowspan="1" class="el-table_3_column_29 is-leaf" style="width: 20%;"><div class="cell">团队角色</div></th>'+
  377. '<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>'+
  378. '<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>';
  379. var attBody = '<div class="el-table__body-wrapper is-scrolling-none" style="height: 450px;">'+
  380. '<table class="el-table__body" style="width: 100%;" cellspacing="0" cellpadding="0" border="0"><tbody></tbody></table>'+
  381. '<div class="el-table__empty-block" style="width: 100%;"><span class="el-table__empty-text">暂无数据</span></div></div></div>';
  382. attHtml = attHtml+attButton+attHeader+attBody+'</div>';
  383. jQuery(that.sectionArea).find("#tab-team").html(attHtml);
  384. this.actions.getTeamMemberListByChanceId(this.options.openId, function (json) {
  385. if(json.type=="success"){
  386. var attDatas = json.data;
  387. var tbodyHtml = "";
  388. for ( i in attDatas){
  389. if(i<attDatas.length){
  390. var attData = attDatas[i];
  391. var unit = (attData.units.length>0)?((attData.units[0]).split("@")[0]):"";
  392. var id = 'all'+i;
  393. var cdiv = '<div class="cell">'+
  394. '<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>'
  395. if(attData.teamRole && attData.teamRole=="负责人"){
  396. cdiv = '<div class="cell">'+
  397. '<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>'
  398. }
  399. if(attData.teamRole && attData.teamRole!=""){
  400. tbodyHtml = tbodyHtml+'<tr><td style="width: 10%;">'+cdiv+'</td><td style="width: 30%;" class="aname" aid="'+attData.person.distinguishedName+'">'+attData.person.name+
  401. '</td><td style="width: 20%;">'+unit+'</td><td style="width: 20%;">'+attData.teamRole+'</td><td style="width: 20%;">'+attData.dispaly_permission+'</td></tr>';
  402. }
  403. }
  404. }
  405. if(tbodyHtml!=""){
  406. jQuery(that.sectionArea).find(".el-table__body").children().html(tbodyHtml);
  407. jQuery(that.sectionArea).find(".el-table__empty-block").hide();
  408. }
  409. }
  410. }.bind(that));
  411. jQuery("[for='all']").click(function(){
  412. //var cobj = jQuery("[for='all1']");
  413. var cobj = jQuery(that.sectionArea).find(".cbxx").not("[for='all']");
  414. if (jQuery(this).prev().is(':checked')) {
  415. cobj.each(function(index,element){
  416. jQuery(element).prev().prop("checked", false);
  417. });
  418. } else {
  419. cobj.each(function(index,element){
  420. jQuery(element).prev().prop("checked", true);
  421. });
  422. }
  423. });
  424. jQuery(that.sectionArea).find(".rc-head-item").click(function() {
  425. if(jQuery(this).children().text()=="添加团队成员"){
  426. that.addTeam();
  427. }
  428. if(jQuery(this).children().text()=="编辑"){
  429. var nameList = [];
  430. jQuery(".el-table__body").find("input:checked").each(function(index,element){
  431. var nobj = jQuery(element).parent().parent().next();
  432. nameList.push(jQuery(nobj).attr("aid"));
  433. });
  434. that.editTeam(nameList);
  435. }
  436. if(jQuery(this).children().text()=="移除"){
  437. that.deleteTeam();
  438. }
  439. });
  440. },
  441. loadOptions: function() {
  442. that = this;
  443. var optionsHtml = '<div class="rc-cont">'+
  444. '<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>'
  445. jQuery(that.sectionArea).find("#tab-options").html(optionsHtml);
  446. this.actions.getOptionsRecord(this.options.openId, function (json) {
  447. if(json.type=="success"){
  448. var recordDatas = json.data;
  449. jQuery(that.sectionArea).find(".rc-cont").find(".vux-flexbox").remove();
  450. var logItemHtml = "";
  451. debugger
  452. for ( i in recordDatas){
  453. if(i<recordDatas.length){
  454. var recordData = recordDatas[i];
  455. debugger
  456. var personImg = 'http://172.16.92.55/x_component_CRM/$Template/portrait.png';
  457. var updatetime = recordData.updateTime;
  458. logItemHtml = logItemHtml+'<div class="vux-flexbox ha-cont vux-flex-row" style="justify-content: flex-start; align-items: stretch;">'+
  459. '<div class="ha-week">'+recordData.DateCN+'</div>'+
  460. '<div class="ha-circle"></div> '+
  461. '<div class="ha-time">'+updatetime.substring(11,16)+'</div>'+
  462. '<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>' +
  463. '<div class="ha-name">'+recordData.person.name+'</div>'+
  464. '<div class="ha-content">'+recordData.content+'</div>'+
  465. '<div class="ha-line"></div></div>'
  466. }
  467. }
  468. if(logItemHtml!=""){
  469. jQuery(that.sectionArea).find(".rc-cont").append(logItemHtml);
  470. }
  471. if(recordDatas.length<1){
  472. jQuery(that.sectionArea).find(".empty-mask").show();
  473. }
  474. }
  475. }.bind(this));
  476. },
  477. transfer: function () {
  478. //转移负责人
  479. _self = this;
  480. var contentHtml = '<div class="vux-flexbox handle-item vux-flex-row" style="align-items: stretch;padding: 30px 20px 0px 20px;line-height:30px;">'+
  481. '<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>'+
  482. '<div class="vux-flexbox handle-item vux-flex-row" style="align-items: stretch;padding: 10px 20px 50px 20px;line-height:30px;">'+
  483. '<div class="handle-item-name" style="margin-top: 8px;width:130px;">将原负责人:</div><div role="radiogroup" class="el-radio-group">'+
  484. '<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>'+
  485. '<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>';
  486. Showbo.Msg.confirm('商机转移',contentHtml,function(){
  487. //_self.confirmCustomerDealstatus();
  488. var transferType = "";
  489. var readOrWrite = "";
  490. var checkFlag = true;
  491. var relationTypeList = [];
  492. jQuery(".ct").find(".is-checked").each(function(i,obj){
  493. var typeStr = jQuery(obj).children(".el-radio__label").text();
  494. if(typeStr=="移出"){
  495. transferType = "1"
  496. }
  497. if(typeStr=="转为团队成员"){
  498. transferType = "2"
  499. }
  500. })
  501. jQuery(".ct").find(".el-checkbox__original").each(function(i,obj){
  502. debugger
  503. if(jQuery(obj).is(':checked')){
  504. debugger
  505. relationTypeList.push(jQuery(obj).val());
  506. }
  507. })
  508. if(jQuery("#selectId").text() == ""){
  509. checkFlag = false;
  510. Showbo.Msg.alert('请选择负责人!');
  511. }
  512. if(transferType == ""){
  513. checkFlag = false;
  514. Showbo.Msg.alert('请选择将负责人移出或转为团队成员!');
  515. }
  516. if(checkFlag){
  517. var filter = {};
  518. filter = {
  519. distinguishName: jQuery('#selectId').text(),
  520. transferType: transferType,
  521. readOrWrite: readOrWrite,
  522. relationTypeList:relationTypeList
  523. }
  524. debugger
  525. _self.actions.chanceTransfer(_self.options.openId, filter, function (json) {
  526. if(json.type=="success"){
  527. Showbo.Msg.alert('操作成功!');
  528. }
  529. setTimeout(function(){
  530. jQuery("#notifyEdit").remove();
  531. if(jQuery(".mask").length>0){
  532. jQuery(".mask").attr("style",'left: 0px; top: 0px; width: 100%; overflow: hidden; position: absolute; z-index: 500000; background-color: rgb(255, 255, 255)');
  533. jQuery(".mask").attr("class","");
  534. }
  535. },200);
  536. }.bind(_self));
  537. }
  538. },function(){
  539. });
  540. jQuery(".ct").find(".se-select-name").click(function(){
  541. _self.selectPerson(jQuery("#appContent")[0],"selectName","selectId",0);
  542. });
  543. jQuery(".ct").find(".el-radio").click(function(){
  544. jQuery(this).siblings().attr("class","el-radio");
  545. jQuery(this).siblings().find("input:radio").attr("checked",false)
  546. jQuery(this).attr("class","el-radio is-checked");
  547. jQuery(this).find("input:radio").attr("checked",true);
  548. var typeName = jQuery(this).find(".el-radio__label").text();
  549. if(typeName == "转为团队成员"){
  550. jQuery(this).parent().parent().next().show();
  551. }
  552. if(typeName == "移出"){
  553. jQuery(this).parent().parent().next().hide();
  554. }
  555. });
  556. },
  557. chanceEdit: function () {
  558. //编辑商机---- 需要重构
  559. _self = this;
  560. this.actions.getChanceInfo(this.options.openId, function (json) {
  561. MWF.xDesktop.requireApp("CRM", "ChanceEdit", function(){
  562. console.log("this.lp",this.lp);
  563. var editForm = new MWF.xApplication.CRM.ChanceEdit(null,json.data,null, {
  564. app: this.app,
  565. container : this.app.content,
  566. lp : this.lp,
  567. actions : this.actions,
  568. css : {}
  569. });
  570. editForm.edit();
  571. }.bind(this))
  572. }.bind(this));
  573. },
  574. contactsCreate: function () {
  575. //编辑联系人
  576. _self = this;
  577. var htmlstr = "";
  578. jQuery("#appContent").next().attr("style","");
  579. jQuery("#appContent").next().attr("class","mask");
  580. var section_header = '<div class="section-header"><div class="section-mark" style="border-left-color: rgb(70, 205, 207);"></div> '+
  581. '<div data-v-ec8f8850="" class="section-title">基本信息</div></div>';
  582. var itemTemplateObject = _self.getContactTemplate(_self.app.lp.contact.contactEdit );
  583. var section_conent = '<div class="section-conent">';
  584. for ( i in itemTemplateObject){
  585. var stype = itemTemplateObject[i].type;
  586. var innerHtml = '<input type="text" class="inline-input" name="'+i+'" id="'+i+'" stype="'+stype+'">';
  587. if(stype=="textarea"){
  588. innerHtml = '<textarea rows="6" class="el-textarea__inner" id="'+i+'" stype="'+stype+'" style="resize: none; min-height: 30.6px;"></textarea>';
  589. }
  590. if(stype=="select"){
  591. 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>';
  592. }
  593. if(stype=="readonly"){
  594. innerHtml = '<input type="text" class="inline-input" disabled="disabled" style="background-color:#e2ebf9;" name="'+i+'" id="'+i+'" value="'+_self.data.customer.customername+'" cid="'+_self.data.customerid+'" stype="'+stype+'">';
  595. }
  596. section_conent = section_conent+'<div class="conent-inline"><div class="conent-title" lable="'+i+'">'+itemTemplateObject[i].text+'</div>' +
  597. '<div class="conent-value">'+innerHtml+'</div></div>';
  598. }
  599. section_conent = section_conent + '</div>';
  600. var section_button = '<div class="section_button"><div><button class="el-button handle-button el-button-cancle"><span>取消</span></button>'+
  601. '<button class="el-button handle-button el-button-primary"><span>保存</span></button></div></div>';
  602. htmlstr = section_header+section_conent+section_button;
  603. jQuery(".headMoreImg").notifyMe(
  604. 'left',
  605. 'default',
  606. _self.app.lp.contact.contactEdit.title,
  607. '',
  608. '',
  609. htmlstr,
  610. 'notifyEdit',
  611. 50
  612. );
  613. jQuery(".conent-value").each(function(index,element){
  614. var cobj = jQuery(element).children().eq(0)
  615. var stype = jQuery(cobj).attr("stype");
  616. if(stype=="datetime"){
  617. _self.loadTimeContainer(jQuery(cobj).attr("id"));
  618. }
  619. if(stype=="select"){
  620. var selectObjects = _self.app.lp.contact;
  621. for ( j in selectObjects){
  622. if(j==jQuery(cobj).attr("id")){
  623. var clp = itemTemplateObject[j];
  624. var valueList = clp.value;
  625. var valueArr = valueList.split(",");
  626. if(valueArr.length>0){
  627. var selectHtml = '<ul class="el-dropdown-type" style="display: none;" tid="'+jQuery(cobj).attr("id")+'">'
  628. for(var n=0;n<valueArr.length;n++){
  629. selectHtml = selectHtml+'<li class="el-dropdown-menu__item">'+valueArr[n]+'</li>'
  630. }
  631. jQuery(".notify-content").append(selectHtml+'<div class="popper__arrow"></div></ul>');
  632. jQuery(cobj).click(function(){
  633. jQuery("[tid='"+jQuery(cobj).attr("id")+"']").css({"left":jQuery(cobj).offset().left-50,"top":jQuery(cobj).offset().top+30,"width":282})
  634. jQuery("[tid='"+jQuery(cobj).attr("id")+"']").toggle(100);
  635. });
  636. jQuery("[tid='"+jQuery(cobj).attr("id")+"']").children().click(function(){
  637. debugger
  638. jQuery(cobj).text(jQuery(this).text());
  639. jQuery("[tid='"+jQuery(cobj).attr("id")+"']").toggle(100);
  640. });
  641. }
  642. }
  643. }
  644. }
  645. }
  646. );
  647. jQuery('.el-button-cancle').click(function(){
  648. setTimeout(function(){
  649. jQuery("#notifyEdit").remove();
  650. if(jQuery(".mask").length>0){
  651. jQuery(".mask").attr("style",'left: 0px; top: 0px; width: 100%; overflow: hidden; position: absolute; z-index: 500000; background-color: rgb(255, 255, 255)');
  652. jQuery(".mask").attr("class","");
  653. }
  654. },200);
  655. });
  656. jQuery('.el-button-primary').click(function(){
  657. var filter = {};
  658. filter = {
  659. contactsname:jQuery('div[lable="contactsname"]').next().children().eq(0).val(),
  660. customerid:jQuery('#customername').attr("cid"),
  661. telephone:jQuery('div[lable="telephone"]').next().children().eq(0).val(),
  662. cellphone:jQuery('div[lable="cellphone"]').next().children().eq(0).val(),
  663. email:jQuery('div[lable="email"]').next().children().eq(0).val(),
  664. decision:jQuery('div[lable="decision"]').next().children().eq(0).text(),
  665. sex:jQuery('div[lable="sex"]').next().children().eq(0).text(),
  666. post:jQuery('div[lable="post"]').next().children().eq(0).val(),
  667. detailaddress:jQuery('div[lable="detailaddress"]').next().children().eq(0).val(),
  668. nexttime:jQuery('div[lable="nexttime"]').next().children().eq(0).val(),
  669. remark:jQuery('div[lable="remark"]').next().children().eq(0).val()
  670. };
  671. debugger
  672. _self.actions.saveContacts(filter, function (json) {
  673. debugger
  674. if(json.type=="success"){
  675. Showbo.Msg.alert('保存成功!');
  676. //这里需要关联商机
  677. _self.loadContacts();
  678. }
  679. setTimeout(function(){
  680. jQuery("#notifyEdit").remove();
  681. if(jQuery(".mask").length>0){
  682. jQuery(".mask").attr("style",'left: 0px; top: 0px; width: 100%; overflow: hidden; position: absolute; z-index: 500000; background-color: rgb(255, 255, 255)');
  683. jQuery(".mask").attr("class","");
  684. }
  685. },200);
  686. }.bind(_self));
  687. });
  688. },
  689. relateChanceAndContact: function(){
  690. //打开联系人list,选择,确定后创建关联关系
  691. this.selectContact = new MWF.xApplication.CRM.ChanceEdit.SelectContact (null,{customerid:this.data.customerId},null, {
  692. app: this,
  693. container: this.formTableArea,
  694. lp: this.lp,
  695. actions: this.actions,
  696. css: {},
  697. }
  698. );
  699. this.selectContact.create();
  700. },
  701. terminatedRelation: function(){
  702. //获取选中的联系人,解除
  703. },
  704. editTeam: function(nameList){
  705. _self = this;
  706. 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;">'+
  707. '<div class="handle-item-name" style="margin-top: 8px;width:60px;">权限:</div><div role="radiogroup" class="el-radio-group">'+
  708. '<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>'+
  709. '<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>'
  710. Showbo.Msg.confirm('编辑权限',contentHtml,function(){
  711. var filter = {};
  712. filter = {
  713. distinguishName: nameList,
  714. }
  715. var val=jQuery(".ct").find('input:radio:checked').val();
  716. if(val==1){
  717. _self.actions.setTeamReaderChance(_self.options.openId, filter, function (json) {
  718. if(json.type=="success"){
  719. Showbo.Msg.alert('操作成功!');
  720. _self.loadTeam();
  721. }
  722. setTimeout(function(){
  723. jQuery("#notifyEdit").remove();
  724. if(jQuery(".mask").length>0){
  725. jQuery(".mask").attr("style",'left: 0px; top: 0px; width: 100%; overflow: hidden; position: absolute; z-index: 500000; background-color: rgb(255, 255, 255)');
  726. jQuery(".mask").attr("class","");
  727. }
  728. },200);
  729. }.bind(_self));
  730. }else{
  731. _self.actions.setTeamWriterChance(_self.options.openId, filter, function (json) {
  732. if(json.type=="success"){
  733. Showbo.Msg.alert('操作成功!');
  734. _self.loadTeam();
  735. }
  736. setTimeout(function(){
  737. jQuery("#notifyEdit").remove();
  738. if(jQuery(".mask").length>0){
  739. jQuery(".mask").attr("style",'left: 0px; top: 0px; width: 100%; overflow: hidden; position: absolute; z-index: 500000; background-color: rgb(255, 255, 255)');
  740. jQuery(".mask").attr("class","");
  741. }
  742. },200);
  743. }.bind(_self));
  744. }
  745. },function(){
  746. });
  747. jQuery(".el-radio").click(function(){
  748. var robj = jQuery(this).find("input");
  749. jQuery(this).siblings().find("input[type=radio]").removeAttr('checked');
  750. });
  751. },
  752. addTeam: function () {
  753. //添加team成员
  754. _self = this;
  755. var contentHtml = '<div class="vux-flexbox handle-item vux-flex-row" style="align-items: stretch;padding: 30px 20px 0px 20px;line-height:30px;">'+
  756. '<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>'+
  757. '<div class="vux-flexbox handle-item vux-flex-row" style="align-items: stretch;padding: 10px 20px 80px 20px;line-height:30px;">'+
  758. '<div class="handle-item-name" style="margin-top: 8px;width:100px;">权限:</div><div role="radiogroup" class="el-radio-group">'+
  759. '<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>'+
  760. '<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>'+
  761. '</div></div></div>'
  762. Showbo.Msg.confirm('添加团队成员',contentHtml,function(){
  763. //_self.confirmCustomerDealstatus();
  764. var readOrWrite = "";
  765. var checkFlag = true;
  766. var relationTypeList = [];
  767. jQuery(".ct").find(".is-checked").each(function(i,obj){
  768. var typeStr = jQuery(obj).children(".el-radio__label").text();
  769. if(typeStr=="只读"){
  770. readOrWrite = "read"
  771. }
  772. if(typeStr=="读写"){
  773. readOrWrite = "write"
  774. }
  775. })
  776. jQuery(".ct").find(".el-checkbox__original").each(function(i,obj){
  777. if(jQuery(obj).is(':checked')){
  778. relationTypeList.push(jQuery(obj).val());
  779. }
  780. })
  781. if(jQuery("#selectId").text() == ""){
  782. checkFlag = false;
  783. Showbo.Msg.alert('选择团队成员!');
  784. }
  785. if(readOrWrite == ""){
  786. checkFlag = false;
  787. Showbo.Msg.alert('请权限!');
  788. }
  789. if(checkFlag){
  790. var filter = {};
  791. filter = {
  792. personList: (jQuery('#selectId').text()).split(","),
  793. relationTypeList: relationTypeList
  794. }
  795. _self.actions.addRelevantPersonChance(_self.options.openId,readOrWrite, filter, function (json) {
  796. if(json.type=="success"){
  797. Showbo.Msg.alert('操作成功!');
  798. _self.loadTeam();
  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. }.bind(_self));
  808. }
  809. },function(){
  810. });
  811. jQuery(".ct").find(".se-select-name").click(function(){
  812. _self.selectPerson(jQuery("#appContent")[0],"selectName","selectId",0);
  813. });
  814. jQuery(".ct").find(".el-radio").click(function(){
  815. jQuery(this).siblings().attr("class","el-radio");
  816. jQuery(this).siblings().find("input:radio").attr("checked",false)
  817. jQuery(this).attr("class","el-radio is-checked");
  818. jQuery(this).find("input:radio").attr("checked",true);
  819. var typeName = jQuery(this).find(".el-radio__label").text();
  820. });
  821. },
  822. deleteTeam: function(){
  823. _self = this;
  824. Showbo.Msg.confirm('提示','此操作将移除这些团队成员是否继续?',function(){
  825. var nameList = [];
  826. jQuery(".el-table__body").find("input:checked").each(function(index,element){
  827. var nobj = jQuery(element).parent().parent().next();
  828. nameList.push(jQuery(nobj).attr("aid"));
  829. });
  830. if(nameList.length<1){
  831. Showbo.Msg.alert('请选择要删除的相关团队成员!');
  832. }else{
  833. var filter = {};
  834. filter = {
  835. distinguishName: nameList
  836. }
  837. _self.actions.removeTeamMemberChance(_self.options.openId,filter, function (json) {
  838. if(json.type=="success"){
  839. Showbo.Msg.alert('操作成功!');
  840. _self.loadTeam();
  841. }
  842. }.bind(self));
  843. }
  844. setTimeout(function(){
  845. jQuery("#notifyEdit").remove();
  846. if(jQuery(".mask").length>0){
  847. jQuery(".mask").attr("style",'left: 0px; top: 0px; width: 100%; overflow: hidden; position: absolute; z-index: 500000; background-color: rgb(255, 255, 255)');
  848. jQuery(".mask").attr("class","");
  849. }
  850. },200);
  851. },function(){
  852. });
  853. },
  854. loadEvent: function(){
  855. that = this;
  856. jQuery(that.sectionArea).find('.tabPanel div').click(function(){
  857. jQuery(this).addClass('hit').siblings().removeClass('hit');
  858. jQuery(that.sectionArea).find('.panes>div:eq('+jQuery(this).index()+')').show().siblings().hide();
  859. that.createTypeHtml();
  860. });
  861. jQuery(that.sectionArea).find('.headMoreBottonDiv').click(function(){
  862. jQuery(that.sectionArea).find(".el-dropdown-menu").toggle(100);
  863. });
  864. jQuery(that.sectionArea).find('.el-dropdown-menu__item').click(function(){
  865. if(jQuery(this).text()=="删除"){
  866. }
  867. //---for记录类型
  868. if(jQuery(this).parent().attr("tid")=="recordType"){
  869. jQuery(".se-select-name").text(jQuery(this).text());
  870. jQuery(this).parent().toggle(100);
  871. }
  872. });
  873. jQuery(that.sectionArea).find('.headMoveBottonDiv').click(function(){
  874. that.transfer();
  875. });
  876. jQuery(that.sectionArea).find('.headEditBottonDiv').click(function(){
  877. that.chanceEdit();
  878. });
  879. jQuery(that.sectionArea).find('#bar-file').change(function(event) {
  880. var files = event.target.files;
  881. debugger
  882. jQuery(that.sectionArea).find('.fileList').empty();
  883. if (files && files.length > 0) {
  884. // 获取目前上传的文件
  885. var fileListHtml = '<div class="fileList">';
  886. for(var i=0;i<files.length;i++){
  887. var file = files[i];
  888. var fsize = file.size/1024;
  889. var lastModifiedDate = file.lastModifiedDate;
  890. 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>';
  891. }
  892. fileListHtml = fileListHtml+'</div>';
  893. jQuery(that.sectionArea).find('.mix-container').append(fileListHtml);
  894. }
  895. });
  896. jQuery(that.sectionArea).find('.se-send').click(function(){
  897. that.sendRecord();
  898. });
  899. jQuery(that.sectionArea).find('.el-dropdown-selfdefine').click(function(){
  900. jQuery(that.sectionArea).find("[tid='recordType']").toggle(100);
  901. });
  902. },
  903. sendRecord: function () {
  904. that = this;
  905. //var objFile = document.getElementById("bar-file");
  906. var filters = {};
  907. filters = {
  908. types:"customer",
  909. typesid:that.options.openId,
  910. content:jQuery(that.sectionArea).find('.el-textarea__inner').val(),
  911. category:jQuery(that.sectionArea).find('.se-select-name').text(),
  912. nexttime:jQuery(that.sectionArea).find('.el-input__inner').text(),
  913. businessids:"",
  914. contactsids:"",
  915. createuser:""
  916. };
  917. that.actions.createRecord(filters,function(json){
  918. if(json.type=="success"){
  919. Showbo.Msg.alert('跟进记录发布成功!');
  920. var objFile = jQuery(that.sectionArea).find('#bar-file')[0].files;
  921. jQuery(objFile).each(function(index,file){
  922. var filter = {};
  923. filter = {
  924. file:file,
  925. fileName:file.name
  926. };
  927. debugger
  928. var formdata=new FormData();
  929. formdata.append("fileName",file.name);
  930. formdata.append("file",file);
  931. that.actions.updateAttachment("att",json.data.id, "record", formdata,file, function (attjson) {
  932. debugger
  933. /*if(json.type=="success"){
  934. Showbo.Msg.alert('附件上传成功!');
  935. }*/
  936. }.bind(that));
  937. }
  938. );
  939. that.loadRecord();
  940. }
  941. }.bind(that),function(xhr,text,error){
  942. }.bind(that));
  943. },
  944. loadRecord: function(){
  945. that = this;
  946. this.actions.getRecord(this.options.openId, function (json) {
  947. if(json.type=="success"){
  948. var recordDatas = json.data;
  949. jQuery(that.sectionArea).find(".fl-c").remove();
  950. var logItemHtml = "";
  951. for ( i in recordDatas){
  952. if(i<recordDatas.length){
  953. var recordData = recordDatas[i];
  954. var personImg = 'http://172.16.92.55/x_component_CRM/$Template/portrait.png';
  955. logItemHtml = logItemHtml+'<div class="fl-c"><div class="vux-flexbox fl-h vux-flex-row">'+
  956. '<div class="div-photo fl-h-img" style="background-image: url(&quot;'+personImg+'&quot;);" lazy="loaded"></div> '+
  957. '<div class="fl-h-b"><div class="fl-h-name">'+recordData.person.name+'</div><div class="fl-h-time">'+recordData.updateTime+'</div></div>'+
  958. //'<div class="vux-flexbox fl-h-mark vux-flex-row"><img src="" class="fl-h-mark-img"><div class="fl-h-mark-name">跟进记录</div></div>'+
  959. //'<div class="el-dropdown"><i class="el-icon-arrow-down el-icon-more el-dropdown-selfdefine" style="color: rgb(205, 205, 205); margin-left: 8px;" aria-haspopup="list" aria-controls="dropdown-menu-4704" role="button" tabindex="0"></i> <ul class="el-dropdown-menu el-popper" style="display: none;" id="dropdown-menu-4704"><li data-v-e36820dc="" tabindex="-1" class="el-dropdown-menu__item">删除</li></ul></div>'+
  960. '</div>'+
  961. '<div class="fl-b"><div class="fl-b-content">'+recordData.content+'</div><div class="follow"><span class="follow-info">'+recordData.category+'</span></div></div>'+
  962. '<div class="full-container" style="display: none;"></div></div>'
  963. }
  964. }
  965. if(logItemHtml!=""){
  966. jQuery(that.sectionArea).find(".load").before(logItemHtml);
  967. }
  968. if(recordDatas.length<1){
  969. jQuery(that.sectionArea).find(".load").hide();
  970. jQuery(that.sectionArea).find(".empty-mask").show();
  971. }
  972. }
  973. }.bind(this));
  974. },
  975. open: function (e) {
  976. this.fireEvent("queryOpen");
  977. this._open();
  978. this.fireEvent("postOpen");
  979. },
  980. create: function () {
  981. this.fireEvent("queryCreate");
  982. this.isNew = true;
  983. this._open();
  984. this.fireEvent("postCreate");
  985. },
  986. edit: function () {
  987. this.fireEvent("queryEdit");
  988. this.isEdited = true;
  989. this._open();
  990. this.fireEvent("postEdit");
  991. },
  992. _open: function () {
  993. if( this.options.hasMask ){
  994. this.formMaskNode = new Element("div.formMaskNode", {
  995. "styles": this.css.formMaskNode,
  996. "events": {
  997. "mouseover": function (e) {
  998. e.stopPropagation();
  999. },
  1000. "mouseout": function (e) {
  1001. e.stopPropagation();
  1002. },
  1003. "click": function (e) {
  1004. e.stopPropagation();
  1005. }
  1006. }
  1007. }).inject( this.container || this.app.content);
  1008. }
  1009. this.formAreaNode = new Element("div.formAreaNode", {
  1010. "styles": this.css.formAreaNode
  1011. });
  1012. this.createFormNode();
  1013. this.formAreaNode.inject(this.formMaskNode || this.container || this.app.content, "after");
  1014. this.formAreaNode.fade("in");
  1015. this.setFormNodeSize();
  1016. this.setFormNodeSizeFun = this.setFormNodeSize.bind(this);
  1017. if( this.app )this.app.addEvent("resize", this.setFormNodeSizeFun);
  1018. if (this.options.draggable && this.formTopNode) {
  1019. var size = (this.container || this.app.content).getSize();
  1020. var nodeSize = this.formAreaNode.getSize();
  1021. this.formAreaNode.makeDraggable({
  1022. "handle": this.formTopNode,
  1023. "limit": {
  1024. "x": [0, size.x - nodeSize.x],
  1025. "y": [0, size.y - nodeSize.y]
  1026. }
  1027. });
  1028. }
  1029. },
  1030. createFormNode: function () {
  1031. var _self = this;
  1032. this.formNode = new Element("div.formNode", {
  1033. "styles": this.css.formNode
  1034. }).inject(this.formAreaNode);
  1035. if (this.options.hasTop) {
  1036. this.createTopNode();
  1037. }
  1038. if (this.options.hasIcon) {
  1039. this.formIconNode = new Element("div.formIconNode", {
  1040. "styles": this.isNew ? this.css.formNewNode : this.css.formIconNode
  1041. }).inject(this.formNode);
  1042. }
  1043. this.createContent();
  1044. //formContentNode.set("html", html);
  1045. if (this.options.hasBottom) {
  1046. this.createBottomNode();
  1047. }
  1048. this._setCustom();
  1049. if( this.options.hasScroll ){
  1050. //this.setScrollBar(this.formTableContainer)
  1051. MWF.require("MWF.widget.ScrollBar", function () {
  1052. new MWF.widget.ScrollBar(this.formTableContainer, {
  1053. "indent": false,
  1054. "style": "default",
  1055. "where": "before",
  1056. "distance": 30,
  1057. "friction": 4,
  1058. "axis": {"x": false, "y": true},
  1059. "onScroll": function (y) {
  1060. //var scrollSize = _self.viewContainerNode.getScrollSize();
  1061. //var clientSize = _self.viewContainerNode.getSize();
  1062. //var scrollHeight = scrollSize.y - clientSize.y;
  1063. //if (y + 200 > scrollHeight && _self.view && _self.view.loadElementList) {
  1064. // if (!_self.view.isItemsLoaded) _self.view.loadElementList();
  1065. //}
  1066. }
  1067. });
  1068. }.bind(this));
  1069. }
  1070. },
  1071. createContent: function () {
  1072. this.formContentNode = new Element("div.formContentNode", {
  1073. "styles": this.css.formContentNode
  1074. }).inject(this.formNode);
  1075. this.formTableContainer = new Element("div.formTableContainer", {
  1076. "styles": this.css.formTableContainer
  1077. }).inject(this.formContentNode);
  1078. this.formTableArea = new Element("div.formTableArea", {
  1079. "styles": this.css.formTableArea,
  1080. "text":"loading..."
  1081. }).inject(this.formTableContainer);
  1082. this._createTableContent();
  1083. },
  1084. createBottomNode: function () {
  1085. this.formBottomNode = new Element("div.formBottomNode", {
  1086. "styles": this.css.formBottomNode
  1087. }).inject(this.formNode);
  1088. this._createBottomContent()
  1089. },
  1090. createTopNode: function () {
  1091. if (!this.formTopNode) {
  1092. this.formTopNode = new Element("div.formTopNode", {
  1093. "styles": this.css.formTopNode
  1094. }).inject(this.formNode);
  1095. this.formTopIconNode = new Element("div", {
  1096. "styles": this.css.formTopIconNode
  1097. }).inject(this.formTopNode);
  1098. this.formTopTextNode = new Element("div", {
  1099. "styles": this.css.formTopTextNode,
  1100. "text": this.options.title + ( this.data.title ? ("-" + this.data.title ) : "" )
  1101. }).inject(this.formTopNode);
  1102. if (this.options.closeAction) {
  1103. this.formTopCloseActionNode = new Element("div", {"styles": this.css.formTopCloseActionNode}).inject(this.formTopNode);
  1104. this.formTopCloseActionNode.addEvent("click", function () {
  1105. this.close();
  1106. }.bind(this))
  1107. }
  1108. this.formTopContentNode = new Element("div", {
  1109. "styles": this.css.formTopContentNode
  1110. }).inject(this.formTopNode);
  1111. this._createTopContent();
  1112. }
  1113. },
  1114. _createTopContent: function () {
  1115. },
  1116. _createTableContent: function () {
  1117. this.loadFormData();
  1118. /*
  1119. var Ttype = "clue";
  1120. this.actions.getProfiles(Ttype,function(json){
  1121. this.profileData = json.data;
  1122. if(this.data.id){
  1123. this.actions.getCustomerInfo(this.data.id,function(json){
  1124. this.customerData = json.data;
  1125. this.loadFormData();
  1126. this.createCustomBottom();
  1127. }.bind(this));
  1128. }else{
  1129. this.loadFormData();
  1130. this.createCustomBottom();
  1131. }
  1132. }.bind(this));
  1133. */
  1134. },
  1135. _createBottomContent: function () {
  1136. this.cancelActionNode = new Element("div.formCancelActionNode", {
  1137. "styles": this.css.formCancelActionNode,
  1138. "text": this.lp.actionCancel
  1139. }).inject(this.formBottomNode);
  1140. if (this.options.isNew || this.options.isEdited) {
  1141. //this.ok();
  1142. this.okActionNode = new Element("div.formOkActionNode", {
  1143. "styles": this.css.formOkActionNode,
  1144. "text": this.lp.actionConfirm
  1145. }).inject(this.formBottomNode);
  1146. this.okActionNode.addEvent("click", function (e) {
  1147. this.ok(e);
  1148. }.bind(this));
  1149. }
  1150. this.cancelActionNode.addEvent("click", function (e) {
  1151. this.cancel(e);
  1152. }.bind(this));
  1153. },
  1154. loadFormData:function(){
  1155. var tmpData={};
  1156. this.loadForm();
  1157. },
  1158. ok: function (e) {
  1159. this.fireEvent("queryOk");
  1160. var data = this.form.getResult(true, ",", true, false, true);
  1161. debugger;
  1162. if (data) {
  1163. this._ok(data, function (json) {
  1164. if (json.type == "error") {
  1165. if( this.app )this.app.notice(json.message, "error");
  1166. } else {
  1167. if( this.formMaskNode )this.formMaskNode.destroy();
  1168. this.formAreaNode.destroy();
  1169. if (this.explorer && this.explorer.view)this.explorer.view.reload();
  1170. if( this.app )this.app.notice(this.isNew ? this.lp.createSuccess : this.lp.updateSuccess, "success");
  1171. this.fireEvent("postOk");
  1172. }
  1173. }.bind(this))
  1174. }
  1175. },
  1176. loadForm: function(){
  1177. _self = this;
  1178. this.form = new MForm(this.formTableArea, this.data, {
  1179. style: "default",
  1180. isEdited: this.isEdited || this.isNew,
  1181. itemTemplate: this.getItemTemplate(this.lp )
  1182. },this.app,this.css);
  1183. var html = "<table width='100%' bordr='0' cellpadding='5' cellspacing='0' styles='formTable'>";
  1184. var itemTemplateObject = this.form.itemTemplate;
  1185. debugger
  1186. for ( i in itemTemplateObject){
  1187. html = html+"<tr>" +
  1188. " <td styles='formTableTitle'><span lable='"+i+"'>"+itemTemplateObject[i].text+"</td>" +
  1189. " <td styles='formTableValue' item='"+i+"'></td>" +
  1190. "</tr>";
  1191. }
  1192. html = html+"</table>";
  1193. debugger
  1194. this.formTableArea.set("html", html);
  1195. this.form.load();
  1196. if(!this.isNew){
  1197. this.actions.getCustomerInfo(this.options.openId, function (json) {
  1198. debugger
  1199. var jsonObj = json.data;
  1200. var spanObject = this.formTableArea.getElements("span");
  1201. for ( j in spanObject){
  1202. if(j < spanObject.length){
  1203. debugger
  1204. if(spanObject[j].get("name")!=null){
  1205. var fieldName = spanObject[j].get("name");
  1206. for (var prop in jsonObj){
  1207. if(prop == fieldName){
  1208. spanObject[j].set("text",jsonObj[prop]);
  1209. }
  1210. }
  1211. }
  1212. }
  1213. }
  1214. }.bind(this));
  1215. }
  1216. //this.nexttime = this.formTableArea.getElement("#nexttime");
  1217. //this.nexttime.addEvent("click",function(){
  1218. //_self.selectCalendar(this);
  1219. //});
  1220. this.formTableArea.getElements("textarea").setStyles({"height":"100px","overflow":"auto","color":"#666666"});
  1221. this.formTableArea.getElements("input").setStyles({"color":"#666666"});
  1222. },
  1223. getItemTemplate: function( lp ){
  1224. _self = this;
  1225. console.log(lp);
  1226. return {
  1227. name: {
  1228. text: lp.name,
  1229. type: "text",
  1230. //attr : {placeholder:lp.name},
  1231. notEmpty:true,
  1232. value:this.data&&this.data.opportunityname?this.data.opportunityname:""
  1233. },
  1234. customer:{
  1235. type: "text",
  1236. text: lp.customer,
  1237. value:this.data && this.data.customer&&this.data.customer.customername?this.data.customer.customername:""
  1238. },
  1239. typeid: {
  1240. type: "select",
  1241. text: lp.typeid,
  1242. value:this.data && this.data.opportunityType&&this.data.opportunityType.opportunitytypename?this.data.opportunityType.opportunitytypename:""
  1243. },
  1244. statusid: {
  1245. type: "select",
  1246. text: lp.statusid,
  1247. value:this.data && this.data.opportunityStatus&&this.data.opportunityStatus.opportunitystatusname?this.data.opportunityStatus.opportunitystatusname:""
  1248. },
  1249. money:{
  1250. type: "text",
  1251. text: lp.money,
  1252. value: this.data && this.data.money?this.data.money:""
  1253. },
  1254. dealdate: {
  1255. text: lp.dealdate,
  1256. name:"dealdate",
  1257. attr : {id:"dealdate"},
  1258. type: "datetime",
  1259. value:this.data && this.data.dealdate?this.data.dealdate:""
  1260. },
  1261. remark: {
  1262. text: lp.remark,
  1263. name:"remark",
  1264. type: "textarea",
  1265. value:this.data && this.data.remark?this.data.remark:""
  1266. }
  1267. }
  1268. },
  1269. getContactTemplate: function( lp ){
  1270. _self = this;
  1271. return {
  1272. contactsname: {
  1273. text: lp.contactsname,
  1274. type: "text",
  1275. notEmpty:true
  1276. },
  1277. customername: {
  1278. text: lp.customername,
  1279. type: "readonly",
  1280. notEmpty:true
  1281. },
  1282. telephone:{
  1283. type: "text",
  1284. text: lp.telephone,
  1285. },
  1286. cellphone: {
  1287. text:lp.cellphone,
  1288. type: "text"
  1289. },
  1290. email:{
  1291. type: "text",
  1292. text: lp.email
  1293. },
  1294. decision: {
  1295. type: "select",
  1296. text: lp.decision,
  1297. value:this.app.lp.contact.decision.value
  1298. },
  1299. post: {
  1300. text:lp.post,
  1301. type: "text"
  1302. },
  1303. sex: {
  1304. type: "select",
  1305. text: lp.sex,
  1306. value:this.app.lp.contact.sex.value
  1307. },
  1308. detailaddress: {
  1309. text:lp.detailaddress,
  1310. type: "text"
  1311. },
  1312. nexttime: {
  1313. text:lp.nexttime,
  1314. attr : {id:"nexttime"},
  1315. type: "datetime"
  1316. },
  1317. remark: {
  1318. text:lp.remark,
  1319. type: "textarea"
  1320. }
  1321. }
  1322. },
  1323. selectPerson: function (showContainer,nameId,fullNameId,count) {
  1324. var options = {
  1325. "type" : "",
  1326. "types": ["person"],
  1327. "values": this.configData,
  1328. "count": count,
  1329. "zIndex": 50000,
  1330. "onComplete": function(items){
  1331. MWF.require("MWF.widget.O2Identity", function(){
  1332. var invitePersonList = [];
  1333. var fullPersonList = [];
  1334. this.configData = [];
  1335. this.process = null;
  1336. items.each(function(item){
  1337. var _self = this;
  1338. if( item.data.distinguishedName.split("@").getLast().toLowerCase() == "i" ){
  1339. var person = new MWF.widget.O2Identity(item.data, it.form.getItem("invitePersonList").container, {"style": "room"});
  1340. invitePersonList.push( item.data.distinguishedName );
  1341. }else{
  1342. //var person = new MWF.widget.O2Person(item.data, it.form.getItem("invitePersonList").container, {"style": "room"});
  1343. invitePersonList.push(item.data.name);
  1344. fullPersonList.push(item.data.distinguishedName);
  1345. var personJson = {
  1346. "name": item.data.name,
  1347. "distinguishedName": item.data.distinguishedName,
  1348. "employee":item.data.employee
  1349. }
  1350. debugger
  1351. this.configData.push(personJson);
  1352. }
  1353. }.bind(this));
  1354. if(items.length==0){
  1355. document.getElementById(nameId).innerHTML = "+点击选择"
  1356. }else{
  1357. document.getElementById(nameId).innerHTML = invitePersonList.join(",");
  1358. if(fullNameId!=""){
  1359. document.getElementById(fullNameId).innerHTML = fullPersonList.join(",");
  1360. }
  1361. }
  1362. }.bind(this));
  1363. }.bind(this)
  1364. };
  1365. var selector = new MWF.O2Selector(showContainer, options);
  1366. },
  1367. getFormateTime: function( timeStr ){
  1368. _self = this;
  1369. var date= new Date(timeStr);
  1370. return date.getFullYear()+'-'+_self.checkTime(date.getMonth()+1)+'-'+_self.checkTime(date.getDate())+ ' ' + _self.checkTime(date.getHours()) + ':' + _self.checkTime(date.getMinutes()) + ':' + _self.checkTime(date.getSeconds());
  1371. },
  1372. checkTime: function( i ){
  1373. if(i<10){
  1374. i = '0'+i
  1375. }
  1376. return i;
  1377. },
  1378. toDecimal: function(x){
  1379. if(x==""){
  1380. return "";
  1381. }else{
  1382. var f = parseFloat(x);
  1383. if (isNaN(f)) {
  1384. return x;
  1385. }
  1386. f = Math.round(x*100)/100;
  1387. return f;
  1388. }
  1389. },
  1390. /*selectCalendar : function( calendarNode ){
  1391. MWF.require("MWF.widget.Calendar", function(){
  1392. var calendar = new MWF.widget.Calendar( calendarNode, {
  1393. "style": "xform",
  1394. "isTime": false
  1395. "target": this.app.content
  1396. });
  1397. calendar.show();
  1398. }.bind(this));
  1399. },*/
  1400. createCustomBottom:function(){
  1401. this.okActionNode = new Element("div.formOkActionNode", {
  1402. "styles": this.css.formOkActionNode,
  1403. "text": this.lp.actionConfirm
  1404. }).inject(this.formBottomNode);
  1405. this.okActionNode.addEvent("click", function (e) {
  1406. this.ok(e);
  1407. }.bind(this));
  1408. },
  1409. _ok: function (data, callback) {
  1410. var saveDataStr = "";
  1411. for ( i in this.data){
  1412. saveDataStr = saveDataStr+"'"+i+"':'"+this.data[i]+"',";
  1413. }
  1414. debugger;
  1415. saveDataStr = "'{"+saveDataStr.replace(/'/g, '"')+"}'";
  1416. debugger;
  1417. //var saveData = JSON.parse(saveDataStr);
  1418. var saveData = eval('(' + saveDataStr.substring(1,saveDataStr.length - 1) + ')');
  1419. debugger;
  1420. //alert(JSON.stringify(saveData))
  1421. this.app.createShade();
  1422. this.actions.saveClue(saveData,function(json){
  1423. this.app.destroyShade();
  1424. this.app.notice(this.lp.saveSuccess,"success");
  1425. this.close();
  1426. this.fireEvent("reloadView",json);
  1427. }.bind(this),function(xhr,text,error){
  1428. this.app.showErrorMessage(xhr,text,error);
  1429. this.app.destroyShade();
  1430. }.bind(this));
  1431. }
  1432. });
  1433. MWF.xApplication.CRM.ChanceEdit.SelectContact = new Class({
  1434. Extends: MWF.xApplication.CRM.Template.SelectForm,
  1435. //一般需要重写分页方法
  1436. _getCurrentPageData: function(callback, count, page, searchText){
  1437. var category = this.category = this.options.category;
  1438. if (!count)count = 10;
  1439. if (!page)page = 1;
  1440. var id = (this.items.length) ? this.items[this.items.length - 1].data.id : "(0)";
  1441. //if(id=="(0)")this.app.createShade();
  1442. var filter = this.options.filterData || {};
  1443. if(this.data.customerid){
  1444. filter = {
  1445. customerId:this.data.customerid
  1446. };
  1447. }
  1448. /*if(searchText){
  1449. filter = {
  1450. customerId:searchText
  1451. };
  1452. }*/
  1453. this.actions.getContactsListPageByCustomerId(page, count, filter, function (json) {
  1454. if (callback)callback(json);
  1455. }.bind(this));
  1456. }
  1457. });