?? salechance.js
字號:
// 銷售機會管理
Ext.namespace("CRM.saleManage");
var salChance_chcId;
// 點擊指派圖標打開指派窗口
function showAssignChcWin() {
if (currentRole == '2') {
var panel = new saleChancePanel();
panel.assign();
} else {
Ext.Msg.alert("警告", "您無權進行指派");
}
}
function showEditChcWin() {
var panel = new saleChancePanel();
panel.edit();
}
function showDelChcWin() {
var panel = new saleChancePanel();
panel.removeData();
}
// 存儲器
var salChanceStore = new Ext.data.JsonStore({
id : "id",
url : 'sale.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"]
});
var salChanceColm = new Ext.grid.ColumnModel([new Ext.grid.RowNumberer(), {
header : '編號',
sortable : true,
dataIndex : 'chcId',
width : 122
header : '客戶名稱',
sortable : true,
dataIndex : 'chcCustName',
width : 122
}, {
header : '概要',
sortable : true,
dataIndex : 'chcTitle',
width : 122
}, {
header : '聯系人',
sortable : true,
dataIndex : 'chcLinkman',
width : 122
}, {
header : '聯系人電話',
sortable : true,
dataIndex : 'chcTel',
width : 122
}, {
header : '創建時間',
sortable : true,
dataIndex : 'chcCreateDate',
width : 122
}, {
header : '操作',
dataIndex : 'chcStatus',
renderer : function(value) {
var operation = '';
if (value == 1) {
operation += ' ';
operation += '<img src="images/bt_linkman.gif" title="指派" onclick="showAssignChcWin()"/>';
operation += ' '
+ '<img src="images/bt_edit.gif" title="編輯" onclick="showEditChcWin()"/>';
operation += ' '
+ '<img src="images/bt_del.gif" title="刪除" onclick="showDelChcWin()">';
return operation;
}
}
}]);
// 表格
var salChanceGrid = new Ext.grid.GridPanel({
store : salChanceStore,
cm : salChanceColm,
height : 300,
stripeRows : true,
pageSize : 15,
tbar : [{
text : '新建',
id : 'add',
iconCls : 'add',
pressed : false,
handler : function() {
var panel = new saleChancePanel();
panel.create();
},
scope : this
}, 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 saleChancePanel();
panel.search();
},
scope : this
}, ' '],
bbar : new Ext.PagingToolbar({
pageSize : 15,
store : salChanceStore,
grid : salChanceGrid,
displayInfo : true,
displayMsg : '當前顯示 {0} - {1}條記錄 共有 {2} 條記錄',
emptyMsg : "沒有記錄"
})
});
// 自定義
CRM.saleManage.saleChance = Ext.extend(Ext.Panel, {
closable : true,
autoScroll : true,
layout : "fit",
maskDisabled : false,
// 初始化新建或編輯窗體
initWin : function(width, height, title) {
var win = new Ext.Window({
width : width,
height : height,
buttonAlign : "center",
title : title,
modal : true,
closeAction : "hide",
resizable : false,
plain : true,
items : [this.fp],
buttons : [{
text : "保存",
handler : this.save,
tooltip : '點擊該按鈕將執行確認操作',
scope : this
}, {
text : "清空",
handler : this.reset,
scope : this
}, {
text : "取消",
id : 'cancel',
handler : function() {
this.closeWin();
},
scope : this
}]
});
return win;
},
// 初始化指派窗體
initAssignWin : function(width, height, title) {
var assignWin = new Ext.Window({
width : width,
height : height,
buttonAlign : "center",
title : title,
modal : true,
closeAction : "hide",
resizable : false,
plain : true,
items : [this.fp],
buttons : [{
text : "保存",
handler : this.doAssign,
tooltip : '點擊該按鈕將執行確認操作',
scope : this
}, {
text : "清空",
handler : this.reset,
scope : this
}, {
text : "取消",
id : 'cancel',
handler : function() {
this.closeWin();
},
scope : this
}]
});
return assignWin;
},
// 打開新建或編輯窗體
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();
},
create : function() {
this.showWin();
this.reset();
},
// 關閉新建或編輯窗口
closeWin : function() {
if (this.win)
this.win.close();
this.win = null;
},
// 關閉指派窗口
closeAssignWin : function() {
if (this.assignWin) {
this.assignWin.close();
this.assignWin = null;
}
},
// 重置
reset : function() {
if (this.win)
this.fp.form.reset();
},
// 加載編輯內容
edit : function() {
var record = salChanceGrid.getSelectionModel().getSelected();
// if (!record) {
// Ext.Msg.alert("提示", "請選擇要編輯的行!");
// return;
// }
this.showWin();
this.fp.form.loadRecord(record);
},
// 保存
save : function() {
if (this.fp.form.isValid()) {
this.fp.form.submit({
waitTitle : '請稍候',
waitMsg : '正在保存......',
url : 'sale.do?actionType=doSaveorUpdate',
method : 'POST',
params : {
chcCreateBy : currentUser
},
success : function(form, action) {
Ext.Msg.alert("系統消息", action.result.msg, function() {
this.closeWin();
salChanceStore.reload();
}, this);
},
failure : function(form, action) {
Ext.Msg.alert('系統消息', action.result.msg);
},
scope : this
});
}
},
// 加載指派窗體
assign : function() {
var record = salChanceGrid.getSelectionModel().getSelected();
salChance_chcId = record.get('chcId');
if (!record) {
Ext.Msg.alert("提示", "請選擇要指派的行!");
return;
}
// 顯示指派窗口
if (!this.assignWin) {
if (!this.fp) {
this.fp = this.createAssignForm();
}
this.assignWin = this.createAssignWin();
this.assignWin.on("close", function() {
this.assignWin = null;
this.fp = null;
}, this);
}
this.assignWin.show();
},
// 進行指派操作
doAssign : function() {
if (this.fp.form.isValid()) {
this.fp.form.submit({
waitTitle : '請稍候',
waitMsg : '正在保存......',
url : 'sale.do?actionType=doAssign',
method : 'POST',
params : {
chcId : salChance_chcId
},
success : function(form, action) {
Ext.Msg.alert("系統消息", action.result.msg, function() {
this.closeAssignWin();
salChanceStore.reload();
}, this);
},
failure : function(form, action) {
Ext.Msg.alert('系統消息', action.result.msg);
},
scope : this
});
}
},
// 刪除
removeData : function() {
var record = salChanceGrid.getSelectionModel().getSelected();
// if (!record) {
// Ext.Msg.alert("提示", "請先選擇要刪除的行!");
// return;
// }
Ext.MessageBox.confirm("確認刪除", "確認刪除所選數據?", function(button) {
if (button == "yes") {
Ext.Ajax.request({
url : this.baseUrl + '?actionType=doDel',
params : {
chcId : record.get("chcId")
},
method : 'POST',
success : function(response) {
Ext.Msg.alert("系統消息", response.responseText,
function() {
salChanceStore.reload();
}, this);
},
scope : this
});
}
}, this);
},
// 查詢
search : function() {
salChanceStore.baseParams.chcCustName = Ext.get('chcCustName')
.getValue();
salChanceStore.baseParams.chcTitle = Ext.get('chcTitle').getValue();
salChanceStore.baseParams.chcLinkman = Ext.get('chcLinkman').getValue();
salChanceStore.load({
params : {
start : 0,
limit : 15
}
});
},
initComponent : function() {
CRM.saleManage.saleChance.superclass.initComponent.call(this);
// 數據載
salChanceStore.load({
params : {
start : 0,
limit : 15
}
});
this.add(salChanceGrid);
}
});
// 銷售機會管理面板
saleChancePanel = Ext.extend(CRM.saleManage.saleChance, {
id : 'saleChance',
baseUrl : 'sale.do',
createAssignForm : function() {
return assignForm = new Ext.form.FormPanel({
labelWidth : 70,
frame : true,
autoHeight : true,
resizable : false,
labelAlign : 'right',
defaultType : 'textfield',
items : [{
xtype : 'combo',
name : 'chcDueTo',
width : 125,
fieldLabel : '指派給',
store : new Ext.data.JsonStore({
url : 'sale.do?actionType=doFindAllCstManager',
root : 'data',
totalProperty : 'rowCount',
fields : ['manName']
}),
displayField : 'manName',
pageSize : 10,
forceSelection : true,
triggerAction : 'all',
editable : false,
allowBlank : false,
blankText : '請輸入被指派人的姓名'
}, {
xtype : 'datefield',
name : 'chcDueDate',
fieldLabel : '指派時間',
format : 'Y年m月d日',
allowBlank : false,
blankText : '指派時間為必填項',
width : 125
}]
});
},
createForm : function() {
var formPanel = new Ext.form.FormPanel({
labelWidth : 80,
frame : true,
autoHeight : true,
resizable : false,
labelAlign : 'right',
defaultType : 'textfield',
items : [{
xtype : 'fieldset',
title : ' ',
autoHeight : true,
items : [{
layout : 'column',
border : false,
items : [{
columnWidth : .5,
layout : 'form',
defaultType : 'textfield',
items : [{
xtype : 'combo',
name : 'chcCustName',
fieldLabel : '客戶名稱',
width : 125,
store : new Ext.data.JsonStore({
url : 'sale.do?actionType=doFindAllCustomer',
root : 'data',
fields : ['custName']
}),
displayField : 'custName',
forceSelection : true,
triggerAction : 'all',
editable : false,
allowBlank : false,
blankText : '客戶名稱為必填項'
}]
}, {
columnWidth : .5,
layout : 'form',
defaultType : 'textfield',
items : [{
xtype : 'numberfield',
name : 'chcRate',
fieldLabel : '成功機率',
allowBlank : false,
blankText : '成功機率為必填項',
maxValue : 100,
minValue : 1
}]
}, {
xtype : 'hidden',
name : 'chcStatus'
}, {
columnWidth : .5,
layout : 'form',
defaultType : 'textfield',
items : [{
xtype : 'hidden',
name : 'chcId'
}]
}]
}, {
layout : 'column',
border : false,
items : [{
columnWidth : .5,
layout : 'form',
defaultType : 'textfield',
items : [{
name : 'chcLinkman',
fieldLabel : '聯系人'
}]
}, {
columnWidth : .5,
layout : 'form',
defaultType : 'textfield',
items : [{
xtype : 'textfield',
name : 'chcTel',
fieldLabel : '聯系人電話'
}]
}]
}, {
layout : 'column',
border : false,
items : [{
columnWidth : .5,
layout : 'form',
defaultType : 'textfield',
items : [{
name : 'chcSource',
fieldLabel : '機會來源'
}]
}, {
columnWidth : .5,
layout : 'form',
defaultType : 'textfield',
items : [{
name : 'chcTitle',
fieldLabel : '概要',
allowBlank : false,
blankText : '概要為必填項'
}]
}]
}]
}, {
xtype : 'fieldset',
title : '機會描述',
autoHeight : true,
items : [{
layout : 'fit',
xtype : 'htmleditor',
height : 125,
width : 500,
name : 'chcDesc',
hideLabel : true,
allowBlank : false,
blankText : '創建人為必填項'
}]
}]
});
return formPanel;
},
createAssignWin : function() {
return this.initAssignWin(300, 140, '營銷機會指派');
},
createWin : function() {
return this.initWin(555, 360, '銷售機會管理');
},
initComponent : function() {
saleChancePanel.superclass.initComponent.call(this);
}
});
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -