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.

1720 lines
61 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('DsTruck');
DsTruck.MsCustTruckFeeTemplateEdit = function (config) {
Ext.applyIf(this, config);
this.initUIComponents();
window.DsTruck.MsCustTruckFeeTemplateEdit.superclass.constructor.call(this);
};
Ext.extend(DsTruck.MsCustTruckFeeTemplateEdit, 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.Audit = false;
//#region 编辑form
//枚举参照相关(编辑form)
this.storeEmUnitType = Ext.create('DsExt.ux.RefEnumStore', {});
this.storeEmUnitType.load({ params: { enumTypeId: 50001 } });
this.storeEmTruckType = Ext.create('DsExt.ux.RefEnumStore', {});
this.storeEmTruckType.load({ params: { enumTypeId: 50002 } });
this.storeMustBe = Ext.create('Ext.data.Store', {
model: 'DsShipping.ux.OpDefValue',
remoteSort: true,
proxy: {
type: 'ajax',
url: '/MvcShipping/MsCodeOpMustField/GetDataList',
reader: {
id: 'GID',
root: 'data',
totalProperty: 'totalCount'
}
}
});
//权限范围
this.StoreOpRange = Ext.create('DsExt.ux.RefTableStore', {
model: 'MsOP',
proxy: { url: '/MvcShipping/MsBaseInfo/GetOpRang' }
});
this.storeCustomerNameRef = Ext.create('DsExt.ux.RefTableStore', {
model: 'DsShipping.ux.CustomRefModel',
proxy: { url: '/CommMng/BasicDataRef/GetCustomRefListRm' }
});
this.storeCustomerNameRef.load();
this.comboxCustomerNameRef = Ext.create('DsExt.ux.RefTableCombox', {
store: this.storeCustomerNameRef,
fieldLabel: '客户名称', //'费用类型',
forceSelection: true,
queryMode: 'remote',
minChars: 1,
queryParam: 'CODENAME',
lazyRender: false,
name: 'CUSTOMERNAME',
valueField: 'CustName',
displayField: 'CodeAndFull'
});
this.storeListGetContract = Ext.create('Ext.data.Store', {
fields: [
{ name: 'GID', type: 'string' },
{ name: 'LINKID', type: 'string' },
{ name: 'CONTRACTNO', type: 'string' },
{ name: 'SIGNINGDATE', type: 'string' },
{ name: 'STARTDATE', type: 'string' },
{ name: 'CANCELDATE', type: 'string' },
{ name: 'CHIEF', type: 'string' },
{ name: 'REMARK', type: 'string' },
{ name: 'CORPID', type: 'string' }
],
pageSize: 5000,
remoteSort: true,
proxy: {
type: 'ajax',
url: '/MvcShipping/MsInfoClient/GetContractDataList',
reader: {
id: '',
root: 'data',
totalProperty: 'totalCount'
}
}
});
this.comboxContract = Ext.create('DsExt.ux.RefTableCombox', {
store: this.storeListGetContract,
forceSelection: true,
fieldLabel: '合同号', //'费用类型',
valueField: 'CONTRACTNO',
name: 'CONTRACTNO',
displayField: 'CONTRACTNO',
listeners: {
scope: this,
'focus': function (combo, records, eOpts) {
var custname = this.formEdit.getForm().findField('CUSTOMERNAME').getValue();
var GID= this.formEdit.getForm().findField('GID').getValue();
if (custname != '') {
var sql = "LINKID in (select GID FROM INFO_CLIENT WHERE SHORTNAME='" + custname + "') and CONTRACTNO NOT IN (SELECT CONTRACTNO FROM Cust_Truck_feetemplate WHERE GID<>'" + GID + "') ";
this.storeListGetContract.load({
params: { start: 0, limit: 5000, sort: '', condition: sql },
waitMsg: "正在查询数据...",
scope: this
});
}
}
}
});
//this.storeListGetContract.load({
// params: { start: 0, limit: 5000, sort: '', condition: '' },
// waitMsg: "正在查询数据...",
// scope: this
//});
this.storeCodeGoodsList = Ext.create('DsExt.ux.RefTableStore', {
model: 'DsShipping.ux.CodeGoodsModel',
proxy: { url: '/CommMng/BasicDataRef/GetCodeGoodsListRm' }
});
this.storeCodeGoodsList.load();
this.comboxGoodCode = Ext.create('DsExt.ux.RefTableCombox', {
fieldLabel: '品名',
store: this.storeCodeGoodsList,
forceSelection: true,
name: 'GOODNAME',
valueField: 'GOODNAME',
queryMode: 'remote',
minChars: 0,
queryParam: 'CODENAME',
fieldLabel: '商品名称', //'费用类型',
displayField: 'CodeAndName'
});
this.storeCodeCtn = Ext.create('DsExt.ux.RefTableStore', {
model: 'DsShipping.ux.CodeCtnModel',
proxy: { url: '/CommMng/BasicDataRef/GetCodeCtnList' }
});
this.storeCodeCtn.load();
this.storeTransType = Ext.create('Ext.data.Store', {
fields: ['DC', 'NAME']
});
this.storeTransType.add({ "DC": "普货", "NAME": "普货" });
this.storeTransType.add({ "DC": "集装箱", "NAME": "集装箱" });
this.comboxTransType = Ext.create('DsExt.ux.RefTableCombox', {
fieldLabel:'运输类型', //'费用类型',
store: this.storeTransType,
valueField: 'DC',
displayField: 'NAME',
forceSelection: true,
name: 'TRANTYPE',
listeners: {
scope: this,
'select': function (combo, records, eOpts) {
if (records.length > 0) {
if (combo.value == "集装箱") {
this.StoreUnitType.removeAll();
this.StoreUnitType.add({ "UnitType": "车" });
}
else {
this.StoreUnitType.removeAll();
for (var i = 0; i < this.storeEmUnitType.getCount() ; i += 1) {
var member = this.storeEmUnitType.getAt(i);
this.StoreUnitType.add({ "Unit": member.data.EnumValueName });
}
//this.StoreUnitType.add({ "UnitType": "吨" });
//this.StoreUnitType.add({ "UnitType": "车" });
//this.StoreUnitType.add({ "UnitType": "公斤" });
//this.StoreUnitType.add({ "UnitType": "立方" });
}
}
}
}
});
this.StoreUnitType = Ext.create('Ext.data.Store', {
fields: ['UnitType']
});
this.comboxUnitType = Ext.create('DsExt.ux.RefTableCombox', {
store: this.StoreUnitType,
forceSelection: true,
name: 'UNITTYPE',
valueField: 'UnitType',
displayField: 'UnitType',
listeners: {
scope: this,
'focus': function (combo, records, eOpts) {
var TRANTYPE = this.formEdit.getForm().findField('TRANTYPE').getValue();
if (TRANTYPE == '集装箱') {
this.StoreUnitType.removeAll();
this.StoreUnitType.add({ "UnitType": "车型" });
var headfield = this.formEdit.getForm().findField('FEEUNIT');
headfield.allowBlank = true;
var headfield2 = this.formEdit.getForm().findField('PRICEUNIT');
headfield2.allowBlank =true;
} else {
this.StoreUnitType.removeAll();
for (var i = 0; i < this.storeEmUnitType.getCount() ; i += 1) {
var member = this.storeEmUnitType.getAt(i);
this.StoreUnitType.add({ "UnitType": member.data.EnumValueName });
}
var headfield = this.formEdit.getForm().findField('FEEUNIT');
headfield.allowBlank = false;
var headfield2 = this.formEdit.getForm().findField('PRICEUNIT');
headfield2.allowBlank = false;
//this.StoreUnitType.add({ "UnitType": "吨" });
//this.StoreUnitType.add({ "UnitType": "车型" });
//this.StoreUnitType.add({ "UnitType": "公斤" });
//this.StoreUnitType.add({ "UnitType": "立方" });
}
}
}
});
this.StoreUnit = Ext.create('Ext.data.Store', {
fields: ['Unit']
});
this.comboxUnit = Ext.create('DsExt.ux.RefTableCombox', {
store: this.StoreUnit,
forceSelection: true,
name: 'UNIT',
valueField: 'Unit',
displayField: 'Unit',
listeners: {
scope: this,
'focus': function (combo, records, eOpts) {
var TRANTYPE = this.formEdit.getForm().findField('TRANTYPE').getValue();
var selections = this.gridList.getSelectionModel().getSelection(); //获得选中的项
var UNITTYPE = selections[0].get('UNITTYPE');
if (UNITTYPE == '车型') {
if (TRANTYPE == '集装箱') {
this.StoreUnit.removeAll();
for (var j = 0; j < this.storeCodeCtn.getCount() ; j += 1) {
var memberbody = this.storeCodeCtn.getAt(j);
this.StoreUnit.add({ "Unit": memberbody.data.CTN });
};
} else {
this.StoreUnit.removeAll();
for (var i = 0; i < this.storeEmTruckType.getCount() ; i += 1) {
var member = this.storeEmTruckType.getAt(i);
this.StoreUnit.add({ "Unit": member.data.EnumValueName });
}
//this.StoreUnit.add({ "Unit": "4.2M" });
//this.StoreUnit.add({ "Unit": "7.2M" });
//this.StoreUnit.add({ "Unit": "9.6M" });
//this.StoreUnit.add({ "Unit": "12.5M" });
//this.StoreUnit.add({ "Unit": "17.5M" });
}
} else this.StoreUnit.removeAll();
}
}
});
this.storeListTruckLoadPort = Ext.create('Ext.data.Store', {
fields: [
{ name: 'PORTID', type: 'string' },
{ name: 'PORTCODE', type: 'string' },
{ name: 'PORT', type: 'string' },
{ name: 'CODEANDNAME', type: 'string' },
{ name: 'PROVINCE', type: 'string' }
],
pageSize: 5000,
remoteSort: true,
proxy: {
type: 'ajax',
url: '/TruckMng/MsCodeTruckPort/GetDataListRm',
reader: {
id: '',
root: 'data',
totalProperty: 'totalCount'
}
}
});
this.storeListTruckLoadPort.load();
this.comboxLoadPort = Ext.create('DsExt.ux.RefTableCombox', {
// fieldLabel: '启运地', //'费用类型',
store: this.storeListTruckLoadPort,
valueField: 'PORT',
displayField: 'CODEANDNAME',
queryMode: 'remote',
minChars: 0,
queryParam: 'CODENAME',
forceSelection: true,
name: 'LOADPORT'
});
this.storeListTruckDistPort = Ext.create('Ext.data.Store', {
fields: [
{ name: 'PORTID', type: 'string' },
{ name: 'PORTCODE', type: 'string' },
{ name: 'PORT', type: 'string' },
{ name: 'CODEANDNAME', type: 'string' },
{ name: 'PROVINCE', type: 'string' }
],
pageSize: 5000,
remoteSort: true,
proxy: {
type: 'ajax',
url: '/TruckMng/MsCodeTruckPort/GetDataListRm',
reader: {
id: '',
root: 'data',
totalProperty: 'totalCount'
}
}
});
this.storeListTruckDistPort.load();
this.comboxDistPort = Ext.create('DsExt.ux.RefTableCombox', {
// fieldLabel: '目的地', //'费用类型',
store: this.storeListTruckDistPort,
valueField: 'PORT',
displayField: 'CODEANDNAME',
queryMode: 'remote',
minChars: 0,
queryParam: 'CODENAME',
forceSelection: true,
name: 'DISTPORT'
});
this.storeDC= Ext.create('Ext.data.Store', {
fields: ['DC', 'NAME']
});
this.storeDC.add({ "DC": "1", "NAME": "收" });
this.storeDC.add({ "DC": "2", "NAME": "付" });
this.comboxDC = Ext.create('DsExt.ux.RefTableCombox', {
fieldLabel: '收付', //'费用类型',
store: this.storeDC,
flex: 0.5,
labelWidth: 50,
valueField: 'DC',
displayField: 'NAME',
forceSelection: true,
name: 'DC'
});
this.storeFeeUnit = Ext.create('Ext.data.Store', {
fields: ['DC', 'NAME']
});
this.storeFeeUnit.add({ "DC": "毛重", "NAME": "毛重" });
this.storeFeeUnit.add({ "DC": "净重", "NAME": "净重" });
this.comboxFeeUnit = Ext.create('DsExt.ux.RefTableCombox', {
fieldLabel: '计费单位', //'费用类型',
store: this.storeFeeUnit,
valueField: 'DC',
displayField: 'NAME',
forceSelection: true,
name: 'FEEUNIT'
});
this.storePriceUnit = Ext.create('Ext.data.Store', {
fields: ['DC', 'NAME']
});
this.storePriceUnit.add({ "DC": "毛重", "NAME": "毛重" });
this.storePriceUnit.add({ "DC": "净重", "NAME": "净重" });
this.comboxPriceUnit = Ext.create('DsExt.ux.RefTableCombox', {
fieldLabel: '计费区间单位', //'费用类型',
store: this.storePriceUnit,
valueField: 'DC',
displayField: 'NAME',
forceSelection: true,
name: 'PRICEUNIT'
});
//表参照相关(编辑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: 80,
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: 'LINKID', //'CORPID',
name: 'LINKID', 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'
}
]
}, {
xtype: 'container',
layout: 'hbox',
defaultType: 'textfield',
items: [{
fieldLabel: '计费方案名称', //'备注',
name: 'TEMPLATENAME'
},this.comboxCustomerNameRef, this.comboxContract,this.comboxTransType,{
fieldLabel: '模板状态', //'录入日期',
flex: 0.5,
readOnly: true,
name: 'BSSTATUS'
},this.comboxDC]
}, {
xtype: 'container',
layout: 'hbox',
defaultType: 'textfield',
items: [this.comboxFeeUnit, this.comboxPriceUnit,this.comboxGoodCode, {
fieldLabel: Zi.LAN.CREATEUSERREF, //'录入人',
readOnly: true,
name: 'CREATEUSERREF'
}, {
fieldLabel: Zi.LAN.CREATETIME, //'录入日期',
readOnly: true,
name: 'CREATETIME'
}]
}, {
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",
id: 'btnESave',
handler: function (button, event) {
this.Save('0');
},
scope: this
},
{
text: Zi.LAN.btnSaveAndClose, //"保存并关闭",
id: 'btnESaveAndClose',
handler: function (button, event) {
this.Save('1');
},
scope: this
},
'-',
{
text: Zi.LAN.btnSaveAndNew, //"保存并新建",
id: 'btnESaveAndNew',
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('');
this.GetEditStatus();
for (var j = 0; j < this.storeBodyList.getCount(); j += 1) {
var memberbody = this.storeBodyList.getAt(j);
memberbody.set("TEMPLATEID", '*');
memberbody.commit();
};
},
scope: this
}, '-', {
id: 'btnSubmitAudit',
text: '提交审核',
tooltip: '提交审核',
handler: function (button, event) {
this.onSubmitAuditClick();
},
scope: this
}, {
id: 'btnSubmitAuditBack',
text: '撤销提交',
tooltip: '撤销提交',
handler: function (button, event) {
this.onSubmitAuditBackClick();
},
scope: this
}, '-', {
id: 'btnAudit',
text: '审核通过',
tooltip: '审核通过',
handler: function (button, event) {
this.onAudit();
},
scope: this
},
{
text: "驳回提交",
id: 'btnAuditBack',
iconCls: "btndelete",
handler: function (button, event) {
var billstatus = this.formEdit.getForm().findField('BSSTATUS').getValue();
if ((billstatus != "提交审核") && (billstatus != "审核通过")) {
Ext.Msg.show({ title: '提示', msg: '当前状态无法驳回!', icon: Ext.Msg.INFO, buttons: Ext.Msg.OK });
return;
}
this.winAuditBackShow.show();
},
scope: this
}, '-', {
text: "关闭",
handler: function (button, event) {
window.close();
},
scope: this
}
]
}); //end 按钮Toolbar
//#endregion
//#region 明细表
//明细表表格相关
//明细表-数据集
this.storeBodyList = Ext.create('Ext.data.Store', {
model: 'MsCustTruckFeeTemplateDetail',
remoteSort: false,
proxy: {
type: 'ajax',
url: '/TruckMng/MsCustTruckFeeTemplate/GetBodyList',
reader: {
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: Zi.LAN.ShuJuJiaZaiZhong },
trackMouseOver: true,
disableSelection: false,
plugins: [this.gridListCellEditing],
selType: 'cellmodel',
tbar: [{
text: Zi.LAN.btnAddDetail, //'增加费用明细',
tooltip: Zi.LAN.btnAddDetail, //'增加费用明细',
iconCls: "btnadddetail",
id: 'btnadddetail',
handler: function (button, event) {
this.onAddDetailClick(button, event, 1);
},
scope: this
}, '-', {
text: Zi.LAN.btnDeleteDetail, //'删除费用明细',
tooltip: Zi.LAN.btnDeleteDetail, //'删除费用明细',
iconCls: "btndeletedetail",
id: 'btndeletedetail',
handler: function (button, event) {
this.onDelDetailClick(button, event, 1);
},
scope: this
}, '-', {
text: 'EXCEL引入',
iconCls: "btnexportexcel",
tooltip: 'EXCEL引入',
handler: function (button, event) {
this.onImportExcelClick();
},
scope: this
}, {
text: "下载EXCEL模板",
handler: function (menu, event) {
window.open("../../download/陆运费用方案模板.xls");
}
}],
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: 'LOADPORT',
header: '启运地', //'费用名称',
editor: this.comboxLoadPort,
width: 140
}, {
sortable: true,
dataIndex: 'DISTPORT',
header: '目的地', //'费用名称',
editor: this.comboxDistPort,
width: 140
}, {
sortable: true,
dataIndex: 'UNITTYPE',
header: '计费标准', //'费用名称',
editor: this.comboxUnitType,
width: 140
}, {
sortable: true,
dataIndex: 'UNIT',
header: '车型', //'费用名称',
editor: this.comboxUnit,
width: 140
}, {
sortable: true,
dataIndex: 'STARTWEIGHT',
header: '计费标准起', //'汇率',
editor: {
xtype: 'numberfield',
keyNavEnabled: false,
selectOnFocus: true,
hideTrigger: true,
mouseWheelEnabled: false,
enableKeyEvents: true
},
align: 'right',
width: 120
}, {
sortable: true,
dataIndex: 'ENDWEIGHT',
header: '计费标准止', //'单价',
editor: {
xtype: 'numberfield',
keyNavEnabled: false,
selectOnFocus: true,
hideTrigger: true,
mouseWheelEnabled: false,
enableKeyEvents: true
},
align: 'right',
width: 120
}, {
sortable: true,
dataIndex: 'UNITPRICE',
header: Zi.LAN.UNITPRICE, //'单价',
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: 'REMARK',
header: Zi.LAN.REMARK, //'备注',
editor: {
xtype: 'textfield',
selectOnFocus: true,
enableKeyEvents: true
},
width: 150
}
]
});
this.panelService = new Ext.Panel({
title: '计费标准', //'费用字段',
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
//绑定查询窗体
//初始化数据
this.ParentWin = window.parent.opener;
this.InitData();
this.LoadMustBe();
//绑定事件
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);
this.formAuditBack = Ext.widget('form', {
frame: true,
region: 'center',
title: "<a href='#'><font color='#FF0000'>驳回原因</font></a>",
bodyPadding: 5,
fieldDefaults: {
margins: '2 2 2 2',
labelAlign: 'right',
flex: 1,
labelWidth: 90,
msgTarget: 'qtip'
},
items: [{
xtype: 'textareafield',
grow: true,
fieldLabel: '',
labelSeparator: '',
labelWidth: 0,
height: 100,
name: 'ORREASON',
anchor: '100%'
}
]//end root items
});
me = this;
this.winAuditBackShow = Ext.create('Ext.window.Window', {
title: "驳回审核",
width: 450,
//height : 120,
//plain : true,
iconCls: "addicon",
resizable: false,
// 是否可以拖动
// draggable:false,
collapsible: true, // 允许缩放条
closeAction: 'close',
closable: true,
modal: 'true',
buttonAlign: "center",
bodyStyle: "padding:0 0 0 0",
items: [this.formAuditBack],
buttons: [{
text: "确认驳回",
minWidth: 70,
handler: function () {
var form = me.formAuditBack.getForm();
var ORREASON = form.findField('ORREASON').getRawValue();
if (ORREASON == '' || ORREASON == null || ORREASON == undefined) {
Ext.Msg.show({ title: '提示', msg: '驳回原因为必填!', icon: Ext.Msg.INFO, buttons: Ext.Msg.OK });
return;
};
me.onAuditBack(ORREASON);
}
}, {
text: "关闭",
minWidth: 70,
handler: function () {
me.winAuditBackShow.close();
}
}]
});
}, //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];
this.Audit = ret[3];
}
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: '/TruckMng/MsCustTruckFeeTemplate/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;
var custname = data.CUSTOMERNAME;
if (custname != '') {
var sql = "LINKID in (select GID FROM INFO_CLIENT WHERE SHORTNAME='" + custname + "')";
this.storeListGetContract.load({
params: { start: 0, limit: 5000, sort: '', condition: sql },
waitMsg: "正在查询数据...",
scope: this
});
}
this.formEdit.getForm().reset();
this.formEdit.getForm().setValues(data);
this.GetEditStatus();
} 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;
}
if (this.storeBodyList.getCount() == 0) {
Ext.Msg.show({ title: '提示', msg: '方案明细不能为空,不能保存 请检查!', icon: Ext.Msg.INFO, buttons: Ext.Msg.OK });
return;
}
var IsPost = this.IsDetailIsPost();
if (!IsPost) {
Ext.Msg.show({ title: '提示', msg: '方案明细计费区间有错误,不能保存 请检查!', icon: Ext.Msg.INFO, buttons: Ext.Msg.OK });
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);
Ext.Msg.wait(Zi.LAN.ZhengZaiCaoZuoShuJu);
Ext.Ajax.request({
waitMsg: Zi.LAN.ZhengZaiCaoZuoShuJu, //'正在保存数据...',
url: '/TruckMng/MsCustTruckFeeTemplate/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') {
var arrNewRecords = this.StoreList.insert(0, returnData);
this.editRecord = this.StoreList.getAt(0);
}
else if (this.opStatus == 'edit') {
var editp = Ext.create('MsCustTruckFeeTemplate', 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("TEMPLATEID", returnData.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
onSubmitAuditClick: function (type) {
var basicForm = this.formEdit.getForm();
if (!basicForm.isValid()) {
return;
}
//判断表格数据是否合法
if (!validateEditorGridPanel(this.gridList)) {
return;
}
var BSSTATUSREF = this.formEdit.getForm().findField('BSSTATUS').getValue();
if (BSSTATUSREF != '新增' && BSSTATUSREF != '' && BSSTATUSREF != '驳回提交') {
Ext.Msg.show({ title: '提示', msg: '当前状态无法提交!', icon: Ext.Msg.INFO, buttons: Ext.Msg.OK });
return;
}
var IsPost = this.IsDetailIsPost();
if (!IsPost) {
Ext.Msg.show({ title: '提示', msg: '方案明细计费区间有错误,不能保存 请检查!', icon: Ext.Msg.INFO, buttons: Ext.Msg.OK });
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);
Ext.Msg.wait(Zi.LAN.ZhengZaiCaoZuoShuJu);
Ext.Ajax.request({
waitMsg: Zi.LAN.ZhengZaiCaoZuoShuJu, //'正在保存数据...',
url: '/TruckMng/MsCustTruckFeeTemplate/SubmitAudit',
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') {
var arrNewRecords = this.StoreList.insert(0, returnData);
this.editRecord = this.StoreList.getAt(0);
}
else if (this.opStatus == 'edit') {
var editp = Ext.create('MsCustTruckFeeTemplate', 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();
}
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("TEMPLATEID", returnData.GID);
memberbody.commit();
};
} 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
onSubmitAuditBackClick: function (type) {
var basicForm = this.formEdit.getForm();
if (!basicForm.isValid()) {
return;
}
var BSSTATUSREF = this.formEdit.getForm().findField('BSSTATUS').getValue();
if (BSSTATUSREF != '提交审核') {
Ext.Msg.show({ title:'提示', msg: '当前状态无法撤销提交!', icon: Ext.Msg.INFO, buttons: Ext.Msg.OK });
return;
}
//判断表格数据是否合法
if (!validateEditorGridPanel(this.gridList)) {
return;
}
basicForm.findField('GID').setDisabled(false);
var data = basicForm.getValues();
basicForm.findField('GID').setDisabled(true);
Ext.Msg.wait(Zi.LAN.ZhengZaiCaoZuoShuJu);
Ext.Ajax.request({
waitMsg: Zi.LAN.ZhengZaiCaoZuoShuJu, //'正在保存数据...',
url: '/TruckMng/MsCustTruckFeeTemplate/SubmitAuditBack',
scope: this,
params: {
data: Ext.JSON.encode(data)
},
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);
this.GetEditStatus();
var editp = Ext.create('MsCustTruckFeeTemplate', 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();
} 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
onAudit: function (type) {
var basicForm = this.formEdit.getForm();
if (!basicForm.isValid()) {
return;
}
//判断表格数据是否合法
if (!validateEditorGridPanel(this.gridList)) {
return;
}
var BSSTATUSREF = this.formEdit.getForm().findField('BSSTATUS').getValue();
if (BSSTATUSREF != '提交审核') {
Ext.Msg.show({ title: '提示', msg: '当前状态无法审核通过!', icon: Ext.Msg.INFO, buttons: Ext.Msg.OK });
return;
}
basicForm.findField('GID').setDisabled(false);
var data = basicForm.getValues();
basicForm.findField('GID').setDisabled(true);
Ext.Msg.wait(Zi.LAN.ZhengZaiCaoZuoShuJu);
Ext.Ajax.request({
waitMsg: Zi.LAN.ZhengZaiCaoZuoShuJu, //'正在保存数据...',
url: '/TruckMng/MsCustTruckFeeTemplate/Audit',
scope: this,
params: {
data: Ext.JSON.encode(data)
},
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);
var editp = Ext.create('MsCustTruckFeeTemplate', 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();
} 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
onAuditBack: function (reason) {
var basicForm = this.formEdit.getForm();
if (!basicForm.isValid()) {
return;
}
var BSSTATUSREF = this.formEdit.getForm().findField('BSSTATUS').getValue();
if (BSSTATUSREF != '审核通过' && BSSTATUSREF != '提交审核') {
Ext.Msg.show({ title: '提示', msg: '当前状态无法撤销审核!', icon: Ext.Msg.INFO, buttons: Ext.Msg.OK });
return;
}
//判断表格数据是否合法
if (!validateEditorGridPanel(this.gridList)) {
return;
}
basicForm.findField('GID').setDisabled(false);
var data = basicForm.getValues();
basicForm.findField('GID').setDisabled(true);
Ext.Msg.wait(Zi.LAN.ZhengZaiCaoZuoShuJu);
Ext.Ajax.request({
waitMsg: Zi.LAN.ZhengZaiCaoZuoShuJu, //'正在保存数据...',
url: '/TruckMng/MsCustTruckFeeTemplate/AuditBack',
scope: this,
params: {
data: Ext.JSON.encode(data),
reason: reason
},
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);
var editp = Ext.create('MsCustTruckFeeTemplate', 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();
this.winAuditBackShow.close();
} 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
onImportExcelClick: function () {
var basicForm = this.formEdit.getForm();
if (!basicForm.isValid()) {
return;
}
var BSSTATUSREF = this.formEdit.getForm().findField('BSSTATUS').getValue();
if (BSSTATUSREF != '新增' && BSSTATUSREF != '' && BSSTATUSREF != '驳回提交') {
Ext.Msg.show({ title: '提示', msg: '当前状态无法上传!', icon: Ext.Msg.INFO, buttons: Ext.Msg.OK });
return;
}
basicForm.findField('GID').setDisabled(false);
var BSNO = this.formEdit.getForm().findField('GID').getValue();
basicForm.findField('GID').setDisabled(true);
me = this;
var imgform = new Ext.FormPanel({
region: 'center',
labelWidth: 20,
frame: true,
autoScroll: false,
border: false,
fileUpload: true,
items: [{
xtype: 'fileuploadfield',
id: 'LoadExcel',
name: 'LoadExcel',
emptyText: '请选择EXCEL文件', //'请选择EXCEL文件',
fieldLabel: 'EXCEL', //'EXCEL',
buttonText: '选择文件', //'选择文件',
allowBlank: false,
width: 200,
buttonCfg:
{
iconCls: 'uploaddialog'
},
anchor: '98%'
}],
buttons: [{
text: '上传', //'上传',
type: 'submit',
handler: function () {
var UserFilePath = Ext.getCmp('LoadExcel').getValue();
if (!CheckFileExt(UserFilePath, /.xls|.xlsx/i)) {
Ext.Msg.show({ title: '错误', msg: '请确认你上传的文件为EXCEL文件!', icon: Ext.Msg.INFO, buttons: Ext.Msg.OK }); //'请确认你上传的文件为EXCEL文件!'
return;
}
if (!imgform.form.isValid()) { return; }
imgform.form.submit({
url: '/TruckMng/MsCustTruckFeeTemplate/ImportDetailData',
waitMsg: '正在操作数据',
method: 'POST',
params: {
bsno: BSNO
},
success: function (form, action) {
_this.storeBodyList.reload();
win.close(this);
},
failure: function (form, action) {
form.reset();
if (action.failureType == Ext.form.Action.SERVER_INVALID)
Ext.MessageBox.alert('警告', action.result.Message);
}
});
}
}, {
text: '关闭', //'关闭',
type: 'submit',
handler: function () {
win.close(this);
}
}]
});
var win = new Ext.Window({
title: "上传EXCEL", //"上传EXCEL",
width: 380,
height: 120,
modal: true,
resizable: false,
border: false,
items: imgform
});
win.show();
return;
},
gridAfterEdit: function (editor, e, eOpts) {
//需要自己实现里面的事件
if (e.field == 'UNITTYPE') {
var TRANTYPE = this.formEdit.getForm().findField('TRANTYPE').getValue();
if (e.value == '') {
}
}
},
addDetail: function (type) {
var newSerialno = 0;
store = this.storeBodyList;
var record = Ext.create('MsCustTruckFeeTemplateDetail', {
GID: '',
TEMPLATEID: '*',
UNITTYPE: "",
UNIT: "",
UNITPRICE: 0,
STARTWEIGHT: 0,
ENDWEIGHT: 0,
CREATEUSER: "",
REMARK: ""
});
var z=store.add(record);
var feeid = z[0].internalId;
var rown = store.data.keys.indexOf(feeid);
this.gridListCellEditing.startEditByPosition({ row: rown, column: 2 });
},
IsDetailIsPost:function(){
this.storeBodyListCopy = Ext.create('DsExt.ux.RefTableStore', {
model: 'MsCustTruckFeeTemplateDetail',
proxy: { url: '/CommMng/BasicDataRef/GetUserLinkRefListRm' }
});
this.storeBodyListCopy.loadData(this.storeBodyList.data.items);
var IsPost = true;
for (var j = 0; j < this.storeBodyList.getCount() ; j += 1) {
var memberbody = this.storeBodyList.getAt(j);
for (var z = 0; z < this.storeBodyListCopy.getCount() ; z += 1) {
var memberbodycopy = this.storeBodyListCopy.getAt(z);
if (memberbodycopy.data.UNITTYPE == memberbody.data.UNITTYPE && memberbodycopy.data.UNIT == memberbody.data.UNIT && memberbodycopy.data.LOADPORT == memberbody.data.LOADPORT && memberbodycopy.data.DISTPORT == memberbody.data.DISTPORT) {
if ((memberbodycopy.data.STARTWEIGHT > memberbody.data.STARTWEIGHT && memberbodycopy.data.STARTWEIGHT < memberbody.data.ENDWEIGHT) || (memberbodycopy.data.ENDWEIGHT > memberbody.data.STARTWEIGHT && memberbodycopy.data.ENDWEIGHT < memberbody.data.ENDWEIGHT))
IsPost = false;
}
};
};
return IsPost;
},
GetEditStatus: function () {
var canedit = false;
var BSSTATUSREF = this.formEdit.getForm().findField('BSSTATUS').getValue();
var op = this.formEdit.getForm().findField('CREATEUSERREF').getValue();
//
_this = this;
if (BSSTATUSREF != '新增' && BSSTATUSREF != '驳回提交') {
canedit = false;
this.setSaveBtnStatus(canedit);
} else {
this.StoreOpRange.load({
params: { optype: "modCustTruckFeeTemplate" },
callback: function (r, options, success) {
if (success) {
if (r.length != 0) {
var records = DsStoreQueryBy(_this.StoreOpRange, 'OPID', op);
if (records.getCount() > 0) {
canedit = true;
} else {
canedit = false;
}
} else { canedit = false; }
_this.setSaveBtnStatus(canedit);
}
}
});
}
//
_this = this;
},
LoadMustBe: function () {
this.storeMustBe.load({
params: { condition: "BSTYPE='陆运费用方案'" },
callback: function (r, options, success) {
if (success) {
if (this.storeMustBe.getCount() > 0) {
for (var j = 0; j < this.storeMustBe.getCount() ; j += 1) {
var member = this.storeMustBe.getAt(j);
var headfield = this.formEdit.getForm().findField(member.data.FIELDNAME);
if (headfield != NaN && headfield != null) {
if (member.data.ISMUST == "1")
headfield.allowBlank = false;
if (member.data.ISCOLOR == "1")
headfield.setFieldStyle({ background: '#ffc' });
if (member.data.ISREADONLY == "1")
headfield.setReadOnly(true);
}
};
} else {
}
}
},
scope: this
});
},
setSaveBtnStatus: function (enable) {
var btnESave = Ext.getCmp('btnESave');
var btnESaveAndClose = Ext.getCmp('btnESaveAndClose');
var btnESaveAndNew = Ext.getCmp('btnESaveAndNew');
var btnadddetail = Ext.getCmp('btnadddetail');
var btndeletedetail = Ext.getCmp('btndeletedetail');
var btnSubmitAudit = Ext.getCmp('btnSubmitAudit');
var btnSubmitAuditBack = Ext.getCmp('btnSubmitAuditBack');
var btnAudit = Ext.getCmp('btnAudit');
var btnAuditBack = Ext.getCmp('btnAuditBack');
if (this.Audit) {
btnSubmitAudit.disable();
btnSubmitAuditBack.disable();
btnAudit.enable();
btnAuditBack.enable();
enable = false;
} else {
btnSubmitAudit.enable();
btnSubmitAuditBack.enable();
btnAudit.disable();
btnAuditBack.disable();
}
if (enable) {
btnESave.enable();
btnESaveAndClose.enable();
btnESaveAndNew.enable();
btnadddetail.enable();
btndeletedetail.enable();
} else {
btnESave.disable();
btnESaveAndClose.disable();
btnESaveAndNew.disable();
btnadddetail.disable();
btndeletedetail.disable();
}
},
deleteDetail: function (type) {
var selectedRecords = this.gridList.selModel.getSelection();
for (var i = 0; i < selectedRecords.length; i++) {
var rec = selectedRecords[i];
if (rec.data.TEMPLATEID == "" || rec.data.TEMPLATEID == "*")//如果是新增但没有保存的数据,没有必要提交到后台
{
this.storeBodyList.remove(selectedRecords[i]);
}
else {
Ext.MessageBox.confirm('提示','确定要删除计费明细吗?', function (btn) {
if (btn == 'yes') {
Ext.Msg.wait('正在删除数据...');
Ext.Ajax.request({
waitMsg: '正在删除数据...', //'正在删除数据...',
url: '/TruckMng/MsCustTruckFeeTemplate/DeleteDetail',
params: {
data: Ext.JSON.encode(rec.data)
},
callback: function (options, success, response) {
if (success) {
var jsonresult = Ext.JSON.decode(response.responseText);
if (jsonresult.Success) {
this.storeBodyList.remove(rec);
Ext.Msg.show({ title: '提示', msg: jsonresult.Message, icon: Ext.Msg.INFO, buttons: Ext.Msg.OK });
}
else {
Ext.Msg.show({ title:'错误', msg: jsonresult.Message, icon: Ext.Msg.ERROR, buttons: Ext.Msg.OK });
}
}
},
failure: function (response, options) {
Ext.Msg.show({ title: '警告', msg:'服务器响应出错', icon: Ext.Msg.INFO, buttons: Ext.Msg.OK });
},
scope: this
}); //end Ext.Ajax.request
}
}, this);
}
//this.storeBodyList.remove(selectedRecords[i]);
}
}
});