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/TruckMng/Viewsjs/MsWlDjPc/MsWlDjPcEdit.js

2273 lines
77 KiB
JavaScript

2 years ago
Ext.namespace('DsTruck');
DsTruck.MsWlDjPcEdit = function (config) {
Ext.applyIf(this, config);
this.initUIComponents();
window.DsTruck.MsWlDjPcEdit.superclass.constructor.call(this);
};
Ext.extend(DsTruck.MsWlDjPcEdit, Ext.Panel, {
ParentWin: null, //弹出式
ParentPanel: null, //Tab页编辑模式
FunType: '',
OpStatus: 'add',
StoreList: null,
EditRecord: null,
RefBillNo: '*',
DataLoading: true,
LoadFuel: 0,
NoLoadFuel: 0,
ratedFuel: 0,
//主要是为了处理修改事件。使用focus和blur模拟change事件。
RealMil: 0,
OverLoadMil: 0,
NoLoadMil: 0,
Ton: 0,
initUIComponents: function () {
this.poundSerialNo = 0;
this.poundBodyDel = [];
this.fixSerialNo = 0;
this.fixBodyDel = [];
this.feeSerialNo = 0;
this.feeBodyDel = [];
//#region 编辑form
//枚举参照相关(编辑form)
this.storeBsType = Ext.create('DsExt.ux.RefEnumStore', {});
this.storeBsType.load({ params: { enumTypeId: 99025} });
this.comboxBsType = Ext.create('DsExt.ux.RefEnumCombox', {
fieldLabel: '托单类型',
store: this.storeBsType,
name: 'BsType'
});
//表参照相关(编辑form)
this.storeTruckNo = Ext.create('DsExt.ux.RefTableStore', {
model: 'MsWlPcHeadRefMsWlTruck',
proxy: { url: '/TruckMng/MsWlDjPc/GetTruckNoList' }
});
this.storeTruckNo.load({ params: { condition: ""} });
this.comboxTruckNo = Ext.create('DsExt.ux.RefTableCombox', {
fieldLabel: '车牌号',
store: this.storeTruckNo,
name: 'TruckNo',
valueField: 'TruckNo',
displayField: 'TruckNo',
listeners: {
change: function (field, newValue, oldValue) {
this.tonAndTruckNoChange(field, newValue, oldValue);
},
scope: this
}
});
this.storeDrvName = Ext.create('DsExt.ux.RefTableStore', {
model: 'MsWlPcHeadRefMsWlDriver',
proxy: { url: '/TruckMng/MsWlDjPc/GetDrvNameList' }
});
this.storeDrvName.load({ params: { condition: ""} });
this.comboxDrvName = Ext.create('DsExt.ux.RefTableCombox', {
fieldLabel: '司机',
store: this.storeDrvName,
name: 'DrvCode',
valueField: 'DrvCode',
displayField: 'CodeAndName',
listeners: {
scope: this,
'select': function (combo, records, eOpts) {
if (records.length > 0) {
this.setDrvName(records[0].data.DrvCode);
}
}
}
});
this.storeDdCode = Ext.create('DsExt.ux.RefTableStore', {
model: 'DsTruckMng.ux.UserRefModel',
proxy: { url: '/CommMng/BasicDataRef/GetUserRefList' }
});
this.storeDdCode.load({ params: { condition: ""} });
this.comboxDdCode = Ext.create('DsExt.ux.RefTableCombox', {
fieldLabel: '调度员编码',
store: this.storeDdCode,
name: 'DdCode',
valueField: 'UserCode',
displayField: 'CodeAndName'
});
//编辑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: [
//#region 界面需要的但不需要显示的控件
{
fieldLabel: '录入日期',
name: 'LrDate',
flex: 0,
hidden: true,
margins: '0'
}, {
fieldLabel: '记账日期',
name: 'JzDate',
flex: 0,
hidden: true,
margins: '0'
}, {
fieldLabel: '用户编码',
name: 'UserCode',
flex: 0,
hidden: true,
margins: '0'
}, {
fieldLabel: '用户姓名',
name: 'UserName',
flex: 0,
hidden: true,
margins: '0'
}, {
fieldLabel: '组织编码',
name: 'OrgCode',
flex: 0,
hidden: true,
margins: '0'
}, {
fieldLabel: '组织名称',
name: 'OrgName',
flex: 0,
hidden: true,
margins: '0'
}, {
fieldLabel: '司机姓名',
name: 'DrvName',
flex: 0,
hidden: true,
margins: '0'
}, {
fieldLabel: '周转量',
name: 'AroundTon',
flex: 0,
hidden: true,
margins: '0'
}, {
fieldLabel: '调度员姓名',
name: 'DdName',
flex: 0,
hidden: true,
margins: '0'
}, {
fieldLabel: '时间戳',
name: 'TimeMark',
flex: 0,
hidden: true,
margins: '0'
},
{
fieldLabel: '相关托单物流号',
name: 'RefBillNo',
flex: 0,
hidden: true,
margins: '0'
}, {
fieldLabel: '单据锁定状态',
name: 'BillStatus',
flex: 0,
hidden: true,
margins: '0'
}, {
fieldLabel: '费用锁定状态',
name: 'FeeStatus',
flex: 0,
hidden: true,
margins: '0'
}, {
fieldLabel: 'GId',
name: 'GId',
flex: 0,
hidden: true,
margins: '0'
},
//#endregion
{
fieldLabel: '物流号',
allowBlank: false,
disabled: true,
name: 'BillNo'
}, this.comboxDdCode, this.comboxTruckNo, this.comboxBsType
]
}, {
xtype: 'container',
layout: 'hbox',
defaultType: 'textfield',
items: [this.comboxDrvName, {
fieldLabel: '司机手机',
name: 'Mobile'
}, {
fieldLabel: '派车日期',
format: 'Y-m-d',
xtype: 'datefield',
name: 'ExpDate'
}, {
fieldLabel: '返回日期',
format: 'Y-m-d',
xtype: 'datefield',
name: 'ReturnDate'
}
]
}, {
xtype: 'container',
layout: 'hbox',
defaultType: 'textfield',
items: [{
fieldLabel: '始发地点',
name: 'LoadPlace'
}, {
fieldLabel: '目的地',
name: 'DstArea'
}, {
fieldLabel: '本次加油量',
xtype: 'numberfield',
allowBlank: false,
hideTrigger: true,
keyNavEnabled: false,
mouseWheelEnabled: false,
disabled: true,
name: 'FuelQty'
}, {
fieldLabel: '运行次数',
xtype: 'numberfield',
allowBlank: false,
hideTrigger: true,
keyNavEnabled: false,
mouseWheelEnabled: false,
allowDecimals: false,
name: 'LoadCount'
}
]
}, {
xtype: 'container',
layout: 'hbox',
defaultType: 'textfield',
items: [{
fieldLabel: '重驶里程',
xtype: 'numberfield',
allowBlank: false,
name: 'OverLoadMil',
hideTrigger: true,
keyNavEnabled: false,
mouseWheelEnabled: false
}, {
fieldLabel: '空驶里程',
xtype: 'numberfield',
allowBlank: false,
name: 'NoLoadMil',
hideTrigger: true,
keyNavEnabled: false,
mouseWheelEnabled: false
}, {
fieldLabel: '合计里程',
xtype: 'numberfield',
allowBlank: false,
name: 'TotalMil',
hideTrigger: true,
keyNavEnabled: false,
mouseWheelEnabled: false
}, {
fieldLabel: '额定油耗',
xtype: 'numberfield',
allowBlank: false,
hideTrigger: true,
keyNavEnabled: false,
mouseWheelEnabled: false,
name: 'RatedFuel'
}
]
}, {
xtype: 'container',
layout: 'hbox',
defaultType: 'textfield',
items: [{
fieldLabel: '变动里程',
xtype: 'numberfield',
allowBlank: false,
hideTrigger: true,
keyNavEnabled: false,
mouseWheelEnabled: false,
name: 'ChangedMil'
}, {
fieldLabel: '变动油耗',
xtype: 'numberfield',
allowBlank: false,
hideTrigger: true,
keyNavEnabled: false,
mouseWheelEnabled: false,
name: 'ChangedFuel'
}, {
fieldLabel: '变动原因',
name: 'ChangedReson'
}, {
fieldLabel: '实际油耗',
xtype: 'numberfield',
allowBlank: false,
hideTrigger: true,
keyNavEnabled: false,
mouseWheelEnabled: false,
hidden: true,
name: 'RealFuel'
}
]
}, {
xtype: 'container',
layout: 'hbox',
defaultType: 'textarea',
height: 36,
items: [{
fieldLabel: '备注',
height: 32,
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: [
{
id: 'pcbtnSave',
text: "保存",
iconCls: "btnsave",
handler: function (button, event) {
this.Save('0');
},
scope: this
},
{
id: 'pcbtnSaveAndClose',
text: "保存并关闭",
handler: function (button, event) {
this.Save('1');
},
scope: this
},
'-',
{
id: 'pcbtnSaveAndNew',
text: "保存并新建",
handler: function (button, event) {
this.Save('2');
},
scope: this
},
'-',
{
text: "关闭",
handler: function (button, event) {
window.close();
},
scope: this
},
{
id: 'pcbtnNew',
text: "新建",
handler: function (button, event) {
this.LoadData('add', '', this.RefBillNo);
var basicForm = this.formEdit.getForm();
basicForm.findField('BillNo').setDisabled(false);
},
scope: this
},
'-',
{
text: "打印",
iconCls: "btnprint",
handler: function (button, event) {
this.Print();
},
scope: this
}
]
}); //end 按钮Toolbar
//#endregion
//#region 固定费用明细表
//派车明细表表格相关
this.storeBulkBillNoRef = Ext.create('DsExt.ux.RefTableStore', {
model: 'MsWlDjPoundRefMsWlDjHead',
proxy: { url: '/TruckMng/MsWlDjPc/GetDjBillNoList' }
});
this.storeBulkBillNoRef.load({ params: { condition: ""} });
this.comboxBulkBillNoRef = Ext.create('DsExt.ux.RefTableCombox', {
store: this.storeBulkBillNoRef,
name: 'DjBillNo',
valueField: 'BillNo',
displayField: 'BillNo',
allowBlank: false,
editable: false
});
this.storeCustCodeRef = Ext.create('DsExt.ux.RefTableStore', {
model: 'DsTruckMng.ux.CustomRefModel',
proxy: { url: '/CommMng/BasicDataRef/GetCustomRefList' }
});
this.storeCustCodeRef.load({ params: { condition: "ISCONTROLLER='1'"} });
this.comboxCustCodeRef = Ext.create('DsExt.ux.RefTableCombox', {
store: this.storeCustCodeRef,
name: 'CustCode',
valueField: 'CustCode',
displayField: 'CodeAndName'
});
//明细表-数据集
this.storePoundBodyList = Ext.create('Ext.data.Store', {
model: 'MsWlDjPound',
remoteSort: true,
proxy: {
type: 'ajax',
url: '/TruckMng/MsWlDjPc/GetBodyList',
reader: {
id: 'BillNo,SerialNo',
root: 'data',
totalProperty: 'totalCount'
}
}
});
//明细表表格
this.PoundgridListCellEditing = Ext.create('Ext.grid.plugin.CellEditing', {
clicksToEdit: 1
});
this.PoundgridList = new Ext.grid.GridPanel({
store: this.storePoundBodyList,
enableHdMenu: false,
region: 'center',
loadMask: { msg: "数据加载中,请稍等..." },
trackMouseOver: true,
disableSelection: false,
plugins: [this.PoundgridListCellEditing],
selType: 'cellmodel',
tbar: [{
text: '增加明细',
tooltip: '增加明细',
iconCls: "btnadddetail",
handler: function (button, event) {
this.onAddDetailClick(button, event, '3');
},
scope: this
}, '-', {
text: '删除明细',
tooltip: '删除明细',
iconCls: "btndeletedetail",
handler: function (button, event) {
this.onDelDetailClick(button, event, '3');
},
scope: this
}],
columns: [{
sortable: true,
dataIndex: 'BillNo',
header: '单据号',
hidden: true,
width: 120
}, {
sortable: true,
dataIndex: 'SerialNo',
header: '序号',
width: 30
}, {
sortable: true,
dataIndex: 'DjBillNo',
header: '托运单号',
editor: this.comboxBulkBillNoRef,
width: 150
}, {
sortable: true,
dataIndex: 'GId',
header: '惟一编号',
hidden: true,
width: 160
}, {
sortable: true,
dataIndex: 'CustCode',
header: '委托单位代码',
renderer: function (value, p, record) {
if (value == null || value == '')
return '';
else
return value + '-' + record.data.CustCode_Ref;
},
editor: this.comboxCustCodeRef,
width: 160
}, {
sortable: true,
dataIndex: 'CustName',
header: '委托单位',
hidden: true,
width: 80
}, {
sortable: true,
dataIndex: 'ClsName',
header: '品名',
editor: {
xtype: 'textfield',
selectOnFocus: true
},
width: 100
}, {
sortable: true,
dataIndex: 'DepartureDate',
header: '起运时间',
editor: {
xtype: 'datefield',
format: 'Y-m-d',
selectOnFocus: true
},
renderer: Ext.util.Format.dateRenderer('Y-m-d'),
width: 80
}, {
sortable: true,
dataIndex: 'LoadPlace',
header: '起点',
editor: {
xtype: 'textfield',
selectOnFocus: true
},
width: 60
}, {
sortable: true,
dataIndex: 'UnLoadPlace',
header: '止点',
editor: {
xtype: 'textfield',
selectOnFocus: true
},
width: 60
}, {
sortable: true,
dataIndex: 'PlanOverLoadMil',
header: '计划重驶里程',
editor: {
xtype: 'numberfield',
allowBlank: false,
selectOnFocus: true
},
width: 76
}, {
sortable: true,
dataIndex: 'PlanNoLoadMil',
header: '计划空驶里程',
editor: {
xtype: 'numberfield',
allowBlank: false,
selectOnFocus: true
},
width: 76
}, {
sortable: true,
dataIndex: 'PlanLoadCount',
header: '计划运行次数',
editor: {
xtype: 'numberfield',
allowBlank: false,
selectOnFocus: true
},
width: 76
}, {
sortable: true,
dataIndex: 'OverLoadMil',
header: '实际重驶里程',
editor: {
xtype: 'numberfield',
allowBlank: false,
selectOnFocus: true
},
width: 76
}, {
sortable: true,
dataIndex: 'NoLoadMil',
header: '实际空驶里程',
editor: {
xtype: 'numberfield',
allowBlank: false,
selectOnFocus: true
},
width: 76
}, {
sortable: true,
dataIndex: 'LoadCount',
header: '实际运行次数',
editor: {
xtype: 'numberfield',
allowBlank: false,
selectOnFocus: true
},
width: 76
}, {
sortable: true,
dataIndex: 'PNum',
header: '装运件数',
editor: {
xtype: 'numberfield',
allowBlank: false,
selectOnFocus: true
},
width: 76
}, {
sortable: true,
dataIndex: 'PKgs',
header: '件重',
editor: {
xtype: 'numberfield',
allowBlank: false,
selectOnFocus: true
},
width: 76
}, {
sortable: true,
dataIndex: 'Weight',
header: '实际运输总重量',
editor: {
xtype: 'numberfield',
allowBlank: false,
selectOnFocus: true
},
width: 76
}, {
sortable: true,
dataIndex: 'RatedFuel',
header: '额定油耗',
editor: {
xtype: 'numberfield',
allowBlank: false,
selectOnFocus: true
},
width: 76
}, {
sortable: true,
dataIndex: 'TonMil',
header: '吨公里',
editor: {
xtype: 'numberfield',
allowBlank: false,
selectOnFocus: true
},
width: 76
}, {
sortable: true,
dataIndex: 'WorkTime',
header: '工作时间',
hidden: true,
width: 160
}
]
});
//明细表表格相关
this.storeCreditDebitRef = Ext.create('DsExt.ux.RefEnumStore', {});
this.storeCreditDebitRef.load({ params: { enumTypeId: 99020} });
this.comboxCreditDebitRef = Ext.create('DsExt.ux.RefEnumCombox', {
store: this.storeCreditDebitRef,
name: 'CreditDebit'
});
this.storeFeeTypeCodeRef = Ext.create('DsExt.ux.RefTableStore', {
model: 'DsTruckMng.ux.FeeTypeRefModel',
proxy: { url: '/CommMng/BasicDataRef/GetFeeTypeRefList' }
});
this.storeFeeTypeCodeRef.load({ params: { condition: "ISTRUCKING='1' and ISTRUCKINGFIXED ='1'"} });
this.comboxFeeTypeCodeRef = Ext.create('DsExt.ux.RefTableCombox', {
store: this.storeFeeTypeCodeRef,
name: 'FeeTypeCode',
valueField: 'FeeCode',
displayField: 'CodeAndName'
});
//明细表-数据集
this.storeBodyFix = Ext.create('Ext.data.Store', {
model: 'MsWlPcFixed',
remoteSort: false,
proxy: {
type: 'ajax',
url: '/TruckMng/MsWlPc/GetFeeFixBodyList',
reader: {
id: 'GId',
root: 'data',
totalProperty: 'totalCount'
}
}
});
//明细表表格
this.cellEditingFix = Ext.create('Ext.grid.plugin.CellEditing', {
clicksToEdit: 1
});
this.gridListFix = new Ext.grid.GridPanel({
store: this.storeBodyFix,
enableHdMenu: false,
region: 'center',
loadMask: { msg: "数据加载中,请稍等..." },
trackMouseOver: true,
disableSelection: false,
plugins: [this.cellEditingFix],
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: 'BillNo',
header: '单据号',
hidden: true,
width: 120
}, {
sortable: true,
dataIndex: 'SerialNo',
header: '序号',
width: 40
}, {
sortable: true,
dataIndex: 'FeeTypeCode',
header: '费用编码',
renderer: function (value, p, record) {
if (value == null || value == '')
return '';
else
return value + '-' + record.data.FeeTypeCode_Ref;
},
editor: this.comboxFeeTypeCodeRef,
width: 80
}, {
sortable: true,
dataIndex: 'FeeTypeName',
header: '费用名称',
hidden: true,
width: 120
}, {
sortable: true,
dataIndex: 'FsTotal',
header: '金额',
editor: {
xtype: 'numberfield',
allowBlank: false,
selectOnFocus: true
},
width: 60
}, {
sortable: true,
dataIndex: 'Remark',
header: '备注',
editor: {
xtype: 'textfield',
selectOnFocus: true
},
width: 150
}
]
});
this.gridListFix.on('edit', function (editor, e, eOpts) {
this.gridListFixAfterEdit(editor, e, eOpts);
}, this);
this.cellEditingFix.on('beforeedit', function (editor, e) {
return this.cellEditingFixBeforeEdit(editor, e);
}, this);
//#endregion 明细表
//#region 费用表
//明细表表格相关
this.storeFeeTypeRef = Ext.create('DsExt.ux.RefEnumStore', {});
this.storeFeeTypeRef.load({ params: { enumTypeId: 99020} });
this.comboxFeeTypeRef = Ext.create('DsExt.ux.RefEnumCombox', {
store: this.storeFeeTypeRef,
name: 'FeeType'
});
this.storeFeeNameRef = Ext.create('DsExt.ux.RefTableStore', {
model: 'DsTruckMng.ux.FeeTypeRefModel',
proxy: { url: '/CommMng/BasicDataRef/GetFeeTypeRefList' }
});
this.storeFeeNameRef.load({ params: { condition: "ISTRUCKING='1' "} });
this.comboxFeeNameRef = Ext.create('DsExt.ux.RefTableCombox', {
store: this.storeFeeNameRef,
name: 'FeeName',
valueField: 'Name',
displayField: 'CodeAndName'
});
this.storeCustomerNameRef = Ext.create('DsExt.ux.RefTableStore', {
model: 'DsTruckMng.ux.CustomRefModel',
proxy: { url: '/CommMng/BasicDataRef/GetCustomRefList' }
});
this.storeCustomerNameRef.load({ params: { condition: ""} });
this.comboxCustomerNameRef = Ext.create('DsExt.ux.RefTableCombox', {
store: this.storeCustomerNameRef,
name: 'CustomerName',
valueField: 'CustName',
displayField: 'CodeAndName'
});
//明细表-数据集
this.storeBodyChFee = Ext.create('Ext.data.Store', {
model: 'MsChFee',
remoteSort: false,
proxy: {
type: 'ajax',
url: '/TruckMng/MsChFee/GetDataList',
reader: {
id: 'GId',
root: 'data',
totalProperty: 'totalCount'
}
}
});
//明细表表格
this.cellEditingChFee = Ext.create('Ext.grid.plugin.CellEditing', {
clicksToEdit: 1
});
this.feeGridCheckBoxModel = Ext.create('Ext.selection.CheckboxModel');
this.gridListChFee = new Ext.grid.GridPanel({
store: this.storeBodyChFee,
enableHdMenu: false,
region: 'center',
loadMask: { msg: "数据加载中,请稍等..." },
trackMouseOver: true,
disableSelection: false,
plugins: [this.cellEditingChFee],
selModel: this.feeGridCheckBoxModel,
selType: 'cellmodel',
viewConfig: {
autoFill: true,
getRowClass: function (record, rowIndex, rowParams, store) {
var feeStatus = record.get('FeeStatus');
return DsTruck.MsChFeeGetRowClass(feeStatus);
}
},
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
}, '-', {
text: '提交审核',
tooltip: '提交审核',
iconCls: 'btnsubmitaudit',
handler: function (button, event) {
this.onSubmitAuditClick(button, event);
},
scope: this
}, {
text: '审核通过',
tooltip: '审核通过',
iconCls: 'btnsubmitaudit',
handler: function (button, event) {
this.onPassAuditClick(button, event);
},
scope: this
}, {
text: '撤销审核',
tooltip: '撤销审核',
iconCls: 'btnsubmitaudit',
handler: function (button, event) {
this.onCancelAuditClick(button, event);
},
scope: this
}],
columns: [{
sortable: true,
dataIndex: 'GId',
header: '惟一编号',
hidden: true,
width: 160
}, {
sortable: true,
dataIndex: 'BsNo',
header: '业务编号',
hidden: true,
width: 200
}, {
sortable: true,
dataIndex: 'FeeStatus',
header: '费用状态',
renderer: function (value, p, record) {
return record.data.FeeStatus_Ref;
},
width: 66
}, {
sortable: true,
dataIndex: 'FeeName',
header: '费用名称',
editor: this.comboxFeeNameRef,
width: 100
}, {
sortable: true,
dataIndex: 'FeeType',
header: '收付方式',
renderer: function (value, p, record) {
if (value == null || value == '')
return '';
else
return value + '-' + record.data.FeeType_Ref;
},
editor: this.comboxFeeTypeRef,
width: 66
}, {
sortable: true,
dataIndex: 'FeeDescription',
header: '费用英文名称',
hidden: true,
width: 200
}, {
sortable: true,
dataIndex: 'CustomerType',
header: '客户类别',
hidden: true,
width: 200
}, {
sortable: true,
dataIndex: 'CustomerName',
header: '结算对象',
editor: this.comboxCustomerNameRef,
width: 120
}, {
sortable: true,
dataIndex: 'Unit',
header: '单位标准',
hidden: true,
width: 200
}, {
sortable: true,
dataIndex: 'UnitPrice',
header: '单价',
editor: {
xtype: 'numberfield',
selectOnFocus: true
},
width: 60
}, {
sortable: true,
dataIndex: 'Quantity',
header: '数量',
editor: {
xtype: 'numberfield',
selectOnFocus: true
},
width: 60
}, {
sortable: true,
dataIndex: 'Amount',
header: '金额',
width: 60
}, {
sortable: true,
dataIndex: 'Currency',
header: '币别',
hidden: true,
width: 200
}, {
sortable: true,
dataIndex: 'ExChangerate',
header: '汇率',
hidden: true,
width: 160
}, {
sortable: true,
dataIndex: 'Reason',
header: '原因',
hidden: true,
width: 200
}, {
sortable: true,
dataIndex: 'Remark',
header: '备注',
editor: {
xtype: 'textfield',
selectOnFocus: true
},
width: 150
}
]
});
this.gridListChFee.on('edit', function (editor, e, eOpts) {
this.gridListChFeeAfterEdit(editor, e, eOpts);
}, this);
this.cellEditingChFee.on('beforeedit', function (editor, e) {
return this.cellEditingChFeeBeforeEdit(editor, e);
}, this);
//#endregion
//#region 布局
this.panelTop = new Ext.Panel({
layout: "border",
region: "north",
height: 226,
items: [this.panelBtn, this.formEdit]
});
this.panelBodypound = new Ext.Panel({
title: '派车明细',
layout: "border",
region: 'north',
margin: '5 10',
height: 240,
items: [this.PoundgridList]
});
this.panelBodyFix = new Ext.Panel({
title: '固定费用(仅报销,不计入利润统计)',
layout: "border",
region: 'west',
width: 270,
margin: '5 10',
items: [this.gridListFix]
});
this.panelBodyChFee = new Ext.Panel({
title: '费用(计入利润统计的应收应付)',
layout: "border",
region: 'center',
margin: '5 10',
items: [this.gridListChFee]
});
this.panelFee = new Ext.Panel({
layout: "border",
region: "center",
items: [
this.panelBodyFix, this.panelBodyChFee
]
});
Ext.apply(this, {
items: [this.panelTop, this.panelBodypound, this.panelFee]
});
//#endregion
this.opStatus = 'add';
this.ParentWin = window.parent.opener;
//初始化数据
this.InitData();
this.PoundgridList.on('edit', function (editor, e, eOpts) {
this.PoundgridAfterEdit(editor, e, eOpts);
}, this);
}, //end initUIComponents
//#region 加载数据
InitData: function () {
var condition = '';
if (this.ParentWin) {
var ret = this.ParentWin.OprationSwap();
this.opStatus = ret[0];
this.StoreList = ret[1];
this.editRecord = ret[2];
this.RefBillNo = ret[3];
}
if (this.opStatus == 'add') {
condition = " BillNo='*'";
} else if (this.opStatus == 'edit') {
condition = " BillNo='" + this.editRecord.get('BillNo') + "'";
}
this.LoadData(this.opStatus, condition, this.RefBillNo);
}, //end InitData
LoadData: function (opstatus, condition, refbillno) {
this.poundSerialNo = 0;
this.poundBodyDel = [];
this.fixSerialNo = 0;
this.fixBodyDel = [];
this.feeSerialNo = 0;
this.feeBodyDel = [];
this.opStatus = opstatus;
Ext.Ajax.request({
waitMsg: '正在查询主表数据...',
url: '/TruckMng/MsWlDjPc/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;
if (this.opStatus == 'add') {
data.RefBillNo = this.RefBillNo;
}
this.DataLoading = true;
var basicForm = this.formEdit.getForm();
basicForm.reset();
basicForm.setValues(data);
// this.LoadFuel = basicForm.findField('LoadFuel').value;
// this.NoLoadFuel = basicForm.findField('NoLoadFuel').value;
this.DataLoading = false;
} else {
Ext.MessageBox.alert('请求出现错误,请重试', response.responseText);
}
},
scope: this
});
var billno = '*';
var gid = '*';
if (this.opStatus == 'edit') {
billno = this.editRecord.get('BillNo');
gid = this.editRecord.get('GId');
}
this.storeBodyFix.load({ params: { billno: gid} });
this.storeBodyChFee.load({ params: { billno: gid} });
this.storePoundBodyList.load({ params: { billno: gid} });
}, // end LoadData
//#endregion
Save: function (type) {
var basicForm = this.formEdit.getForm();
if (!basicForm.isValid()) {
return;
}
basicForm.findField('BillNo').setDisabled(false);
var data = basicForm.getValues();
basicForm.findField('BillNo').setDisabled(true);
var bodypounddatas = [];
for (var i = 0; i < this.storePoundBodyList.getCount(); i += 1) {
var member = this.storePoundBodyList.getAt(i);
var dpt = member.get('DepartureDate');
var dptstr = Ext.util.Format.date(dpt, 'Y-m-d')
member.set("DepartureDate",dptstr);
// member.commit();
bodypounddatas.push(member);
};
var jsonpoundBody = ConvertRecordsToJson(bodypounddatas);
var jsonpoundDelBody = ConvertRecordsToJsonAll(this.poundBodyDel);
var bodyFixdatas = [];
for (var i = 0; i < this.storeBodyFix.getCount(); i += 1) {
var member = this.storeBodyFix.getAt(i);
bodyFixdatas.push(member);
};
var jsonFixBody = ConvertRecordsToJson(bodyFixdatas);
var jsonFixDelBody = ConvertRecordsToJsonAll(this.fixBodyDel);
var bodyChFeeDatas = [];
for (i = 0; i < this.storeBodyChFee.getCount(); i += 1) {
var memberyf = this.storeBodyChFee.getAt(i);
bodyChFeeDatas.push(memberyf);
var amount = memberyf.data.Amount;
if (amount == 0) {
Ext.Msg.show({ title: '警告',
msg: '费用的金额不允许为0请修改后再保存',
icon: Ext.Msg.ERROR, buttons: Ext.Msg.OK
});
return;
}
}
;
var jsonChFeeBody = ConvertRecordsToJson(bodyChFeeDatas);
var jsonChFeeDelBody = ConvertRecordsToJsonAll(this.feeBodyDel);
Ext.Msg.wait('正在保存数据, 请稍侯..');
Ext.Ajax.request({
waitMsg: '正在保存数据...',
url: '/TruckMng/MsWlDjPc/Save',
scope: this,
params: {
opstatus: this.opStatus,
data: Ext.JSON.encode(data),
poundbody: jsonpoundBody,
pounddelbody: jsonpoundDelBody,
fixbody: jsonFixBody,
fixdelbody: jsonFixDelBody,
chfeebody: jsonChFeeBody,
chfeedelbody: jsonChFeeDelBody
},
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') {
var editp = Ext.create('MsWlPcHead', 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('BillNo').setDisabled(true);
for (var i = 0; i < this.storePoundBodyList.getCount(); i += 1) {
var member = this.storePoundBodyList.getAt(i);
member.set("BillNo", this.editRecord.get('BillNo'));
member.commit();
}
;
for (var i = 0; i < this.storeBodyFix.getCount(); i += 1) {
var member = this.storeBodyFix.getAt(i);
member.set("BillNo", this.editRecord.get('BillNo'));
member.commit();
}
;
// for (var i = 0; i < this.storeBodyChFee.getCount(); i += 1) {
// var member = this.storeBodyChFee.getAt(i);
// //member.set("BsNo", this.editRecord.get('BillNo'));
// member.commit();
// };
let gid = this.editRecord.get('GId');
let billno = this.editRecord.get('BillNo')
this.storeBodyChFee.load({ params: { condition: "Bsno='" + gid + "' or Bsno='" + billno + "'" } });
} else if (type == '1') {
window.close();
} else {
this.LoadData('add', '', this.RefBillNo);
//basicForm.findField('BillNo').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
onAddPoundDetailClick: function (button, event) {
this.addPoundDetail();
}, //end onAddDetailClick
onDelPoundDetailClick: function (button, event) {
this.deletePoundDetail();
}, //onDelDetailClick
PoundgridAfterEdit: function (editor, e, eOpts) {
//需要自己实现里面的事件
if (e.field == 'CustCode') {
var records = DsStoreQueryBy(this.storeCustCodeRef, 'CustCode', e.value);
if (records.getCount() > 0) {
var data = records.getAt(0).data;
var custName = data.CustName;
if (e.field == 'CustCode') {
e.record.set('CustCode_Ref', custName);
e.record.set('CustName', custName);
}
} else {
if (e.field == 'CustCode') {
e.record.set('CustCode_Ref', '');
e.record.set('CustName', '');
}
}
}
else if (e.field == 'DjBillNo') {
var opStatus = 'edit';
var bulkBillNo = e.value;
var condition = " BillNo='" + bulkBillNo + "'";
Ext.Ajax.request({
waitMsg: '正在查询托单数据...',
url: '/TruckMng/MsWlDj/GetData',
async: false,
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
});
this.copyBulkHeadData(e, null);
return;
}
var bulkHeadData = result.data;
this.copyBulkHeadData(e, bulkHeadData);
} else {
Ext.MessageBox.alert('请求出现错误,请重试', response.responseText);
this.copyBulkHeadData(e, null);
}
},
scope: this
});
}
else if (e.field == 'PlanOverLoadMil') {
e.record.set('OverLoadMil', e.value);
var overloadmil = e.record.data['OverLoadMil'];
var noloadmil = e.record.data['NoLoadMil'];
var weight = e.record.data['Weight'];
var nofuel = this.getTruckLoadFuel(weight, noloadmil, '0');
var overfuel = this.getTruckLoadFuel(weight, overloadmil, '1');
e.record.set('RatedFuel', nofuel + overfuel);
this.setOverLoadMilTotal();
this.setNoFuelCountTotal();
}
else if (e.field == 'OverLoadMil') {
var planoverloadmil = e.record.data['PlanOverLoadMil'];
var plannoloadmil = e.record.data['PlanNoLoadMil'];
var overloadmil = e.record.data['OverLoadMil'];
var noloadmil = e.record.data['NoLoadMil'];
var weight = e.record.data['Weight'];
var nofuel = this.getTruckLoadFuel(weight, noloadmil, '0');
var overfuel = this.getTruckLoadFuel(weight, overloadmil, '1');
e.record.set('RatedFuel', nofuel + overfuel);
this.setOverLoadMilTotal();
this.setNoFuelCountTotal();
}
else if (e.field == 'PlanNoLoadMil') {
e.record.set('NoLoadMil', e.value);
var planoverloadmil = e.record.data['PlanOverLoadMil'];
var plannoloadmil = e.record.data['PlanNoLoadMil'];
var overloadmil = e.record.data['OverLoadMil'];
var noloadmil = e.record.data['NoLoadMil'];
var weight = e.record.data['Weight'];
var nofuel = this.getTruckLoadFuel(weight, noloadmil, '0');
var overfuel = this.getTruckLoadFuel(weight, overloadmil, '1');
e.record.set('RatedFuel', nofuel + overfuel);
this.setNoLoadMilTotal();
this.setNoFuelCountTotal();
}
else if (e.field == 'NoLoadMil') {
var planoverloadmil = e.record.data['PlanOverLoadMil'];
var plannoloadmil = e.record.data['PlanNoLoadMil'];
var overloadmil = e.record.data['OverLoadMil'];
var noloadmil = e.record.data['NoLoadMil'];
var weight = e.record.data['Weight'];
var nofuel = this.getTruckLoadFuel(weight, noloadmil, '0');
var overfuel = this.getTruckLoadFuel(weight, overloadmil, '1');
e.record.set('RatedFuel', nofuel + overfuel);
this.setNoLoadMilTotal();
this.setNoFuelCountTotal();
} else if (e.field == 'LoadCount') {
this.setLoadCountTotal();
}
else if (e.field == 'PNum' || e.field == 'PKgs') {
var PNum = e.record.data['PNum'];
var PKgs = e.record.data['PKgs'];
var overloadmil = e.record.data['OverLoadMil'];
e.record.set('Weight', (PNum * PKgs).toFixed(2));
var weight = e.record.data['Weight'];
var noloadmil = e.record.data['NoLoadMil'];
var nofuel = this.getTruckLoadFuel(weight, noloadmil, '0');
var overfuel = this.getTruckLoadFuel(weight, overloadmil, '1');
e.record.set('RatedFuel', nofuel + overfuel);
e.record.set('TonMil', (overloadmil * PNum * PKgs).toFixed(2));
this.setNoFuelCountTotal();
} else if (e.field == 'Weight') {
// this.setWeightCountTotal();
var overloadmil = e.record.data['OverLoadMil'];
var noloadmil = e.record.data['NoLoadMil'];
var weight = e.record.data['Weight'];
var nofuel = this.getTruckLoadFuel(weight, noloadmil, '0');
var overfuel = this.getTruckLoadFuel(weight, overloadmil, '1');
e.record.set('RatedFuel', nofuel + overfuel);
e.record.set('TonMil', (overloadmil * weight).toFixed(2));
this.setNoFuelCountTotal();
} else if (e.field == 'RatedFuel') {
this.setNoFuelCountTotal();
}
},
//#region 明细表合计
setAllTotal: function () {
this.setOverLoadMilTotal();
this.setNoLoadMilTotal();
this.setLoadCountTotal();
// this.setWeightCountTotal();
this.setNoFuelCountTotal();
},
setOverLoadMilTotal: function () {
var total = this.calcDetailTotal('OverLoadMil');
this.setHeadFieldValue('OverLoadMil', total);
},
setNoLoadMilTotal: function () {
var total = this.calcDetailTotal('NoLoadMil');
this.setHeadFieldValue('NoLoadMil', total);
},
setLoadCountTotal: function () {
var total = this.calcDetailTotal('LoadCount');
this.setHeadFieldValue('LoadCount', total);
},
setNoFuelCountTotal: function () {
var total = this.calcDetailTotal('RatedFuel');
this.setHeadFieldValue('RatedFuel', total);
},
calcDetailTotal: function (fieldName) {
var total = 0;
for (var i = 0; i < this.storePoundBodyList.getCount(); i += 1) {
var member = this.storePoundBodyList.getAt(i);
var value = member.get(fieldName);
total = total + value;
}
return total;
},
setHeadFieldValue: function (fieldName, value) {
var field = this.formEdit.getForm().findField(fieldName);
field.setValue(value);
},
//#endregion
addPoundDetail: function () {
var newSerialno = DsGetNewSerialNo(this.storePoundBodyList, this.poundserialNo);
this.poundserialNo = newSerialno;
var record = Ext.create('MsWlDjPound', {
BillNo: '*',
SerialNo: newSerialno,
DjBillNo: '',
DjBillNo_Ref: '',
GId: NewGuid(),
CustCode: '',
CustCode_Ref: '',
CustName: '',
ClsName: '',
DepartureDate: '',
LoadPlace: '',
UnLoadPlace: '',
PlanOverLoadMil: 0,
PlanNoLoadMil: 0,
PlanLoadCount: 1,
OverLoadMil: 0,
NoLoadMil: 0,
LoadCount: 1,
PNum: 0,
PKgs: 0,
Weight: 0,
RatedFuel: 0,
WorkTime: ''
});
this.storePoundBodyList.add(record);
var n = this.storePoundBodyList.getCount();
this.PoundgridListCellEditing.startEditByPosition({ row: n - 1, column: 2 });
},
deletePoundDetail: function () {
// this.poundserialNo = DsGetCurSerialNo(this.storePoundBodyList, this.poundserialNo);
var selectedRecords = this.PoundgridList.selModel.getSelection();
for (var i = 0; i < selectedRecords.length; i++) {
var rec = selectedRecords[i];
if (rec.BillNo != "" || rec.BillNo != "*") //如果是新增但没有保存的数据,没有必要提交到后台
{
this.poundBodyDel.push(rec);
}
this.storePoundBodyList.remove(selectedRecords[i]);
this.setAllTotal();
}
},
getPoundcustname: function () {
result = '';
var selectedRecords = this.PoundgridList.selModel.getSelection();
for (var i = 0; i < selectedRecords.length; i++) {
var rec = selectedRecords[i];
result = rec.custname;
}
return result;
},
copyBulkHeadData: function (e, bulkHeadData) {
if (bulkHeadData != null) {
e.record.set('CustCode', bulkHeadData.CustCode);
e.record.set('CustCode_Ref', bulkHeadData.CustName);
e.record.set('CustName', bulkHeadData.CustName);
e.record.set('ClsName', bulkHeadData.ClsName);
e.record.set('PNum', bulkHeadData.PNum - bulkHeadData.OverPNum);
e.record.set('PKgs', bulkHeadData.PKgs);
e.record.set('Weight', (bulkHeadData.PNum - bulkHeadData.OverPNum)*bulkHeadData.PKgs);
e.record.set('LoadPlace', bulkHeadData.SedArea);
e.record.set('UnLoadPlace', bulkHeadData.DstArea);
} else {
e.record.set('CustCode', '');
e.record.set('CustCode_Ref', '');
e.record.set('CustName', '');
e.record.set('ClsName', '');
e.record.set('PNum', 0);
e.record.set('PKgs', 0);
e.record.set('Weight', 0);
e.record.set('LoadPlace', '');
e.record.set('UnLoadPlace', '');
}
},
//#region 明细操作
onAddDetailClick: function (button, event, type) {
var allow = this.getAllowOperationDetail();
if (allow == false) {
return;
}
var store = null;
if (type == 1) {
store = this.storeBodyFix;
} else if (type == 2) {
store = this.storeBodyChFee;
} else if (type == 3) {
store = this.storePoundBodyList;
} else {
alert('函数(onAddDetailClick)的参数type类型设置的不对');
return;
}
var newSerialno = this.GetHandleSerialNo(store, type);
var record = null;
if (type == 1) {
record = Ext.create('MsWlPcFixed', {
GId: NewGuid(),
BillNo: '*',
SerialNo: newSerialno,
FeeStatus: 1,
FeeStatus_Ref: '录入状态',
AuditStatus: 0,
CreditDebit: "2",
CreditDebit_Ref: "应付",
FeeTypeCode: '',
FeeTypeCode_Ref: '',
FeeTypeName: '',
DistCount: 0,
Price: 0,
FsTotal: 0,
JsTotal: 0,
Remark: ''
});
} else if (type == 2) {
record = Ext.create('MsChFee', {
GId: NewGuid(),
BsNo: '*',
FeeStatus: 1,
FeeStatus_Ref: '录入状态',
FeeType: 1,
FeeType_Ref: '应收',
FeeName: '',
FeeName_Ref: '',
FeeDescription: '',
CustomerType: '',
CustomerName: this.getPoundcustname(),
CustomerName_Ref: '',
Unit: '',
UnitPrice: 0,
Quantity: 1,
Amount: 0,
Currency: 'RMB',
ExChangerate: 1,
Reason: '',
Remark: '',
Commissionrate: 0,
Settlement: 0,
Invoice: 0,
OrderAmount: 0,
OrderInvoice: 0,
SubmitDate: null,
Auditoperator: '',
AuditDate: null,
EnteroPerator: GetCookie_UserId(),
EnterDate: null,
DebitNo: '',
IsDebit: "0",
IsOpen: "0",
IsAdvancedpay: "0",
Sort: "0",
IsInvoice: "0",
FeeFrt: '',
IsCrmOrderFee: "0",
AuditStatus: 0,
InvoiceNum: '',
ChequeNum: '',
WmsOutBsNo: ''
});
} else if (type == 3) {
record = Ext.create('MsWlDjPound', {
BillNo: '*',
SerialNo: newSerialno,
DjBillNo: '',
DjBillNo_Ref: '',
GId: NewGuid(),
CustCode: '',
CustCode_Ref: '',
CustName: '',
ClsName: '',
DepartureDate: '',
LoadPlace: '',
UnLoadPlace: '',
PlanOverLoadMil: 0,
PlanNoLoadMil: 0,
PlanLoadCount: 0,
OverLoadMil: 0,
NoLoadMil: 0,
LoadCount: 0,
PNum: 0,
PKgs: 0,
Weight: 0,
WorkTime: ''
});
}
store.add(record);
var editColumnIndex = 0;
var cellediting = null;
if (type == 1) {
cellediting = this.cellEditingFix;
editColumnIndex = 2;
} else if (type == 2) {
cellediting = this.cellEditingChFee;
editColumnIndex = 4;
} else if (type == 3) {
cellediting = this.PoundgridListCellEditing;
editColumnIndex = 2;
}
var n = store.getCount();
cellediting.startEditByPosition({ row: n - 1, column: editColumnIndex });
},
GetHandleSerialNo: function (store, type) {
var result = 0;
if (type == 1) {
result = this.fixSerialNo;
} else if (type == 2) {
result = this.feeSerialNo;
} else if (type == 3) {
result = this.poundSerialNo;
}
if (result == 0) {
for (var i = 0; i < store.getCount(); i += 1) {
var member = store.getAt(i);
if (member.data.SerialNo > result) {
result = member.data.SerialNo;
}
}
}
result = result + 1;
if (type == 1) {
this.fixSerialNo = result;
} else if (type == 2) {
this.feeSerialNo = result;
} else if (type == 3) {
this.poundSerialNo = result;
}
return result;
},
onDelDetailClick: function (button, event, type) {
var allow = this.getAllowOperationDetail();
if (allow == false) {
return;
}
var store = null;
if (type == 1) {
store = this.storeBodyFix;
} else if (type == 2) {
store = this.storeBodyChFee;
} else if (type == 3) {
store = this.storePoundBodyList;
} else {
alert('函数(onAddDetailClick)的参数type类型设置的不对');
return;
}
var result = 0;
if (type == '1') {
result = this.fixSerialNo;
} else if (type == '2') {
result = this.feeSerialNo;
} else if (type == '3') {
result = this.poundSerialNo;
}
if (result == 0) {
for (var i = 0; i < store.getCount(); i += 1) {
var member = store.getAt(i);
if (member.data.SerialNo > this.giSerialNo) {
result = member.data.SerialNo;
}
}
}
if (type == '1') {
this.fixSerialNo = result;
} else if (type == '2') {
this.feeSerialNo = result;
} else if (type == '3') {
this.poundSerialNo = result;
}
var selectedRecords = [];
if (type == '1') {
selectedRecords = this.gridListFix.selModel.getSelection();
} else if (type == '2') {
selectedRecords = this.gridListChFee.selModel.getSelection();
var candelete = DsTruck.CheckChFeeDelete(selectedRecords);
if (candelete == false)
return;
} else if (type == '3') {
selectedRecords = this.PoundgridList.selModel.getSelection();
}
if (selectedRecords.length > 0) {
for (var i = 0; i < selectedRecords.length; i++) {
var rec = selectedRecords[i];
if (rec.BillNo != "" || rec.BillNo != "*") //如果是新增但没有保存的数据,没有必要提交到后台
{
if (type == '1') {
this.fixBodyDel.push(rec);
} else if (type == '2') {
this.feeBodyDel.push(rec);
} else if (type == '3') {
this.poundBodyDel.push(rec);
}
}
if (type == '1') {
this.storeBodyFix.remove(selectedRecords[i]);
} else if (type == '2') {
this.storeBodyChFee.remove(selectedRecords[i]);
} else if (type == '3') {
this.storePoundBodyList.remove(selectedRecords[i]);
this.setAllTotal();
}
}
}
},
getAllowOperationDetail: function () {
var feeStatus = this.getFeeStatus();
if (feeStatus == '0')
return true;
else {
Ext.Msg.show({ title: '错误', msg: "费用已锁定,不允许操作费用!", icon: Ext.Msg.ERROR, buttons: Ext.Msg.OK });
return false;
}
},
//#endregion
//#region 表格的AfterEdit
gridListFixAfterEdit: function (editor, e, eOpts) {
if (e.field == 'FeeTypeCode') {
var records = DsStoreQueryBy(this.storeFeeTypeCodeRef, 'FeeCode', e.value);
if (records.getCount() > 0) {
var data = records.getAt(0).data;
e.record.set('FeeTypeCode_Ref', data.Name);
e.record.set('FeeTypeName', data.Name);
} else {
e.record.set('FeeTypeCode_Ref', '');
e.record.set('FeeTypeName', '');
}
} else if (e.field == 'CreditDebit') {
var recordsCreditDebit = DsStoreQueryBy(this.storeCreditDebitRef, 'EnumValueId', e.value);
if (recordsCreditDebit.getCount() > 0) {
var dataCreditDebit = recordsCreditDebit.getAt(0).data;
e.record.set('CreditDebit_Ref', dataCreditDebit.EnumValueName);
} else {
e.record.set('CreditDebit_Ref', '');
}
}
},
gridListChFeeAfterEdit: function (editor, e, eOpts) {
if (e.field == 'FeeType') {
var records = DsStoreQueryBy(this.storeFeeTypeRef, 'EnumValueId', e.value);
if (records.getCount() > 0) {
var data = records.getAt(0).data;
e.record.set('FeeType_Ref', data.EnumValueName);
} else {
e.record.set('FeeType_Ref', '');
}
} else if (e.field == 'UnitPrice' || e.field == 'Quantity') {
var unitPrice = e.record.data['UnitPrice'];
var quantity = e.record.data['Quantity'];
e.record.set('Amount', (unitPrice * quantity).toFixed(2));
}
},
//#endregion
cellEditingFixBeforeEdit: function (editor, e) {
var feeStatus = this.getFeeStatus();
var billStatus = this.getBillStatus();
var canedit = feeStatus == '0' && billStatus == '0';
return canedit;
},
cellEditingChFeeBeforeEdit: function (editor, e) {
var chfeefeeStatus = e.record.get('FeeStatus');
var canedit = chfeefeeStatus == 1 || chfeefeeStatus == 6;
if (canedit) {
var feeStatus = this.getFeeStatus();
var billStatus = this.getBillStatus();
canedit = feeStatus == '0' && billStatus == '0';
}
return canedit;
},
refBillNoSeChange: function (field, newValue, oldValue) {
// if (newValue != oldValue) {
// alert(newValue + "," + oldValue);
// }
},
realMilChange: function (field, newValue, oldValue) {
if (this.DataLoading == true) return;
if (newValue == oldValue) return;
var realMil = newValue;
var basicForm = this.formEdit.getForm();
basicForm.findField('OverLoadMil').setValue(realMil);
basicForm.findField('NoLoadMil').setValue(realMil);
},
overLoadMilChange: function (field, newValue, oldValue) {
if (this.DataLoading == true) return;
var basicForm = this.formEdit.getForm();
// basicForm.findField('LoadFuel').setValue(this.LoadFuel);
basicForm.findField('RatedFuel').setValue(this.ratedFuel);
},
noLoadMilChange: function (field, newValue, oldValue) {
if (this.DataLoading == true) return;
var basicForm = this.formEdit.getForm();
},
tonAndTruckNoChange: function (field, newValue, oldValue) {
if (this.DataLoading == true) return;
var basicForm = this.formEdit.getForm();
// basicForm.findField('LoadFuel').setValue(this.LoadFuel);
// basicForm.findField('NoLoadFuel').setValue(this.NoLoadFuel);
basicForm.findField('RatedFuel').setValue(this.ratedFuel);
if (field.name == 'TruckNo') {
var records = DsStoreQueryBy(this.storeTruckNo, 'TruckNo', newValue);
if (records.getCount() > 0) {
var data = records.getAt(0).data;
basicForm.findField('DrvCode').setValue(data.DrvCode);
this.setDrvName(data.DrvCode);
basicForm.findField('Mobile').setValue(data.Mobile);
} else {
basicForm.findField('DrvCode').setValue('');
basicForm.findField('DrvName').setValue('');
basicForm.findField('Mobile').setValue('');
}
}
},
onSubmitAuditClick: function (button, event) {
var records = this.feeGridCheckBoxModel.selected.items;
DsTruck.MsChFeeAudit(records, 2, '正在提交审核数据, 请稍侯..' );
this.InitData();
},
onPassAuditClick: function (button, event) {
var records = this.feeGridCheckBoxModel.selected.items;
DsTruck.MsChFeeAudit(records, 0, '正在审核数据, 请稍侯..' );
this.InitData();
},
onCancelAuditClick: function (button, event) {
var records = this.feeGridCheckBoxModel.selected.items;
DsTruck.MsChFeeAudit(records, 1, '正在撤销提交审核数据, 请稍侯..' );
this.InitData();
},
setSaveBtnStatus: function (enable) {
var bsbtnSave = Ext.getCmp('pcbtnSave');
var bsbtnSaveAndClose = Ext.getCmp('pcbtnSaveAndClose');
var bsbtnSaveAndNew = Ext.getCmp('pcbtnSaveAndNew');
var pcbtnNew = Ext.getCmp('pcbtnNew');
if (enable) {
bsbtnSave.enable();
bsbtnSaveAndClose.enable();
bsbtnSaveAndNew.enable();
pcbtnNew.enable();
} else {
//bsbtnSave.disable();
//bsbtnSaveAndClose.disable();
bsbtnSaveAndNew.disable();
pcbtnNew.disable();
}
},
getFeeStatus: function () {
var basicForm = this.formEdit.getForm();
var feeStatus = basicForm.findField('FeeStatus').value;
return feeStatus;
},
getBillStatus: function () {
var basicForm = this.formEdit.getForm();
var billStatus = basicForm.findField('BillStatus').value;
return billStatus;
},
// getCustName: function () {
// var custName = this.formEdit.getForm().findField('RefCustomerName');
// return custName.getValue();
// },
getTruckNo: function () {
var truckNo = this.formEdit.getForm().findField('TruckNo');
return truckNo.getValue();
},
Print: function () {
var basicForm = this.formEdit.getForm();
var billNo = basicForm.findField('BillNo').value;
if (billNo == '*' || billNo == '') {
Ext.Msg.show({ title: '错误', msg: '单据还没有保存,请保存后再打印', icon: Ext.Msg.ERROR, buttons: Ext.Msg.OK });
return;
}
var gid = basicForm.findField('GId').value;
var refBillNo = basicForm.findField('RefBillNo').value;
var printType = 'MSWLPC';
var sql1 = "SET LANGUAGE 'us_english' "
+ " select * from vMsWlPcHeadPrint WHERE BillNo = '" + billNo + "'";
var sql2 = "SET LANGUAGE 'us_english' SELECT * from ch_fee where BsNo='" + gid + "'";
var records = this.feeGridCheckBoxModel.selected.items;
if (records.length > 0) {
var feeGidSql = '';
for (var i = 0; i < records.length; i++) {
var record = records[i];
var feeGId = "'" + record.get('GId') + "'";
if (feeGidSql == '') {
feeGidSql = feeGId;
} else {
feeGidSql = feeGidSql + "," + feeGId;
}
}
if (feeGidSql != '') {
sql2 = sql2 + ' and Gid in (' + feeGidSql + ')';
}
}
var sql3 = "SET LANGUAGE 'us_english ' "
+ " SET LANGUAGE 'us_english' select A.*,B.* from tMsWlDjPound A,tMsWlDjHead B where A.DjBillNo=B.BillNo and A.BillNo = '" + gid + "' order by A.SerialNo";
var sql4 = "SET LANGUAGE 'us_english' select A.*,B.* from vMsWlPcHeadPrint A,tMsWlPcFixed B where A.Gid=B.BillNo and A.BillNo='" + billNo + "' order by A.BillNo";
var sql5 = "";
var sql6 = "";
PrintComm(printType, sql1, sql2, sql3, sql4, sql5, sql6);
},
//获取油耗
getTruckLoadFuel: function (ton, mil, type) {
var resultFuel = 0;
var truckNo = this.getTruckNo();
if (truckNo == null || truckNo == "") {
resultFuel = 0;
return resultFuel;
}
if (ton == null || ton == "" || mil == null) {
resultFuel = 0;
return resultFuel;
}
resultFuel = this.getTruckFuel(truckNo, type, ton, mil);
return resultFuel;
},
getTruckFuel: function (truckNo, loadType, ton, mil) {
var resultFuel = 0;
Ext.Ajax.request({
waitMsg: '正在计算车里油量信息...',
url: '/TruckMng/MsWlDjPc/GetTruckFuel',
async: false,
params: {
truckNo: truckNo,
loadType: loadType,
ton: ton,
mil: mil
},
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
});
resultFuel = 0;
}
var data = result.data;
resultFuel = data;
} else {
Ext.MessageBox.alert('请求出现错误,请重试', response.responseText);
resultFuel = 0;
}
},
scope: this
});
return resultFuel;
},
setDrvName: function (drvCode) {
var recs = DsStoreQueryBy(this.storeDrvName, 'DrvCode', drvCode);
var basicForm = this.formEdit.getForm();
var custname = basicForm.findField('DrvName');
var mobile = basicForm.findField('Mobile');
if (recs.getCount() > 0) {
var data = recs.getAt(0).data;
custname.setValue(data.DrvName);
mobile.setValue(data.Mobile);
} else {
custname.setValue('');
mobile.setValue('');
}
},
setBtnOnlyQuery: function () {
var bsbtnSave = Ext.getCmp('pcbtnSave');
var bsbtnSaveAndClose = Ext.getCmp('pcbtnSaveAndClose');
var bsbtnSaveAndNew = Ext.getCmp('pcbtnSaveAndNew');
var pcbtnNew = Ext.getCmp('pcbtnNew');
bsbtnSave.setVisible(false);
bsbtnSaveAndClose.setVisible(false);
bsbtnSaveAndNew.setVisible(false);
pcbtnNew.setVisible(false);
}
});