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.
530 lines
16 KiB
JavaScript
530 lines
16 KiB
JavaScript
Ext.namespace('Shipping');
|
|
|
|
Shipping.MsCodeAllEdit = function (config) {
|
|
Ext.applyIf(this, config);
|
|
this.initUIComponents();
|
|
window.Shipping.MsCodeAllEdit.superclass.constructor.call(this);
|
|
};
|
|
|
|
Ext.extend(Shipping.MsCodeAllEdit, Ext.Panel, {
|
|
|
|
ParentWin: null,
|
|
OpStatus: 'add',
|
|
StoreList: null,
|
|
EditRecord: null,
|
|
|
|
initUIComponents: function () {
|
|
this.serialNo = 0;
|
|
this.workSerialNo = 0;
|
|
this.bodyDel = [];
|
|
this.LANEID = "";
|
|
|
|
//#region 编辑form
|
|
|
|
//枚举参照相关(编辑form)
|
|
|
|
|
|
//表参照相关(编辑form)
|
|
|
|
//this.storeCodeDisport = Ext.create('DsExt.ux.RefTableStore', {
|
|
// model: 'DsShipping.ux.CodeDisportModel',
|
|
// proxy: { url: '/CommMng/BasicDataRef/GetCodeDisportListRm' }
|
|
//});
|
|
|
|
this.storeCodePort = Ext.create('DsExt.ux.RefTableStore', {
|
|
model: 'DsTruckMng.ux.GeneralValue',
|
|
proxy: { url: '/CommMng/BasicDataRef/GetAllPort' }
|
|
});
|
|
|
|
this.comboxPORT = Ext.create('DsExt.ux.RefTableCombox', {
|
|
//fieldLabel: "港口", //'卸货港',
|
|
store: this.storeCodePort,
|
|
name: 'PORTID',
|
|
matchFieldWidth: false,
|
|
// forceSelection: true,
|
|
valueField: 'GID',
|
|
queryMode: 'remote',
|
|
minChars: 2,
|
|
queryParam: 'PORT',
|
|
displayField: 'GVALUE',
|
|
listeners: {
|
|
scope: this,
|
|
blur: function (field, The, eOpts) {
|
|
field.setRawValue(field.value);
|
|
|
|
}
|
|
,
|
|
beforequery: function (e) {
|
|
//return FilterCombox(e, 2);//在beforequery使用此方法
|
|
},
|
|
specialkey: function (field, e) {
|
|
if (e.getKey() == e.ENTER) {
|
|
e.keyCode = 9;
|
|
}
|
|
}
|
|
}
|
|
});
|
|
|
|
// this.storeOPField = Ext.create('DsExt.ux.RefEnumStore', {});
|
|
// this.storeOPField.load({ params: { enumTypeId: 96006} });
|
|
|
|
|
|
|
|
//编辑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: 'SERVICENAME'
|
|
}, {
|
|
fieldLabel: '排序',
|
|
name: 'SORT'
|
|
}
|
|
]
|
|
}, {
|
|
xtype: 'container',
|
|
layout: 'hbox',
|
|
defaultType: 'textfield',
|
|
items: [{
|
|
fieldLabel: '说明',
|
|
name: 'REMARK'
|
|
}]
|
|
|
|
}
|
|
]//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
|
|
}
|
|
]
|
|
}); //end 按钮Toolbar
|
|
|
|
//#endregion
|
|
|
|
//#region 明细表
|
|
|
|
//明细表表格相关
|
|
|
|
|
|
//明细表-数据集
|
|
this.storeBodyList = Ext.create('Ext.data.Store', {
|
|
model: 'code_lanes_port_mb',
|
|
remoteSort: false,
|
|
sortInfo: { field:'ORDERNO', direction:'ASC' },
|
|
proxy: {
|
|
type: 'ajax',
|
|
url: '/MvcShipping/MsCodeAll/GetLanesPortList',
|
|
reader: {
|
|
id: 'PORTID',
|
|
root: 'data',
|
|
totalProperty: 'totalCount'
|
|
}
|
|
}
|
|
});
|
|
|
|
//明细表表格
|
|
this.gridListCellEditing = Ext.create('Ext.grid.plugin.CellEditing', {
|
|
clicksToEdit: 1
|
|
});
|
|
|
|
this.gridList = new Ext.grid.GridPanel({
|
|
store: this.storeBodyList,
|
|
enableHdMenu: false,
|
|
region: 'center',
|
|
loadMask: { msg: "数据加载中,请稍等..." },
|
|
trackMouseOver: true,
|
|
disableSelection: false,
|
|
plugins: [this.gridListCellEditing],
|
|
selType: 'cellmodel',
|
|
tbar: [{
|
|
text: '增加明细',
|
|
tooltip: '增加明细',
|
|
iconCls: "btnadddetail",
|
|
handler: function (button, event) {
|
|
this.onAddDetailClick(button, event, 1);
|
|
},
|
|
scope: this
|
|
}, '-', {
|
|
text: '删除明细',
|
|
tooltip: '删除明细',
|
|
iconCls: "btndeletedetail",
|
|
handler: function (button, event) {
|
|
this.onDelDetailClick(button, event, 1);
|
|
},
|
|
scope: this
|
|
}],
|
|
columns: [
|
|
{
|
|
sortable: true,
|
|
dataIndex: 'GID',
|
|
header: 'GID',
|
|
hidden: true,
|
|
width: 20
|
|
},
|
|
{
|
|
sortable: true,
|
|
dataIndex: 'LANEID',
|
|
header: 'LANEID',
|
|
hidden: true,
|
|
width: 20
|
|
},
|
|
{
|
|
sortable: true,
|
|
dataIndex: 'ORDERNO',
|
|
header: '顺序号',
|
|
width: 60,
|
|
editor: {
|
|
xtype: 'numberfield',
|
|
keyNavEnabled: false,
|
|
allowDecimals: true,
|
|
//decimalPrecision: 2,
|
|
selectOnFocus: true,
|
|
mouseWheelEnabled: false,
|
|
enableKeyEvents: true,
|
|
listeners: {
|
|
//keydown: function (textfield, e) {
|
|
// if (e.getKey() == 40) {
|
|
// _this.onNextKeyClick(9)
|
|
// } else if (e.getKey() == 38) {
|
|
// _this.onUpKeyClick(9)
|
|
// }
|
|
//}
|
|
}
|
|
}
|
|
},
|
|
{
|
|
sortable: true,
|
|
dataIndex: 'PORTID',
|
|
header: '港口',
|
|
editor: this.comboxPORT,
|
|
renderer: function (value, p, record) {
|
|
if (value == null || value == '')
|
|
return '';
|
|
else
|
|
return record.data.PORTNAME;
|
|
},
|
|
width: 160
|
|
}
|
|
]
|
|
});
|
|
|
|
|
|
this.paneldetail = new Ext.Panel({
|
|
layout: "border",
|
|
region: "center",
|
|
items: [
|
|
this.gridList
|
|
]
|
|
});
|
|
|
|
//#endregion 明细表
|
|
|
|
//#region 布局
|
|
//控件布局
|
|
this.panelTop = new Ext.Panel({
|
|
layout: "border",
|
|
region: "north",
|
|
height: 30,
|
|
items: [this.panelBtn
|
|
//, this.formEdit
|
|
|
|
]
|
|
});
|
|
|
|
Ext.apply(this, {
|
|
items: [this.panelTop, this.paneldetail]
|
|
});
|
|
|
|
//#endregion
|
|
|
|
//绑定查询窗体
|
|
this.ParentWin = window.parent.opener;
|
|
|
|
//初始化数据
|
|
this.InitData();
|
|
|
|
//绑定事件
|
|
this.gridList.on('edit', function (editor, e, eOpts) {
|
|
this.gridAfterEdit(editor, e, eOpts);
|
|
}, this);
|
|
}, //end initUIComponents
|
|
|
|
InitData: function () {
|
|
this.opStatus = 'add';
|
|
var LANEID = '';
|
|
if (this.ParentWin) {
|
|
var ret = this.ParentWin.OprationSwap();
|
|
this.opStatus = ret[0];
|
|
this.StoreList = ret[1];
|
|
this.editRecord = ret[2];
|
|
}
|
|
|
|
if (this.opStatus == 'edit')
|
|
this.LANEID = this.editRecord.get('GID');
|
|
|
|
this.LoadData(this.opStatus, this.LANEID);
|
|
|
|
}, //end InitData
|
|
|
|
LoadData: function (opstatus, LANEID) {
|
|
this.serialNo = 0;
|
|
this.workSerialNo = 0;
|
|
this.bodyDel = [];
|
|
|
|
var headcondition = " GID='" + LANEID + "'";
|
|
|
|
this.opStatus = opstatus;
|
|
Ext.Ajax.request({
|
|
waitMsg: '正在查询主表数据...',
|
|
url: '/MvcShipping/MsCodeAll/GetLanesList',
|
|
params: {
|
|
//handle: opstatus,
|
|
condition: headcondition,
|
|
sort:''
|
|
},
|
|
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);
|
|
|
|
this.storeBodyList.load({ params: { LANEID: LANEID } });
|
|
} else {
|
|
this.storeBodyList.load({ params: { LANEID: "0" } });
|
|
Ext.MessageBox.alert('请求出现错误,请重试', response.responseText);
|
|
}
|
|
},
|
|
scope: this
|
|
});
|
|
|
|
|
|
}, // end LoadDate
|
|
|
|
|
|
Save: function (type) {
|
|
var basicForm = this.formEdit.getForm();
|
|
|
|
//if (!basicForm.isValid()) {
|
|
// return;
|
|
//}
|
|
|
|
//判断表格数据是否合法
|
|
//if (!validateEditorGridPanel(this.gridList)) {
|
|
// return;
|
|
//}
|
|
|
|
basicForm.findField('GID').setDisabled(false);
|
|
var data = basicForm.getValues();
|
|
basicForm.findField('GID').setDisabled(true);
|
|
if (this.opStatus == 'add') {
|
|
data.GID = NewGuid();
|
|
}
|
|
var bodydatas = [];
|
|
for (var i = 0; i < this.storeBodyList.getCount(); i += 1) {
|
|
var member = this.storeBodyList.getAt(i);
|
|
bodydatas.push(member);
|
|
}
|
|
|
|
var jsonBody = ConvertRecordsToJsonAll(bodydatas);
|
|
|
|
var jsonData = Ext.JSON.encode(this.editRecord.data);
|
|
|
|
Ext.Msg.wait('正在保存数据, 请稍侯..');
|
|
Ext.Ajax.request({
|
|
waitMsg: '正在保存数据...',
|
|
url: '/MvcShipping/MsCodeAll/SaveLanesPort',
|
|
scope: this,
|
|
params: {
|
|
data: jsonData,
|
|
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') {
|
|
// var arrNewRecords = this.StoreList.add(returnData);
|
|
// this.editRecord = arrNewRecords[0];
|
|
//}
|
|
//else if (this.opStatus == 'edit') {
|
|
// this.editRecord.commit();
|
|
//}
|
|
if (type == '0') {
|
|
//this.opStatus = 'edit';
|
|
|
|
//basicForm.findField('OS_ID').setDisabled(true);
|
|
|
|
//for (var j = 0; j < this.storeBodyList.getCount(); j += 1) {
|
|
// var memberbody = this.storeBodyList.getAt(j);
|
|
// memberbody.set("OS_ID", this.editRecord.get('OS_ID'));
|
|
// memberbody.commit();
|
|
//};
|
|
//for (var j = 0; j < this.storeWorkList.getCount(); j += 1) {
|
|
// var memberwork = this.storeWorkList.getAt(j);
|
|
// memberwork.set("OS_ID", this.editRecord.get('OS_ID'));
|
|
// memberwork.commit();
|
|
//};
|
|
this.storeBodyList.load({ params: { LANEID: this.LANEID } });
|
|
} else if (type == '1') {
|
|
window.close();
|
|
} else {
|
|
//this.LoadData('add', '');
|
|
//basicForm.findField('OS_ID').setDisabled(false);
|
|
}
|
|
} 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) {
|
|
//需要自己实现里面的事件
|
|
this.PortAfterEdit(editor, e, eOpts);
|
|
},
|
|
|
|
addDetail: function (type) {
|
|
|
|
store = this.storeBodyList;
|
|
newSerialno = DsGetNewSerialNo(store, this.serialNo);
|
|
|
|
|
|
var record = Ext.create('code_lanes_port_mb', {
|
|
GID: '',
|
|
LANEID: this.LANEID,
|
|
PORTID: "",
|
|
ORDERNO: 0
|
|
});
|
|
|
|
store.add(record);
|
|
|
|
var n = store.getCount();
|
|
if (type == 2) {
|
|
this.gridworkListCellEditing.startEditByPosition({ row: n - 1, column: 1 });
|
|
|
|
} else if (type == 1) {
|
|
this.gridListCellEditing.startEditByPosition({ row: n - 1, column: 1 });
|
|
|
|
}
|
|
|
|
},
|
|
|
|
deleteDetail: function (type) {
|
|
|
|
if (type == 1) {
|
|
|
|
var selectedRecords = this.gridList.selModel.getSelection();
|
|
|
|
for (var i = 0; i < selectedRecords.length; i++) {
|
|
var rec = selectedRecords[i];
|
|
|
|
this.storeBodyList.remove(rec);
|
|
}
|
|
} else if (type == 2) {
|
|
|
|
var selectedRecords = this.gridWorkList.selModel.getSelection();
|
|
|
|
for (var i = 0; i < selectedRecords.length; i++) {
|
|
var rec = selectedRecords[i];
|
|
|
|
this.storeWorkList.remove(rec);
|
|
}
|
|
|
|
}
|
|
|
|
},
|
|
|
|
PortAfterEdit: function (editor, e, eOpts) {
|
|
//需要自己实现里面的事件
|
|
if (e.field == 'PORTID') {
|
|
var records = DsStoreQueryBy(this.storeCodePort, 'GID', e.value);
|
|
if (records.getCount() > 0) {
|
|
var griddata = records.getAt(0).data;
|
|
e.record.set('PORTNAME', griddata.GVALUE);
|
|
} else {
|
|
e.record.set('PORTNAME', '');
|
|
}
|
|
}
|
|
|
|
},
|
|
});
|
|
|
|
|