|
|
Ext.namespace('Shipping');
|
|
|
|
|
|
Shipping.MsCodeFeeTemplateCtnApplyEdit = function (config) {
|
|
|
Ext.applyIf(this, config);
|
|
|
this.initUIComponents();
|
|
|
window.Shipping.MsCodeFeeTemplateCtnApplyEdit.superclass.constructor.call(this);
|
|
|
};
|
|
|
|
|
|
Ext.extend(Shipping.MsCodeFeeTemplateCtnApplyEdit, Ext.Panel, {
|
|
|
|
|
|
ParentWin: null,
|
|
|
OpStatus: 'add',
|
|
|
StoreList: null,
|
|
|
EditRecord: null,
|
|
|
feeType: 0,
|
|
|
StoreFee: null,
|
|
|
|
|
|
//需求编号:SR2017061200005-3
|
|
|
initUIComponents: function () {
|
|
|
this.serialNo = 0;
|
|
|
this.workSerialNo = 0;
|
|
|
this.bodyDel = [];
|
|
|
|
|
|
this.feeaddtemplate = getUrlParam('feeaddtemplate');
|
|
|
|
|
|
//#region 编辑form
|
|
|
|
|
|
//枚举参照相关(编辑form)
|
|
|
|
|
|
_this = this;
|
|
|
|
|
|
this.storeISPUBLIC = Ext.create('Ext.data.Store', {
|
|
|
fields: ['DC', 'NAME']
|
|
|
});
|
|
|
this.storeISPUBLIC.add({ "DC": "是", "NAME": "是" });
|
|
|
this.storeISPUBLIC.add({ "DC": "否", "NAME": "否" });
|
|
|
|
|
|
this.comboxISPUBLIC = Ext.create('DsExt.ux.RefTableCombox', {
|
|
|
fieldLabel: Zi.LAN.ISPUBLIC, //'是否公共',
|
|
|
store: this.storeISPUBLIC,
|
|
|
valueField: 'DC',
|
|
|
displayField: 'NAME',
|
|
|
name: 'ISPUBLIC'
|
|
|
});
|
|
|
|
|
|
|
|
|
//表参照相关(编辑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: Zi.LAN.GID, //'GID',
|
|
|
name: 'GID', flex: 0, hidden: true, margins: '0'
|
|
|
}, {
|
|
|
fieldLabel: Zi.LAN.CORPID, //'CORPID',
|
|
|
name: 'CORPID', flex: 0, hidden: true, margins: '0'
|
|
|
}, {
|
|
|
fieldLabel: Zi.LAN.CREATEUSER, //'CREATEUSER',
|
|
|
name: 'CREATEUSER', flex: 0, hidden: true, margins: '0'
|
|
|
}, {
|
|
|
fieldLabel: Zi.LAN.NAME, //'模板名称',
|
|
|
name: 'NAME',
|
|
|
allowBlank: false
|
|
|
}, {
|
|
|
fieldLabel: Zi.LAN.DESCRIPTION, //'模板说明',
|
|
|
flex: 2, name: 'DESCRIPTION'
|
|
|
}, this.comboxISPUBLIC,{
|
|
|
fieldLabel: Zi.LAN.CREATEUSERREF, //'录入人',
|
|
|
readOnly: true,
|
|
|
name: 'CREATEUSERREF'
|
|
|
}, {
|
|
|
fieldLabel: Zi.LAN.CREATETIME, //'录入日期',
|
|
|
readOnly: true,
|
|
|
name: 'CREATETIME'
|
|
|
}
|
|
|
]
|
|
|
}, {
|
|
|
xtype: 'container',
|
|
|
layout: 'hbox',
|
|
|
defaultType: 'textfield',
|
|
|
items: []
|
|
|
|
|
|
}, {
|
|
|
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: Zi.LAN.btnSave, //"保存",
|
|
|
iconCls: "btnsave",
|
|
|
handler: function (button, event) {
|
|
|
this.Save('0');
|
|
|
},
|
|
|
scope: this
|
|
|
},
|
|
|
{
|
|
|
text: Zi.LAN.btnSaveAndClose, //"保存并关闭",
|
|
|
handler: function (button, event) {
|
|
|
this.Save('1');
|
|
|
},
|
|
|
scope: this
|
|
|
},
|
|
|
'-',
|
|
|
{
|
|
|
text: Zi.LAN.btnSaveAndNew, //"保存并新建",
|
|
|
handler: function (button, event) {
|
|
|
this.Save('2');
|
|
|
},
|
|
|
scope: this
|
|
|
},
|
|
|
'-',
|
|
|
{
|
|
|
text: Zi.LAN.btnCopyAndNew, //"复制新建",
|
|
|
handler: function (button, event) {
|
|
|
|
|
|
var basicForm = this.formEdit.getForm();
|
|
|
this.opStatus = 'add';
|
|
|
basicForm.findField('GID').setDisabled(false);
|
|
|
var field = basicForm.findField('GID');
|
|
|
field.setValue(NewGuid());
|
|
|
basicForm.findField('GID').setDisabled(true);
|
|
|
field = basicForm.findField('CREATEUSERREF');
|
|
|
field.setValue('');
|
|
|
field = basicForm.findField('NAME');
|
|
|
field.setValue('');
|
|
|
|
|
|
for (var j = 0; j < this.storeBodyList.getCount(); j += 1) {
|
|
|
var memberbody = this.storeBodyList.getAt(j);
|
|
|
memberbody.set("TEMPLATEID", '*');
|
|
|
memberbody.commit();
|
|
|
};
|
|
|
},
|
|
|
scope: this
|
|
|
}
|
|
|
]
|
|
|
}); //end 按钮Toolbar
|
|
|
|
|
|
//#endregion
|
|
|
|
|
|
//#region 明细表
|
|
|
|
|
|
//明细表表格相关
|
|
|
|
|
|
|
|
|
//明细表-数据集
|
|
|
this.storeBodyList = Ext.create('Ext.data.Store', {
|
|
|
model: 'MsCodeFeeTemplateCtnApplyDetail',
|
|
|
remoteSort: true,
|
|
|
proxy: {
|
|
|
type: 'ajax',
|
|
|
url: '/MvcShipping/MsCodeFeeTemplateCtnApply/GetBodyList',
|
|
|
reader: {
|
|
|
root: 'data',
|
|
|
totalProperty: 'totalCount'
|
|
|
}
|
|
|
}
|
|
|
});
|
|
|
|
|
|
//明细表表格
|
|
|
this.gridListCellEditing = Ext.create('Ext.grid.plugin.CellEditing', {
|
|
|
clicksToEdit: 1
|
|
|
});
|
|
|
|
|
|
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.StoreCurr = Ext.create('DsExt.ux.RefTableStore', {
|
|
|
model: 'MsFeeCurr',
|
|
|
proxy: { url: '/MvcShipping/MsChFee/GetFeeCurrList' }
|
|
|
});
|
|
|
this.StoreCurr.load({ params: { condition: ""} });
|
|
|
|
|
|
|
|
|
this.comboxCurr = Ext.create('DsExt.ux.RefTableCombox', {
|
|
|
store: this.StoreCurr,
|
|
|
forceSelection: true,
|
|
|
name: 'CURRENCY',
|
|
|
valueField: 'CURR',
|
|
|
displayField: 'CURR'
|
|
|
});
|
|
|
|
|
|
|
|
|
this.storeFeeUnit = Ext.create('DsExt.ux.RefTableStore', {
|
|
|
fields: ['UNIT'],
|
|
|
proxy: { url: '/MvcShipping/MsCodeFeeTemplate/GetFeeUnit' }
|
|
|
});
|
|
|
this.storeFeeUnit.load({ params: { condition: ""} });
|
|
|
|
|
|
|
|
|
this.comboxFeeUnit = Ext.create('DsExt.ux.RefTableCombox', {
|
|
|
store: this.storeFeeUnit,
|
|
|
forceSelection: true,
|
|
|
name: 'UNIT',
|
|
|
valueField: 'UNIT',
|
|
|
displayField: 'UNIT'
|
|
|
});
|
|
|
|
|
|
this.storeCustomerNameRef = Ext.create('DsExt.ux.RefTableStore', {
|
|
|
model: 'DsShipping.ux.CustomRefModel',
|
|
|
proxy: { url: '/CommMng/BasicDataRef/GetCustomRefListRm' }
|
|
|
});
|
|
|
this.comboxCustomerNameRef = Ext.create('DsExt.ux.RefTableCombox', {
|
|
|
store: this.storeCustomerNameRef,
|
|
|
forceSelection: true,
|
|
|
queryMode: 'remote',
|
|
|
minChars: 1,
|
|
|
queryParam: 'CODENAME',
|
|
|
lazyRender: false,
|
|
|
name: 'CUSTOMERNAME',
|
|
|
valueField: 'CustName',
|
|
|
displayField: 'CodeAndName',
|
|
|
listeners: {
|
|
|
scope: this,
|
|
|
'focus': function (_this, eOpts) {
|
|
|
var selections = this.gridList.getSelectionModel().getSelection(); //获得选中的项
|
|
|
var strCustomerName = selections[0].get('CUSTOMERNAME');
|
|
|
var recordCustCode = Ext.create('DsShipping.ux.CustomRefModel', {
|
|
|
GId: NewGuid(),
|
|
|
CustCode: strCustomerName,
|
|
|
CustName: strCustomerName,
|
|
|
CodeAndName: strCustomerName,
|
|
|
DESCRIPTION: strCustomerName
|
|
|
});
|
|
|
_this.storeCustomerNameRef.add(recordCustCode);
|
|
|
}
|
|
|
}
|
|
|
});
|
|
|
|
|
|
|
|
|
this.gridList = new Ext.grid.GridPanel({
|
|
|
store: this.storeBodyList,
|
|
|
enableHdMenu: false,
|
|
|
region: 'center',
|
|
|
loadMask: { msg: Zi.LAN.ShuJuJiaZaiZhong },
|
|
|
trackMouseOver: true,
|
|
|
disableSelection: false,
|
|
|
plugins: [this.gridListCellEditing],
|
|
|
selType: 'cellmodel',
|
|
|
tbar: [{
|
|
|
text: Zi.LAN.btnAddDetail, //'增加费用明细',
|
|
|
tooltip: Zi.LAN.btnAddDetail, //'增加费用明细',
|
|
|
iconCls: "btnadddetail",
|
|
|
handler: function (button, event) {
|
|
|
this.onAddDetailClick(button, event, 1);
|
|
|
},
|
|
|
scope: this
|
|
|
}, '-', {
|
|
|
text: Zi.LAN.btnDeleteDetail, //'删除费用明细',
|
|
|
tooltip: Zi.LAN.btnDeleteDetail, //'删除费用明细',
|
|
|
iconCls: "btndeletedetail",
|
|
|
handler: function (button, event) {
|
|
|
this.onDelDetailClick(button, event, 1);
|
|
|
},
|
|
|
scope: this
|
|
|
}],
|
|
|
columns: [{
|
|
|
sortable: true,
|
|
|
dataIndex: 'GID',
|
|
|
header: Zi.LAN.GID, //'GID',
|
|
|
hidden: true,
|
|
|
width: 100
|
|
|
}, {
|
|
|
sortable: true,
|
|
|
dataIndex: 'TEMPLATEID',
|
|
|
header: Zi.LAN.TEMPLATEID, //'TEMPLATEID',
|
|
|
hidden: true,
|
|
|
width: 100
|
|
|
}, {
|
|
|
sortable: true,
|
|
|
dataIndex: 'FEENAME',
|
|
|
header: Zi.LAN.FEENAME, //'费用名称',
|
|
|
editor: this.comboxFeeNameRef,
|
|
|
width: 140
|
|
|
}, {
|
|
|
sortable: true,
|
|
|
dataIndex: 'CUSTOMERNAME',
|
|
|
header: '费用对象', //'备注',
|
|
|
editor: this.comboxCustomerNameRef,
|
|
|
width: 150
|
|
|
}, {
|
|
|
sortable: true,
|
|
|
dataIndex: 'CURRENCY',
|
|
|
header: Zi.LAN.CURRENCY, //'币别',
|
|
|
editor: this.comboxCurr,
|
|
|
width: 100
|
|
|
}, {
|
|
|
sortable: true,
|
|
|
dataIndex: 'UNIT',
|
|
|
header: Zi.LAN.UNIT, //'标准',
|
|
|
editor: this.comboxFeeUnit,
|
|
|
width: 80
|
|
|
}, {
|
|
|
sortable: true,
|
|
|
dataIndex: 'UNITPRICE',
|
|
|
header: Zi.LAN.UNITPRICE, //'单价',
|
|
|
editor: {
|
|
|
xtype: 'numberfield',
|
|
|
keyNavEnabled: false,
|
|
|
selectOnFocus: true,
|
|
|
hideTrigger: true,
|
|
|
mouseWheelEnabled: false,
|
|
|
enableKeyEvents: true
|
|
|
},
|
|
|
align: 'right',
|
|
|
width: 80
|
|
|
}, {
|
|
|
sortable: true,
|
|
|
dataIndex: 'SORT',
|
|
|
header: Zi.LAN.SORT, //'排序',
|
|
|
editor: {
|
|
|
xtype: 'numberfield',
|
|
|
keyNavEnabled: false,
|
|
|
selectOnFocus: true,
|
|
|
hideTrigger: true,
|
|
|
mouseWheelEnabled: false,
|
|
|
enableKeyEvents: true
|
|
|
},
|
|
|
align: 'right',
|
|
|
width: 80
|
|
|
}, {
|
|
|
sortable: true,
|
|
|
dataIndex: 'REMARK',
|
|
|
header: Zi.LAN.FEEDESCRIPTION, //'备注',
|
|
|
editor: {
|
|
|
xtype: 'textfield',
|
|
|
selectOnFocus: true,
|
|
|
enableKeyEvents: true
|
|
|
|
|
|
},
|
|
|
width: 150
|
|
|
}
|
|
|
]
|
|
|
});
|
|
|
|
|
|
this.gridList.on({
|
|
|
selectionchange: function (sm, selections) {
|
|
|
if (selections.length == 0) {
|
|
|
} else {
|
|
|
var rec = selections[0];
|
|
|
var custname = rec.data.CUSTOMERNAME;
|
|
|
var recordCustCode = Ext.create('DsShipping.ux.CustomRefModel', {
|
|
|
GId: NewGuid(),
|
|
|
CustCode: custname,
|
|
|
CustName: custname,
|
|
|
CodeAndName: custname,
|
|
|
DESCRIPTION: custname
|
|
|
});
|
|
|
_this.storeCustomerNameRef.add(recordCustCode);
|
|
|
}
|
|
|
}
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
this.panelService = new Ext.Panel({
|
|
|
title: Zi.LAN.FeeField, //'费用字段',
|
|
|
layout: "border",
|
|
|
region: 'center',
|
|
|
margin: '5 10',
|
|
|
|
|
|
items: [this.gridList]
|
|
|
});
|
|
|
|
|
|
|
|
|
this.paneldetail = new Ext.Panel({
|
|
|
layout: "border",
|
|
|
region: "center",
|
|
|
items: [
|
|
|
this.panelService
|
|
|
]
|
|
|
});
|
|
|
|
|
|
//#endregion 明细表
|
|
|
|
|
|
//#region 布局
|
|
|
//控件布局
|
|
|
this.panelTop = new Ext.Panel({
|
|
|
layout: "border",
|
|
|
region: "north",
|
|
|
height: 140,
|
|
|
items: [this.panelBtn, this.formEdit]
|
|
|
});
|
|
|
|
|
|
Ext.apply(this, {
|
|
|
items: [this.panelTop, this.paneldetail]
|
|
|
});
|
|
|
|
|
|
//#endregion
|
|
|
|
|
|
//绑定查询窗体
|
|
|
|
|
|
//初始化数据
|
|
|
|
|
|
if (this.feeaddtemplate == undefined) {
|
|
|
this.ParentWin = window.parent.opener;
|
|
|
this.InitData();
|
|
|
} else {
|
|
|
this.opStatus = 'add';
|
|
|
this.parentWin = window.parent.opener._this;
|
|
|
if (this.parentWin) {
|
|
|
this.StoreFee = this.parentWin.storeBodyCostList;
|
|
|
var myDate = new Date();
|
|
|
var mydatestr = Ext.util.Format.date(myDate, 'Y-m-d');
|
|
|
this.formEdit.getForm().findField('CREATETIME').setValue(mydatestr);
|
|
|
this.formEdit.getForm().findField('CREATEUSERREF').setValue(SHOWNAME);
|
|
|
var GID = NewGuid();
|
|
|
this.formEdit.getForm().findField('GID').setValue(GID);
|
|
|
this.formEdit.getForm().findField('ISPUBLIC').setValue('否');
|
|
|
for (i = 0; i < this.StoreFee.getCount(); i += 1) {
|
|
|
var memberyf = this.StoreFee.getAt(i);
|
|
|
var newSerialno = this.GetHandleSerialNo(this.storeBodyList);
|
|
|
|
|
|
|
|
|
var record = Ext.create('MsCodeFeeTemplateCtnApplyDetail', {
|
|
|
GID: NewGuid(),
|
|
|
TEMPLATEID: '*',
|
|
|
FEENAME: memberyf.data.FEENAME,
|
|
|
CUSTOMERNAME: memberyf.data.CUSTOMERNAME,
|
|
|
CURRENCY: memberyf.data.CURRENCY,
|
|
|
UNITPRICE: memberyf.data.UNITPRICE,
|
|
|
UNIT: memberyf.data.UNIT,
|
|
|
SORT: newSerialno,
|
|
|
CREATEUSER: "",
|
|
|
REMARK: ""
|
|
|
|
|
|
});
|
|
|
|
|
|
this.storeBodyList.add(record);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
//绑定事件
|
|
|
this.gridList.on('edit', function (editor, e, eOpts) {
|
|
|
this.gridAfterEdit(editor, e, eOpts);
|
|
|
}, this);
|
|
|
|
|
|
this.storeBodyList.on('beforeload', function (store) {
|
|
|
var cargoid = 0;
|
|
|
if (this.opStatus == 'edit') {
|
|
|
cargoid = this.editRecord.get('GID');
|
|
|
|
|
|
}
|
|
|
var sql = " TEMPLATEID='" + cargoid + "'";
|
|
|
Ext.apply(store.proxy.extraParams, { condition: sql });
|
|
|
}, 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: Zi.LAN.ZhengZaiChaXunShuJu, //'正在查询主表数据...',
|
|
|
url: '/MvcShipping/MsCodeFeeTemplateCtnApply/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: Zi.LAN.TiShi, //'提示',
|
|
|
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(Zi.LAN.FuWuQiXiangYingChuCuo, response.responseText);
|
|
|
}
|
|
|
},
|
|
|
scope: this
|
|
|
});
|
|
|
|
|
|
var billno = '*';
|
|
|
var cargoid = 0;
|
|
|
if (this.opStatus == 'edit') {
|
|
|
cargoid = this.editRecord.get('GID');
|
|
|
|
|
|
}
|
|
|
this.storeBodyList.load({ params: { condition: " TEMPLATEID='" + cargoid + "'"} });
|
|
|
}, // 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.DM_ID = 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);
|
|
|
|
|
|
|
|
|
Ext.Msg.wait(Zi.LAN.ZhengZaiCaoZuoShuJu);
|
|
|
Ext.Ajax.request({
|
|
|
waitMsg: Zi.LAN.ZhengZaiCaoZuoShuJu, //'正在保存数据...',
|
|
|
url: '/MvcShipping/MsCodeFeeTemplateCtnApply/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') {
|
|
|
if (this.feeaddtemplate == undefined) {
|
|
|
} else {
|
|
|
var arrNewRecords = this.StoreList.add(returnData);
|
|
|
this.editRecord = arrNewRecords[0];
|
|
|
}
|
|
|
}
|
|
|
else if (this.opStatus == 'edit') {
|
|
|
var editp = Ext.create('MsCodeFeeTemplate', returnData);
|
|
|
this.editRecord.fields.each(function (field) {
|
|
|
if (field.persist) {
|
|
|
name = field.name;
|
|
|
if (name != 'id')
|
|
|
this.editRecord.set(name, editp.get(name));
|
|
|
}
|
|
|
}, this);
|
|
|
this.editRecord.commit();
|
|
|
}
|
|
|
if (type == '0') {
|
|
|
this.opStatus = 'edit';
|
|
|
|
|
|
basicForm.findField('GID').setDisabled(true);
|
|
|
|
|
|
for (var j = 0; j < this.storeBodyList.getCount(); j += 1) {
|
|
|
var memberbody = this.storeBodyList.getAt(j);
|
|
|
memberbody.set("GID", this.editRecord.get('GID'));
|
|
|
memberbody.commit();
|
|
|
};
|
|
|
|
|
|
} else if (type == '1') {
|
|
|
window.close();
|
|
|
} else {
|
|
|
this.LoadData('add', '');
|
|
|
basicForm.findField('GID').setDisabled(false);
|
|
|
}
|
|
|
} else {
|
|
|
Ext.Msg.show({ title: Zi.LAN.CuoWu, msg: jsonresult.Message, icon: Ext.Msg.ERROR, buttons: Ext.Msg.OK });
|
|
|
}
|
|
|
} else {
|
|
|
Ext.Msg.show({ title: Zi.LAN.TiShi,
|
|
|
msg: Zi.LAN.FuWuQiXiangYingChuCuo,
|
|
|
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) {
|
|
|
//需要自己实现里面的事件
|
|
|
if (e.value == e.originalValue) return;
|
|
|
|
|
|
},
|
|
|
|
|
|
addDetail: function (type) {
|
|
|
var newSerialno = 0;
|
|
|
var n = this.storeBodyList.getCount();
|
|
|
store = this.storeBodyList;
|
|
|
var newSerialno = this.GetHandleSerialNo(store);
|
|
|
|
|
|
var record = Ext.create('MsCodeFeeTemplateCtnApplyDetail', {
|
|
|
GID: NewGuid(),
|
|
|
TEMPLATEID: '*',
|
|
|
FEENAME: "",
|
|
|
CUSTOMERNAME: "",
|
|
|
CURRENCY: "USD",
|
|
|
UNITPRICE: 0,
|
|
|
UNIT: "单票",
|
|
|
SORT: newSerialno,
|
|
|
CREATEUSER: "",
|
|
|
REMARK: ""
|
|
|
|
|
|
});
|
|
|
|
|
|
store.add(record);
|
|
|
|
|
|
|
|
|
this.gridListCellEditing.startEditByPosition({ row: n - 1, column: 1 });
|
|
|
|
|
|
},
|
|
|
|
|
|
GetHandleSerialNo: function (store) {
|
|
|
var result = 0;
|
|
|
|
|
|
if (result == 0) {
|
|
|
for (var i = 0; i < store.getCount(); i += 1) {
|
|
|
var member = store.getAt(i);
|
|
|
if (parseInt(member.data.SORT) > parseInt(result)) {
|
|
|
result = member.data.SORT;
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
|
|
|
result = parseInt(result) + 1;
|
|
|
return result;
|
|
|
},
|
|
|
|
|
|
deleteDetail: function (type) {
|
|
|
|
|
|
var selectedRecords = this.gridList.selModel.getSelection();
|
|
|
|
|
|
for (var i = 0; i < selectedRecords.length; i++) {
|
|
|
var rec = selectedRecords[i];
|
|
|
|
|
|
this.storeBodyList.remove(rec);
|
|
|
}
|
|
|
|
|
|
|
|
|
}
|
|
|
});
|
|
|
|
|
|
|