You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
306 lines
10 KiB
JavaScript
306 lines
10 KiB
JavaScript
Ext.namespace('DsTruck');
|
|
|
|
DsTruck.MsTruckPluEdit = function (config) {
|
|
Ext.applyIf(this, config);
|
|
this.initUIComponents();
|
|
window.DsTruck.MsTruckPluEdit.superclass.constructor.call(this);
|
|
};
|
|
|
|
Ext.extend(DsTruck.MsTruckPluEdit, Ext.Panel, {
|
|
|
|
ParentWin: null,
|
|
OpStatus: 'add',
|
|
StoreList: null,
|
|
EditRecord: null,
|
|
|
|
initUIComponents: function () {
|
|
|
|
//枚举参照相关
|
|
this.storePluType = Ext.create('DsExt.ux.RefEnumStore', {});
|
|
this.storePluType.load({ params: { enumTypeId: 99036} });
|
|
|
|
this.comboxPluType = Ext.create('DsExt.ux.RefEnumCombox', {
|
|
fieldLabel: '配件分类',
|
|
store: this.storePluType,
|
|
forceSelection: true,
|
|
name: 'PluType'
|
|
});
|
|
|
|
//表参照相关
|
|
|
|
this.storeUnit = Ext.create('DsExt.ux.RefTableStore', {
|
|
model: 'MsTruckPluRefSysEnumValue',
|
|
proxy: { url: '/TruckMng/MsTruckPlu/GetUnitList' }
|
|
});
|
|
|
|
this.storeUnit.load();
|
|
this.comboxUnit = Ext.create('DsExt.ux.RefTableCombox', {
|
|
fieldLabel: '单位',
|
|
store: this.storeUnit,
|
|
name: 'Unit',
|
|
valueField: 'EnumValueName',
|
|
displayField: 'EnumValueName'
|
|
});
|
|
|
|
//编辑form
|
|
this.formEdit = Ext.widget('form', {
|
|
region: 'center',
|
|
frame: true,
|
|
bodyPadding: 5,
|
|
fieldDefaults: {
|
|
margins: '2 2 2 2',
|
|
labelAlign: 'right',
|
|
flex: 1,
|
|
labelWidth: 90,
|
|
msgTarget: 'qtip'
|
|
},
|
|
|
|
items: [
|
|
{//fieldset 1
|
|
xtype: 'fieldset',
|
|
defaultType: 'textfield',
|
|
layout: 'anchor',
|
|
defaults: {
|
|
anchor: '100%'
|
|
},
|
|
items: [{
|
|
xtype: 'container',
|
|
layout: 'hbox',
|
|
defaultType: 'textfield',
|
|
items: [{
|
|
fieldLabel: '录入日期',
|
|
format: 'Y-m-d',
|
|
xtype: 'datefield',
|
|
name: 'LrDate', flex: 0, hidden: true, margins: '0'
|
|
}, {
|
|
fieldLabel: '录入人编码',
|
|
name: 'UserCode', flex: 0, hidden: true, margins: '0'
|
|
}, {
|
|
fieldLabel: '录入人姓名',
|
|
name: 'UserName', flex: 0, hidden: true, margins: '0'
|
|
}, {
|
|
fieldLabel: '配件编码',
|
|
allowBlank: false,
|
|
name: 'PluCode'
|
|
}, {
|
|
fieldLabel: '配件名称',
|
|
allowBlank: false,
|
|
name: 'PluName'
|
|
}, {
|
|
fieldLabel: '货号',
|
|
name: 'CargoNo'
|
|
}
|
|
]
|
|
}, {
|
|
xtype: 'container',
|
|
layout: 'hbox',
|
|
defaultType: 'textfield',
|
|
items: [this.comboxUnit, {
|
|
fieldLabel: '规格',
|
|
name: 'Spec'
|
|
}, {
|
|
fieldLabel: '包装重量',
|
|
xtype: 'numberfield',
|
|
allowBlank: false,
|
|
name: 'Weight'
|
|
}
|
|
]
|
|
}, {
|
|
xtype: 'container',
|
|
layout: 'hbox',
|
|
defaultType: 'textfield',
|
|
items: [{
|
|
fieldLabel: '包装体积',
|
|
name: 'Volume'
|
|
}, {
|
|
fieldLabel: '产地',
|
|
name: 'Produce'
|
|
}, {
|
|
fieldLabel: '等级',
|
|
name: 'Grade'
|
|
}
|
|
]
|
|
}, {
|
|
xtype: 'container',
|
|
layout: 'hbox',
|
|
defaultType: 'textfield',
|
|
items: [{
|
|
fieldLabel: '生产厂家',
|
|
name: 'ScEtpName'
|
|
}, {
|
|
fieldLabel: '存储要求',
|
|
name: 'PluCcYq'
|
|
}, {
|
|
fieldLabel: '价格',
|
|
xtype: 'numberfield',
|
|
allowBlank: false,
|
|
name: 'Price'
|
|
}
|
|
]
|
|
}, {
|
|
xtype: 'container',
|
|
layout: 'hbox',
|
|
defaultType: 'textfield',
|
|
items: [
|
|
this.comboxPluType
|
|
]
|
|
}
|
|
]//end items(fieldset 1)
|
|
}//end fieldset 1
|
|
]//end root items
|
|
}); //end this.formEdit
|
|
|
|
//按钮Toolbar
|
|
this.panelBtn = new Ext.Panel({
|
|
region: "north",
|
|
tbar: [
|
|
{
|
|
text: "保存",
|
|
iconCls: "btnsave",
|
|
handler: function (button, event) {
|
|
this.Save('0');
|
|
},
|
|
scope: this
|
|
},
|
|
{
|
|
text: "保存并关闭",
|
|
handler: function (button, event) {
|
|
this.Save('1');
|
|
},
|
|
scope: this
|
|
},
|
|
'-',
|
|
{
|
|
text: "保存并新建",
|
|
handler: function (button, event) {
|
|
this.Save('2');
|
|
},
|
|
scope: this
|
|
}
|
|
]
|
|
}); //end 按钮Toolbar
|
|
|
|
Ext.apply(this, {
|
|
items: [this.panelBtn, this.formEdit]
|
|
});
|
|
|
|
parentWin = window.parent.opener;
|
|
this.InitData();
|
|
}, //end initUIComponents
|
|
|
|
InitData: function () {
|
|
this.opStatus = 'add';
|
|
var condition = '';
|
|
if (parentWin) {
|
|
var ret = parentWin.OprationSwap();
|
|
this.opStatus = ret[0];
|
|
this.StoreList = ret[1];
|
|
this.editRecord = ret[2];
|
|
}
|
|
|
|
if (this.opStatus == 'edit')
|
|
condition = " PluCode='" + this.editRecord.get('PluCode') + "'";
|
|
|
|
this.LoadData(this.opStatus, condition);
|
|
|
|
}, //end InitData
|
|
|
|
LoadData: function (opstatus, condition) {
|
|
this.opStatus = opstatus;
|
|
Ext.Ajax.request({
|
|
waitMsg: '正在查询主表数据...',
|
|
url: '/TruckMng/MsTruckPlu/GetData',
|
|
params: {
|
|
handle: opstatus,
|
|
condition: condition
|
|
},
|
|
callback: function (options, success, response) {
|
|
if (success) {
|
|
var result = Ext.JSON.decode(response.responseText);
|
|
if (!result.Success) {
|
|
Ext.Msg.show({
|
|
title: '提示',
|
|
msg: result.Message,
|
|
icon: Ext.MessageBox.ERROR,
|
|
buttons: Ext.Msg.OK
|
|
});
|
|
return;
|
|
}
|
|
|
|
var data = result.data;
|
|
this.formEdit.getForm().reset();
|
|
this.formEdit.getForm().setValues(data);
|
|
|
|
} else {
|
|
Ext.MessageBox.alert('请求出现错误,请重试', response.responseText);
|
|
}
|
|
},
|
|
scope: this
|
|
});
|
|
}, // end LoadDate
|
|
|
|
|
|
Save: function (type) {
|
|
if (!this.formEdit.getForm().isValid()) {
|
|
return;
|
|
}
|
|
|
|
var data = this.formEdit.getForm().getValues();
|
|
|
|
Ext.Msg.wait('正在保存数据, 请稍侯..');
|
|
Ext.Ajax.request({
|
|
waitMsg: '正在保存数据...',
|
|
url: '/TruckMng/MsTruckPlu/Save',
|
|
scope: this,
|
|
params: {
|
|
opstatus: this.opStatus,
|
|
data: Ext.JSON.encode(data)
|
|
},
|
|
callback: function (options, success, response) {
|
|
if (success) {
|
|
Ext.MessageBox.hide();
|
|
var jsonresult = Ext.JSON.decode(response.responseText);
|
|
if (jsonresult.Success) {
|
|
var returnData = jsonresult.Data;
|
|
this.formEdit.getForm().setValues(returnData);
|
|
|
|
if (this.opStatus == 'add') {
|
|
var arrNewRecords = this.StoreList.insert(0, returnData);
|
|
this.editRecord = this.StoreList.getAt(0);
|
|
|
|
}
|
|
else if (this.opStatus == 'edit') {
|
|
var editp = Ext.create('MsTruckPlu', returnData);
|
|
this.editRecord.fields.each(function (field) {
|
|
if (field.persist) {
|
|
name = field.name;
|
|
if (name != 'id')
|
|
this.editRecord.set(name, editp.get(name));
|
|
}
|
|
}, this);
|
|
this.editRecord.commit();
|
|
}
|
|
if (type == '0') {
|
|
this.opStatus = 'edit';
|
|
} else if (type == '1') {
|
|
window.close();
|
|
} else {
|
|
this.LoadData('add', '');
|
|
}
|
|
} else {
|
|
Ext.Msg.show({ title: '错误', msg: jsonresult.Message, icon: Ext.Msg.ERROR, buttons: Ext.Msg.OK });
|
|
}
|
|
} else {
|
|
Ext.Msg.show({ title: '请重试',
|
|
msg: '服务器响应出错',
|
|
icon: Ext.Msg.ERROR, buttons: Ext.Msg.OK
|
|
});
|
|
}
|
|
}
|
|
});
|
|
} //end save
|
|
|
|
});
|
|
|
|
|