MWF.xApplication.CRM.AddressExplorer={}; MWF.require("MWF.widget.O2Identity", null, false); MWF.xDesktop.requireApp("Selector", "package", null, false); MWF.xApplication.CRM.CustomerOpen = new Class({ Extends: MWF.xApplication.CRM.Template.PopupForm, Implements: [Options, Events], options: { "style": "default", "width": "800", "height": "100%", "top" : 0, "left" : 0, "hasTop": true, "hasIcon": false, "hasBottom": true, "title": "", "draggable": false, "closeAction": true }, initialize: function (explorer, actions, data, options) { this.setOptions(options); this.explorer = explorer; this.app = explorer.app; this.lp = this.app.lp.customer.customerEdit; this.path = "../x_component_CRM/$ClueEdit/"; this.cssPath = this.path + this.options.style + "/css.wcss"; this._loadCss(); this.options.title = this.lp.title; this.data = data || {}; this.actions = actions; this.configData = []; debugger }, load: function () { that = this; this.loadResource(function(){ this.appArea = jQuery("body").children(":first"); this.createForm(); this.loadEvent(); }.bind(this)) }, loadResource: function ( callback ) { if(callback)callback(); }, createForm:function(){ that = this; var clueName = this.options.openName; /*this.createContentHtml(this.options.clueId);*/ var buttonHtml = '
转移
编辑
' + '
更多
'; var moreHtml = ''; var sectionId = that.getNotifyMax(); var sjson = this.options.openStyle?this.options.openStyle:this.xxx; jQuery(".headMoreImg").notifyMe( 'right', 'default', clueName, buttonHtml, moreHtml, '', sectionId, 500, sjson ); that.createContentHtml(sectionId); }, getNotifyMax : function () { var sectionId = 'notify'; var sectionNum = 0; if(!(this.options.openType) || (this.options.openType !="single")) { jQuery(".notify").each(function (index, element) { var notifyId = jQuery(element).attr("id"); var notifyNum = 0; if (notifyId.indexOf("_") > 0) { notifyNum = parseInt(notifyId.split("_")[1]); if (notifyNum > sectionNum) { sectionNum = notifyNum; } } else { if (sectionNum == 0) { sectionNum = 1; } } }); if (sectionNum > 0) { sectionId = sectionId + '_' + sectionNum; } } return sectionId; }, createContentHtml: function (sectionId) { that = this; this.sectionArea = jQuery("body")[0].getElement("#"+sectionId); debugger this.actions.getCustomerInfo(this.options.openId, function (json) { var jsonObj = json.data; var owneruser = (jsonObj.owneruser=="" || (typeof(jsonObj.owneruser)=="undefined"))?"--":(jsonObj.owneruser).split("@")[0]; var briefDiv = "
"+ "
客户级别
"+jsonObj.level+"
"+ "
成交状态
"+jsonObj.dealstatus+"
"+ "
负责人
"+owneruser+"
"+ "
更新时间
"+jsonObj.updateTime+"
"+ "
" var tabPanel = "
跟进记录
基本信息
"+ "
联系人
相关团队
商机
"+ "
附件
操作记录
" var tabConent ="

First tab content

"+ "

Secend tab content

"+ "

contacts tab content

"+ "

team tab content

"+ "

business tab content

"+ "

Third tab content

"+ "

Four tab content

" //jQuery("#"+sectionId).find(".notify-content").html( briefDiv+tabPanel+tabConent); this.sectionArea.getElement(".notify-content").set("html",briefDiv+tabPanel+tabConent); var size = this.sectionArea.getSize(); this.sectionArea.getElement(".panes").setStyles({"height":(size.y-250)+"px"}); var indexHtml = '
'+ '
'+ '
'+ '
图片
'+ '
附件
'+ '
'; var indexSendHtml = '
记录类型
'+ '
邮箱
'+ '
下次联系时间
'+ '
'+ ''; var indexContentHtml = '
'+ '
'+ '
'+ ''+ '
'; //jQuery("#"+sectionId).find("#tab-follow").html(indexHtml+indexSendHtml+indexContentHtml); this.sectionArea.getElement("#tab-follow").set("html",indexHtml+indexSendHtml+indexContentHtml); that.loadTimeContainer('stime'); that.loadRecord(); }.bind(this)); }, createTypeHtml: function () { var createType = jQuery(this.sectionArea).find(".hit").text(); debugger if(createType == "基本信息") { this.getCustomerInfo(); } if(createType == "联系人") { this.loadContacts(); } if(createType == "相关团队") { this.loadTeam(); } if(createType == "商机") { this.loadBusiness(); } if(createType == "附件") { this.loadAttachment(); } if(createType == "操作记录") { this.loadOptions(); } }, loadTimeContainer: function(stime){ jQuery("#"+stime).ymdateplugin({ showTimePanel: true }); }, getCustomerInfo: function () { _self = this; this.actions.getCustomerInfo(this.options.openId, function (json) { var jsonObj = json.data; var section_header = '
'+ '
基本信息
' var itemTemplateObject = _self.lp; var section_conent = '
'; for ( i in itemTemplateObject){ section_conent = section_conent+'
'+itemTemplateObject[i].text+'
' + '
'+((typeof(jsonObj[i])=="undefined")?"" : jsonObj[i])+'
'; } section_conent = section_conent + '
'; //jQuery("#tab-basicinfo").html(section_header+section_conent); jQuery(_self.sectionArea).find("#tab-basicinfo").html(section_header+section_conent); //this.contentHtml = briefDiv+tabPanel+tabConent; }.bind(this)); }, loadAttachment: function() { that = this; var attHtml = '
'; var attButton = '
上传附件
'; var attHeader = '
'+ '
'+ ''+ ''+ ''+ ''+ '
附件名称
附件大小
上传人
上传时间
操作
'; var attBody = '
'+ '
'+ '
暂无数据
'; attHtml = attHtml+attButton+attHeader+attBody+'
'; jQuery(that.sectionArea).find("#tab-att").html(attHtml); jQuery(that.sectionArea).find('#afile').change(function(event) { var objFile = jQuery(that.sectionArea).find('#afile')[0].files; jQuery(objFile).each(function(index,file){ var filter = {}; filter = { file:file, fileName:file.name }; var formdata=new FormData(); formdata.append("fileName",file.name); formdata.append("file",file); that.actions.updateAttachment("att", that.options.openId, "customer", formdata,file, function (json) { if(json.type=="success"){ //Showbo.Msg.alert('附件上传成功!'); that.getAttachment(); } }.bind(that)); } ); }); that.getAttachment(); }, getAttachment: function(){ that = this; this.actions.getAttachment(this.options.openId, function (json) { debugger if(json.type=="success"){ var attDatas = json.data; var tbodyHtml = ""; for ( i in attDatas){ if(i'+attData.name+''+that.toDecimal(fsize)+'kb'+ ''+lastUpdatePerson+''+attData.updateTime+'删除'; } } if(tbodyHtml!=""){ jQuery(that.sectionArea).find(".el-table__body").children().html(tbodyHtml); jQuery(that.sectionArea).find(".el-table__empty-block").hide(); jQuery(that.sectionArea).find(".attOption").click(function(){ self = this; Showbo.Msg.confirm('提示','确定删除该附件吗?',function(){ var aid = jQuery(self).parent().children(":first").attr("aid"); if(aid && aid !=""){ that.actions.delAttachment(aid, function (ajson) { if(ajson.type=="success"){ that.getAttachment(); } }.bind(self)); } },function(){ }); }); jQuery(that.sectionArea).find(".aname").click(function(){ var attUrl = 'http://172.16.92.55:20020/x_wcrm_assemble_control/jaxrs/attachment/download/'+jQuery(this).attr("aid")+'/work/'+jQuery(this).attr("wcrm") window.open(attUrl); /*that.actions.downloadAttachment(jQuery(this).attr("aid"),jQuery(this).attr("wcrm"), function (wjson) { }.bind(that));*/ }); } } }.bind(that)); }, loadContacts: function() { that = this; var attHtml = '
'; var attButton = '
新建联系人
'; var attHeader = '
'+ '
'+ ''+ ''+ '
姓名
手机
职务
'; var attBody = '
'+ '
'+ '
暂无数据
'; attHtml = attHtml+attButton+attHeader+attBody+'
'; jQuery(that.sectionArea).find("#tab-contacts").html(attHtml); this.actions.getContacts(this.options.openId, function (json) { if(json.type=="success"){ var attDatas = json.data; var tbodyHtml = ""; for ( i in attDatas){ if(i'+attData.contactsname+''+ ''+attData.cellphone+''+attData.post+''; } } if(tbodyHtml!=""){ jQuery(that.sectionArea).find(".el-table__body").children().html(tbodyHtml); jQuery(that.sectionArea).find(".el-table__empty-block").hide(); } } }.bind(that)); jQuery(that.sectionArea).find("#tab-contacts").find(".rc-head-item").click(function(){ that.contactsCreate(); }); jQuery(that.sectionArea).find("#tab-contacts").find(".aname").click(function(){ //that.contactsEdit(jQuery(this).attr("aid")); }); }, loadTeam: function() { that = this; var attHtml = '
'; var attButton = '
移除
'+ '
编辑
添加团队成员
'; var attHeader = '
'+ '
'+ ''+ ''+ ''+ ''+ '
'+ '
姓名
职位
团队角色
权限
'+ ''; var attBody = '
'+ '
'+ '
暂无数据
'; attHtml = attHtml+attButton+attHeader+attBody+'
'; jQuery(that.sectionArea).find("#tab-team").html(attHtml); this.actions.getTeamMemberListById(this.options.openId, function (json) { if(json.type=="success"){ var attDatas = json.data; var tbodyHtml = ""; for ( i in attDatas){ if(i0)?((attData.units[0]).split("@")[0]):""; var id = 'all'+i; var cdiv = '
'+ '
' if(attData.teamRole && attData.teamRole=="负责人"){ cdiv = '
'+ '
' } if(attData.teamRole && attData.teamRole!=""){ tbodyHtml = tbodyHtml+''+cdiv+''+attData.person.name+ ''+unit+''+attData.teamRole+''+attData.dispaly_permission+''; } } } if(tbodyHtml!=""){ jQuery(that.sectionArea).find(".el-table__body").children().html(tbodyHtml); jQuery(that.sectionArea).find(".el-table__empty-block").hide(); } } }.bind(that)); jQuery("[for='all']").click(function(){ //var cobj = jQuery("[for='all1']"); var cobj = jQuery(that.sectionArea).find(".cbxx").not("[for='all']"); if (jQuery(this).prev().is(':checked')) { cobj.each(function(index,element){ jQuery(element).prev().prop("checked", false); }); } else { cobj.each(function(index,element){ jQuery(element).prev().prop("checked", true); }); } }); jQuery(that.sectionArea).find(".rc-head-item").click(function() { if(jQuery(this).children().text()=="添加团队成员"){ that.addTeam(); } if(jQuery(this).children().text()=="编辑"){ var nameList = []; jQuery(".el-table__body").find("input:checked").each(function(index,element){ var nobj = jQuery(element).parent().parent().next(); nameList.push(jQuery(nobj).attr("aid")); }); that.editTeam(nameList); } if(jQuery(this).children().text()=="移除"){ that.deleteTeam(); } }); }, loadBusiness: function() { that = this; var attHtml = '
'; var attButton = '
新建商机
'; var attHeader = '
'+ '
'+ ''+ ''+ ''+ ''+ '
商机名称
商品金额
客户名称
商机状态组
状态
'; var attBody = '
'+ '
'+ '
暂无数据
'; attHtml = attHtml+attButton+attHeader+attBody+'
'; jQuery(that.sectionArea).find("#tab-business").html(attHtml); this.actions.getOpportunityListByCustomerId(this.options.openId, function (json) { if(json.type=="success"){ var attDatas = json.data; var tbodyHtml = ""; for ( i in attDatas){ if(i'+attData.opportunityname+ ''+attData.money+''+attData.customer.customername+ ''+attData.opportunityType.opportunitytypename+''+attData.opportunityStatus.opportunitystatusname+''; } } if(tbodyHtml!=""){ jQuery(that.sectionArea).find(".el-table__body").children().html(tbodyHtml); jQuery(that.sectionArea).find(".el-table__empty-block").hide(); } } }.bind(that)); jQuery(that.sectionArea).find("#tab-business").find(".rc-head-item").click(function(){ that.businessCreate(); }); jQuery(that.sectionArea).find("#tab-business").find(".aname").click(function(){ //that.contactsEdit(jQuery(this).attr("aid")); }); }, loadOptions: function() { that = this; var optionsHtml = '
'+ '
' jQuery(that.sectionArea).find("#tab-options").html(optionsHtml); this.actions.getOptionsRecord(this.options.openId, function (json) { if(json.type=="success"){ var recordDatas = json.data; jQuery(that.sectionArea).find(".rc-cont").find(".vux-flexbox").remove(); var logItemHtml = ""; for ( i in recordDatas){ if(i'+ '
'+recordData.DateCN+'
'+ '
'+ '
'+updatetime.substring(11,16)+'
'+ '
' + '
'+recordData.person.name+'
'+ '
'+recordData.content+'
'+ '
' } } if(logItemHtml!=""){ jQuery(that.sectionArea).find(".rc-cont").append(logItemHtml); } if(recordDatas.length<1){ jQuery(that.sectionArea).find(".empty-mask").show(); } } }.bind(this)); }, transformCustomerDealstatus: function () { _self = this; var contentHtml = '
成交状态:
'+ '
已成交
' contentHtml = contentHtml+'' Showbo.Msg.confirm('客户成交状态',contentHtml,function(){ _self.confirmCustomerDealstatus(); },function(){ }); jQuery('.handle-item-content').click(function(){ jQuery(".ct").find(".el-dropdown-confirm").toggle(100); }); jQuery('.el-dropdown-menu__item').click(function(){ if(jQuery(this).parent().attr("class")=="el-dropdown-confirm"){ jQuery(".ct").find(".se-select-name").text(jQuery(this).text()); jQuery(this).parent().toggle(100); } }); }, lockCustomer: function () { _self = this; var contentHtml = '确定要锁定此客户吗?锁定后将不会掉入公海。' Showbo.Msg.confirm('提示',contentHtml,function(){ _self.confirmLockCustomer(); },function(){ }); jQuery('.handle-item-content').click(function(){ jQuery(".ct").find(".el-dropdown-confirm").toggle(100); }); }, unLockCustomer: function () { _self = this; var contentHtml = '确定要解锁此客户吗?' Showbo.Msg.confirm('提示',contentHtml,function(){ _self.confirmUnLockCustomer(); },function(){ }); jQuery('.handle-item-content').click(function(){ jQuery(".ct").find(".el-dropdown-confirm").toggle(100); }); }, putToCustomerPool: function () { _self = this; var contentHtml = '确定转移到公海吗?' Showbo.Msg.confirm('提示',contentHtml,function(){ _self.actions.putToCustomerPool(_self.options.openId, function (json) { debugger if(json.type == "success"){ Showbo.Msg.alert('操作成功!'); } }.bind(this)); },function(){ }); jQuery('.handle-item-content').click(function(){ jQuery(".ct").find(".el-dropdown-confirm").toggle(100); }); }, confirmCustomerDealstatus: function () { _self = this; if(jQuery(".ct").find(".se-select-name").text()=="已成交"){ this.actions.customerDealStatus_completed(this.options.openId, function (json) { if(json.type == "success"){ Showbo.Msg.alert('操作成功!'); } }.bind(this)); } if(jQuery(".ct").find(".se-select-name").text()=="未成交"){ this.actions.customerDealStatus_processing(this.options.openId, function (json) { if(json.type == "success"){ Showbo.Msg.alert('操作成功!'); } }.bind(this)); } }, confirmLockCustomer: function () { this.actions.lockCustomer(this.options.openId, function (json) { if(json.type == "success"){ Showbo.Msg.alert('操作成功!'); } }.bind(this)); }, confirmUnLockCustomer: function () { this.actions.unLockCustomer(this.options.openId, function (json) { if(json.type == "success"){ Showbo.Msg.alert('操作成功!'); } }.bind(this)); }, transfer: function () { //转移负责人 _self = this; var contentHtml = '
'+ '
变更负责人为:
+点击选择
'+ '
'+ '
将原负责人:
'+ ''+ '
'+ ''+ '
'+ '
同时变更负责人至:
'+ ''+ '
' Showbo.Msg.confirm('客户转移',contentHtml,function(){ //_self.confirmCustomerDealstatus(); var transferType = ""; var readOrWrite = ""; var checkFlag = true; var relationTypeList = []; jQuery(".ct").find(".is-checked").each(function(i,obj){ var typeStr = jQuery(obj).children(".el-radio__label").text(); if(typeStr=="移出"){ transferType = "1" } if(typeStr=="转为团队成员"){ transferType = "2" } if(typeStr=="只读"){ readOrWrite = "readonly" } if(typeStr=="读写"){ readOrWrite = "readandwrite" } }) jQuery(".ct").find(".el-checkbox__original").each(function(i,obj){ debugger if(jQuery(obj).is(':checked')){ debugger relationTypeList.push(jQuery(obj).val()); } }) if(jQuery("#selectId").text() == ""){ checkFlag = false; Showbo.Msg.alert('请选择负责人!'); } if(transferType == ""){ checkFlag = false; Showbo.Msg.alert('请选择将负责人移出或转为团队成员!'); } if(checkFlag){ var filter = {}; filter = { distinguishName: jQuery('#selectId').text(), transferType: transferType, readOrWrite: readOrWrite, relationTypeList:relationTypeList } debugger _self.actions.customerTransfer(_self.options.openId, filter, function (json) { if(json.type=="success"){ Showbo.Msg.alert('操作成功!'); } setTimeout(function(){ jQuery("#notifyEdit").remove(); if(jQuery(".mask").length>0){ jQuery(".mask").attr("style",'left: 0px; top: 0px; width: 100%; overflow: hidden; position: absolute; z-index: 500000; background-color: rgb(255, 255, 255)'); jQuery(".mask").attr("class",""); } },200); }.bind(_self)); } },function(){ }); jQuery(".ct").find(".se-select-name").click(function(){ _self.selectPerson(jQuery(_self.appArea)[0],"selectName","selectId",0); }); jQuery(".ct").find(".el-radio").click(function(){ jQuery(this).siblings().attr("class","el-radio"); jQuery(this).siblings().find("input:radio").attr("checked",false) jQuery(this).attr("class","el-radio is-checked"); jQuery(this).find("input:radio").attr("checked",true); var typeName = jQuery(this).find(".el-radio__label").text(); if(typeName == "转为团队成员"){ jQuery(this).parent().parent().next().show(); } if(typeName == "移出"){ jQuery(this).parent().parent().next().hide(); } }); }, customerEdit: function () { //编辑线索 _self = this; this.actions.getCustomerInfo(this.options.openId, function (json) { jQuery(_self.appArea).next().attr("style",""); jQuery(_self.appArea).next().attr("class","mask"); var jsonObj = json.data; var section_header = '
'+ '
基本信息
' var itemTemplateObject = _self.lp; debugger var section_conent = '
'; for ( i in itemTemplateObject){ var stype = itemTemplateObject[i].type; var notEmpty = itemTemplateObject[i].notEmpty?itemTemplateObject[i].notEmpty:"false"; var innerHtml = ''; if(stype=="textarea"){ innerHtml = ''; } if(stype=="select"){ innerHtml = '
'+((typeof(jsonObj[i])=="undefined")?"" : jsonObj[i])+'
'; } if(stype=="map"){ innerHtml = '
'; } if(i=="detailaddress"){ var location = ((typeof(jsonObj["location"])=="undefined")?"" : jsonObj["location"]); var lng = ((typeof(jsonObj["lng"])=="undefined")?"" : jsonObj["lng"]); var lat = ((typeof(jsonObj["lat"])=="undefined")?"" : jsonObj["lat"]); innerHtml = ''; } if(stype!="hide"){ section_conent = section_conent+'
'+itemTemplateObject[i].text+'
' + '
'+innerHtml+'
'; } } section_conent = section_conent + '
'; var section_button = '
'+ '
'; var htmlstr = section_header+section_conent+section_button; jQuery(".headMoreImg").notifyMe( 'left', 'default', '编辑客户', '', '', htmlstr, 'notifyEdit', 50 ); jQuery(".conent-value").each(function(index,element){ var cobj = jQuery(element).children().eq(0) var stype = jQuery(cobj).attr("stype"); if(stype=="datetime"){ _self.loadTimeContainer(jQuery(cobj).attr("id")); } if(stype=="select"){ var selectObjects = _self.app.lp.customer; for ( j in selectObjects){ if(j==jQuery(cobj).attr("id")){ var clp = itemTemplateObject[j]; var valueList = clp.value; var valueArr = valueList.split(","); if(valueArr.length>0){ var selectHtml = ''); jQuery(cobj).click(function(){ jQuery("[tid='"+jQuery(cobj).attr("id")+"']").css({"left":jQuery(cobj).offset().left-50,"top":jQuery(cobj).offset().top+30,"width":282}) jQuery("[tid='"+jQuery(cobj).attr("id")+"']").toggle(100); }); jQuery("[tid='"+jQuery(cobj).attr("id")+"']").children().click(function(){ debugger jQuery(cobj).text(jQuery(this).text()); jQuery("[tid='"+jQuery(cobj).attr("id")+"']").toggle(100); }); } } } } if(stype=="map"){ debugger _self.loadMap(); } } ); jQuery('.el-button-cancle').click(function(){ setTimeout(function(){ jQuery("#notifyEdit").remove(); if(jQuery(".mask").length>0){ jQuery(".mask").attr("style",'left: 0px; top: 0px; width: 100%; overflow: hidden; position: absolute; z-index: 500000; background-color: rgb(255, 255, 255)'); jQuery(".mask").attr("class",""); } },200); }); jQuery('.el-button-primary').click(function(){ var sflag = true; jQuery(".inline-input[notempty='true']").each(function(index,element){ if(jQuery(element).val()=="" && jQuery(element).text()==""){ sflag = false; var nameStr = jQuery(element).parent().prev().text()+'不能为空'; if(jQuery(element).nextAll(".empError").length>0)jQuery(element).nextAll(".empError").remove(); jQuery(element).parent().append('
'+nameStr+'
'); }else{ if(jQuery(element).nextAll(".empError").length>0)jQuery(element).nextAll(".empError").remove(); } }); if(sflag){ var filter = {}; filter = { customername:jQuery('div[lable="customername"]').next().children().eq(0).val(), level:jQuery('div[lable="level"]').next().children().eq(0).text(), industry:jQuery('div[lable="industry"]').next().children().eq(0).text(), source:jQuery('div[lable="source"]').next().children().eq(0).text(), telephone:jQuery('div[lable="telephone"]').next().children().eq(0).val(), cellphone:jQuery('div[lable="cellphone"]').next().children().eq(0).val(), website:jQuery('div[lable="website"]').next().children().eq(0).val(), location:jQuery('div[lable="detailaddress"]').next().children().eq(0).attr("location"), lng:jQuery('div[lable="detailaddress"]').next().children().eq(0).attr("lng"), lat:jQuery('div[lable="detailaddress"]').next().children().eq(0).attr("lat"), province:jQuery('div[lable="detailaddress"]').next().children().eq(0).attr("province"), city:jQuery('div[lable="detailaddress"]').next().children().eq(0).attr("city"), detailaddress:jQuery('div[lable="detailaddress"]').next().children().eq(0).val(), nexttime:jQuery('div[lable="nexttime"]').next().children().eq(0).val(), remark:jQuery('div[lable="remark"]').next().children().eq(0).val(), pinyin:((typeof(jsonObj["pinyin"])=="undefined")?"" : jsonObj["pinyin"]), pinyinInitial:((typeof(jsonObj["pinyinInitial"])=="undefined")?"" : jsonObj["pinyinInitial"]), islock:((typeof(jsonObj["islock"])=="undefined")?"" : jsonObj["islock"]), dealstatus:((typeof(jsonObj["dealstatus"])=="undefined")?"" : jsonObj["dealstatus"]), readerUserIds:((typeof(jsonObj["readerUserIds"])=="undefined")?"" : jsonObj["readerUserIds"]), writerUserIds:((typeof(jsonObj["writerUserIds"])=="undefined")?"" : jsonObj["writerUserIds"]), createuser:((typeof(jsonObj["createuser"])=="undefined")?"" : jsonObj["createuser"]), owneruser:((typeof(jsonObj["owneruser"])=="undefined")?"" : jsonObj["owneruser"]) }; _self.actions.updateCustomer(_self.options.openId, filter, function (json) { if(json.type=="success"){ Showbo.Msg.alert('保存成功!'); } setTimeout(function(){ jQuery("#notifyEdit").remove(); if(jQuery(".mask").length>0){ jQuery(".mask").attr("style",'left: 0px; top: 0px; width: 100%; overflow: hidden; position: absolute; z-index: 500000; background-color: rgb(255, 255, 255)'); jQuery(".mask").attr("class",""); } },200); }.bind(_self)); } }); jQuery(".inline-input[notempty='true']").blur( function () { if(jQuery(this).attr("stype")!="datetime"){ if(jQuery(this).val()=="" && jQuery(this).text()==""){ var nameStr = jQuery(this).parent().prev().text()+'不能为空'; if(jQuery(this).nextAll(".empError").length>0)jQuery(this).nextAll(".empError").remove(); jQuery(this).parent().append('
'+nameStr+'
'); }else{ if(jQuery(this).nextAll(".empError").length>0)jQuery(this).nextAll(".empError").remove(); } } }); }.bind(this)); }, contactsCreate: function () { //编辑联系人 _self = this; var htmlstr = ""; jQuery(_self.appArea).next().attr("style",""); jQuery(_self.appArea).next().attr("class","mask"); var section_header = '
'+ '
基本信息
'; var itemTemplateObject = _self.app.lp.contact.contactEdit; var section_conent = '
'; for ( i in itemTemplateObject){ var stype = itemTemplateObject[i].type; var notEmpty = itemTemplateObject[i].notEmpty?itemTemplateObject[i].notEmpty:"false"; var innerHtml = ''; if(stype=="textarea"){ innerHtml = ''; } if(stype=="select"){ innerHtml = '
'; } if(stype=="openSelect"){ innerHtml = ''; } section_conent = section_conent+'
'+itemTemplateObject[i].text+'
' + '
'+innerHtml+'
'; } section_conent = section_conent + '
'; var section_button = '
'+ '
'; htmlstr = section_header+section_conent+section_button; jQuery(".headMoreImg").notifyMe( 'left', 'default', "新建联系人", '', '', htmlstr, 'notifyEdit', 50 ); jQuery(".conent-value").each(function(index,element){ var cobj = jQuery(element).children().eq(0) var stype = jQuery(cobj).attr("stype"); if(stype=="datetime"){ _self.loadTimeContainer(jQuery(cobj).attr("id")); } if(stype=="select"){ var selectObjects = _self.app.lp.contact; for ( j in selectObjects){ if(j==jQuery(cobj).attr("id")){ var clp = itemTemplateObject[j]; var valueList = clp.value; var valueArr = valueList.split(","); if(valueArr.length>0){ var selectHtml = ''); jQuery(cobj).click(function(){ jQuery("[tid='"+jQuery(cobj).attr("id")+"']").css({"left":jQuery(cobj).offset().left-50,"top":jQuery(cobj).offset().top+30,"width":282}) jQuery("[tid='"+jQuery(cobj).attr("id")+"']").toggle(100); }); jQuery("[tid='"+jQuery(cobj).attr("id")+"']").children().click(function(){ debugger jQuery(cobj).text(jQuery(this).text()); jQuery("[tid='"+jQuery(cobj).attr("id")+"']").toggle(100); }); } } } } } ); jQuery('.el-button-cancle').click(function(){ setTimeout(function(){ jQuery("#notifyEdit").remove(); if(jQuery(".mask").length>0){ jQuery(".mask").attr("style",'left: 0px; top: 0px; width: 100%; overflow: hidden; position: absolute; z-index: 500000; background-color: rgb(255, 255, 255)'); jQuery(".mask").attr("class",""); } },200); }); jQuery('.el-button-primary').click(function(){ var sflag = true; jQuery(".inline-input[notempty='true']").each(function(index,element){ if(jQuery(element).val()=="" && jQuery(element).text()==""){ sflag = false; var nameStr = jQuery(element).parent().prev().text()+'不能为空'; if(jQuery(element).nextAll(".empError").length>0)jQuery(element).nextAll(".empError").remove(); jQuery(element).parent().append('
'+nameStr+'
'); }else{ if(jQuery(element).nextAll(".empError").length>0)jQuery(element).nextAll(".empError").remove(); } }); if(sflag) { var filter = {}; filter = { contactsname: jQuery('div[lable="contactsname"]').next().children().eq(0).val(), customerid: jQuery('#customername').attr("cid"), telephone: jQuery('div[lable="telephone"]').next().children().eq(0).val(), cellphone: jQuery('div[lable="cellphone"]').next().children().eq(0).val(), email: jQuery('div[lable="email"]').next().children().eq(0).val(), decision: jQuery('div[lable="decision"]').next().children().eq(0).text(), sex: jQuery('div[lable="sex"]').next().children().eq(0).text(), post: jQuery('div[lable="post"]').next().children().eq(0).val(), detailaddress: jQuery('div[lable="detailaddress"]').next().children().eq(0).val(), nexttime: jQuery('div[lable="nexttime"]').next().children().eq(0).val(), remark: jQuery('div[lable="remark"]').next().children().eq(0).val() }; debugger _self.actions.saveContacts(filter, function (json) { debugger if (json.type == "success") { Showbo.Msg.alert('保存成功!'); _self.loadContacts(); } setTimeout(function () { jQuery("#notifyEdit").remove(); if (jQuery(".mask").length > 0) { jQuery(".mask").attr("style", 'left: 0px; top: 0px; width: 100%; overflow: hidden; position: absolute; z-index: 500000; background-color: rgb(255, 255, 255)'); jQuery(".mask").attr("class", ""); } }, 200); }.bind(_self)); } }); jQuery(".inline-input[notempty='true']").blur( function () { if(jQuery(this).attr("stype")!="datetime" || jQuery(this).attr("stype")!="openSelect"){ if(jQuery(this).val()=="" && jQuery(this).text()==""){ var nameStr = jQuery(this).parent().prev().text()+'不能为空'; if(jQuery(this).nextAll(".empError").length>0)jQuery(this).nextAll(".empError").remove(); jQuery(this).parent().append('
'+nameStr+'
'); }else{ if(jQuery(this).nextAll(".empError").length>0)jQuery(this).nextAll(".empError").remove(); } } }); }, businessCreate: function(){ that = this; MWF.xDesktop.requireApp("CRM", "ChanceEdit", function(){ //console.log("this.lp",this.lp); var editForm = new MWF.xApplication.CRM.ChanceEdit(null,{},null, { app: this.app, container : this.app.content, lp : this.app.lp.chance, actions : this.actions, css : {}, customer :{"id":that.options.openCustomerId}, callback : function () { //editForm.create(); } }); editForm.create(); }.bind(this)); that.app.content.getElement("#customer").setProperty("value",that.options.openCustomerName); }, editTeam: function(nameList){ _self = this; var contentHtml = '
'+ '
权限:
'+ ''+ '
' Showbo.Msg.confirm('编辑权限',contentHtml,function(){ var filter = {}; filter = { distinguishName: nameList, } var val=jQuery(".ct").find('input:radio:checked').val(); if(val==1){ _self.actions.setTeamReader(_self.options.openId, filter, function (json) { if(json.type=="success"){ Showbo.Msg.alert('操作成功!'); _self.loadTeam(); } setTimeout(function(){ jQuery("#notifyEdit").remove(); if(jQuery(".mask").length>0){ jQuery(".mask").attr("style",'left: 0px; top: 0px; width: 100%; overflow: hidden; position: absolute; z-index: 500000; background-color: rgb(255, 255, 255)'); jQuery(".mask").attr("class",""); } },200); }.bind(_self)); }else{ _self.actions.setTeamWriter(_self.options.openId, filter, function (json) { if(json.type=="success"){ Showbo.Msg.alert('操作成功!'); _self.loadTeam(); } setTimeout(function(){ jQuery("#notifyEdit").remove(); if(jQuery(".mask").length>0){ jQuery(".mask").attr("style",'left: 0px; top: 0px; width: 100%; overflow: hidden; position: absolute; z-index: 500000; background-color: rgb(255, 255, 255)'); jQuery(".mask").attr("class",""); } },200); }.bind(_self)); } },function(){ }); jQuery(".el-radio").click(function(){ var robj = jQuery(this).find("input"); jQuery(this).siblings().find("input[type=radio]").removeAttr('checked'); }); }, addTeam: function () { //添加team成员 _self = this; var contentHtml = '
'+ '
选择团队成员:
+点击选择
'+ '
'+ '
权限:
'+ ''+ '
'+ '
'+ '
同时添加至:
'+ ''+ '
' Showbo.Msg.confirm('添加团队成员',contentHtml,function(){ //_self.confirmCustomerDealstatus(); var readOrWrite = ""; var checkFlag = true; var relationTypeList = []; jQuery(".ct").find(".is-checked").each(function(i,obj){ var typeStr = jQuery(obj).children(".el-radio__label").text(); if(typeStr=="只读"){ readOrWrite = "read" } if(typeStr=="读写"){ readOrWrite = "write" } }) jQuery(".ct").find(".el-checkbox__original").each(function(i,obj){ if(jQuery(obj).is(':checked')){ relationTypeList.push(jQuery(obj).val()); } }) if(jQuery("#selectId").text() == ""){ checkFlag = false; Showbo.Msg.alert('选择团队成员!'); } if(readOrWrite == ""){ checkFlag = false; Showbo.Msg.alert('请权限!'); } if(checkFlag){ var filter = {}; filter = { personList: (jQuery('#selectId').text()).split(","), relationTypeList: relationTypeList } _self.actions.addRelevantPerson(_self.options.openId,readOrWrite, filter, function (json) { if(json.type=="success"){ Showbo.Msg.alert('操作成功!'); _self.loadTeam(); } setTimeout(function(){ jQuery("#notifyEdit").remove(); if(jQuery(".mask").length>0){ jQuery(".mask").attr("style",'left: 0px; top: 0px; width: 100%; overflow: hidden; position: absolute; z-index: 500000; background-color: rgb(255, 255, 255)'); jQuery(".mask").attr("class",""); } },200); }.bind(_self)); } },function(){ }); jQuery(".ct").find(".se-select-name").click(function(){ _self.selectPerson(jQuery(_self.appArea)[0],"selectName","selectId",0); }); jQuery(".ct").find(".el-radio").click(function(){ jQuery(this).siblings().attr("class","el-radio"); jQuery(this).siblings().find("input:radio").attr("checked",false) jQuery(this).attr("class","el-radio is-checked"); jQuery(this).find("input:radio").attr("checked",true); var typeName = jQuery(this).find(".el-radio__label").text(); }); }, deleteTeam: function(){ _self = this; Showbo.Msg.confirm('提示','此操作将移除这些团队成员是否继续?',function(){ var nameList = []; jQuery(".el-table__body").find("input:checked").each(function(index,element){ var nobj = jQuery(element).parent().parent().next(); nameList.push(jQuery(nobj).attr("aid")); }); if(nameList.length<1){ Showbo.Msg.alert('请选择要删除的相关团队成员!'); }else{ var filter = {}; filter = { distinguishName: nameList } _self.actions.removeTeamMember(_self.options.openId,filter, function (json) { if(json.type=="success"){ Showbo.Msg.alert('操作成功!'); _self.loadTeam(); } }.bind(self)); } setTimeout(function(){ jQuery("#notifyEdit").remove(); if(jQuery(".mask").length>0){ jQuery(".mask").attr("style",'left: 0px; top: 0px; width: 100%; overflow: hidden; position: absolute; z-index: 500000; background-color: rgb(255, 255, 255)'); jQuery(".mask").attr("class",""); } },200); },function(){ }); }, loadEvent: function(){ that = this; jQuery(that.sectionArea).find('.tabPanel div').click(function(){ debugger jQuery(this).addClass('hit').siblings().removeClass('hit'); jQuery(that.sectionArea).find('.panes>div:eq('+jQuery(this).index()+')').show().siblings().hide(); that.createTypeHtml(); }); jQuery(that.sectionArea).find('.headMoreBottonDiv').click(function(){ jQuery(that.sectionArea).find(".el-dropdown-menu").toggle(100); }); jQuery(that.sectionArea).find('.el-dropdown-menu__item').click(function(){ debugger if(jQuery(this).text()=="放入公海"){ that.putToCustomerPool(); } if(jQuery(this).text()=="更改成交状态"){ that.transformCustomerDealstatus(); } if(jQuery(this).text()=="锁定"){ that.lockCustomer(); } if(jQuery(this).text()=="解锁"){ that.unLockCustomer(); } if(jQuery(this).text()=="删除"){ } //---for记录类型 if(jQuery(this).parent().attr("tid")=="recordType"){ jQuery(that.sectionArea).find(".se-select-name").text(jQuery(this).text()); jQuery(this).parent().toggle(100); } }); jQuery(that.sectionArea).find('.headMoveBottonDiv').click(function(){ that.transfer(); }); jQuery(that.sectionArea).find('.headEditBottonDiv').click(function(){ that.customerEdit(); }); jQuery(that.sectionArea).find('#bar-file').change(function(event) { var files = event.target.files; debugger jQuery(that.sectionArea).find('.fileList').empty(); if (files && files.length > 0) { // 获取目前上传的文件 var fileListHtml = '
'; for(var i=0;i
'+file.name+'
'+that.toDecimal(fsize)+'kb
'+that.getFormateTime(lastModifiedDate)+'
'; } fileListHtml = fileListHtml+''; jQuery(that.sectionArea).find('.mix-container').append(fileListHtml); /* file = files[0]; // 来在控制台看看到底这个对象是什么 console.log(file); var filter = {}; filter = { file:file, fileName:file.name }; debugger var formdata=new FormData(); formdata.append("fileName",file.name); formdata.append("file",file); that.actions.updateAttachment(that.options.clueId, "leads", formdata,file, function (json) { debugger if(json.type=="success"){ Showbo.Msg.alert('附件上传成功!'); } }.bind(that)); /!*!// 那么我们可以做一下诸如文件大小校验的动作 if(file.size > 1024 * 1024 * 2) { alert('图片大小不能超过 2MB!'); return false; }*!/ // 下面是关键的关键,通过这个 file 对象生成一个可用的图像 URL // 获取 window 的 URL 工具 var URL = window.URL || window.webkitURL; // 通过 file 生成目标 url var imgURL = URL.createObjectURL(file); // 用这个 URL 产生一个 将其显示出来 //jQuery('.fbpj .container').prev().find("img").attr('src', imgURL); jQuery('.mix-container').append('
'); // 使用下面这句可以在内存中释放对此 url 的伺服,跑了之后那个 URL 就无效了 //URL.revokeObjectURL(imgURL); */ } }); jQuery(that.sectionArea).find('.se-send').click(function(){ that.sendRecord(); }); jQuery(that.sectionArea).find('.el-dropdown-selfdefine').click(function(){ jQuery(that.sectionArea).find("[tid='recordType']").toggle(100); }); }, sendRecord: function () { that = this; //var objFile = document.getElementById("bar-file"); var filters = {}; filters = { types:"customer", typesid:that.options.openId, content:jQuery(that.sectionArea).find('.el-textarea__inner').val(), category:jQuery(that.sectionArea).find('.se-select-name').text(), nexttime:jQuery(that.sectionArea).find('.hasDatepicker').val(), businessids:"", contactsids:"", createuser:"" }; that.actions.createRecord(filters,function(json){ if(json.type=="success"){ Showbo.Msg.alert('跟进记录发布成功!'); var objFile = jQuery(that.sectionArea).find('#bar-file')[0].files; jQuery(objFile).each(function(index,file){ var filter = {}; filter = { file:file, fileName:file.name }; debugger var formdata=new FormData(); formdata.append("fileName",file.name); formdata.append("file",file); that.actions.updateAttachment("att",json.data.id, "record", formdata,file, function (attjson) { debugger /*if(json.type=="success"){ Showbo.Msg.alert('附件上传成功!'); }*/ }.bind(that)); } ); that.loadRecord(); } }.bind(that),function(xhr,text,error){ }.bind(that)); }, loadRecord: function(){ that = this; this.actions.getRecord(this.options.openId, function (json) { if(json.type=="success"){ var recordDatas = json.data; jQuery(that.sectionArea).find(".fl-c").remove(); var logItemHtml = ""; for ( i in recordDatas){ if(i0){ attHtml = attHtml+'
' } if(recordData.attachmentList.length>0){ attHtml = attHtml+'
'; var attList = recordData.attachmentList; for(j in attList){ if(j'+ '
'+attData.name+'('+that.toDecimal(attData.length)+'KB)
'+ '
' } } attHtml = attHtml+''; } logItemHtml = logItemHtml+'
'+ '
'+ '
'+recordData.person.name+'
'+recordData.updateTime+'
'+ '
'+recordData.content+'
'+attHtml+ '
'+ '
' } } if(logItemHtml!=""){ jQuery(that.sectionArea).find(".load").before(logItemHtml); } if(recordDatas.length<1){ jQuery(that.sectionArea).find(".load").hide(); jQuery(that.sectionArea).find(".empty-mask").show(); } jQuery(".aname").click(function(){ var attUrl = 'http://172.16.92.55:20020/x_wcrm_assemble_control/jaxrs/attachment/download/'+jQuery(this).attr("aid")+'/work/'+jQuery(this).attr("wcrm") window.open(attUrl); }); } }.bind(this)); }, open: function (e) { this.fireEvent("queryOpen"); this._open(); this.fireEvent("postOpen"); }, create: function () { this.fireEvent("queryCreate"); this.isNew = true; this._open(); this.fireEvent("postCreate"); }, edit: function () { this.fireEvent("queryEdit"); this.isEdited = true; this._open(); this.fireEvent("postEdit"); }, _open: function () { if( this.options.hasMask ){ this.formMaskNode = new Element("div.formMaskNode", { "styles": this.css.formMaskNode, "events": { "mouseover": function (e) { e.stopPropagation(); }, "mouseout": function (e) { e.stopPropagation(); }, "click": function (e) { e.stopPropagation(); } } }).inject( this.container || this.app.content); } this.formAreaNode = new Element("div.formAreaNode", { "styles": this.css.formAreaNode }); this.createFormNode(); this.formAreaNode.inject(this.formMaskNode || this.container || this.app.content, "after"); this.formAreaNode.fade("in"); this.setFormNodeSize(); this.setFormNodeSizeFun = this.setFormNodeSize.bind(this); if( this.app )this.app.addEvent("resize", this.setFormNodeSizeFun); if (this.options.draggable && this.formTopNode) { var size = (this.container || this.app.content).getSize(); var nodeSize = this.formAreaNode.getSize(); this.formAreaNode.makeDraggable({ "handle": this.formTopNode, "limit": { "x": [0, size.x - nodeSize.x], "y": [0, size.y - nodeSize.y] } }); } }, createFormNode: function () { var _self = this; this.formNode = new Element("div.formNode", { "styles": this.css.formNode }).inject(this.formAreaNode); if (this.options.hasTop) { this.createTopNode(); } if (this.options.hasIcon) { this.formIconNode = new Element("div.formIconNode", { "styles": this.isNew ? this.css.formNewNode : this.css.formIconNode }).inject(this.formNode); } this.createContent(); //formContentNode.set("html", html); if (this.options.hasBottom) { this.createBottomNode(); } this._setCustom(); if( this.options.hasScroll ){ //this.setScrollBar(this.formTableContainer) MWF.require("MWF.widget.ScrollBar", function () { new MWF.widget.ScrollBar(this.formTableContainer, { "indent": false, "style": "default", "where": "before", "distance": 30, "friction": 4, "axis": {"x": false, "y": true}, "onScroll": function (y) { //var scrollSize = _self.viewContainerNode.getScrollSize(); //var clientSize = _self.viewContainerNode.getSize(); //var scrollHeight = scrollSize.y - clientSize.y; //if (y + 200 > scrollHeight && _self.view && _self.view.loadElementList) { // if (!_self.view.isItemsLoaded) _self.view.loadElementList(); //} } }); }.bind(this)); } }, createContent: function () { this.formContentNode = new Element("div.formContentNode", { "styles": this.css.formContentNode }).inject(this.formNode); this.formTableContainer = new Element("div.formTableContainer", { "styles": this.css.formTableContainer }).inject(this.formContentNode); this.formTableArea = new Element("div.formTableArea", { "styles": this.css.formTableArea, "text":"loading..." }).inject(this.formTableContainer); this._createTableContent(); }, createBottomNode: function () { this.formBottomNode = new Element("div.formBottomNode", { "styles": this.css.formBottomNode }).inject(this.formNode); this._createBottomContent() }, createTopNode: function () { if (!this.formTopNode) { this.formTopNode = new Element("div.formTopNode", { "styles": this.css.formTopNode }).inject(this.formNode); this.formTopIconNode = new Element("div", { "styles": this.css.formTopIconNode }).inject(this.formTopNode); this.formTopTextNode = new Element("div", { "styles": this.css.formTopTextNode, "text": this.options.title + ( this.data.title ? ("-" + this.data.title ) : "" ) }).inject(this.formTopNode); if (this.options.closeAction) { this.formTopCloseActionNode = new Element("div", {"styles": this.css.formTopCloseActionNode}).inject(this.formTopNode); this.formTopCloseActionNode.addEvent("click", function () { this.close(); }.bind(this)) } this.formTopContentNode = new Element("div", { "styles": this.css.formTopContentNode }).inject(this.formTopNode); this._createTopContent(); } }, _createTopContent: function () { }, _createTableContent: function () { this.loadFormData(); /* var Ttype = "clue"; this.actions.getProfiles(Ttype,function(json){ this.profileData = json.data; if(this.data.id){ this.actions.getCustomerInfo(this.data.id,function(json){ this.customerData = json.data; this.loadFormData(); this.createCustomBottom(); }.bind(this)); }else{ this.loadFormData(); this.createCustomBottom(); } }.bind(this)); */ }, _createBottomContent: function () { this.cancelActionNode = new Element("div.formCancelActionNode", { "styles": this.css.formCancelActionNode, "text": this.lp.actionCancel }).inject(this.formBottomNode); if (this.options.isNew || this.options.isEdited) { //this.ok(); this.okActionNode = new Element("div.formOkActionNode", { "styles": this.css.formOkActionNode, "text": this.lp.actionConfirm }).inject(this.formBottomNode); this.okActionNode.addEvent("click", function (e) { this.ok(e); }.bind(this)); } this.cancelActionNode.addEvent("click", function (e) { this.cancel(e); }.bind(this)); }, loadFormData:function(){ var tmpData={}; this.loadForm(); /* var html = "" + "" + " " + " " + "" + " " + " " + "" + " " + " " + "" + " " + " " + "" + " " + " " + "" + " " + " " + "" + " " + " " + "" + " " + " " + "" + " " + " " + "" + " " + " " + "" + " " + " " + "" + " " + " " + "" + " " + " " + "" + " " + " " + "" + " " + " " + "" + " " + " " + "" + "
*
" this.formTableArea.set("html", html); this.TCustomerType = this.formTableArea.getElement("#TCustomerType"); this.TCustomerLevel = this.formTableArea.getElement("#TCustomerLevel"); this.TSource = this.formTableArea.getElement("#TSource"); this.TIndustryFirst = this.formTableArea.getElement("#TIndustryFirst"); this.TIndustrySecond = this.formTableArea.getElement("#TIndustrySecond"); this.TProvince = this.formTableArea.getElement("#TProvince"); this.TCity = this.formTableArea.getElement("#TCity"); this.TArea = this.formTableArea.getElement("#TArea"); this.TCustomerStatus = this.formTableArea.getElement("#TCustomerStatus"); this.TCustomerGrade = this.formTableArea.getElement("#TCustomerGrade"); var size = {"width":230,"height":30}; this.TIndustryFirst.setStyles({"float":"left"}); this.TIndustrySecond.setStyles({"float":"left","margin-left":"10px"}); //客户类型 this.TCustomerTypeSelector = new MWF.xApplication.CRM.Template.Select(this.TCustomerType,this, this.actions, size); this.TCustomerTypeSelector.load(); alert(JSON.stringify(this.profileData.customertype_config)) this.TCustomerTypeSelector.setList(this.profileData.customertype_config); if(this.customerData && this.customerData.customertype){ this.TCustomerTypeSelector.selectValueDiv.set({"text":this.customerData.customertype}); this.TCustomerTypeSelector.node.set("value",this.customerData.customertype); } //客户级别 this.TCustomerLevelSelector = new MWF.xApplication.CRM.Template.Select(this.TCustomerLevel,this, this.actions, size); this.TCustomerLevelSelector.load(); this.TCustomerLevelSelector.setList(this.profileData.level_config); if(this.customerData && this.customerData.level){ this.TCustomerLevelSelector.selectValueDiv.set({"text":this.customerData.level}); this.TCustomerLevelSelector.node.set("value",this.customerData.level); } //来源 this.TSourceSelector = new MWF.xApplication.CRM.Template.Select(this.TSource,this, this.actions, size); this.TSourceSelector.load(); this.TSourceSelector.setList(this.profileData.source_config); if(this.customerData && this.customerData.source){ this.TSourceSelector.selectValueDiv.set({"text":this.customerData.source}); this.TSourceSelector.node.set("value",this.customerData.source); } //行业 this.TIndustryFirstSelector = new MWF.xApplication.CRM.Template.Select(this.TIndustryFirst,this, this.actions, {"width":230,"height":30}); this.TIndustrySecondSelector = new MWF.xApplication.CRM.Template.Select(this.TIndustrySecond,this, this.actions, {"width":230,"height":30,"available":"no"}); this.TIndustrySecondSelector.load(); this.TIndustryFirstSelector.load(); if(this.customerData && this.customerData.industryfirst){ this.TIndustryFirstSelector.selectValueDiv.set({"text":this.customerData.industryfirst}); this.TIndustryFirstSelector.node.set("value",this.customerData.industryfirst); this.profileData.industry_config.childNodes.each(function(d){ if(d.configname == this.customerData.industryfirst){ tmpData = d; } }.bind(this)); this.TIndustrySecondSelector.setList(tmpData); this.TIndustrySecond.set("available","yes"); this.TIndustrySecond.setStyles({"background-color":""}); } if(this.customerData && this.customerData.industrysecond){ this.TIndustrySecondSelector.selectValueDiv.set({"text":this.customerData.industrysecond}); this.TIndustrySecondSelector.node.set("value",this.customerData.industrysecond); this.profileData.industry_config.childNodes.each(function(d){ if(d.configname == this.customerData.industryfirst){ tmpData = d; } }.bind(this)); this.TIndustrySecondSelector.setList(tmpData); this.TIndustrySecond.set("available","yes"); this.TIndustrySecond.setStyles({"background-color":""}); } this.TIndustryFirstSelector.setList(this.profileData.industry_config,function(d){ if(this.TIndustryFirst.get("value") == this.lp.defaultSelect){ this.TIndustrySecondSelector.createDefault(); this.TIndustrySecondSelector.setList(); this.TIndustrySecond.set("available","no"); this.TIndustrySecond.setStyles({"background-color":"#eeeeee"}) }else{ this.TIndustrySecondSelector.createDefault(); this.TIndustrySecondSelector.setList(d); this.TIndustrySecond.set("available","yes"); this.TIndustrySecond.setStyles({"background-color":""}); } }.bind(this)); //省、市、区 this.TProvinceSelector = new MWF.xApplication.CRM.Template.Select(this.TProvince,this, this.actions, {"width":150,"height":30}); this.TProvinceSelector.load({},function(){ this.actions.getProvinceList(function(json){ this.TProvinceSelector.setAddress(json.data,function(d){ //city if(this.TProvince.get("value") == this.lp.defaultSelect){ this.TCitySelector.createDefault(); this.TCitySelector.setAddress(); this.TCity.set("available","no"); this.TCity.setStyles({"background-color":"#eeeeee"}); }else{ this.actions.getCityList({pid: d.cityid},function(json){ this.TCitySelector.createDefault(); this.TCitySelector.setAddress(json.data,function(dd){ //area if(this.TCity.get("value") == this.lp.defaultSelect){ this.TAreaSelector.createDefault(); this.TAreaSelector.setAddress(); this.TArea.set("available","no"); this.TArea.setStyles({"background-color":"#eeeeee"}); }else{ this.actions.getAreaList({pid:dd.cityid},function(json){ this.TAreaSelector.createDefault(); this.TAreaSelector.setAddress(json.data); this.TArea.set("available","yes"); this.TArea.setStyles({"background-color":""}); }.bind(this)); } }.bind(this)); this.TCity.set("available","yes"); this.TCity.setStyles({"background-color":""}); }.bind(this)); } this.TAreaSelector.createDefault(); this.TAreaSelector.setAddress(); this.TArea.set("available","no"); this.TArea.setStyles({"background-color":"#eeeeee"}); }.bind(this)) }.bind(this)) }.bind(this)); this.TCitySelector = new MWF.xApplication.CRM.Template.Select(this.TCity,this, this.actions, {"width":150,"height":30,"available":"no"}); this.TCitySelector.load(); this.TAreaSelector = new MWF.xApplication.CRM.Template.Select(this.TArea,this, this.actions, {"width":150,"height":30,"available":"no"}); this.TAreaSelector.load(); if(this.customerData && this.customerData.province){ //省 this.TProvinceSelector.selectValueDiv.set({"text":this.customerData.province}); this.TProvinceSelector.node.set("value",this.customerData.province); } if(this.customerData && this.customerData.city){ //市 if(this.customerData && this.customerData.province){ this.actions.getCityListByName({"regionname":this.customerData.province}, function(json){ this.TCitySelector.setAddress(json.data,function(dd){ //area if(this.TCity.get("value") == this.lp.defaultSelect){ this.TAreaSelector.createDefault(); this.TAreaSelector.setAddress(); this.TArea.set("available","no"); this.TArea.setStyles({"background-color":"#eeeeee"}); }else{ this.actions.getAreaList({pid:dd.cityid},function(json){ this.TAreaSelector.createDefault(); this.TAreaSelector.setAddress(json.data); this.TArea.set("available","yes"); this.TArea.setStyles({"background-color":""}); }.bind(this)); } }.bind(this)); }.bind(this)); } this.TCitySelector.selectValueDiv.set({"text":this.customerData.city}); this.TCitySelector.node.set("value",this.customerData.city); this.TCity.set("available","yes"); this.TCity.setStyles({"background-color":""}); } if(this.customerData && this.customerData.county){ //区 if(this.customerData && this.customerData.city){ this.actions.getAreaListByName({"regionname":this.customerData.city}, function(json){ this.TAreaSelector.setAddress(json.data); }.bind(this)); } this.TAreaSelector.selectValueDiv.set({"text":this.customerData.county}); this.TAreaSelector.node.set("value",this.customerData.county); this.TArea.set("available","yes"); this.TArea.setStyles({"background-color":""}); } this.TProvince.setStyles({"float":"left"}); this.TCity.setStyles({"float":"left","margin-left":"10px"}); this.TArea.setStyles({"float":"left","margin-left":"10px"}); this.TCustomerStatusSelector = new MWF.xApplication.CRM.Template.Select(this.TCustomerStatus,this, this.actions, size); this.TCustomerStatusSelector.load(); this.TCustomerStatusSelector.setList(this.profileData.state_config); if(this.customerData && this.customerData.state){ this.TCustomerStatusSelector.selectValueDiv.set({"text":this.customerData.state}); this.TCustomerStatusSelector.node.set("value",this.customerData.state); } this.TCustomerGradeSelector = new MWF.xApplication.CRM.Template.Select(this.TCustomerGrade,this, this.actions, size); this.TCustomerGradeSelector.load(); this.TCustomerGradeSelector.setList(this.profileData.customerrank_config); this.TMap = this.formTableArea.getElement("#mapDiv"); this.TMap.addEvents({ "mousewheel":function(e){ e.stopPropagation(); } }); this.mapLocation = this.formTableArea.getElement("#mapLocation"); this.mapLocation.setStyles({ "width": "99%", "text-indent":"5px", "border":"1px solid #999", "background-color":"#eee", "border-radius": "3px", "box-shadow": "0px 0px 6px #eee", "height": "26px" }); MWF.xDesktop.requireApp("CRM", "BaiduMap", function(){ this.bMap = new MWF.xApplication.CRM.BaiduMap(this.TMap,this.app,this,this.actions,{"from":"newCustomer"}); var mapData = {}; if(this.customerData && this.customerData.addresslatitude){ mapData.latitude = this.customerData.addresslatitude } if(this.customerData && this.customerData.addresslongitude){ mapData.longitude = this.customerData.addresslongitude } this.bMap.load(mapData); }.bind(this)); */ }, ok: function (e) { this.fireEvent("queryOk"); var data = this.form.getResult(true, ",", true, false, true); debugger; if (data) { this._ok(data, function (json) { if (json.type == "error") { if( this.app )this.app.notice(json.message, "error"); } else { if( this.formMaskNode )this.formMaskNode.destroy(); this.formAreaNode.destroy(); if (this.explorer && this.explorer.view)this.explorer.view.reload(); if( this.app )this.app.notice(this.isNew ? this.lp.createSuccess : this.lp.updateSuccess, "success"); this.fireEvent("postOk"); } }.bind(this)) } }, loadForm: function(){ _self = this; this.form = new MForm(this.formTableArea, this.data, { style: "default", isEdited: this.isEdited || this.isNew, itemTemplate: this.lp },this.app,this.css); var html = ""; var itemTemplateObject = this.form.itemTemplate; debugger for ( i in itemTemplateObject){ html = html+"" + " " + " " + ""; } html = html+"
"+itemTemplateObject[i].text+"
"; debugger this.formTableArea.set("html", html); this.form.load(); if(!this.isNew){ this.actions.getCustomerInfo(this.options.openId, function (json) { debugger var jsonObj = json.data; var spanObject = this.formTableArea.getElements("span"); for ( j in spanObject){ if(j < spanObject.length){ debugger if(spanObject[j].get("name")!=null){ var fieldName = spanObject[j].get("name"); for (var prop in jsonObj){ if(prop == fieldName){ spanObject[j].set("text",jsonObj[prop]); } } } } } }.bind(this)); } //this.nexttime = this.formTableArea.getElement("#nexttime"); //this.nexttime.addEvent("click",function(){ //_self.selectCalendar(this); //}); this.formTableArea.getElements("textarea").setStyles({"height":"100px","overflow":"auto","color":"#666666"}); this.formTableArea.getElements("input").setStyles({"color":"#666666"}); }, loadMap: function(){ debugger _self = this; _self.mapDiv = jQuery("#setMap")[0]; jQuery(".section-conent").css("height","700px"); if(_self.mapDiv)_self.mapDiv.empty(); if(_self.addressModule) delete _self.addressModule; MWF.xDesktop.requireApp("CRM", "AddressExplorer", function(){ _self.addressModule = new MWF.xApplication.CRM.AddressExplorer(_self.mapDiv,_self,_self.actions,{}); _self.addressModule.load(); }.bind(_self)) }, getItemTemplate: function( lp ){ _self = this; return { customername: { text: lp.customername, type: "text", //attr : {placeholder:lp.name}, notEmpty:true, value:this.customerData && this.customerData.customername?this.customerData.customername:"" }, level:{ type: "select", text: lp.level, notEmpty:true, value:this.app.lp.customer.level.value }, industry: { type: "select", notEmpty:true, text: lp.industry, value:this.app.lp.customer.industry.value }, source: { type: "select", text: lp.source, notEmpty:true, value:this.app.lp.customer.source.value }, /*dealstatus:{ type: "hide", text: lp.dealstatus, value:this.app.lp.customer.dealstatus.value },*/ telephone:{ type: "text", notEmpty:true, text: lp.telephone, value:this.app.lp.clue.level.value }, website: { text:lp.website, type: "text" }, nexttime: { text:lp.nexttime, notEmpty:true, attr : {id:"nexttime"}, type: "datetime" }, cellphone: { text:lp.cellphone, type: "text" }, detailaddress: { text:lp.detailaddress, type: "text" }, remark: { text:lp.remark, type: "textarea" }, location: { text:lp.location, type: "map" } } }, getContactTemplate: function( lp ){ _self = this; return { contactsname: { text: lp.contactsname, type: "text", notEmpty:true }, customername: { text: lp.customername, type: "openSelect", notEmpty:true }, telephone:{ type: "text", text: lp.telephone, }, cellphone: { text:lp.cellphone, type: "text" }, email:{ type: "text", text: lp.email }, decision: { type: "select", text: lp.decision, value:this.app.lp.contact.decision.value }, post: { text:lp.post, type: "text" }, sex: { type: "select", text: lp.sex, value:this.app.lp.contact.sex.value }, detailaddress: { text:lp.detailaddress, type: "text" }, nexttime: { text:lp.nexttime, attr : {id:"nexttime"}, type: "datetime" }, remark: { text:lp.remark, type: "textarea" } } }, selectPerson: function (showContainer,nameId,fullNameId,count) { var options = { "type" : "", "types": ["person"], "values": this.configData, "count": count, "zIndex": 50000, "onComplete": function(items){ MWF.require("MWF.widget.O2Identity", function(){ var invitePersonList = []; var fullPersonList = []; this.configData = []; this.process = null; items.each(function(item){ var _self = this; if( item.data.distinguishedName.split("@").getLast().toLowerCase() == "i" ){ var person = new MWF.widget.O2Identity(item.data, it.form.getItem("invitePersonList").container, {"style": "room"}); invitePersonList.push( item.data.distinguishedName ); }else{ //var person = new MWF.widget.O2Person(item.data, it.form.getItem("invitePersonList").container, {"style": "room"}); invitePersonList.push(item.data.name); fullPersonList.push(item.data.distinguishedName); var personJson = { "name": item.data.name, "distinguishedName": item.data.distinguishedName, "employee":item.data.employee } debugger this.configData.push(personJson); } }.bind(this)); if(items.length==0){ document.getElementById(nameId).innerHTML = "+点击选择" }else{ document.getElementById(nameId).innerHTML = invitePersonList.join(","); if(fullNameId!=""){ document.getElementById(fullNameId).innerHTML = fullPersonList.join(","); } } }.bind(this)); }.bind(this) }; var selector = new MWF.O2Selector(showContainer, options); }, getFormateTime: function( timeStr ){ _self = this; var date= new Date(timeStr); return date.getFullYear()+'-'+_self.checkTime(date.getMonth()+1)+'-'+_self.checkTime(date.getDate())+ ' ' + _self.checkTime(date.getHours()) + ':' + _self.checkTime(date.getMinutes()) + ':' + _self.checkTime(date.getSeconds()); }, checkTime: function( i ){ if(i<10){ i = '0'+i } return i; }, toDecimal: function(x){ if(x==""){ return ""; }else{ var f = parseFloat(x); if (isNaN(f)) { return x; } f = Math.round(x*100)/100; return f; } }, /*selectCalendar : function( calendarNode ){ MWF.require("MWF.widget.Calendar", function(){ var calendar = new MWF.widget.Calendar( calendarNode, { "style": "xform", "isTime": false "target": this.app.content }); calendar.show(); }.bind(this)); },*/ createCustomBottom:function(){ this.okActionNode = new Element("div.formOkActionNode", { "styles": this.css.formOkActionNode, "text": this.lp.actionConfirm }).inject(this.formBottomNode); this.okActionNode.addEvent("click", function (e) { this.ok(e); }.bind(this)); }, _ok: function (data, callback) { var saveDataStr = ""; for ( i in this.data){ saveDataStr = saveDataStr+"'"+i+"':'"+this.data[i]+"',"; } debugger; saveDataStr = "'{"+saveDataStr.replace(/'/g, '"')+"}'"; debugger; //var saveData = JSON.parse(saveDataStr); var saveData = eval('(' + saveDataStr.substring(1,saveDataStr.length - 1) + ')'); debugger; //alert(JSON.stringify(saveData)) this.app.createShade(); this.actions.saveClue(saveData,function(json){ this.app.destroyShade(); this.app.notice(this.lp.saveSuccess,"success"); this.close(); this.fireEvent("reloadView",json); }.bind(this),function(xhr,text,error){ this.app.showErrorMessage(xhr,text,error); this.app.destroyShade(); }.bind(this)); } });