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

📄 truckinfo.js

📁 hibernate+spring+ext2.0 的物流网站
💻 JS
📖 第 1 页 / 共 2 页
字号:
				text : '提交',
				handler : function() {
					if (from.form.isValid()) {
						from.getForm().submit({
							success : function() {
								Ext.MessageBox.alert('信息', '添加成功,点击返回列表页面');
								grid.render();
								store.load({
									params : {
										start : 0,
										limit : 10
									}
								});
								win.close();
							},
							failure : function() {
								Ext.MessageBox.alert('信息', '添加失败,请与管理员联系!');
							}
						});
					}
				}
			}, {
				text : '重置',
				handler : function() {
					from.getForm().reset();
				}
			}]
		});

		/**
		 * 声明一个window,包装FormPanel
		 */
		var win = new Ext.Window({
			title : 'InfoWindow',
			closable : true,
			width : 660,
			height : 435,
			// border:false,
			plain : true,
			draggable : true,
			collapsible : true,

			items : [from]
		});

		win.show(Ext.get('addbtn'));

	};

	/**
	 * 为操作列删除按钮编写单击事件
	 */

	window.delInfo = function() {
		var sm = grid.getSelectionModel();
		var count = sm.getCount();
		if (count == 0) {
			Ext.MessageBox.alert('信息', '您没有勾选任何记录!');
		} else {
			Ext.MessageBox.confirm('Message', '确定要删除?', function(btn) {
				if (btn == 'yes') {
					var record = sm.getSelected();

					var str = record.get('TruckID');

					Ext.Ajax.request({
						url : '../carmacktruckInfoDelete.do',
						params : {
							TruckID : str
						},
						success : function() {
							Ext.MessageBox.alert('信息', '删除成功');
							store.reload();
						},
						failure : function() {
							Ext.MessageBox.alert('错误', '请与后台服务人员联系');
						},
						timeout : 30000,
						headers : {
							'my-header' : 'foo'
						}
					});
				}
			});
		}
	};

	/**
	 * 为操作列修改按钮编写单击事件
	 */

	window.updateInfo = function() {
		/**
		 * 获取Grid中选中行Record
		 */
		var selectRecode = grid.getSelectionModel().getSelected();

		/**
		 * 创建车辆类型数据适配器,读取分公司信息
		 */
		var TruckModestore = new Ext.data.Store({
			proxy : new Ext.data.HttpProxy({
				url : '../Carmack/JsonFactory/TruckMode.jsp'
			}),
			reader : new Ext.data.JsonReader({}, [{
				name : 'tmid'
			}, {
				name : 'tmname'
			}])
		});

		/**
		 * 创建车辆类型Combox
		 */
		var TruckModecombo = new Ext.form.ComboBox({
			fieldLabel : '型号名称',
			hiddenName : 'TMID',
			xtype : 'combo',
			store : TruckModestore,
			mode : 'remote',
			emptyText : '请选择类型',
			triggerAction : 'all',
			valueField : 'tmid',
			displayField : 'tmname',
			width : 125,
			readOnly : true,
			allowBlank : false,
			editable : false,
			typeAhead : true,
			selectOnFocus : true,
			anchor : '85%'
		});

		/**
		 * 创建分公司数据适配器,读取分公司信息
		 */
		var Branchstore = new Ext.data.Store({
			proxy : new Ext.data.HttpProxy({
				url : '../Opt/JsonFactory/BranchInfo.jsp'
			}),
			reader : new Ext.data.JsonReader({}, [{
				name : 'branchid'
			}, {
				name : 'branchname'
			}])
		});

		/**
		 * 创建分公司Combox
		 */
		var Branchcombo = new Ext.form.ComboBox({
			fieldLabel : '公司名称',
			hiddenName : 'BranchID',
			xtype : 'combo',
			store : Branchstore,
			mode : 'remote',
			emptyText : '请选择公司',
			triggerAction : 'all',
			valueField : 'branchid',
			displayField : 'branchname',
			width : 125,
			readOnly : true,
			allowBlank : false,
			editable : false,
			typeAhead : true,
			selectOnFocus : true,
			anchor : '85%'
		});
		/**
		 * 声明一个FormPanel,显示选中信息,更改后提交
		 */
		var from = new Ext.form.FormPanel({
			labelAlign : 'top',
			buttonAlign : 'right',
			title : '更新车辆信息',
			bodyStyle : 'padding:5px',
			height : 400,
			width : 650,
			frame : true,
			url : '../CarmacktruckInfoUpdate.do',

			items : [{
				layout : 'column',
				border : false,
				items : [{
					columnWidth : .5,
					layout : 'form',
					border : false,
					items : [{
						// 编号
						xtype : 'textfield',
						fieldLabel : '编号',
						name : 'TruckID',
						allowBlank : false,
						readOnly:true,
						anchor : '85%'
					},{
						// 号码
						xtype : 'textfield',
						fieldLabel : '号码',
						name : 'TruckNum',
						allowBlank : false,
						anchor : '85%'
					}, {
						// 发动机号
						xtype : 'textfield',
						fieldLabel : '发动机号',
						name : 'TruckEngineNum',
						vtype: 'alphanum',
						minLength : 6,
						maxLength : 17,
						anchor : '85%'
					}, {
						// 行驶证号
						xtype : 'textfield',
						fieldLabel : '行驶证号',
						name : 'TruckRunNum',
						vtype: 'alphanum',
						minLength : 4,
						maxLength : 17,
						anchor : '85%'
					}, Branchcombo]
				}, {
					columnWidth : .5,
					layout : 'form',
					border : false,
					items : [{
						// 保险单号
						xtype : 'textfield',
						fieldLabel : '保险单号',
						name : 'TruckInsuranceNum',
						vtype: 'alphanum',
						minLength : 6,
						maxLength : 17,
						anchor : '85%'
					}, {
						// 颜色
						xtype : 'textfield',
						fieldLabel : '颜色',
						name : 'TruckColor',
						allowBlank : false,
						anchor : '85%'
					},{
						// 购买时间
						xtype : 'datefield',
						fieldLabel : '购买时间',
						name : 'TruckBuyData',
						format : 'Ymd',
						allowBlank : false,
						anchor : '85%'
					}, {
						// 状态
						xtype : 'combo',
						store : new Ext.data.SimpleStore({
							fields : ["TruckIsVacancy", "TruckIsVacancyV"],
							data : [['0', '空闲'], ['1', '在途'],['2','维修']]
						}),
						valueField : "TruckIsVacancy",
						displayField : "TruckIsVacancyV",
						mode : 'local',
						forceSelection : true,
						blankText : '请选择状态',
						emptyText : '请选择状态',
						hiddenName : 'TruckIsVacancy',
						width : 125,
						editable : false,
						triggerAction : 'all',
						allowBlank : false,
						fieldLabel : '状态',
						anchor : '85%'
					}, TruckModecombo]
				}]
			}],

			buttons : [{
				text : '修改',
				handler : function() {
					from.getForm().submit({
						success : function() {
							Ext.MessageBox.alert('信息', '更新成功,点击返回列表页面');
							grid.render();
							store.load({
								params : {
									start : 0,
									limit : 10
								}
							});
							win.close();
						},
						failure : function() {
							Ext.MessageBox.alert('信息', '更新失败,请与管理员联系!');
						}
					});
				}
			}]
		});

		/**
		 * 声明一个window,包装FormPanel
		 */
		var win = new Ext.Window({
			title : 'InfoWindow',
			closable : true,
			width : 660,
			height : 435,
			// border:false,
			plain : true,
			draggable : true,
			collapsible : true,

			items : [from]
		});

		win.show(Ext.get('update-btn'));

		/**
		 * form加载事件
		 */
		from.getForm().loadRecord(selectRecode);

	};

	// =================================渲染呈现========================================
	/**
	 * 渲染呈现Grid,Store初始化
	 */
	grid.render();
	store.load({
		params : {
			start : 0,
			limit : 10
		}
	});

})

⌨️ 快捷键说明

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