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.
DS7/DSWeb/Areas/TruckMng/Viewsjs/MsWlTyreScrap/MsWlTyreScrapEdit.js

292 lines
9.9 KiB
JavaScript

2 years ago
Ext.namespace('DsTruck');
DsTruck.MsWlTyreScrapEdit = function (config) {
Ext.applyIf(this, config);
this.initUIComponents();
window.DsTruck.MsWlTyreScrapEdit.superclass.constructor.call(this);
};
Ext.extend(DsTruck.MsWlTyreScrapEdit, Ext.Panel, {
ParentWin: null,
OpStatus: 'add',
StoreList: null,
EditRecord: null,
initUIComponents: function () {
//枚举参照相关
this.storeTyreType = Ext.create('DsExt.ux.RefEnumStore', {});
this.storeTyreType.load({ params: { enumTypeId: 99013} });
this.comboxTyreType = Ext.create('DsExt.ux.RefEnumCombox', {
fieldLabel: '轮胎类型',
store: this.storeTyreType,
name: 'TyreType'
});
this.storeTyrePos = Ext.create('DsExt.ux.RefEnumStore', {});
this.storeTyrePos.load({ params: { enumTypeId: 99015} });
this.comboxTyrePos = Ext.create('DsExt.ux.RefEnumCombox', {
fieldLabel: '轮胎位置',
store: this.storeTyrePos,
name: 'TyrePos'
});
//表参照相关
this.storeTruckNo = Ext.create('DsExt.ux.RefTableStore', {
model: 'MsWlTyreScrapRefMsWlTruck',
proxy: { url: '/TruckMng/MsWlTyreScrap/GetTruckNoList' }
});
this.storeTruckNo.load();
this.comboxTruckNo = Ext.create('DsExt.ux.RefTableCombox', {
fieldLabel: '车牌号',
store: this.storeTruckNo,
name: 'TruckNo',
valueField: 'TruckNo',
displayField: 'CodeAndName'
});
this.storePluCode = Ext.create('DsExt.ux.RefTableStore', {
model: 'DsTruckMng.ux.PluRefModel',
proxy: { url: '/CommMng/BasicDataRef/GetPluRefList' }
});
this.storePluCode.load();
this.comboxPluCode = Ext.create('DsExt.ux.RefTableCombox', {
fieldLabel: '轮胎编码',
store: this.storePluCode,
name: 'PluCode',
valueField: 'PluCode',
displayField: 'BarCode'
});
//编辑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: '序号',
xtype: 'numberfield',
name: 'SerialNo', flex: 0, hidden: true, margins: '0'
}, {
fieldLabel: '组织编码',
name: 'OrgCode', flex: 0, hidden: true, margins: '0'
}, {
fieldLabel: '轮胎名称',
name: 'PluName', flex: 0, hidden: true, margins: '0'
}, {
fieldLabel: '规格',
name: 'Spec', flex: 0, hidden: true, margins: '0'
}, this.comboxTruckNo, {
fieldLabel: '轮胎串号',
name: 'PcNo'
}, this.comboxPluCode
]
}, {
xtype: 'container',
layout: 'hbox',
defaultType: 'textfield',
items: [this.comboxTyreType, this.comboxTyrePos, {
fieldLabel: '行驶里程',
xtype: 'numberfield',
allowBlank: false,
name: 'RealMil'
}
]
}, {
xtype: 'container',
layout: 'hbox',
defaultType: 'textfield',
items: [{
fieldLabel: '报废日期',
format: 'Y-m-d',
xtype: 'datefield',
name: 'ScrapDate'
}, {
fieldLabel: '报废原因',
name: 'ScrapReason'
}, {
fieldLabel: '备注',
name: 'Remark'
}
]
}
]//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
}
]
}); //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 = " SerialNo='" + this.editRecord.get('SerialNo') + "'";
this.LoadData(this.opStatus, condition);
}, //end InitData
LoadData: function (opstatus, condition) {
this.opStatus = opstatus;
Ext.Ajax.request({
waitMsg: '正在查询主表数据...',
url: '/TruckMng/MsWlTyreScrap/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/MsWlTyreScrap/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 p = Ext.create('MsWlTyreScrap', returnData); // Ext.create('MsWlTyreScrap', data, NewGuid()); //或者new MsWlTyreScrap(data, NewGuid());
this.storeList.add(p);
this.editRecord = p;
}
else if (this.opStatus == 'edit') {
var editp = Ext.create('MsWlTyreScrap', 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
});