⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 custinfo.js

📁 本系统基本完善了CRM管理系统的各个模块
💻 JS
📖 第 1 页 / 共 2 页
字号:
Ext.namespace("CRM.custManage");
var custNo;
var custName;
// 点击图标打开联系人面板
function openCstLinkmanPanel() {
	var panel = new custInfoPanel();
	panel.showPanel('cstLinkman', '联系人', custLinkmanPanel);
}
// 点击图标打开客户交往记录面板
function openCstActivityPanel() {
	var panel = new custInfoPanel();
	panel.showPanel('cstActivity', '客户交往记录', custActivityPanel);
}
// 点击图标打开历史订单面板
function showCustOrdersPanel() {
	var panel = new custInfoPanel();
	panel.showPanel('orders', '历史订单', custOrdersPanel);
}
// 点击图标打开编辑窗体
function showCustEditWin() {
	var panel = new custInfoPanel();
	panel.edit();
}
// 点击图标打开删除窗体
function showCustDelWin() {
	var panel = new custInfoPanel();
	panel.removeData();
}

var custInfoStore = new Ext.data.JsonStore({
	id : "id",
	url : 'customer.do?actionType=doList',
	root : "data",
	totalProperty : "rowCount",
	baseParams : {
		custNo : null,
		custName : null,
		custManName : null,
		custLevel : null,
		custRegion : null
	},
	remoteSort : true,
	fields : ["custNo", "custName", "custRegion", "custManagerName",
			"custLevel", "custSatisfy", "custCredit", "custAddr", "custZip",
			"custTel", "custFax", "custWebsite", "custLicenceNo",
			"custChieftain", "custBankroll", "custTurnover", "custBank",
			"custBankAccount", "custLocalTaxNo", "custNationalTaxNo",
			"operation"]
});
var custInfColm = new Ext.grid.ColumnModel([new Ext.grid.RowNumberer(), {
	header : '客户编号',
	sortable : true,
	dataIndex : 'custNo',
	width : 120
}, {
	header : '名称',
	sortable : true,
	dataIndex : 'custName',
	width : 193
}, {
	header : '地区',
	sortable : true,
	dataIndex : 'custRegion',
	width : 150
}, {
	header : '客户经理',
	sortable : true,
	dataIndex : 'custManagerName',
	width : 150
}, {
	header : '客户等级',
	sortable : true,
	dataIndex : 'custLevel',
	width : 120
}, {
	header : '操作',
	dataIndex : 'operation',
	renderer : function() {
		var operation = "<img src='images/bt_edit.gif' title='编辑' onclick='showCustEditWin()'/>";
		operation += "<img src='images/bt_linkman.gif' title='联系人' onclick='openCstLinkmanPanel()'/>";
		operation += "<img src='images/bt_acti.gif' title='交往记录' onclick='openCstActivityPanel()'/>";
		operation += "<img src='images/bt_orders.gif' title='历史订单' onclick='showCustOrdersPanel()'/>";
		operation += "<img src='images/bt_del.gif' title='删除' onclick='showCustDelWin()'/>";
		return operation;
	}
}]);
var custInfoGrid = new Ext.grid.GridPanel({
	store : custInfoStore,
	cm : custInfColm,
	height : 300,
	stripeRows : true,
	pageSize : 10,
	tbar : [ {
		text : '新建',
		id : 'add',
		pressed : false,
		iconCls : 'add',
		handler : function() {
			var win = new custInfoPanel();
			win.create();
		},
		scope : this
	}, '-', '客户编号', {
		xtype : 'textfield',
		name : 'custNo',
		width : 100,
		scope : this
	}, '名称', {
		xtype : 'textfield',
		name : 'custName',
		width : 130,
		scope : this
	}, '客户经理', {
		xtype : 'combo',
		name : 'manName',
		fieldLabel : '客户经理',
		width : 100,
		store : new Ext.data.JsonStore({
			url : 'sale.do?actionType=doFindAllCstManager',
			root : 'data',
			totalProperty : 'rowCount',
			fields : ['manName']
		}),
		displayField : 'manName',
		pageSize : 10,
		forceSelection : true,
		triggerAction : 'all'
	}, '客户等级', {
		xtype : 'combo',
		name : 'custLevel',
		fieldLabel : '客户等级',
		store : new Ext.data.SimpleStore({
			fields : ['level'],
			data : [['全部'], ['战略合作伙伴'], ['合作伙伴'], ['大客户'], ['重点开发客户'], ['普通客户']]
		}),
		displayField : 'level',
		mode : 'local',
		forceSelection : true,
		editable : false,
		triggerAction : 'all',
		width : 90,
		scope : this
	}, '地区', {
		xtype : 'combo',
		name : 'custRegion',
		fieldLabel : '地区',
		store : new Ext.data.SimpleStore({
			fields : ['region'],
			data : [['北京'], ['华北'], ['中南'], ['东北'], ['西部']]
		}),
		displayField : 'region',
		mode : 'local',
		forceSelection : true,
		editable : false,
		triggerAction : 'all',
		width : 90,
		scope : this
	}, '&nbsp;&nbsp;&nbsp;&nbsp;', {
		text : '查询',
		iconCls : 'search',
		pressed : true,
		handler : function() {
			var panel = new custInfoPanel();
			panel.search();
		},
		scope : this
	}],
	bbar : new Ext.PagingToolbar({
		pageSize : 10,
		store : custInfoStore,
		grid : custInfoGrid,
		displayInfo : true,
		displayMsg : '显示 {0} - {1}条记录&nbsp;&nbsp;共有 {2} 条记录',
		emptyMsg : "没有记录"
	})
});

