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.
627 lines
19 KiB
JavaScript
627 lines
19 KiB
JavaScript
Ext.namespace('Shipping');
|
|
|
|
Shipping.MsOpCtnFeeModelEdit = function (config) {
|
|
Ext.applyIf(this, config);
|
|
this.initUIComponents();
|
|
window.Shipping.MsOpCtnFeeModelEdit.superclass.constructor.call(this);
|
|
};
|
|
var CTN = '';
|
|
var GID = '';
|
|
Ext.extend(Shipping.MsOpCtnFeeModelEdit, Ext.Panel, {
|
|
|
|
ParentWin: null,
|
|
OpStatus: 'add',
|
|
StoreList: null,
|
|
EditRecord: null,
|
|
CTN: '',
|
|
initUIComponents: function () {
|
|
this.serialNo = 0;
|
|
this.workSerialNo = 0;
|
|
this.detailsDel = [];
|
|
|
|
//#region 编辑form
|
|
|
|
//枚举参照相关(编辑form)
|
|
|
|
|
|
//表参照相关(编辑form)
|
|
Ext.regModel('IsCustOnly', {
|
|
fields: [{ name: 'value' }, { name: 'text'}]
|
|
})
|
|
var IsCustOnlyStore = new Ext.data.Store({
|
|
model: 'IsCustOnly',
|
|
data: [{ 'value': '0', 'text': '否' },
|
|
{ 'value': '1', 'text': '是'}]
|
|
});
|
|
var cbIsCustOnly = Ext.create('Ext.form.ComboBox', {
|
|
name: 'IsCustOnly',
|
|
queryMode: 'local',
|
|
id: 'IsCustOnly',
|
|
triggerAction: 'all',
|
|
forceSelection: true,
|
|
allowBlank: false,
|
|
flex: 1,
|
|
valueField: 'value',
|
|
displayField: 'text',
|
|
store: IsCustOnlyStore,
|
|
fieldLabel: '是否客户专有',
|
|
hidden:true,
|
|
listeners: {
|
|
afterRender: function (combo) {
|
|
combo.setValue('1'); //同时下拉框会将与name为firstValue值对应的 text显示
|
|
}
|
|
}
|
|
});
|
|
cbIsCustOnly.on('load', function () { Ext.getCmp("IsCustOnly").setValue('1'); });
|
|
|
|
|
|
//客户加载_场站
|
|
this.storeYARD = Ext.create('DsExt.ux.RefTableStore', {
|
|
model: 'DsShipping.ux.CustomRefModel',
|
|
proxy: { url: '/CommMng/BasicDataRef/GetCustomRefListYARD' }
|
|
});
|
|
this.storeYARD.load();
|
|
//
|
|
this.comboxYARD = Ext.create('DsExt.ux.RefTableCombox', {
|
|
fieldLabel: '场站', //'场站',
|
|
store: this.storeYARD,
|
|
forceSelection: true,
|
|
queryMode: 'remote',
|
|
minChars: 0,
|
|
queryParam: 'CODENAME',
|
|
name: 'PortAndYardName',
|
|
valueField: 'CodeAndName',
|
|
displayField: 'CodeAndName'
|
|
});
|
|
|
|
//编辑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: 'GID',
|
|
name: 'GID', flex: 0, hidden: true, margins: '0'
|
|
}, {
|
|
fieldLabel: '模板名称',
|
|
allowBlank: false,
|
|
name: 'ModelName'
|
|
}, this.comboxYARD,
|
|
// {
|
|
// fieldLabel: '港口全称',
|
|
// allowBlank: true,
|
|
// name: 'PortAndYardName'
|
|
// },
|
|
{
|
|
fieldLabel: '录入人',
|
|
readOnly: true,
|
|
name: 'Oper'
|
|
}, {
|
|
fieldLabel: '录入日期',
|
|
readOnly: true,
|
|
name: 'Optime'
|
|
}
|
|
]
|
|
}
|
|
]//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: "保存",
|
|
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
|
|
|
|
//#endregion
|
|
|
|
//#region 明细表
|
|
|
|
//明细表表格相关
|
|
|
|
|
|
//明细表-数据集
|
|
this.storeCtnList = Ext.create('Ext.data.Store', {
|
|
model: 'MsOpCtn',
|
|
remoteSort: true,
|
|
proxy: {
|
|
type: 'ajax',
|
|
url: '/MvcShipping/MsOpCtnFeeModelDuiCun/GetCtn',
|
|
reader: {
|
|
root: 'data',
|
|
totalProperty: 'totalCount'
|
|
}
|
|
}
|
|
});
|
|
|
|
|
|
this.gridList = new Ext.grid.GridPanel({
|
|
store: this.storeCtnList,
|
|
enableHdMenu: false,
|
|
region: 'center',
|
|
loadMask: { msg: "数据加载中,请稍等..." },
|
|
trackMouseOver: true,
|
|
disableSelection: false,
|
|
columns: [{
|
|
sortable: true,
|
|
dataIndex: 'CtnType',
|
|
header: '箱型',
|
|
width: 140
|
|
}
|
|
]
|
|
});
|
|
|
|
|
|
this.gridList.addListener('cellclick', function (dataview, record, item, data, e, b) {
|
|
|
|
CTN = data.data.CtnType;
|
|
var condition = "";
|
|
if (this.opStatus == 'edit') {
|
|
condition = " MainGID='" + GID + "' and XiangXing = '" + CTN + "'";
|
|
this.storeDetailsList.load({ params: { condition: condition} });
|
|
}
|
|
|
|
|
|
}, this);
|
|
|
|
this.storeFangXiang = Ext.create('Ext.data.Store', {
|
|
fields: ['ID', 'TYPE']
|
|
});
|
|
this.storeFangXiang.add({ "ID": "1", "TYPE": "收" });
|
|
this.storeFangXiang.add({ "ID": "2", "TYPE": "付" });
|
|
|
|
this.comboxFangXiang = Ext.create('DsExt.ux.RefTableCombox', {
|
|
store: this.storeFangXiang,
|
|
valueField: 'ID',
|
|
displayField: 'TYPE',
|
|
forceSelection: true,
|
|
name: 'SortType'
|
|
});
|
|
|
|
|
|
this.storeDetailsList = Ext.create('Ext.data.Store', {
|
|
model: 'MsOpCtnFeeModelDetails',
|
|
remoteSort: false,
|
|
pruneModifiedRecords: true,
|
|
proxy: {
|
|
type: 'ajax',
|
|
url: '/MvcShipping/MsOpCtnFeeModelDuiCun/GetDataDetailsList',
|
|
reader: {
|
|
id: 'gid',
|
|
root: 'data',
|
|
totalProperty: 'totalCount'
|
|
}
|
|
}
|
|
});
|
|
|
|
|
|
|
|
//明细表表格
|
|
this.gridDetailsListCellEditing = Ext.create('Ext.grid.plugin.CellEditing', {
|
|
clicksToEdit: 1
|
|
});
|
|
|
|
this.gridDetailsList = new Ext.grid.GridPanel({
|
|
store: this.storeDetailsList,
|
|
enableHdMenu: false,
|
|
region: 'center',
|
|
loadMask: { msg: "数据加载中,请稍等..." },
|
|
trackMouseOver: true,
|
|
disableSelection: false,
|
|
plugins: [this.gridDetailsListCellEditing],
|
|
selType: 'cellmodel',
|
|
tbar: [{
|
|
text: '增加明细',
|
|
tooltip: '增加明细',
|
|
iconCls: "btnadddetail",
|
|
handler: function (button, event) {
|
|
this.onAddDetailClick(button, event, 2);
|
|
},
|
|
scope: this
|
|
}, '-', {
|
|
text: '删除明细',
|
|
tooltip: '删除明细',
|
|
iconCls: "btndeletedetail",
|
|
handler: function (button, event) {
|
|
this.onDelDetailClick(button, event, 2);
|
|
},
|
|
scope: this
|
|
}],
|
|
columns: [{
|
|
sortable: true,
|
|
dataIndex: 'GID',
|
|
header: 'GID',
|
|
hidden: true,
|
|
width: 100
|
|
}, {
|
|
sortable: true,
|
|
dataIndex: 'MainGID',
|
|
header: 'MainGID',
|
|
hidden: true,
|
|
width: 100
|
|
}, {
|
|
sortable: true,
|
|
dataIndex: 'XiangXing',
|
|
header: '箱型',
|
|
width: 100
|
|
}, {
|
|
sortable: true,
|
|
dataIndex: 'JiFeiDengJi',
|
|
header: '计费等级',
|
|
editor: {
|
|
xtype: 'numberfield',
|
|
selectOnFocus: true
|
|
},
|
|
width: 160
|
|
}, {
|
|
sortable: true,
|
|
dataIndex: 'ShouFuFangXiang',
|
|
header: '收付方向',
|
|
editor: this.comboxFangXiang,
|
|
renderer: function (value, p, record) {
|
|
return record.data.ShouFuFangXiang == '1' ? "收" : "付";
|
|
},
|
|
width: 100
|
|
}, {
|
|
sortable: true,
|
|
dataIndex: 'JiFeiQuJian',
|
|
header: '计费区间',
|
|
editor: {
|
|
xtype: 'numberfield',
|
|
selectOnFocus: true
|
|
},
|
|
width: 60
|
|
}, {
|
|
sortable: true,
|
|
dataIndex: 'JiFeiDanJia',
|
|
header: '计费单价',
|
|
editor: {
|
|
xtype: 'numberfield',
|
|
selectOnFocus: true
|
|
},
|
|
width: 60
|
|
}, {
|
|
sortable: true,
|
|
dataIndex: 'Optime',
|
|
header: '修改时间',
|
|
width: 60
|
|
}
|
|
]
|
|
});
|
|
|
|
|
|
this.panelService = new Ext.Panel({
|
|
title: '箱型',
|
|
layout: "border",
|
|
region: 'west',
|
|
width: 140,
|
|
margin: '5 10',
|
|
|
|
items: [this.gridList]
|
|
});
|
|
this.panelwork = new Ext.Panel({
|
|
title: '集装箱收费模板明细',
|
|
layout: "border",
|
|
region: 'center',
|
|
margin: '5 10',
|
|
items: [this.gridDetailsList]
|
|
});
|
|
|
|
this.paneldetail = new Ext.Panel({
|
|
layout: "border",
|
|
region: "center",
|
|
items: [
|
|
this.panelService, this.panelwork
|
|
]
|
|
});
|
|
|
|
//#endregion 明细表
|
|
|
|
//#region 布局
|
|
//控件布局
|
|
this.panelTop = new Ext.Panel({
|
|
layout: "border",
|
|
region: "north",
|
|
height: 100,
|
|
items: [this.panelBtn, this.formEdit]
|
|
});
|
|
|
|
Ext.apply(this, {
|
|
items: [this.panelTop, this.paneldetail]
|
|
});
|
|
|
|
//#endregion
|
|
|
|
//绑定查询窗体
|
|
this.ParentWin = window.parent.opener;
|
|
|
|
//初始化数据
|
|
this.InitData();
|
|
if (this.opStatus == 'edit') {
|
|
|
|
} else {
|
|
|
|
}
|
|
//绑定事件
|
|
this.gridList.on('edit', function (editor, e, eOpts) {
|
|
this.gridAfterEdit(editor, e, eOpts);
|
|
}, this);
|
|
}, //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 = " GID='" + this.editRecord.get('GID') + "'";
|
|
|
|
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/MsOpCtnFeeModelDuiCun/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;
|
|
GID = data.GID;
|
|
|
|
if (this.opStatus == 'edit') {
|
|
this.formEdit.getForm().reset();
|
|
this.formEdit.getForm().setValues(data);
|
|
}
|
|
|
|
|
|
} else {
|
|
Ext.MessageBox.alert('请求出现错误,请重试', response.responseText);
|
|
}
|
|
},
|
|
scope: this
|
|
});
|
|
|
|
var billno = '*';
|
|
var modelid = 0;
|
|
if (this.opStatus == 'edit') {
|
|
modelid = this.editRecord.get('GID');
|
|
|
|
}
|
|
this.storeCtnList.load();
|
|
|
|
// this.storeDetailsList.load({ params: { condition: " GID='" + modelid + "'"} });
|
|
}, // end LoadDate
|
|
|
|
|
|
Save: function (type) {
|
|
var basicForm = this.formEdit.getForm();
|
|
|
|
if (!basicForm.isValid()) {
|
|
return;
|
|
}
|
|
|
|
var data = basicForm.getValues();
|
|
data.Oper = SHOWNAME;
|
|
if (this.opStatus == 'add') {
|
|
data.GID = "*";
|
|
}
|
|
|
|
var detailsArr = [];
|
|
for (var i = 0; i < this.storeDetailsList.getCount(); i += 1) {
|
|
var member = this.storeDetailsList.getAt(i);
|
|
detailsArr.push(member);
|
|
}
|
|
|
|
var details = ConvertRecordsToJson(detailsArr);
|
|
var detailsDel = ConvertRecordsToJsonAll(this.detailsDel);
|
|
|
|
Ext.Msg.wait('正在保存数据, 请稍侯..');
|
|
Ext.Ajax.request({
|
|
waitMsg: '正在保存数据...',
|
|
url: '/MvcShipping/MsOpCtnFeeModelDuiCun/Save',
|
|
scope: this,
|
|
params: {
|
|
opstatus: this.opStatus,
|
|
data: Ext.JSON.encode(data),
|
|
details: details,
|
|
detailsDel: detailsDel
|
|
},
|
|
callback: function (options, success, response) {
|
|
if (success) {
|
|
Ext.MessageBox.hide();
|
|
var jsonresult = Ext.JSON.decode(response.responseText);
|
|
if (jsonresult.Success) {
|
|
this.opStatus == 'edit'
|
|
var returnData = jsonresult.Data;
|
|
GID = returnData.GID;
|
|
this.formEdit.getForm().setValues(returnData);
|
|
|
|
if (type == '0') {
|
|
this.opStatus = 'edit';
|
|
this.LoadData('edit', " GID='" + GID + "'");
|
|
var condition = "";
|
|
if (this.opStatus == 'edit') {
|
|
condition = " PGID='" + GID + "' and GGID = '" + GGID + "'";
|
|
this.storeDetailsList.load({ params: { condition: condition} });
|
|
}
|
|
} else if (type == '1') {
|
|
window.close();
|
|
} else {
|
|
this.LoadData('add', '');
|
|
}
|
|
Ext.Msg.show({ title: '提示', msg: jsonresult.Message, icon: Ext.Msg.OK, buttons: Ext.Msg.OK });
|
|
} 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.addDetails(type);
|
|
},
|
|
|
|
onDelDetailClick: function (button, event, type) {
|
|
this.deleteDetail(type);
|
|
},
|
|
|
|
gridAfterEdit: function (editor, e, eOpts) {
|
|
//需要自己实现里面的事件
|
|
|
|
if (e.field == 'FeeName') {
|
|
var records = DsStoreQueryBy(this.storeFeeNameRef, 'Name', e.value);
|
|
|
|
if (records.getCount() > 0) {
|
|
var data = records.getAt(0).data;
|
|
var FeeCode = data.FeeCode;
|
|
e.record.set('FeeCode', FeeCode);
|
|
|
|
} else {
|
|
e.record.set('FeeCode', '');
|
|
}
|
|
}
|
|
|
|
},
|
|
|
|
|
|
|
|
deleteDetail: function (type) {
|
|
|
|
var selectedRecords = this.gridList.selModel.getSelection();
|
|
|
|
for (var i = 0; i < selectedRecords.length; i++) {
|
|
var rec = selectedRecords[i];
|
|
this.detailsDel.push(rec);
|
|
this.storeBodyList.remove(rec);
|
|
}
|
|
|
|
|
|
},
|
|
|
|
addDetails: function (type) {
|
|
if (CTN == '') {
|
|
Ext.Msg.show({ title: '提示', msg: '请先选择箱型!', icon: Ext.Msg.WARNNING, buttons: Ext.Msg.OK });
|
|
return;
|
|
}
|
|
var newSerialno = 0;
|
|
|
|
store = this.storeDetailsList;
|
|
var newSerialno = this.storeDetailsList.getCount() + 1;
|
|
|
|
var record = Ext.create('MsOpCtnFeeModelDetails', {
|
|
GID: '*',
|
|
MainGID: GID,
|
|
XiangXing: CTN,
|
|
JiFeiDengJi: 0,
|
|
ShouFuFangXiang: 0,
|
|
JiFeiQuJian: 0,
|
|
JiFeiDanJia: 0
|
|
});
|
|
|
|
store.add(record);
|
|
|
|
var n = store.getCount();
|
|
this.gridDetailsListCellEditing.startEditByPosition({ row: n + 1, column: 1 });
|
|
|
|
|
|
|
|
},
|
|
|
|
deleteDetail: function (type) {
|
|
|
|
var selectedRecords = this.gridDetailsList.selModel.getSelection();
|
|
|
|
for (var i = 0; i < selectedRecords.length; i++) {
|
|
var rec = selectedRecords[i];
|
|
|
|
this.storeDetailsList.remove(rec);
|
|
}
|
|
|
|
|
|
}
|
|
});
|
|
|
|
|