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.
539 lines
18 KiB
JavaScript
539 lines
18 KiB
JavaScript
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',
|
|
forceSelection: true,
|
|
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.storeListPORTDISCHARGE = Ext.create('Ext.data.Store', {
|
|
model: 'MsCodeCtnEdi',
|
|
remoteSort: true,
|
|
proxy: {
|
|
type: 'ajax',
|
|
url: '/MvcShipping/MsCodeCtnEdi/GetVesselList',
|
|
reader: {
|
|
id: 'GID',
|
|
root: 'data',
|
|
totalProperty: 'totalCount'
|
|
}
|
|
}
|
|
});
|
|
this.gridListPORTDISCHARGECellEditing = Ext.create('Ext.grid.plugin.CellEditing', {
|
|
clicksToEdit: 1
|
|
});
|
|
|
|
this.storeEdiType = Ext.create('DsExt.ux.RefEnumStore', {});
|
|
this.storeEdiType.load({ params: { enumTypeId: 97012 } });
|
|
|
|
this.comboxEdiType = Ext.create('DsExt.ux.RefTableCombox', {
|
|
store: this.storeEdiType,
|
|
forceSelection: true,
|
|
name: 'EDINAME',
|
|
valueField: 'EnumValueId',
|
|
displayField: 'EnumValueName'
|
|
});
|
|
|
|
//定义Grid
|
|
this.gridListPORTDISCHARGE = new Ext.grid.GridPanel({
|
|
store: this.storeListPORTDISCHARGE,
|
|
enableHdMenu: false,
|
|
region: 'center',
|
|
loadMask: { msg: "数据加载中,请稍等..." },
|
|
trackMouseOver: true,
|
|
disableSelection: false,
|
|
plugins: [this.gridListPORTDISCHARGECellEditing],
|
|
selType: 'cellmodel',
|
|
tbar: [{
|
|
text: '增加明细',
|
|
tooltip: '增加明细',
|
|
iconCls: "btnadddetail",
|
|
handler: function (button, event) {
|
|
this.onAddDetailClick();
|
|
},
|
|
scope: this
|
|
}, '-', {
|
|
text: '删除明细',
|
|
tooltip: '删除明细',
|
|
iconCls: "btndeletedetail",
|
|
handler: function (button, event) {
|
|
this.onDeletePORTDISCHARGEClick();
|
|
},
|
|
scope: this
|
|
}],
|
|
columns: [{
|
|
sortable: true,
|
|
dataIndex: 'GID',
|
|
header: 'GID',
|
|
hidden: true,
|
|
width: 120
|
|
}, {
|
|
sortable: true,
|
|
dataIndex: 'EDINAME',
|
|
header: 'EDI类别',
|
|
width: 100,
|
|
editor: this.comboxEdiType,
|
|
renderer: function (value, p, record) {
|
|
return record.data.EDINAMEREF;
|
|
}
|
|
}, {
|
|
sortable: true,
|
|
dataIndex: 'EDICODE',
|
|
header: 'EDI代码',
|
|
width: 160,
|
|
editor: {
|
|
xtype: 'textfield',
|
|
selectOnFocus: true
|
|
}
|
|
}, {
|
|
sortable: true,
|
|
dataIndex: 'REMARK',
|
|
header: '备注',
|
|
width: 160,
|
|
editor: {
|
|
xtype: 'textfield',
|
|
selectOnFocus: true
|
|
}
|
|
}]
|
|
});
|
|
|
|
this.panelPORTDISCHARGE = new Ext.Panel({
|
|
layout: "border",
|
|
title: 'EDI代码维护',
|
|
id: 'pnlPORTDISCHARGE',
|
|
region: "center",
|
|
items: [this.gridListPORTDISCHARGE]
|
|
});
|
|
//#endregion
|
|
|
|
|
|
|
|
|
|
//#region 布局
|
|
//控件布局
|
|
this.panelTop = new Ext.Panel({
|
|
layout: "border",
|
|
region: "north",
|
|
height: 190,
|
|
width:100,
|
|
items: [this.panelBtn, this.formEdit]
|
|
});
|
|
|
|
Ext.apply(this, {
|
|
items: [this.panelTop, this.panelPORTDISCHARGE]
|
|
});
|
|
|
|
//#endregion
|
|
|
|
//绑定查询窗体
|
|
|
|
//初始化数据
|
|
this.storeListPORTDISCHARGE.on('beforeload', function (store) {
|
|
var cargoid = '0';
|
|
if (this.opStatus == 'edit') {
|
|
cargoid = this.editRecord.get('vessel');
|
|
}
|
|
var sql = " VESSEL='" + cargoid + "'";
|
|
Ext.apply(store.proxy.extraParams, { condition: sql });
|
|
}, this);
|
|
this.storeListPORTDISCHARGE.on('load', function (store, records) {
|
|
if (store.getCount() > 0) {
|
|
this.formEdit.getForm().findField('vessel').setReadOnly(true);
|
|
|
|
} else {
|
|
|
|
}
|
|
}, this);
|
|
|
|
this.gridListPORTDISCHARGE.on('edit', function (editor, e, eOpts) {
|
|
this.gridListAfterEdit(editor, e, eOpts);
|
|
}, this);
|
|
|
|
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('vessel');
|
|
}
|
|
this.storeListPORTDISCHARGE.load({ params: { condition: " VESSEL='" + cargoid + "'" } });
|
|
}, // 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);
|
|
|
|
var bodydatas = [];
|
|
for (var i = 0; i < this.storeListPORTDISCHARGE.getCount(); i += 1) {
|
|
var member = this.storeListPORTDISCHARGE.getAt(i);
|
|
bodydatas.push(member);
|
|
}
|
|
|
|
var jsonBody = ConvertRecordsToJsonAll(bodydatas);
|
|
|
|
Ext.Msg.wait('正在保存数据, 请稍侯..');
|
|
Ext.Ajax.request({
|
|
waitMsg: '正在保存数据...',
|
|
url: '/MvcShipping/MsCodeVesselSet/Save',
|
|
scope: this,
|
|
params: {
|
|
opstatus: this.opStatus,
|
|
data: Ext.JSON.encode(data),
|
|
body: jsonBody
|
|
},
|
|
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';
|
|
this.storeListPORTDISCHARGE.load();
|
|
|
|
} 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
|
|
|
|
|
|
gridListAfterEdit: function (editor, e, eOpts) {
|
|
if (e.value == e.originalValue) return;
|
|
if (e.field == 'EDINAME') {
|
|
var selectrecords = DsStoreQueryBy(this.storeEdiType, 'EnumValueId', e.value);
|
|
if (selectrecords.getCount() > 0) {
|
|
var selectdata = selectrecords.getAt(0).data;
|
|
e.record.set('EDINAMEREF', selectdata.EnumValueName);
|
|
} else {
|
|
e.record.set('EDINAMEREF', '');
|
|
}
|
|
}
|
|
},
|
|
|
|
addDetail: function (type) {
|
|
var newSerialno = 0;
|
|
var PORT = this.formEdit.getForm().findField("vessel").getValue();
|
|
if (PORT == '') {
|
|
Ext.Msg.show({ title: '提示', msg: '英文船名不能为空', icon: Ext.Msg.INFO, buttons: Ext.Msg.OK });//没有选择要申请的费用!
|
|
|
|
return;
|
|
}
|
|
|
|
|
|
store = this.storeListPORTDISCHARGE;
|
|
|
|
var record = Ext.create('MsCodeCtnEdi', {
|
|
GID: '*',
|
|
CTN: PORT,
|
|
EDICODE: '',
|
|
EDINAME: ''
|
|
|
|
});
|
|
|
|
store.add(record);
|
|
|
|
var n = this.storeListPORTDISCHARGE.getCount();
|
|
this.gridListPORTDISCHARGECellEditing.startEditByPosition({ row: n - 1, column: 1 });
|
|
|
|
},
|
|
|
|
|
|
onDeletePORTDISCHARGEClick: function () {
|
|
var selections = this.gridListPORTDISCHARGE.getSelectionModel().getSelection();
|
|
if (selections.length == 0) {
|
|
Ext.Msg.show({ title: '提示', msg: '请先选择单据!', icon: Ext.Msg.INFO, buttons: Ext.Msg.OK });
|
|
return;
|
|
}
|
|
|
|
var record = selections[0];
|
|
Ext.MessageBox.confirm('提示', '确定删除该记录吗?', function (btn) {
|
|
if (btn == 'yes') {
|
|
Ext.Msg.wait('正在删除数据...');
|
|
Ext.Ajax.request({
|
|
waitMsg: '正在删除数据...',
|
|
url: '/MvcShipping/MsCodeCtnEdi/DeleteVessel',
|
|
params: {
|
|
data: Ext.JSON.encode(record.data)
|
|
},
|
|
callback: function (options, success, response) {
|
|
if (success) {
|
|
var jsonresult = Ext.JSON.decode(response.responseText);
|
|
if (jsonresult.Success) {
|
|
this.storeListPORTDISCHARGE.remove(record);
|
|
//Ext.Msg.show({ title: '提示', msg: jsonresult.Message, icon: Ext.Msg.INFO, buttons: Ext.Msg.OK });
|
|
Ext.Msg.hide();
|
|
}
|
|
else {
|
|
Ext.Msg.show({ title: '错误', msg: jsonresult.Message, icon: Ext.Msg.ERROR, buttons: Ext.Msg.OK });
|
|
}
|
|
}
|
|
},
|
|
failure: function (response, options) {
|
|
Ext.Msg.show({ title: '警告', msg: '服务器响应出错,请重试', icon: Ext.Msg.INFO, buttons: Ext.Msg.OK });
|
|
},
|
|
success: function (response, options) {
|
|
},
|
|
scope: this
|
|
});
|
|
}
|
|
}, this);
|
|
} //onDeleteClick
|
|
});
|
|
|
|
|