CRM.custManage.custInfo = Ext.extend(Ext.Panel, {
	closable : true,
	autoScroll : true,
	layout : "fit",
	maskDisabled : false,
	gridViewConfig : {
		animate : true
	},
	refresh : function() {
		store.removeAll();
		store.reload();
	},
	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('cancel');
				},
				scope : this
			}]
		});
		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();
	},
	create : function() {
		this.showWin();
		this.reset();
	},

	reset : function() {
		if (this.win)
			this.fp.form.reset();
	},
	closeWin : function() {
		if (this.win)
			this.win.close();
		this.win = null;
	},
	// 按条件查询客户信息
	search : function() {
		custInfoStore.baseParams.custNo = Ext.get('custNo').getValue();
		custInfoStore.baseParams.custName = Ext.get('custName').getValue();
		custInfoStore.baseParams.custManName = Ext.get('manName').getValue();
		custInfoStore.baseParams.custLevel = Ext.get('custLevel').getValue();
		custInfoStore.baseParams.custRegion = Ext.get('custRegion').getValue();
		custInfoStore.load({
			params : {
				start : 0,
				limit : 10
			}
		});
	},
	// 编辑客户信息
	edit : function() {
		var record = custInfoGrid.getSelectionModel().getSelected();
		if (!record) {
			Ext.Msg.alert("提示", "请选择要编辑的行!");
			return;
		}
		this.showWin();
		this.fp.form.loadRecord(record);
	},
	// 保存新增或修改的客户信息
	save : function() {
		var id = this.fp.form.findField("custNo").getValue();
		if (this.fp.form.isValid()) {
			this.fp.form.submit({
				waitTitle : '请稍候',
				waitMsg : '正在保存......',
				url : this.baseUrl + '?actionType=doSaveorUpdate',
				method : 'POST',
				success : function(form, action) {
					Ext.Msg.alert("系统消息", action.result.msg, function() {
						this.closeWin();
						custInfoStore.reload();
					}, this);
				},
				failure : function(form, action) {
					Ext.Msg.alert('系统消息', action.result.msg);
				},
				scope : this
			});
		}
	},
	// 删除客户信息
	removeData : function() {
		var record = custInfoGrid.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 : {
						custNo : record.get("custNo")
					},
					method : 'POST',
					success : function(response) {
						Ext.Msg.alert("提示信息", response.responseText,
								function() {
									custInfoStore.reload();
								}, this);
					},
					scope : this
				});
			}
		}, this);
	},
	// 打开面板
	showPanel : function(id, title, panel) {
		var record = custInfoGrid.getSelectionModel().getSelected();
		custNo = record.get('custNo');
		custName = record.get('custName');
		var p = new panel();
		p.id = id;
		p.title = title;
		var n = main.add(p);
		main.setActiveTab(n);
	},
	// 右键菜单
	showMenu : function(grid, index, e) {
		this.menu = new Ext.menu.Menu({
			items : [{
				id : 'add',
				text : '新建',
				iconCls : 'add',
				handler : function() {
					this.create();
				},
				scope : this
			}, {
				id : 'modify',
				text : '编辑',
				iconCls : 'modify',
				handler : function() {
					this.edit();
				},
				scope : this
			}, {
				id : 'del',
				text : '删除',
				iconCls : 'del',
				handler : this.removeData,
				scope : this
			}, {
				id : 'linkman',
				text : '联系人',
				icon : 'images/bt_linkman.gif',
				handler : function() {
					this.showPanel('cstLinkman', '联系人', custLinkmanPanel);
				},
				scope : this
			}, {
				id : 'orders',
				text : '历史订单',
				icon : 'images/bt_orders.gif',
				handler : function() {
					this.showPanel('orders', '历史订单', custOrdersPanel);

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -