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.
676 lines
23 KiB
JavaScript
676 lines
23 KiB
JavaScript
Ext.namespace('Shipping');
|
|
|
|
Shipping.MsCodeOpServiceEdit = function (config) {
|
|
Ext.applyIf(this, config);
|
|
this.initUIComponents();
|
|
window.Shipping.MsCodeOpServiceEdit.superclass.constructor.call(this);
|
|
};
|
|
|
|
Ext.extend(Shipping.MsCodeOpServiceEdit, Ext.Panel, {
|
|
|
|
ParentWin: null,
|
|
OpStatus: 'add',
|
|
StoreList: null,
|
|
EditRecord: null,
|
|
|
|
initUIComponents: function () {
|
|
this.serialNo = 0;
|
|
this.workSerialNo = 0;
|
|
this.bodyDel = [];
|
|
|
|
//#region 编辑form
|
|
|
|
//枚举参照相关(编辑form)
|
|
|
|
|
|
//表参照相关(编辑form)
|
|
|
|
this.storeOpType = Ext.create('DsExt.ux.RefEnumStore', {});
|
|
this.storeOpType.load({ params: { enumTypeId: 96005} });
|
|
|
|
this.comboxOpType = Ext.create('DsExt.ux.RefEnumCombox', {
|
|
fieldLabel: '业务类型',
|
|
store: this.storeOpType,
|
|
name: 'OPTYPE',
|
|
listeners: {
|
|
scope: this,
|
|
'select': function (combo, records, eOpts) {
|
|
if (records.length > 0) {
|
|
if (records[0].data.EnumValueName == '海运出口' || records[0].data.EnumValueName == '海运进口') {
|
|
this.storeOPField.removeAll();
|
|
this.storeOPField.add({ "OPField": "ISFUMIGATION" });
|
|
this.storeOPField.add({ "OPField": "ISSTORAGE" });
|
|
this.storeOPField.add({ "OPField": "ISLAND" });
|
|
this.storeOPField.add({ "OPField": "ISCUSTOMS" });
|
|
this.storeOPField.add({ "OPField": "ISINSPECTION" });
|
|
this.storeOPField.add({ "OPField": "ISBOOKING" });
|
|
this.storeOPField.add({ "OPField": "ISAGENT" });
|
|
this.storeOPField.add({ "OPField": "ISHBLNO" });
|
|
this.storeOPField.add({ "OPField": "SERVICE9" });
|
|
this.storeOPField.add({ "OPField": "SERVICE10" });
|
|
} else if (records[0].data.EnumValueName == '报关业务' || records[0].data.EnumValueName == '综合业务') {
|
|
this.storeOPField.removeAll();
|
|
this.storeOPField.add({ "OPField": "SERVICE1" });
|
|
this.storeOPField.add({ "OPField": "SERVICE2" });
|
|
this.storeOPField.add({ "OPField": "SERVICE3" });
|
|
this.storeOPField.add({ "OPField": "SERVICE4" });
|
|
this.storeOPField.add({ "OPField": "SERVICE5" });
|
|
this.storeOPField.add({ "OPField": "SERVICE6" });
|
|
this.storeOPField.add({ "OPField": "SERVICE7" });
|
|
this.storeOPField.add({ "OPField": "SERVICE8" });
|
|
this.storeOPField.add({ "OPField": "SERVICE9" });
|
|
this.storeOPField.add({ "OPField": "SERVICE10" });
|
|
this.storeOPField.add({ "OPField": "SERVICE11" });
|
|
this.storeOPField.add({ "OPField": "SERVICE12" });
|
|
this.storeOPField.add({ "OPField": "SERVICE13" });
|
|
this.storeOPField.add({ "OPField": "SERVICE14" });
|
|
this.storeOPField.add({ "OPField": "SERVICE15" });
|
|
this.storeOPField.add({ "OPField": "SERVICE16" });
|
|
} else {
|
|
this.storeOPField.removeAll();
|
|
this.storeOPField.add({ "OPField": "SERVICE1" });
|
|
this.storeOPField.add({ "OPField": "SERVICE2" });
|
|
this.storeOPField.add({ "OPField": "SERVICE3" });
|
|
this.storeOPField.add({ "OPField": "SERVICE4" });
|
|
this.storeOPField.add({ "OPField": "SERVICE5" });
|
|
this.storeOPField.add({ "OPField": "SERVICE6" });
|
|
this.storeOPField.add({ "OPField": "SERVICE7" });
|
|
this.storeOPField.add({ "OPField": "SERVICE8" });
|
|
this.storeOPField.add({ "OPField": "SERVICE9" });
|
|
this.storeOPField.add({ "OPField": "SERVICE10" });
|
|
}
|
|
}
|
|
}
|
|
}
|
|
});
|
|
|
|
|
|
this.storeOPField = Ext.create('Ext.data.Store', {
|
|
fields: ['OPField']
|
|
});
|
|
|
|
// this.storeOPField = Ext.create('DsExt.ux.RefEnumStore', {});
|
|
// this.storeOPField.load({ params: { enumTypeId: 96006} });
|
|
|
|
this.comboxOPField = Ext.create('DsExt.ux.RefTableCombox', {
|
|
fieldLabel: '字段名称',
|
|
valueField: 'OPField',
|
|
displayField: 'OPField',
|
|
store: this.storeOPField,
|
|
name: 'OPField'
|
|
});
|
|
|
|
//编辑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: 'OS_ID',
|
|
name: 'OS_ID', flex: 0, hidden: true, margins: '0'
|
|
}, this.comboxOpType, this.comboxOPField, {
|
|
fieldLabel: '服务项目',
|
|
allowBlank: false,
|
|
name: 'SERVICENAME'
|
|
}, {
|
|
fieldLabel: '英文显示',
|
|
allowBlank: false,
|
|
name: 'ENAME'
|
|
}, {
|
|
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
|
|
},
|
|
'-',
|
|
{
|
|
text: "保存并新建",
|
|
handler: function (button, event) {
|
|
this.Save('2');
|
|
},
|
|
scope: this
|
|
}
|
|
]
|
|
}); //end 按钮Toolbar
|
|
|
|
//#endregion
|
|
|
|
//#region 明细表
|
|
|
|
//明细表表格相关
|
|
|
|
|
|
//明细表-数据集
|
|
this.storeBodyList = Ext.create('Ext.data.Store', {
|
|
model: 'MsCodeOpServiceDetail',
|
|
remoteSort: true,
|
|
proxy: {
|
|
type: 'ajax',
|
|
url: '/MvcShipping/MsCodeOpService/GetBodyList',
|
|
reader: {
|
|
id: 'OS_ID,SerialNo',
|
|
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: 'OS_ID',
|
|
header: 'OS_ID',
|
|
hidden: true,
|
|
width: 100
|
|
}, {
|
|
sortable: true,
|
|
dataIndex: 'NAME',
|
|
header: '服务项目类别',
|
|
editor: {
|
|
xtype: 'textfield',
|
|
selectOnFocus: true
|
|
},
|
|
width: 160
|
|
}, {
|
|
sortable: true,
|
|
dataIndex: 'WORKLOAD',
|
|
header: '工量',
|
|
editor: {
|
|
xtype: 'numberfield',
|
|
selectOnFocus: true
|
|
},
|
|
width: 160
|
|
}, {
|
|
sortable: true,
|
|
dataIndex: 'REMARK',
|
|
header: '类别说明',
|
|
editor: {
|
|
xtype: 'textfield',
|
|
selectOnFocus: true
|
|
},
|
|
width: 160
|
|
}
|
|
]
|
|
});
|
|
|
|
|
|
this.storeWorkList = Ext.create('Ext.data.Store', {
|
|
model: 'MsCodeOpServiceDetail',
|
|
remoteSort: true,
|
|
proxy: {
|
|
type: 'ajax',
|
|
url: '/MvcShipping/MsCodeOpService/GetWorkList',
|
|
reader: {
|
|
id: 'OS_ID,SerialNo',
|
|
root: 'data',
|
|
totalProperty: 'totalCount'
|
|
}
|
|
}
|
|
});
|
|
|
|
this.storeFeeNameRef = Ext.create('DsExt.ux.RefTableStore', {
|
|
model: 'DsShipping.ux.FeeTypeRefModel',
|
|
proxy: { url: '/MvcShipping/MsChFee/GetFeeTypeRefList' }
|
|
});
|
|
this.storeFeeNameRef.load({ params: { condition: ""} });
|
|
|
|
this.comboxFeeNameRef = Ext.create('DsExt.ux.RefTableCombox', {
|
|
store: this.storeFeeNameRef,
|
|
forceSelection: true,
|
|
name: 'FeeName',
|
|
valueField: 'Name',
|
|
displayField: 'CodeAndName'
|
|
});
|
|
|
|
|
|
//明细表表格
|
|
this.gridworkListCellEditing = Ext.create('Ext.grid.plugin.CellEditing', {
|
|
clicksToEdit: 1
|
|
});
|
|
|
|
this.gridWorkList = new Ext.grid.GridPanel({
|
|
store: this.storeWorkList,
|
|
enableHdMenu: false,
|
|
region: 'center',
|
|
loadMask: { msg: "数据加载中,请稍等..." },
|
|
trackMouseOver: true,
|
|
disableSelection: false,
|
|
plugins: [this.gridworkListCellEditing],
|
|
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: 'OS_ID',
|
|
header: 'OS_ID',
|
|
hidden: true,
|
|
width: 100
|
|
}, {
|
|
sortable: true,
|
|
dataIndex: 'NAME',
|
|
header: '服务项目流程',
|
|
editor: {
|
|
xtype: 'textfield',
|
|
selectOnFocus: true
|
|
},
|
|
width: 160
|
|
}, {
|
|
sortable: true,
|
|
dataIndex: 'WORKLOAD',
|
|
header: '工量',
|
|
editor: {
|
|
xtype: 'numberfield',
|
|
selectOnFocus: true
|
|
},
|
|
width: 160
|
|
}, {
|
|
sortable: true,
|
|
dataIndex: 'FEENAME',
|
|
header: '费用名称',
|
|
editor: this.comboxFeeNameRef,
|
|
width: 90
|
|
}, {
|
|
sortable: true,
|
|
dataIndex: 'REMARK',
|
|
header: '流程说明',
|
|
editor: {
|
|
xtype: 'textfield',
|
|
selectOnFocus: true
|
|
},
|
|
width: 160
|
|
}
|
|
]
|
|
});
|
|
|
|
this.panelService = new Ext.Panel({
|
|
title: '服务项目类别',
|
|
layout: "border",
|
|
region: 'west',
|
|
width: 470,
|
|
margin: '5 10',
|
|
|
|
items: [this.gridList]
|
|
});
|
|
this.panelwork = new Ext.Panel({
|
|
title: '服务项目流程',
|
|
layout: "border",
|
|
region: 'center',
|
|
margin: '5 10',
|
|
items: [this.gridWorkList]
|
|
});
|
|
|
|
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: 120,
|
|
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 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 = " OS_ID='" + this.editRecord.get('OS_ID') + "'";
|
|
|
|
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/MsCodeOpService/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('OS_ID');
|
|
|
|
}
|
|
this.storeBodyList.load({ params: { condition: " OS_ID='" + cargoid + "'"} });
|
|
this.storeWorkList.load({ params: { condition: " OS_ID='" + cargoid + "'"} });
|
|
}, // end LoadDate
|
|
|
|
|
|
Save: function (type) {
|
|
var basicForm = this.formEdit.getForm();
|
|
|
|
if (!basicForm.isValid()) {
|
|
return;
|
|
}
|
|
|
|
//判断表格数据是否合法
|
|
if (!validateEditorGridPanel(this.gridList)) {
|
|
return;
|
|
}
|
|
|
|
basicForm.findField('OS_ID').setDisabled(false);
|
|
var data = basicForm.getValues();
|
|
basicForm.findField('OS_ID').setDisabled(true);
|
|
if (this.opStatus == 'add') {
|
|
data.OS_ID = NewGuid();
|
|
}
|
|
var bodydatas = [];
|
|
for (var i = 0; i < this.storeBodyList.getCount(); i += 1) {
|
|
var member = this.storeBodyList.getAt(i);
|
|
bodydatas.push(member);
|
|
}
|
|
var workdatas = [];
|
|
for (var i = 0; i < this.storeWorkList.getCount(); i += 1) {
|
|
var member = this.storeWorkList.getAt(i);
|
|
workdatas.push(member);
|
|
}
|
|
|
|
var jsonBody = ConvertRecordsToJsonAll(bodydatas);
|
|
var workBody = ConvertRecordsToJsonAll(workdatas);
|
|
|
|
Ext.Msg.wait('正在保存数据, 请稍侯..');
|
|
Ext.Ajax.request({
|
|
waitMsg: '正在保存数据...',
|
|
url: '/MvcShipping/MsCodeOpService/Save',
|
|
scope: this,
|
|
params: {
|
|
opstatus: this.opStatus,
|
|
data: Ext.JSON.encode(data),
|
|
body: jsonBody,
|
|
bodywork: workBody
|
|
},
|
|
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();
|
|
};
|
|
|
|
} 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) {
|
|
//需要自己实现里面的事件
|
|
|
|
},
|
|
|
|
addDetail: function (type) {
|
|
var newSerialno = 0;
|
|
if (type == 2) {
|
|
store = this.storeWorkList;
|
|
newSerialno = DsGetNewSerialNo(store, this.workSerialNo);
|
|
this.workSerialNo = newSerialno;
|
|
|
|
} else if (type == 1) {
|
|
store = this.storeBodyList;
|
|
newSerialno = DsGetNewSerialNo(store, this.serialNo);
|
|
this.serialNo = newSerialno;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
var record = Ext.create('MsCodeOpServiceDetail', {
|
|
OS_ID: '',
|
|
SerialNo: newSerialno,
|
|
NAME: "",
|
|
WORKLOAD: 0,
|
|
REMARK: ""
|
|
});
|
|
|
|
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);
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
});
|
|
|
|
|