代码拉取完成,页面将自动刷新
MWF.xApplication.CRM.ClueEdit = 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.clue.clueEdit;
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;
debugger
},
load: function () {
this.createForm();
},
createForm:function(){
this.allArrowArr = [];
if (this.options.isNew) {
this.create();
} else if (this.options.isEdited) {
this.edit();
} else {
this.open();
}
this.formContentNode.addEvents({
"click": function () {
if(this.listContentDiv){
this.listContentDiv.destroy();
}
if(this.allArrowArr.length>0){
this.allArrowArr.each(function(d){
d.setStyles({
"background":"url(/x_component_CRM/$Template/default/icons/arrow.png) no-repeat center"
});
}.bind(this))
}
}.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 = "<table width='100%' bordr='0' cellpadding='5' cellspacing='0' styles='formTable'>" +
"<tr>" +
" <td styles='formTableTitle'><span lable='TCustomerName'></span><span style='color:#f00'>*</span></td>" +
" <td styles='formTableValue' item='TCustomerName'></td>" +
"</tr><tr>" +
" <td styles='formTableTitle' lable='TCustomerType'></td>" +
" <td styles='formTableValue'><div id='TCustomerType'></div></td>" +
"</tr><tr>" +
" <td styles='formTableTitle' lable='TCustomerLevel'></td>" +
" <td styles='formTableValue'><div id='TCustomerLevel'></div></td>" +
"</tr><tr>" +
" <td styles='formTableTitle' lable='TSource'></td>" +
" <td styles='formTableValue'><div id='TSource'></div></td>" +
"</tr><tr>" +
" <td styles='formTableTitle' lable='TIndustryFirst'></td>" +
" <td styles='formTableValue'><div id='TIndustryFirst'></div><div id='TIndustrySecond'></div></td>" +
"</tr><tr>" +
" <td styles='formTableTitle' lable='TDistrict'></td>" +
" <td styles='formTableValue'><div id='TProvince'></div><div id='TCity'></div><div id='TArea'></div></td>" +
"</tr><tr>" +
" <td styles='formTableTitle' lable='TStreet'></td>" +
" <td styles='formTableValue' item='TStreet'></td>" +
"</tr><tr>" +
" <td styles='formTableTitle' lable='TLocation'></td>" +
" <td styles='formTableValue'><div style='width:100%;height:30px;'><input type='text' placeholder='"+this.lp.TLocationNotice+"' id='mapLocation' disabled/></div></td>" +
"</tr><tr>" +
" <td styles='formTableTitle'></td>" +
" <td styles='formTableValue'><div id='mapDiv' styles='mapDiv'></div></td>" +
"</tr><tr>" +
" <td styles='formTableTitle' lable='TTelphone'></td>" +
" <td styles='formTableValue' item='TTelphone'></td>" +
"</tr><tr>" +
" <td styles='formTableTitle' lable='TFax'></td>" +
" <td styles='formTableValue' item='TFax'></td>" +
"</tr><tr>" +
" <td styles='formTableTitle' lable='TRemark'></td>" +
" <td styles='formTableValue' item='TRemark'></td>" +
"</tr><tr>" +
" <td styles='formTableTitle' lable='TWebSite'></td>" +
" <td styles='formTableValue' item='TWebSite'></td>" +
"</tr><tr>" +
" <td styles='formTableTitle' lable='TEmail'></td>" +
" <td styles='formTableValue' item='TEmail'></td>" +
"</tr><tr>" +
" <td styles='formTableTitle' lable='TCustomerStatus'></td>" +
" <td styles='formTableValue'><div id='TCustomerStatus'></div></td>" +
"</tr><tr>" +
" <td styles='formTableTitle' lable='TCustomerGrade'></td>" +
" <td styles='formTableValue'><div id='TCustomerGrade'></div></td>" +
"</tr>" +
"</table>"
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.getItemTemplate(this.lp )
},this.app,this.css);
var html = "<table width='100%' bordr='0' cellpadding='5' cellspacing='0' styles='formTable'>";
var itemTemplateObject = this.form.itemTemplate;
debugger
for ( i in itemTemplateObject){
html = html+"<tr>" +
" <td styles='formTableTitle'><span lable='"+i+"'>"+itemTemplateObject[i].text+"</td>" +
" <td styles='formTableValue' item='"+i+"'></td>" +
"</tr>";
}
html = html+"</table>";
debugger
this.formTableArea.set("html", html);
this.form.load();
if(!this.isNew){
this.actions.getClueInfo(this.options.clueId, 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"});
},
getItemTemplate: function( lp ){
_self = this;
return {
name: {
text: lp.name,
type: "text",
//attr : {placeholder:lp.name},
notEmpty:true,
value:this.customerData && this.customerData.customername?this.customerData.customername:""
},
source:{
text: lp.source
},
telephone: {
text: lp.telephone
},
cellphone: {
text: lp.cellphone
},
industry:{
text: lp.industry
},
level:{
text: lp.level
},
address: {
text: lp.address,
name:"address",
type: "textarea",
value:this.customerData && this.customerData.address?this.customerData.address:""
},
nexttime: {
text: lp.nexttime,
name:"nexttime",
attr : {id:"nexttime"},
tType: "datetime"
},
remark: {
text: lp.remark,
name:"remark",
type: "textarea"
}
}
},
/*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));
}
});
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。