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/MsCodeVesselSet/MsCodeVesselSetEdit.js

353 lines
11 KiB
JavaScript

2 years ago
Ext.namespace('Shipping');
Shipping.MsCodeGoodsEdit = function (config) {
Ext.applyIf(this, config);
this.initUIComponents();
window.Shipping.MsCodeGoodsEdit.superclass.constructor.call(this);
};
Ext.extend(Shipping.MsCodeGoodsEdit, Ext.Panel, {
ParentWin: null,
OpStatus: 'add',
storeList: null,
EditRecord: null,
feeType: 0,
StoreFee: null,
initUIComponents: function () {
this.serialNo = 0;
this.workSerialNo = 0;
this.bodyDel = [];
this.CodeGoodsEdit = getUrlParam('CodeGoodsEdit');
//#region 编辑form
//枚举参照相关(编辑form)
this.storeCARRIER = Ext.create('DsExt.ux.RefTableStore', {
model: 'DsShipping.ux.CustomRefModel',
proxy: { url: '/CommMng/BasicDataRef/GetCustomRefListCARRIER' }
});
this.storeCARRIER.load({ params: { condition: "ISCARRIER='1'"} });
this.comboxCARRIER = Ext.create('DsExt.ux.RefTableCombox', {
fieldLabel: '船公司',
store: this.storeCARRIER,
name: 'carrier',
valueField: 'CustName',
displayField: 'CodeAndName'
});
//表参照相关(编辑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: '船名代码',
name: 'vsid',
hidden:true
},
this.comboxCARRIER]
}, {
xtype: 'container',
layout: 'hbox',
defaultType: 'textfield',
items: [{
fieldLabel: '船名英文名称',
name: 'vessel',
allowBlank: false,
flex:1
}]
},{
xtype: 'container',
layout: 'hbox',
defaultType: 'textfield',
items: [{
fieldLabel: '船名中文文名称',
name: 'cname',
allowBlank: true,
flex:1
}
]
}, {
xtype: 'container',
layout: 'hbox',
defaultType: 'textfield',
items: [{
fieldLabel: '船舶呼号',
name: 'edicode',
allowBlank: true,
flex:1
}]
}
]//end items(fieldset 1)
}//end fieldset 1
]//end root items
}); //end this.formEdit
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
},
'-',
{
text: "复制新建",
handler: function (button, event) {
var basicForm = this.formEdit.getForm();
this.opStatus = 'add';
},
scope: this
}
]
}); //end 按钮Toolbar
//#endregion
//#region 明细表
//#region 布局
//控件布局
this.panelTop = new Ext.Panel({
layout: "border",
region: "north",
height: 360,
width:100,
items: [this.panelBtn, this.formEdit]
});
Ext.apply(this, {
items: [this.panelTop, this.paneldetail]
});
//#endregion
//绑定查询窗体
//初始化数据
this.ParentWin = window.parent.opener;
this.InitData();
}, //end initUIComponents
InitData: function () {
this.opStatus = 'add';
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 =this.editRecord.get('vsid');
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/MsCodeVesselSet/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
});
var billno = '*';
var cargoid = 0;
if (this.opStatus == 'edit') {
cargoid = this.editRecord.get('PORTID');
}
}, // end LoadDate
Save: function (type) {
var basicForm = this.formEdit.getForm();
if (!basicForm.isValid()) {
return;
}
var data = basicForm.getValues();
data.DM_ID = NewGuid();
basicForm.findField('vsid').setValue(data.DM_ID);
Ext.Msg.wait('正在保存数据, 请稍侯..');
Ext.Ajax.request({
waitMsg: '正在保存数据...',
url: '/MvcShipping/MsCodeVesselSet/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') {
Ext.Msg.alert('提示','添加成功');
var arrNewRecords = this.storeList.add(returnData);
this.editRecord = arrNewRecords[0];
}
else if (this.opStatus == 'edit') {
this.opStatus='edit';
Ext.Msg.alert('提示','修改成功');
// var editp = Ext.create('MsCodeVesselSet', returnData);
// this.editRecord.fields.each(function (field) {
// if (field.persist) {
// name = field.name;
// if (name != 'id')
// this.editRecord.set(name, returnData.get(name));
// }
// }, this);
this.storeList.reload();
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
onAddDetailClick: function (button, event, type) {
this.addDetail(type);
}, //end onAddDetailClick
onDelDetailClick: function (button, event, type) {
this.deleteDetail(type);
}, //onDelDetailClick
gridAfterEdit: function (editor, e, eOpts) {
},
addDetail: function (type) {
var newSerialno = 0;
store = this.storeBodyList;
var record = Ext.create('MsCodeGoodsDetail', {
GID: '',
LINKGID: '',
GOODSDETAILNAME: "",
GOODSDETAILPKGS: 0
});
store.add(record);
this.gridListCellEditing.startEditByPosition({ row: 2, column: 1 });
},
});