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/MvcShipping/Viewsjs/MsContainerSetCtn/MsContainerSetCtnEdit.js

439 lines
15 KiB
JavaScript

Ext.namespace('Shipping');
Shipping.MsContainerSetCtnEdit = function (config) {
Ext.applyIf(this, config);
this.initUIComponents();
window.Shipping.MsContainerSetCtnEdit.superclass.constructor.call(this);
};
Ext.extend(Shipping.MsContainerSetCtnEdit, Ext.Panel, {
ParentWin: null,
OpStatus: 'add',
StoreList: null,
EditRecord: null,
initUIComponents: function () {
this.serialNo = 0;
this.workSerialNo = 0;
this.bodyDel = [];
//#region 定义CNT下拉
_this = this;
this.storeCNT1 = Ext.create('DsExt.ux.RefTableStore', {
model: 'MsContainerSetEntity',
proxy: { url: '/MvcShipping/MsContainerSet/GetDataList' }
});
this.storeCNT2 = Ext.create('DsExt.ux.RefTableStore', {
model: 'MsContainerSetEntity',
proxy: { url: '/MvcShipping/MsContainerSet/GetDataList' }
});
this.storeCNT3 = Ext.create('DsExt.ux.RefTableStore', {
model: 'MsContainerSetEntity',
proxy: { url: '/MvcShipping/MsContainerSet/GetDataList' }
});
this.storeCNT4 = Ext.create('DsExt.ux.RefTableStore', {
model: 'MsContainerSetEntity',
proxy: { url: '/MvcShipping/MsContainerSet/GetDataList' }
});
this.storeCNT5 = Ext.create('DsExt.ux.RefTableStore', {
model: 'MsContainerSetEntity',
proxy: { url: '/MvcShipping/MsContainerSet/GetDataList' }
});
this.storeCNT6 = Ext.create('DsExt.ux.RefTableStore', {
model: 'MsContainerSetEntity',
proxy: { url: '/MvcShipping/MsContainerSet/GetDataList' }
});
this.storeCNT7 = Ext.create('DsExt.ux.RefTableStore', {
model: 'MsContainerSetEntity',
proxy: { url: '/MvcShipping/MsContainerSet/GetDataList' }
});
this.storeCNT8 = Ext.create('DsExt.ux.RefTableStore', {
model: 'MsContainerSetEntity',
proxy: { url: '/MvcShipping/MsContainerSet/GetDataList' }
});
this.storeCNT9 = Ext.create('DsExt.ux.RefTableStore', {
model: 'MsContainerSetEntity',
proxy: { url: '/MvcShipping/MsContainerSet/GetDataList' }
});
this.storeCNT10 = Ext.create('DsExt.ux.RefTableStore', {
model: 'MsContainerSetEntity',
proxy: { url: '/MvcShipping/MsContainerSet/GetDataList' }
});
this.storeCNT1.load({
params: { start: 0, limit: 500, condition: '' },
waitMsg: "正在查询数据...",
callback: function (options, success, response) {
_this.storeCNT2.loadData(_this.storeCNT1.data.items);
_this.storeCNT3.loadData(_this.storeCNT1.data.items);
_this.storeCNT4.loadData(_this.storeCNT1.data.items);
_this.storeCNT5.loadData(_this.storeCNT1.data.items);
_this.storeCNT6.loadData(_this.storeCNT1.data.items);
_this.storeCNT7.loadData(_this.storeCNT1.data.items);
_this.storeCNT8.loadData(_this.storeCNT1.data.items);
_this.storeCNT9.loadData(_this.storeCNT1.data.items);
_this.storeCNT10.loadData(_this.storeCNT1.data.items);
},
scope: this
});
this.comboxCTN1 = Ext.create('DsExt.ux.RefTableCombox', {
fieldLabel: 'CNT1',
store: this.storeCNT1,
forceSelection: true,
name: 'CNT1',
valueField: 'CTN',
displayField: 'CTN'
});
this.comboxCTN2 = Ext.create('DsExt.ux.RefTableCombox', {
fieldLabel: 'CNT2',
store: this.storeCNT2,
forceSelection: true,
name: 'CNT2',
valueField: 'CTN',
displayField: 'CTN'
});
this.comboxCTN3 = Ext.create('DsExt.ux.RefTableCombox', {
fieldLabel: 'CNT3',
store: this.storeCNT3,
forceSelection: true,
name: 'CNT3',
valueField: 'CTN',
displayField: 'CTN'
});
this.comboxCTN4 = Ext.create('DsExt.ux.RefTableCombox', {
fieldLabel: 'CNT4',
store: this.storeCNT4,
forceSelection: true,
name: 'CNT4',
valueField: 'CTN',
displayField: 'CTN'
});
this.comboxCTN5 = Ext.create('DsExt.ux.RefTableCombox', {
fieldLabel: 'CNT5',
store: this.storeCNT5,
forceSelection: true,
name: 'CNT5',
valueField: 'CTN',
displayField: 'CTN'
});
this.comboxCTN6 = Ext.create('DsExt.ux.RefTableCombox', {
fieldLabel: 'CNT6',
store: this.storeCNT6,
forceSelection: true,
name: 'CNT6',
valueField: 'CTN',
displayField: 'CTN'
});
this.comboxCTN7 = Ext.create('DsExt.ux.RefTableCombox', {
fieldLabel: 'CNT7',
store: this.storeCNT7,
forceSelection: true,
name: 'CNT7',
valueField: 'CTN',
displayField: 'CTN'
});
this.comboxCTN8 = Ext.create('DsExt.ux.RefTableCombox', {
fieldLabel: 'CNT8',
store: this.storeCNT8,
forceSelection: true,
name: 'CNT8',
valueField: 'CTN',
displayField: 'CTN'
});
this.comboxCTN9 = Ext.create('DsExt.ux.RefTableCombox', {
fieldLabel: 'CNT9',
store: this.storeCNT9,
forceSelection: true,
name: 'CNT9',
valueField: 'CTN',
displayField: 'CTN'
});
this.comboxCTN10 = Ext.create('DsExt.ux.RefTableCombox', {
fieldLabel: 'CNT10',
store: this.storeCNT10,
forceSelection: true,
name: 'CNT10',
valueField: 'CTN',
displayField: 'CTN'
});
//#endregion 定义CNT下拉-结束
//#region 编辑form
//枚举参照相关(编辑form)
this.storeEdiType = Ext.create('DsExt.ux.RefEnumStore', {});
this.storeEdiType.load({ params: { enumTypeId: 97012 } });
this.comboxEdiType = Ext.create('DsExt.ux.RefTableCombox', {
fieldLabel: 'EDI名称',
store: this.storeEdiType,
forceSelection: true,
name: 'EDINAME',
valueField: 'EnumValueId',
displayField: 'EnumValueName'
});
this.StoreISUSETEL = Ext.create('Ext.data.Store', {
fields: ['value', 'text']
});
this.StoreISUSETEL.add({ 'value': '1', 'text': '是' });
this.StoreISUSETEL.add({ 'value': '', 'text': '否' });
this.comboxISUSETEL = Ext.create('DsExt.ux.RefTableCombox', {
fieldLabel: '启用设置TEL', //'默认FRT',
store: this.StoreISUSETEL,
valueField: 'value',
displayField: 'text',
forceSelection: true,
name: 'ISUSETEL'
});
//表参照相关(编辑form)
//编辑form
this.formEdit = Ext.widget('form', {
region: 'center',
frame: true,
bodyPadding: 5,
autoScroll: true,
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: 'CORPID',
name: 'CORPID', flex: 0, hidden: true, margins: '0'
}, {
fieldLabel: 'ID',
name: 'ID', flex: 0, hidden: true, margins: '0'
}
]
}, {
xtype: 'container',
layout: 'hbox',
defaultType: 'combobox',
items: [this.comboxCTN1, this.comboxCTN2 ]
}, {
xtype: 'container',
layout: 'hbox',
defaultType: 'combobox',
items: [this.comboxCTN3, this.comboxCTN4 ]
}, {
xtype: 'container',
layout: 'hbox',
defaultType: 'combobox',
items: [this.comboxCTN5, this.comboxCTN6 ]
}, {
xtype: 'container',
layout: 'hbox',
defaultType: 'combobox',
items: [this.comboxCTN7, this.comboxCTN8 ]
}, {
xtype: 'container',
layout: 'hbox',
defaultType: 'combobox',
items: [this.comboxCTN9, this.comboxCTN10 ]
}
]//end items(fieldset 1)
}//end fieldset 1
]//end root items
}); //end this.formEdit
//#endregion
//#region 按钮Toolbar
this.panelBtn = new Ext.Panel({
region: "north",
tbar: [
{
text: "保存并关闭",
handler: function (button, event) {
this.Save('1');
window.close();
},
scope: this
},
{
text: "关闭",
handler: function (button, event) {
window.close();
},
scope: this
}
]
}); //end 按钮Toolbar
//#endregion
//#region 布局
//控件布局
Ext.apply(this, {
items: [this.panelBtn, this.formEdit]
});
//#endregion
//绑定查询窗体
this.ParentWin = window.parent.opener;
//初始化数据
this.InitData();
}, //end initUIComponents
InitData: function () {
this.opStatus = 'edit';
var condition = '';
if (this.ParentWin) {
var ret = this.ParentWin.OprationSwap();
this.opStatus = ret[0];
this.StoreList = ret[1];
this.editRecord = ret[2];
}
if (this.opStatus == 'edit')
condition = " CORPID='" + CORPID + "'";
this.LoadData(this.opStatus, condition);
}, //end InitData
LoadData: function (opstatus, condition) {
this.serialNo = 0;
this.workSerialNo = 0;
this.bodyDel = [];
this.opStatus = opstatus;
Ext.Ajax.request({
waitMsg: '正在查询主表数据...',
url: '/MvcShipping/MsContainerSetCtn/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) {
var basicForm = this.formEdit.getForm();
if (!basicForm.isValid()) {
return;
}
basicForm.findField('CORPID').setDisabled(false);
var data = basicForm.getValues();
basicForm.findField('CORPID').setDisabled(true);
if (this.opStatus == 'edit') {
data.CORPID = CORPID;
//data.ID = NewGuid();
if (data.ID == "")
data.ID = NewGuid();
}
Ext.Msg.wait('正在保存数据, 请稍侯..');
Ext.Ajax.request({
waitMsg: '正在保存数据...',
url: '/MvcShipping/MsContainerSetCtn/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.add(returnData);
this.editRecord = arrNewRecords[0];
}
else if (this.opStatus == 'edit') {
var editp = Ext.create('MsContainerSetCtn', returnData);
this.editRecord.fields.each(function (field) {
if (field.persist) {
name = field.name;
if (name != 'CORPID'&&name!='ID')
this.editRecord.set(name, editp.get(name));
}
}, this);
this.editRecord.commit();
}
} 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
});
}
}
});
}
});