?? custdevelplan.js
字號:
Ext.namespace("CRM.saleManage");
var chcId; // 全局變量,用來獲取銷售機會編號
// 顯示制定開發計劃窗體。。
function showCreatePlanWin() {
var panel = new custdevelPlanPanel();
panel.edit();
};
// 顯示執行開發計劃的窗體。。。。
function showExePlanWin() {
if (currentRole == '2') {
var panel = new custdevelPlanPanel();
panel.exePlan();
} else {
Ext.Msg.alert("警告", "您無權執行開發計劃");
}
};
// 顯示查看窗體。。。。
function showSeeWin() {
var panel = new custdevelPlanPanel();
panel.seePlan();
};
// 點擊開發成功按鈕事件。。。
function showSuccess() {
if (currentRole == '3') {
var panel = new custdevelPlanPanel();
panel.success();
} else {
Ext.Msg.alert("警告", "您無權進行此操作");
}
};
// 銷售機會的Store。。。。。。
var custDevelPlanStore = new Ext.data.JsonStore({
id : "id",
url : 'plan.do?actionType=doList',
root : "data",
totalProperty : "rowCount",
baseParams : {
chcCustName : null,
chcTitle : null,
chcLinkman : null
},
remoteSort : true,
fields : ["chcId", "chcSource", "chcCustName", "chcTitle", "chcRate",
"chcLinkman", "chcTel", "chcDesc", "chcCreateBy", "chcCreateDate",
"chcDueTo", "chcDueDate", "chcStatus"]
});
// 計劃項的store。。。。
var planStore = new Ext.data.JsonStore({
url : 'plan.do?actionType=doFindTodo',
root : "data",
baseParams : {
chcId : null
},
totalProperty : "rowCount",
remoteSort : true,
fields : ["plaId", "plaChcId", "plaDate", "plaTodo", "plaResult",
"operation"]
});
// 顯示銷售機會信息的表格。。。
var custDevelPlanClom = new Ext.grid.ColumnModel([new Ext.grid.RowNumberer(), {
header : '編號',
sortable : true,
dataIndex : 'chcId',
width : 90
}, {
header : '客戶名稱',
sortable : true,
dataIndex : 'chcCustName',
width : 105
}, {
header : '概要',
sortable : true,
dataIndex : 'chcTitle',
width : 105
}, {
header : '聯系人',
sortable : true,
dataIndex : 'chcLinkman',
width : 105
}, {
header : '聯系人電話',
sortable : true,
dataIndex : 'chcTel',
width : 105
}, {
header : '創建時間',
sortable : true,
dataIndex : 'chcCreateDate',
width : 105
}, {
header : '狀態',
sortable : true,
dataIndex : 'chcStatus',
width : 105,
renderer : function(value) {
if (value == 1) {
return '未開發'
}
if (value == 2) {
return '開發中'
}
if (value == 3 || value == 4) {
return '已歸檔'
}
}
}, {
header : '操作',
dataIndex : 'chcStatus',
renderer : function(value) {
var operation = '';
if (value == 3 || value == 4) {
operation += '<img src="images/bt_detail.gif" title="查看" onclick="showSeeWin()"/>';
} else {
operation += '<img src="images/bt_plan.gif" title="制定計劃" onclick="showCreatePlanWin()"/>';
operation += '<img src="images/bt_feedback.gif" title="執行計劃" onclick="showExePlanWin()"/>';
operation += '<img src="images/bt_yes.gif" title="開發成功" onclick="showSuccess()"/>';
}
return operation;
}
}]);
// 查詢及狀態欄。。。。
var custDevelPlanGrid = new Ext.grid.GridPanel({
store : custDevelPlanStore,
cm : custDevelPlanClom,
height : 300,
stripeRows : true,
pageSize : 10,
tbar : [new Ext.Toolbar.Fill(), '客戶名稱', {
xtype : 'textfield',
name : 'chcCustName',
width : 150
}, ' ', '概要', {
xtype : "textfield",
name : 'chcTitle',
width : 150
}, ' ', '聯系人', {
xtype : 'textfield',
name : 'chcLinkman',
width : 150
}, {
text : '查詢',
iconCls : 'search',
pressed : true,
handler : function() {
var panel = new custdevelPlanPanel();
panel.search();
},
scope : this
}, ' '],
bbar : new Ext.PagingToolbar({
pageSize : 10,
store : custDevelPlanStore,
grid : custDevelPlanGrid,
displayInfo : true,
displayMsg : '當前顯示 {0} - {1}條記錄 共有 {2} 條記錄',
emptyMsg : "沒有記錄"
})
});
// 顯示計劃項的表格。。。。
var planGrid = new Ext.grid.GridPanel({
store : planStore,
cm : new Ext.grid.ColumnModel([{
header : '編號',
dataIndex : 'plaId',
width : 40
}, {
header : '日期',
sortable : true,
dataIndex : 'plaDate',
width : 100
}, {
header : '計劃項',
sortable : true,
dataIndex : 'plaTodo',
width : 250
}, {
header : '操作',
dataIndex : 'operation',
renderer : function() {
return '<img src="images/bt_edit.gif" title="編輯" onclick="showPlanEditWin()"/>'
+ '<img src="images/bt_del.gif" title="刪除" onclick="del()"/>';
}
}]),
autoHeight : true,
width : 440,
stripeRows : true,
pageSize : 10,
bbar : new Ext.PagingToolbar({
pageSize : 3,
store : planStore,
displayInfo : true,
displayMsg : '顯示 {0} - {1}條記錄 共有 {2} 條記錄',
emptyMsg : "沒有記錄"
})
});
planGrid.on('celldblclick', showPlanEditWin, this);
// 顯示執行結果的表格。。。。
var exePlanGrid = new Ext.grid.GridPanel({
store : planStore,
cm : new Ext.grid.ColumnModel([{
header : '編號',
dataIndex : 'plaId',
width : 40
}, {
header : '日期',
sortable : true,
dataIndex : 'plaDate',
width : 100
}, {
header : '計劃項',
sortable : true,
dataIndex : 'plaTodo',
width : 130
}, {
header : '執行效果',
dataIndex : 'plaResult',
width : 170,
renderer : function(value) {
if (value == "") {
return '<img src="images/bt_feedback.gif" onclick="showPlaResultWin()"/>';
} else {
return value;
}
}
}]),
autoHeight : true,
width : 440,
stripeRows : true,
pageSize : 10,
loadMask : true,
bbar : new Ext.PagingToolbar({
pageSize : 3,
store : planStore,
displayInfo : true,
displayMsg : '顯示 {0} - {1}條記錄 共有 {2} 條記錄',
emptyMsg : "沒有記錄"
})
});
var plaResultWin;
// 執行效果的窗體。。。
planResultWin = Ext.extend(Ext.Window, {
title : '執行效果',
width : 530,
height : 230,
modal : true,
buttonAlign : 'center',
createForm : function() {
return new Ext.form.FormPanel({
textAlign : 'left',
defaultType : 'htmleditor',
frame : true,
items : [{
name : 'plaResult',
hideLabel : true,
width : 520,
// value : record.get('plaResult'),
allowBlank : false,
blankText : '執行效果不能為空'
}]
});
},
// 保存執行效果的操作。。。
save : function() {
var record = exePlanGrid.getSelectionModel().getSelected();
if (this.fp.form.isValid()) {
this.fp.form.submit({
waitTitle : '請稍候',
waitMsg : '正在保存......',
url : 'plan.do?actionType=doSaveResult',
params : {
plaId : record.get('plaId')
},
success : function(form, action) {
Ext.Msg.alert('系統消息', action.result.msg, function() {
plaResultWin.close();
planStore.reload();
})
},
failure : function(form, action) {
form.reset();
Ext.Msg.alert('警告', action.result.msg);
}
});
}
},
initComponent : function() {
planResultWin.superclass.initComponent.call(this);
this.fp = this.createForm();
this.add(this.fp);
this.addButton('保存', this.save, this);
}
});
// 執行效果。。。。
function showPlaResultWin() {
plaResultWin = new planResultWin();
plaResultWin.show();
}
// 顯示開發計劃信息的表格。。。。
var showPlanGrid = new Ext.grid.GridPanel({
store : planStore,
cm : new Ext.grid.ColumnModel([{
header : '日期',
sortable : true,
dataIndex : 'plaDate',
width : 120
}, {
header : '計劃項',
sortable : true,
dataIndex : 'plaTodo',
width : 160
}, {
header : '執行效果',
sortable : true,
dataIndex : 'plaResult',
width : 160
}]),
autoHeight : true,
width : 440,
stripeRows : true,
pageSize : 10,
bbar : new Ext.PagingToolbar({
pageSize : 3,
store : planStore,
displayInfo : true,
displayMsg : '顯示 {0} - {1}條記錄 共有 {2} 條記錄',
emptyMsg : "沒有記錄"
})
});
var win;
// 修改計劃項的窗體。。。
planWin = Ext.extend(Ext.Window, {
title : '修改計劃項',
width : 530,
height : 230,
modal : true,
buttonAlign : 'center',
createForm : function() {
var record = planGrid.getSelectionModel().getSelected();
return new Ext.form.FormPanel({
textAlign : 'left',
defaultType : 'htmleditor',
frame : true,
items : [{
name : 'plaTodo',
hideLabel : true,
width : 520,
value : record.get('plaTodo'),
allowBlank : false,
blankText : '計劃項不能為空'
}]
});
},
// 保存計劃項的操作。。。
save : function() {
var record = planGrid.getSelectionModel().getSelected();
if (this.fp.form.isValid()) {
this.fp.form.submit({
waitTitle : '請稍候',
waitMsg : '正在保存......',
url : 'plan.do?actionType=doSaveorUpdate',
params : {
chcId : chcId,
plaId : record.get('plaId'),
plaDate : record.get('plaDate')
},
success : function(form, action) {
Ext.Msg.alert('系統消息', action.result.msg, function() {
win.close();
planStore.reload();
})
},
failure : function(form, action) {
form.reset();
Ext.Msg.alert('警告', action.result.msg);
}
});
}
},
initComponent : function() {
planWin.superclass.initComponent.call(this);
this.fp = this.createForm();
this.add(this.fp);
this.addButton('保存', this.save, this);
}
});
// 修改計劃項。。。。
function showPlanEditWin() {
win = new planWin();
win.show();
}
// 刪除計劃項。。。
function del() {
var panel = new custdevelPlanPanel();
panel.del();
}
CRM.saleManage.custDevelPlan = Ext.extend(Ext.Panel, {
closable : true,
autoScroll : true,
layout : "fit",
maskDisabled : false,
gridViewConfig : {
animate : true
},
// 刷新。。。。
refresh : function() {
custDevelPlanStore.removeAll();
custDevelPlanStore.reload();
},
// 制定開發計劃窗體中的操作。。。
initWin : function(width, title) {
var win = new Ext.Window({
width : width,
autoHeight : true,
buttonAlign : "center",
title : title,
modal : true,
closeAction : "hide",
resizable : false,
plain : true,
items : [this.fp],
buttons : [{
text : "保存",
handler : this.savePlan,
tooltip : '點擊該按鈕將執行確認操作',
scope : this
}]
});
return win;
},
// 執行開發計劃中的操作。。。
initExePlanWin : function(width, title) {
var win = new Ext.Window({
width : width,
autoHeight : true,
buttonAlign : 'center',
title : title,
modal : true,
closeAction : 'hide',
resizable : false,
plain : true,
items : [this.fp],
buttons : [{
text : '開發成功',
handler : this.success,
tooltip : '點擊該按鈕此計劃將開發成功',
scope : this
}, {
text : '終止開發',
handler : this.failure,
tooltip : '點擊此按鈕此計劃將開發失敗',
scope : this
}]
});
return win;
},
// 查看窗體中的操作。。。。
initSeeWin : function(width, title) {
var win = new Ext.Window({
width : width,
autoHeight : true,
title : title,
modal : true,
closeAction : 'hide',
resizable : false,
plain : true,
items : [this.fp]
});
return win;
},
// 顯示制定開發計劃的窗體。。。
showWin : function() {
if (!this.win) {
if (!this.fp) {
this.fp = this.createForm();
}
this.win = this.createWin();
this.win.on("close", function() {
this.win = null;
this.fp = null;
}, this);
}
this.win.show();
},
// 關閉窗體操作。。。
closeWin : function(show) {
if (this.win)
this.win.close(show);
this.win = null;
},
// 顯示執行開發計劃的窗體。。。
showExePlanWin : function() {
if (!this.win) {
if (!this.fp) {
this.fp = this.createExePlanForm();
}
this.win = this.createExePlanWin();
this.win.on("close", function() {
this.win = null;
this.fp = null;
}, this);
}
this.win.show();
},
// 顯示查看窗體。。。
showSeeWin : function() {
if (!this.win) {
if (!this.fp) {
this.fp = this.createSeeForm();
}
this.win = this.createSeeWin();
this.win.on("close", function() {
this.win = null;
this.fp = null;
}, this);
}
this.win.show();
},
createExeWin : function() {
this.showExePlanWin();
this.reset();
},
create : function() {
this.showWin();
this.reset();
},
createSee : function() {
this.showSeeWin();
this.reset();
},
// 執行計劃時開發成功操作。。。
success : function() {
var record = exePlanGrid.getSelectionModel().getSelected();
Ext.MessageBox.confirm("確認", "確認開發成功?", function(button) {
if (button == "yes") {
Ext.Ajax.request({
url : this.baseUrl + '?actionType=doSuccessorFailure',
params : {
chcId : chcId,
type : 'success'
},
method : 'POST',
success : function(response) {
Ext.Msg.alert("提示信息", response.responseText,
function() {
this.closeWin();
custDevelPlanStore.reload();
}, this);
},
scope : this
});
}
}, this);
},
// 執行開發計劃時開發失敗操作。。。
failure : function() {
var record = exePlanGrid.getSelectionModel().getSelected();
Ext.MessageBox.confirm("確認", "確認終止開發?", function(button) {
if (button == "yes") {
Ext.Ajax.request({
url : this.baseUrl + '?actionType=doSuccessorFailure',
params : {
chcId : chcId,
type : 'failure'
},
method : 'POST',
success : function(response) {
Ext.Msg.alert("提示信息", response.responseText,
function() {
this.closeWin();
custDevelPlanStore.reload();
}, this);
},
scope : this
});
}
}, this);
},
// 重置。。。
reset : function() {
if (this.win)
this.fp.form.reset();
},
// 關閉窗體操作。。。
closeWin : function() {
if (this.win)
this.win.close();
this.win = null;
},
// 主面板的查詢操作。。。。
search : function() {
custDevelPlanStore.baseParams.chcCustName = Ext.get('chcCustName')
.getValue();
custDevelPlanStore.baseParams.chcTitle = Ext.get('chcTitle').getValue();
custDevelPlanStore.baseParams.chcLinkman = Ext.get('chcLinkman')
.getValue();
custDevelPlanStore.load({
params : {
start : 0,
limit : 10
}
});
},
// 制定開發計劃。。。。
edit : function() {
var record = custDevelPlanGrid.getSelectionModel().getSelected();
chcId = record.get('chcId');
if (!record) {
Ext.Msg.alert("提示", "請選擇要編輯的行!");
return;
}
this.showWin();
this.fp.form.loadRecord(record);
planStore.baseParams.chcId = chcId;
planStore.load({
params : {
start : 0,
limit : 3
}
});
},
// 添加計劃項時的保存操作。。。
savePlan : function() {
if (this.fp.form.isValid()) {
this.fp.form.submit({
waitTitle : '請稍候',
waitMsg : '正在保存。。。。',
url : 'plan.do?actionType=doSaveorUpdate',
params : {
chcId : chcId
},
success : function(form, action) {
Ext.Msg.alert('系統消息', action.result.msg, function() {
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -