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.
DS7/DSWeb/Areas/MvcShipping/Viewsjs/MsCodeFeeTemplateAuto/MsCodeFeeTemplateEdit.js

1489 lines
52 KiB
JavaScript

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

Ext.namespace('Shipping');
Shipping.MsCodeFeeTemplateEdit = function (config) {
Ext.applyIf(this, config);
this.initUIComponents();
window.Shipping.MsCodeFeeTemplateEdit.superclass.constructor.call(this);
};
Ext.extend(Shipping.MsCodeFeeTemplateEdit, 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');
this.formname = 'MsCodeFeeTemplateAutoEdit';
//#region 编辑form
//枚举参照相关(编辑form)
this.StoreOpLb = Ext.create('DsExt.ux.RefEnumStore', {});
this.StoreOpLb.load({ params: { enumTypeId: 96200 } });
this.comboxOpLb = Ext.create('DsExt.ux.RefTableCombox', {
fieldLabel: Zi.LAN.OPTYPE, //'业务类别',
store: this.StoreOpLb,
valueField: 'EnumValueId',
displayField: 'EnumValueName',
forceSelection: true,
name: 'OPTYPE'
});
this.storeAddDCType = Ext.create('Ext.data.Store', {
fields: ['DC', 'NAME']
});
this.storeAddDCType.add({ "DC": 1, "NAME": "应收" });
this.storeAddDCType.add({ "DC": 2, "NAME": "应付" });
this.comboxaddDCType = Ext.create('DsExt.ux.RefTableCombox', {
fieldLabel: Zi.LAN.FEETYPE, //'费用类型',
store: this.storeAddDCType,
valueField: 'DC',
displayField: 'NAME',
forceSelection: true,
name: 'FEETYPE'
});
this.storeISDEF = Ext.create('Ext.data.Store', {
fields: ['DC', 'NAME']
});
this.storeISDEF.add({ "DC": "是", "NAME": "是" });
this.storeISDEF.add({ "DC": "否", "NAME": "否" });
this.comboxISDEF = Ext.create('DsExt.ux.RefTableCombox', {
fieldLabel: '是否默认', //'是否公共',
store: this.storeISDEF,
valueField: 'DC',
displayField: 'NAME',
name: 'ISDEF'
});
this.storeFEEGROUP = Ext.create('DsExt.ux.RefEnumStore', {});
this.storeFEEGROUP.load({ params: { enumTypeId: 96202 } });
this.comboxFEEGROUP = Ext.create('DsExt.ux.RefTableCombox', {
store: this.storeFEEGROUP,
fieldLabel: '费用类别', //'是否公共',
valueField: 'EnumValueName',
displayField: 'EnumValueName',
forceSelection: true,
name: 'FEEGROUP'
});
//表参照相关(编辑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'
}, this.comboxOpLb, this.comboxaddDCType, {
fieldLabel: Zi.LAN.CREATEUSERREF, //'录入人',
readOnly: true,
name: 'CREATEUSERREF'
}, {
fieldLabel: Zi.LAN.CREATETIME, //'录入日期',
readOnly: true,
name: 'CREATETIME'
}, this.comboxFEEGROUP, this.comboxISDEF
]
}, {
xtype: 'container',
layout: 'hbox',
defaultType: 'textfield',
items: [{
fieldLabel: Zi.LAN.NAME, //'模板名称',
name: 'NAME',
allowBlank: false
}, {
fieldLabel: Zi.LAN.DESCRIPTION, //'模板说明',
flex: 2,
name: 'DESCRIPTION'
}, {
fieldLabel: '开始时间',
format: 'Y-m-d',
xtype: 'datefield',
renderer: Ext.util.Format.dateRenderer('Y-m-d'),
allowBlank: false,
name: 'BGNDATE'
}
, {
fieldLabel: '结束时间',
format: 'Y-m-d',
xtype: 'datefield',
allowBlank: false,
renderer: Ext.util.Format.dateRenderer('Y-m-d'),
name: 'ENDDATE'
}, {
fieldLabel:'优先等级', //'模板说明',
name: 'CLASS'
}]
}, {
xtype: 'container',
layout: 'hbox',
defaultType: 'textfield',
items: [{
fieldLabel: Zi.LAN.REMARK, //'备注',
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
}, '-', {
text: "打印",
iconCls: "btnprint",
handler: function (button, event) {
this.Print();
},
scope: this
}
]
}); //end 按钮Toolbar
//#endregion
//#region 明细表
//明细表表格相关
//明细表-数据集
this.storeBodyList = Ext.create('Ext.data.Store', {
model: 'MsCodeFeeTemplateDetail',
remoteSort: true,
proxy: {
type: 'ajax',
url: '/MvcShipping/MsCodeFeeTemplateAuto/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.comboxFeeENameRef = Ext.create('DsExt.ux.DCombox', {
store: this.storeFeeNameRef,
matchFieldWidth: false,
name: 'FEEDESCRIPTION',
valueField: 'Description',
displayField: 'Description'
});
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.storeCustomerNameRef = Ext.create('DsExt.ux.RefTableStore', {
model: 'DsShipping.ux.CustomRefModel',
proxy: { url: '/CommMng/BasicDataRef/GetCustomRefList' }
});
this.storeCustomerNameRef.load({ params: { condition: ""} });
this.comboxCustomerNameRef = Ext.create('DsExt.ux.RefTableCombox', {
store: this.storeCustomerNameRef,
forceSelection: true,
name: 'CUSTOMERNAME',
valueField: 'CustName',
displayField: 'CodeAndName'
});
//this.storeCustType = Ext.create('Ext.data.Store', {
// fields: ['CLIENT', 'NAME']
//});
//this.storeCustType.add({ "CLIENT": "CARRIER", "NAME": "船公司" });
//this.storeCustType.add({ "CLIENT": "FORWARDER", "NAME": "订舱代理" });
//this.storeCustType.add({ "CLIENT": "YARD", "NAME": "场站" });
//this.storeCustType.add({ "CLIENT": "TRUCK", "NAME": "车队" });
//this.storeCustType.add({ "CLIENT": "CUSTOMERNAME", "NAME": "委托单位" });
//this.storeCustType.add({ "CLIENT": "CUSTOMSER", "NAME": "报关行" });
//this.storeCustType.add({ "CLIENT": "AGENTID", "NAME": "代理" });
//this.storeCustType.add({ "CLIENT": "SHIPPERID", "NAME": "发货人" });
//this.storeCustType.add({ "CLIENT": "CONSIGNEEID", "NAME": "收货人" });
//this.storeCustType.add({ "CLIENT": "SHIPAGENCY", "NAME": "船代" });
this.storeCustType = Ext.create('DsExt.ux.RefEnumStore', {});
this.storeCustType.load({ params: { enumTypeId: 96201 } });
this.comboxCustType = Ext.create('DsExt.ux.RefTableCombox', {
store: this.storeCustType,
valueField: 'EnumValueId',
displayField: 'EnumValueName',
forceSelection: true,
name: 'CLIENT'
});
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.storeIsCtn = Ext.create('Ext.data.Store', {
fields: ['DC', 'NAME']
});
this.storeIsCtn.add({ "DC": true, "NAME": "是" });
this.storeIsCtn.add({ "DC": false, "NAME": "否" });
this.comboxIsCtn = Ext.create('DsExt.ux.RefTableCombox', {
store: this.storeIsCtn,
valueField: 'DC',
displayField: 'NAME',
forceSelection: true,
name: 'ISCTN'
});
this.storeIsExChange = Ext.create('Ext.data.Store', {
fields: ['DC', 'NAME']
});
this.storeIsExChange.add({ "DC": 0, "NAME": "根据汇率设置" });
this.comboxIsExChange = Ext.create('DsExt.ux.RefTableCombox', {
store: this.storeIsExChange,
valueField: 'DC',
displayField: 'NAME',
// forceSelection: true,
name: 'EXCHANGERATE'
});
this.StoreFeeFrt = Ext.create('Ext.data.Store', {
fields: ['Frt']
});
this.StoreFeeFrt.add({ "Frt": "PP" });
this.StoreFeeFrt.add({ "Frt": "CC" });
this.comboxFeeFrt = Ext.create('DsExt.ux.RefTableCombox', {
store: this.StoreFeeFrt,
forceSelection: true,
name: 'FeeFrt',
valueField: 'Frt',
displayField: 'Frt'
});
Ext.define('MsCompanySale', {
extend: 'Ext.data.Model',
idProperty: 'GID',
fields: [
{ name: 'GID', type: 'string' }, //GID
{ name: 'CODENAME', type: 'string' }, //CODENAME
{ name: 'NAME', type: 'string' }, //NAME
{ name: 'CodeAndName', type: 'string' }, //NAME
{ name: 'FULLNAME', type: 'string' }
]
});
this.storeSALECORP = Ext.create('DsExt.ux.RefTableStore', {
model: 'MsCompanySale',
proxy: { url: '/MvcShipping/MsCompanys/GetNoPicDataList' }
});
this.storeSALECORP.load({
params: { condition: "" },
callback: function (r, options, success) {
if (success) {
}
}
});
this.comboxSALECORP = Ext.create('DsExt.ux.RefTableCombox', {
store: this.storeSALECORP,
forceSelection: true,
name: 'SALECORP',
valueField: 'NAME',
displayField: 'CodeAndName'
});
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
}, '-', {
text: Zi.LAN.btnClearCUSTOMERNAME, //'删除费用明细',
tooltip: Zi.LAN.btnClearCUSTOMERNAME, //'删除费用明细',
iconCls: "btndeletedetail",
handler: function (button, event) {
this.onClearCustomerClick(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: 'FEEDESCRIPTION',
header: Zi.LAN.FeeDescription, //'费用英文名称',
editor: this.comboxFeeENameRef,
width: 150
}, {
sortable: true,
dataIndex: 'CLIENT',
header: Zi.LAN.CLIENT, //'结算对象类型',
editor: this.comboxCustType,
renderer: function (value, p, record) {
return record.data.CLIENTREF;
},
width: 80
}, {
sortable: true,
dataIndex: 'CUSTOMERNAME',
header: Zi.LAN.CUSTOMERNAME, //'结算对象',
editor: this.comboxCustomerNameRef,
width: 110
}, {
sortable: true,
dataIndex: 'UNIT',
header: Zi.LAN.UNIT, //'标准',
editor: this.comboxFeeUnit,
width: 80
}, {
sortable: true,
dataIndex: 'ISCTN',
header: Zi.LAN.ISCTN, //'是否箱型',
editor: this.comboxIsCtn,
renderer: function (value, p, record) {
return record.data.ISCTNREF;
},
width: 80
}, {
sortable: true,
dataIndex: 'CURRENCY',
header: Zi.LAN.CURRENCY, //'币别',
editor: this.comboxCurr,
width: 100
}, {
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: 'EXCHANGERATE',
header: Zi.LAN.EXCHANGERATE, //'汇率',
editor: this.comboxIsExChange,
renderer: function (value, p, record) {
if (value == 0)
return Zi.LAN.GenJuSheZhiHuiLvShengCheng; //'根据设置汇率生成';
else return value;
},
// {
// xtype: 'numberfield',
// keyNavEnabled: false,
// selectOnFocus: true,
// hideTrigger: true,
// mouseWheelEnabled: false,
// decimalPrecision: 6,
// enableKeyEvents: true
// },
// renderer: function (value, cellmeta, record, rowIndex, columnIndex, store) { try { var lsValue = usMoney(value, 6, '', false); if (lsValue != "NaN") { value = lsValue; if (parseFloat(lsValue) < 0) { return '<SPAN style="COLOR: red">' + lsValue + '</SPAN>'; } } else { return value; } } catch (e) { return value; } return value; },
align: 'right',
width: 180
}, {
sortable: true,
dataIndex: 'TAXRATE',
header: Zi.LAN.TAXRATE, //'单价',
editor: {
xtype: 'numberfield',
keyNavEnabled: false,
selectOnFocus: true,
hideTrigger: true,
mouseWheelEnabled: false,
enableKeyEvents: true
},
align: 'right',
width: 80
}, {
sortable: true,
dataIndex: 'TAXUNITPRICE',
header: Zi.LAN.TAXUNITPRICE, //'单价',
editor: {
xtype: 'numberfield',
keyNavEnabled: false,
selectOnFocus: true,
hideTrigger: true,
mouseWheelEnabled: false,
enableKeyEvents: true
},
align: 'right',
width: 80
}, {
sortable: true,
dataIndex: 'TAX',
header: Zi.LAN.TAX, //'单价',
editor: {
xtype: 'numberfield',
keyNavEnabled: false,
selectOnFocus: true,
hideTrigger: true,
mouseWheelEnabled: false,
enableKeyEvents: true
},
renderer: function (value, cellmeta, record, rowIndex, columnIndex, store) {
try {
var lsValue = usMoney(value, 2, '', false);
if (lsValue != "NaN") {
value = lsValue; if (parseFloat(lsValue) < 0) {
return '<SPAN style="COLOR: red">' + lsValue + '</SPAN>';
}
}
else {
return value;
}
}
catch (e) {
return value;
}
return value;
},
align: 'right',
width: 80
}, {
sortable: true,
dataIndex: 'ACCTAXRATE',
header: Zi.LAN.ACCTAXRATE, //'单价',
editor: {
xtype: 'numberfield',
keyNavEnabled: false,
selectOnFocus: true,
hideTrigger: true,
mouseWheelEnabled: false,
enableKeyEvents: true
},
align: 'right',
width: 80
}, {
sortable: true,
dataIndex: 'FEEFRT',
header: Zi.LAN.FEEFRT, //'FRT',
editor: this.comboxFeeFrt,
width: 40
}, {
sortable: true,
dataIndex: 'ISADVANCEDPAY',
header: Zi.LAN.ISADVANCEDPAY, //'垫付',
editor: {
xtype: 'checkboxfield',
inputValue: '1',
uncheckedValue: '0'
// selectOnFocus: true
},
renderer: function (value, cellmeta) {
if (value == '1') {
return "是";
}
},
width: 60
}, {
sortable: true,
dataIndex: 'ISINVOICE',
header: Zi.LAN.ISINVOICE, //'不开发票',
editor: {
xtype: 'checkboxfield',
inputValue: '1',
uncheckedValue: '0'
// selectOnFocus: true
},
renderer: function (value, cellmeta) {
if (value == '1') {
return "是";
}
},
width: 60
}, {
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: 'SALECORP',
header: Zi.LAN.SALECORP, //'MANAGER',
editor: this.comboxSALECORP,
width: 100
}, {
sortable: true,
dataIndex: 'REMARK',
header: Zi.LAN.REMARK, //'备注',
editor: {
xtype: 'textfield',
selectOnFocus: true,
enableKeyEvents: true
},
width: 150
}, {
sortable: true,
dataIndex: 'UNITPRICEDESCRPTION',
header: Zi.LAN.UNITPRICEDESCRPTION, //'备注',
editor: {
xtype: 'textfield',
selectOnFocus: true,
enableKeyEvents: true
},
width: 150
}
]
});
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.storeConditList = Ext.create('Ext.data.Store', {
model: 'MsCodeFeeTemplateCondit',
remoteSort: true,
proxy: {
type: 'ajax',
url: '/MvcShipping/MsCodeFeeTemplateAuto/GetConditList',
reader: {
root: 'data',
totalProperty: 'totalCount'
}
}
});
//明细表表格
this.gridListConditCellEditing = Ext.create('Ext.grid.plugin.CellEditing', {
clicksToEdit: 1
});
Ext.define('FieldQueryModel', {
extend: 'Ext.data.Model',
fields: [
{ name: 'GID', type: 'string' },
{ name: 'FORMNAME', type: 'string' },
{ name: 'FIELDCNAME', type: 'string' },
{ name: 'FIELDENAME', type: 'string' },
{ name: 'FIELDTYPE', type: 'string' },
{ name: 'FIELDNAME', type: 'string' },
{ name: 'NESTEDSQL', type: 'string' }
]
});
Ext.define('DsQueryListModel', {
extend: 'Ext.data.Model',
fields: [
{ name: 'NAME', type: 'string' },
{ name: 'VALUE', type: 'string' }
]
});
this.StoreFieldQuery = Ext.create('DsExt.ux.RefTableStore', {
model: 'FieldQueryModel',
proxy: { url: '/MvcShipping/MsBaseInfo/GetQueryFieldSetting' }
});
this.StoreFieldQuery.load({
params: { formname: this.formname },
callback: function (r, options, success) {
if (success) {
if (r.length != 0) {
}
}
}
});
this.comboxQueryField1 = Ext.create('DsExt.ux.RefTableCombox', {
store: this.StoreFieldQuery,
name: 'QUERYFIELD1',
valueField: 'FIELDNAME',
displayField:'FIELDCNAME'
});
this.storeListCode1 = Ext.create('DsExt.ux.RefTableStore', {
model: 'DsQueryListModel',
proxy: { url: '/MvcShipping/MsBaseInfo/GetQueryListValue' }
});
this.comboxListField1 = Ext.create('DsExt.ux.RefTableCombox', {
store: this.storeListCode1,
valueField: 'VALUE',
displayField: 'NAME',
enableKeyEvents: true
});
Ext.define('ConditionModel', {
extend: 'Ext.data.Model',
fields: [
{ name: 'Name', type: 'string' }
]
});
this.dataEditCondition = [{ "Name": '等于' }, { "Name": '不等于' }, { "Name": '模糊' }, { "Name": '大于' }, { "Name": '小于' }];
this.storeEditCondition = Ext.create('Ext.data.Store', {
model: 'ConditionModel',
data: this.dataEditCondition
});
this.comboxCONDIT1 = Ext.create('DsExt.ux.RefTableCombox', {
store: this.storeEditCondition,
forceSelection: true,
valueField: 'Name',
displayField: 'Name'
});
this.gridConditList = new Ext.grid.GridPanel({
store: this.storeConditList,
enableHdMenu: false,
region: 'center',
loadMask: { msg: Zi.LAN.ShuJuJiaZaiZhong },
trackMouseOver: true,
disableSelection: false,
plugins: [this.gridListConditCellEditing],
selType: 'cellmodel',
tbar: [{
text: Zi.LAN.btnAddDetail, //'增加费用明细',
tooltip: Zi.LAN.btnAddDetail, //'增加费用明细',
iconCls: "btnadddetail",
handler: function (button, event) {
this.onAddConditDetailClick(button, event, 1);
},
scope: this
}, '-', {
text: Zi.LAN.btnDeleteDetail, //'删除费用明细',
tooltip: Zi.LAN.btnDeleteDetail, //'删除费用明细',
iconCls: "btndeletedetail",
handler: function (button, event) {
this.onDelConditDetailClick(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: 'FIELDNAME',
header:'字段名称', //'费用名称',
editor: this.comboxQueryField1,
renderer: function (value, p, record) {
return record.data.FIELDCNAME;
},
width: 140
}, {
sortable: true,
dataIndex: 'FIELDCONDIT',
header:'关系', //'费用英文名称',
editor: this.comboxCONDIT1,
width: 150
}, {
sortable: true,
dataIndex: 'FIELDVALUE',
header:'字段值', //'备注',
editor: this.comboxListField1,
width: 150
}
]
});
this.panelCondit = new Ext.Panel({
title: '方案条件', //'费用字段',
layout: "border",
region: 'center',
//margin: '5 10',
items: [this.gridConditList]
});
this.panelService = new Ext.Panel({
title: Zi.LAN.FeeField, //'费用字段',
layout: "border",
region: 'center',
//margin: '5 10',
items: [this.gridList]
});
this.paneldetail = new Ext.tab.Panel({
layout: "border",
region: "center",
items: [
this.panelService,
this.panelCondit
]
});
//#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._thisfee;
if (this.parentWin) {
this.feeType = this.parentWin.feeType;
if (this.feeType == 1) {
this.StoreFee = this.parentWin.storeDrChFee;
} else if (this.feeType == 2) {
this.StoreFee = this.parentWin.storeCrChFee;
}
this.stroplb = this.parentWin.stroplb;
this.formEdit.getForm().findField('FEETYPE').setValue(this.feeType);
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('否');
if (this.stroplb == 'op_Seae') {
this.formEdit.getForm().findField('OPTYPE').setValue(1);
} else if (this.stroplb == 'op_Seai') {
this.formEdit.getForm().findField('OPTYPE').setValue(2);
} else if (this.stroplb == 'op_Aire') {
this.formEdit.getForm().findField('OPTYPE').setValue(3);
} else if (this.stroplb == 'op_Airi') {
this.formEdit.getForm().findField('OPTYPE').setValue(7);
} else if (this.stroplb == 'op_Apply') {
this.formEdit.getForm().findField('OPTYPE').setValue(4);
} else if (this.stroplb == 'op_Bulk') {
this.formEdit.getForm().findField('OPTYPE').setValue(5);
} else if (this.stroplb == 'op_other') {
this.formEdit.getForm().findField('OPTYPE').setValue(6);
}
for (i = 0; i < this.StoreFee.getCount(); i += 1) {
var memberyf = this.StoreFee.getAt(i);
var newSerialno = this.GetHandleSerialNo(this.storeBodyList);
var CustomerType = memberyf.data.CustomerType;
var records = DsStoreQueryBy(this.storeCustType, 'NAME', CustomerType);
var CLIENT = '';
if (records.getCount() > 0) {
var data = records.getAt(0).data;
CLIENT = data.CLIENT;
}
var Currency = memberyf.data.Currency;
var ExChangerate = 0;
if (Currency == 'RMB') ExChangerate = 1;
var record = Ext.create('MsCodeFeeTemplateDetail', {
GID: '',
TEMPLATEID: '',
FEENAME: memberyf.data.FeeName,
FEEDESCRIPTION: memberyf.data.FeeDescription,
CUSTOMERNAME: memberyf.data.CustomerName,
CLIENT: CLIENT,
CLIENTREF: CustomerType,
UNIT: memberyf.data.Unit,
CURRENCY: memberyf.data.Currency,
UNITPRICE: memberyf.data.UnitPrice,
TAXUNITPRICE: memberyf.data.TaxUnitPrice,
SORT: newSerialno,
EXCHANGERATE: ExChangerate,
CREATEUSER: "",
REMARK: memberyf.data.Remark,
FEEFRT: memberyf.data.FeeFrt,
SALECORP: memberyf.data.SALECORP,
TAXRATE: memberyf.data.TaxRate,
ISCTN: false,
ISCTNREF: "否"
});
this.storeBodyList.add(record);
}
}
}
//绑定事件
this.gridList.on('edit', function (editor, e, eOpts) {
this.gridAfterEdit(editor, e, eOpts);
}, this);
this.gridConditList.on('edit', function (editor, e, eOpts) {
this.gridConditAfterEdit(editor, e, eOpts);
}, this);
this.gridListConditCellEditing.on('beforeedit', function (editor, e) {
return this.cellEditinggridConditBeforeEdit(editor, e);
}, 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);
this.storeConditList.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/MsCodeFeeTemplateAuto/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 + "'" } });
this.storeConditList.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);
var Conditbodydatas = [];
for (var i = 0; i < this.storeConditList.getCount(); i += 1) {
var member = this.storeConditList.getAt(i);
Conditbodydatas.push(member);
}
var jsonConditBody = ConvertRecordsToJsonAll(Conditbodydatas);
Ext.Msg.wait(Zi.LAN.ZhengZaiCaoZuoShuJu);
Ext.Ajax.request({
waitMsg: Zi.LAN.ZhengZaiCaoZuoShuJu, //'正在保存数据...',
url: '/MvcShipping/MsCodeFeeTemplateAuto/Save',
scope: this,
params: {
opstatus: this.opStatus,
data: Ext.JSON.encode(data),
body: jsonBody,
condit: jsonConditBody
},
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();
};
for (var j = 0; j < this.storeConditList.getCount(); j += 1) {
var memberbody = this.storeConditList.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.field == 'CLIENT') {
var records = DsStoreQueryBy(this.storeCustType, 'EnumValueId', e.value);
if (records.getCount() > 0) {
var data = records.getAt(0).data;
var CLIENTNAME = data.EnumValueName;
e.record.set('CLIENTREF', CLIENTNAME);
}
}
if (e.field == 'ISCTN') {
var isctn = e.value;
if (isctn == true)
e.record.set('ISCTNREF', "是");
else
e.record.set('ISCTNREF', "否");
}
if (e.field == 'CURRENCY') {
var isctn = e.value;
if (isctn == 'RMB')
e.record.set('EXCHANGERATE', 1);
else
e.record.set('EXCHANGERATE', 0);
} if (e.field == 'UNITPRICE') {
var unitPrice = e.record.data['UNITPRICE'];
var taxrate = e.record.data['TAXRATE'];
if (taxrate != null) {
var taxrateb = Add(1, Div(taxrate, 100, 4), 4);
//parseFloat(1 + parseFloat(taxrate).mul(0.01));
var TaxUnitPrice = Mul(unitPrice, taxrateb, 4);
//(parseFloat(unitPrice).mul(taxrateb)).toFixed(2);
e.record.set('TAXUNITPRICE', TaxUnitPrice);
}
// var PreAmountttl = Mul(PreAmount, quantity);
// e.record.set('PreAmountttl', PreAmountttl);
} else if (e.field == 'TAXUNITPRICE') {
var TaxUnitPrice = e.record.data['TAXUNITPRICE'];
var taxrate = e.record.data['TAXRATE'];
var taxrateb = Add(1, Div(taxrate, 100, 4), 4); //parseFloat(1 + parseFloat(taxrate).mul(0.01));
var unitPrice = Div(TaxUnitPrice, taxrateb, 4); //(parseFloat(TaxUnitPrice).div(parseFloat(taxrateb))).toFixed(2);
e.record.set('UNITPRICE', unitPrice);
} else if (e.field == 'FEENAME' || e.field == 'FEEDESCRIPTION') {
if (e.field == 'FEEDESCRIPTION') {
if (e.value == '') return;
}
if (e.field == 'FEEDESCRIPTION') {
var records = DsStoreQueryBy(this.storeFeeNameRef, 'Description', e.value);
if (records.getCount() > 0) {
var data = records.getAt(0).data;
e.record.set('FEENAME', data.Name);
}
} else {
var records = DsStoreQueryBy(this.storeFeeNameRef, 'Name', e.value);
if (records.getCount() > 0) {
var data = records.getAt(0).data;
e.record.set('FEEDESCRIPTION', data.Description);
}
}
}
},
gridConditAfterEdit: function (editor, e, eOpts) {
//需要自己实现里面的事件
if (e.field == 'FIELDNAME') {
var records = DsStoreQueryBy(this.StoreFieldQuery, 'FIELDNAME', e.value);
if (records.getCount() > 0) {
var data = records.getAt(0).data;
var CLIENTNAME = data.FIELDCNAME;
e.record.set('FIELDCNAME', CLIENTNAME);
e.record.set('FIELDTYPE', data.FIELDTYPE);
}
}
},
cellEditinggridConditBeforeEdit: function (editor, e) {
if (e.field == 'FIELDVALUE') {
var FIELDTYPE = e.record.get('FIELDTYPE');
this.storeListCode1.load({ params: { type: FIELDTYPE} });
}
return true;
},
addDetail: function (type) {
var newSerialno = 0;
store = this.storeBodyList;
var newSerialno = this.GetHandleSerialNo(store);
var record = Ext.create('MsCodeFeeTemplateDetail', {
GID: '',
TEMPLATEID: '',
FEENAME: "",
CUSTOMERNAME: "",
CLIENT: "CUSTOMERNAME",
CLIENTREF: "委托单位",
UNIT: "单票",
CURRENCY: "RMB",
UNITPRICE: 0,
TAXUNITPRICE: 0,
SORT: newSerialno,
EXCHANGERATE: 1,
CREATEUSER: "",
FEEFRT: "PP",
REMARK: "",
ISCTN: false,
ISCTNREF: "否"
});
store.add(record);
var n = store.getCount();
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);
}
},
onClearCustomerClick: function () {
for (var i = 0; i < this.storeBodyList.getCount(); i += 1) {
var member = this.storeBodyList.getAt(i);
member.set("CUSTOMERNAME", "");
member.commit();
}
},
onAddConditDetailClick: function () {
store = this.storeConditList;
var record = Ext.create('MsCodeFeeTemplateCondit', {
GID: '',
TEMPLATEID: '',
FIELDNAME: "",
FIELDCONDIT: "",
FIELDVALUE:""
});
store.add(record);
var n = store.getCount();
this.gridListConditCellEditing.startEditByPosition({ row: n - 1, column: 1 });
},
onDelConditDetailClick: function (type) {
var selectedRecords = this.gridConditList.selModel.getSelection();
for (var i = 0; i < selectedRecords.length; i++) {
var rec = selectedRecords[i];
this.storeConditList.remove(rec);
}
},
Print: function () {
var basicForm = this.formEdit.getForm();
var billNo = basicForm.findField('GID').value;
if (billNo == '*' || billNo == '') {
Ext.Msg.show({ title: '错误', msg: '单据还没有保存,请保存后再打印', icon: Ext.Msg.ERROR, buttons: Ext.Msg.OK });
return;
}
var printType = 'MSCODEFEETEMPLATEEDI';
var sql1 = "SET LANGUAGE 'us_english' SELECT * FROM code_fee_template_auto WHERE GID = '" + billNo + "'";
var sql2 = "";
var sql3 = "";
var sql4 = "";
var sql5 = "";
var sql6 = "";
PrintComm(printType, sql1, sql2, sql3, sql4, sql5, sql6);
}
});