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.

2716 lines
95 KiB
JavaScript

10 months ago
Ext.namespace('DsTruck');
DsTruck.TMSRPT_MONTHEdit = function (config) {
Ext.applyIf(this, config);
this.initUIComponents();
window.DsTruck.TMSRPT_MONTHEdit.superclass.constructor.call(this);
};
var RPTLINKGID = '';
var gongzuocheri = 0;
var wanhaocheri = 0;
var zongchengben = 0;
var zongshouru = 0;
var LINKGID = '*';
Date.prototype.format = function (format) {
var o = {
"M+": this.getMonth() + 1, //month
"d+": this.getDate(), //day
"h+": this.getHours(), //hour
"m+": this.getMinutes(), //minute
"s+": this.getSeconds(), //second
"q+": Math.floor((this.getMonth() + 3) / 3), //quarter
"S": this.getMilliseconds() //millisecond
}
if (/(y+)/.test(format)) format = format.replace(RegExp.$1,
(this.getFullYear() + "").substr(4 - RegExp.$1.length));
for (var k in o) if (new RegExp("(" + k + ")").test(format))
format = format.replace(RegExp.$1,
RegExp.$1.length == 1 ? o[k] :
("00" + o[k]).substr(("" + o[k]).length));
return format;
}
var xhr = new XMLHttpRequest();
var currdate = new Date();
if (!xhr) {
//...其他生成xmlhttprequest方法
}
xhr.open("HEAD", location.href, true);
xhr.onreadystatechange = function () {
if (xhr.readyState == 4 && xhr.status == 200) {
var datestr = xhr.getResponseHeader("Date");
currdate = new Date(datestr);
// alert(currdate.format('yyyy-MM-dd'));
}
}
xhr.send(null);
Ext.extend(DsTruck.TMSRPT_MONTHEdit, Ext.Panel, {
ParentWin: null,
OpStatus: 'add',
StoreList: null,
EditRecord: null,
thisGID: "",
initUIComponents: function () {
this.serialNo = 0;
this.bodyDel = [];
this.cardDel = [];
this.carduseDel = [];
this.TruckMonthDel = [];
this.CARDGID = "";
//#region 枚举参照相关
//车辆性质
this.storeProperty = Ext.create('DsExt.ux.RefEnumStore', {});
this.storeProperty.load({ params: { enumTypeId: 99033} });
this.comboxProperty = Ext.create('Ext.ux.form.field.BoxSelect', {
fieldLabel: '车辆性质',
autosize: true,
bodyPadding: 5,
flex: 4,
width: 500,
labelWidth: 90,
store: this.storeProperty,
queryMode: 'local',
triggerOnClick: false,
name: 'Property',
valueField: 'EnumValueId',
displayField: 'EnumValueName',
listeners: {
change: {
fn: function (field, newValue, oldValue) {
if (newValue == "") {
me.storeBodyList.load({ params: { start: 0, limit: 9999, condition: "AMOUNT <> 0 AND LINKGID='" + LINKGID + "'"} });
return;
}
var types = newValue.split(',');
var sqlpart = "";
for (var i in types) {
var type = types[i].trim();
sqlpart += "'" + type + "',";
}
sqlpart = sqlpart.substr(0, sqlpart.length - 1);
var sqlstr = " and truckno in (select truckno from tMsWlTruck where Property in (" + sqlpart + "))";
me.storeBodyList.load({ params: { start: 0, limit: 9999, condition: "AMOUNT <> 0 AND LINKGID='" + LINKGID + "'" + sqlstr} });
}
}
}
});
this.storeCompany = Ext.create('DsExt.ux.RefTableStore', {
model: 'companymb', proxy: { url: '/CommMng/BasicDataRef/GetcompanyList' }
});
this.storeCompany.load({ params: { condition: ""} });
this.comboxCompany = Ext.create('DsExt.ux.RefTableCombox', {
fieldLabel: '分公司', readOnly: true,
forceSelection: true,
allowBlank: false,
store: this.storeCompany,
name: 'COMPANYID',
valueField: 'gid',
displayField: 'name', flex: 1,
listeners: {
change: function (field, eOpts) {
if (field.lastValue != "") {
this.storeTruckNo.load({ params: { condition: " ORGCODE=(select CODENAME from company where GID='" + field.lastValue + "') "} });
this.formEdit.getForm().findField('COMPANYNAME').setValue(field.rawValue);
}
this.Cansearch = false;
},
scope: this
}
});
//表参照相关
this.storeDrvCode = Ext.create('DsExt.ux.RefTableStore', {
model: 'MsWlTruckRefMsWlDriver',
proxy: { url: '/TruckMng/MsWlTruck/GetDrvCodeList' }
});
this.storeDrvCode.load();
this.comboxDrvCode = Ext.create('DsExt.ux.RefTableCombox', {
fieldLabel: '驾驶员编码',
store: this.storeDrvCode,
name: 'DrvCode',
valueField: 'DrvCode',
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,
fieldLabel: '所有者',
//forceSelection: true,
allowBlank: true,
name: 'OWNER',
valueField: 'GId',
displayField: 'CodeAndName'
});
this.storeTruckNo = Ext.create('DsExt.ux.RefTableStore', {
model: 'MsWlBsHeadRefMsWlTruck',
proxy: { url: '/TruckMng/MsWlPc/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
}
});
//#endregion
//#region 编辑form
var me = this;
this.formEdit = Ext.widget('form', {
region: 'center',
frame: true,
bodyPadding: 5,
fieldDefaults: {
margins: '2 2 2 2',
labelAlign: 'right',
flex: 1,
labelWidth: 100,
msgTarget: 'qtip'
},
items: [
{//fieldset 1
xtype: 'fieldset',
defaultType: 'textfield',
layout: 'anchor',
defaults: {
anchor: '100%'
},
items: [
{
xtype: 'container',
layout: 'hbox',
defaultType: 'textfield',
items: [{
fieldLabel: 'GID',
name: 'GID', flex: 0, hidden: true, margins: '0'
}, {
fieldLabel: 'TimeMark', values: 0,
name: 'TimeMark', flex: 0, hidden: true, margins: '0'
}, {
fieldLabel: 'BLSTATUS', values: 0,
name: 'BLSTATUS', flex: 0, hidden: true, margins: '0'
}
, this.comboxCompany
, {
sortable: true, hidden: true,
fieldLabel: 'COMPANYNAME',
name: 'COMPANYNAME'
}, {
sortable: true, id: "ACCDATE",
xtype: 'monthfield', readOnly: true,
format: 'Y-m',
fieldLabel: '统计期间',
allowBlank: false,
name: 'ACCDATE', flex: 1
}, {
fieldLabel: '从..日期',
format: 'Y-m-d',
xtype: 'datefield',
allowBlank: false,
name: 'EXPDATEBGN', flex: 1
}, {
fieldLabel: '到..日期',
format: 'Y-m-d',
xtype: 'datefield',
allowBlank: false,
name: 'EXPDATEEND', flex: 1
}, { xtype: 'hiddenfield', flex: 1 }
]
}
, {
xtype: 'container',
layout: 'hbox',
defaultType: 'textfield',
items: [{
fieldLabel: '统计燃油价格', flex: 1,
xtype: 'numberfield',
minValue: 0,
name: 'FUELPRICE',
allowBlank: false,
decimalPrecision: 4
}, {
fieldLabel: '备注', flex: 4,
name: 'REMARK'
}
]
}, {
xtype: 'container',
layout: 'hbox',
defaultType: 'textfield',
items: [{
fieldLabel: '制单人', flex: 1,
name: 'OP', readOnly: true
}, {
fieldLabel: '制单时间', flex: 1,
format: 'Y-m-d',
xtype: 'datetimefield',
renderer: Ext.util.Format.dateRenderer('Y-m-d'),
name: 'OPDATE', readOnly: true
}, {
fieldLabel: '审核人', flex: 1,
name: 'AUDITOR', readOnly: true
}, {
fieldLabel: '审核时间', flex: 1,
format: 'Y-m-d',
xtype: 'datetimefield',
renderer: Ext.util.Format.dateRenderer('Y-m-d'),
name: 'AUDITTIME', readOnly: true
}, this.comboxProperty
]
}
]//end items(fieldset 1)
}//end fieldset 1
]//end root items
}); //end this.formEdit
//#endregion
//按钮Toolbar
this.panelBtn = new Ext.Panel({
region: "north",
tbar: [
{
text: "保存",
iconCls: "btnsave",
handler: function (button, event) {
this.Save('0');
},
scope: this
},
{
text: "保存并关闭",
handler: function (button, event) {
this.Save('1');
},
scope: this
},
'-',
{
text: "保存并新建",
handler: function (button, event) {
this.Save('2');
},
scope: this
}, '-', {
text: "生成报表内容", hidden: true,
disabled: true, id: "SCBB",
handler: function (button, event) {
this.StartAudit(button, event);
},
scope: this
}, '-',
{
text: "提交审核",
disabled: true, id: "StartAudit",
handler: function (button, event) {
this.StartAudit(button, event);
},
scope: this
},
{
text: "撤回提交",
disabled: true, id: "ResetAudit",
handler: function (button, event) {
this.ResetAudit(button, event);
},
scope: this
},
{
text: "审核通过", disabled: true,
//iconCls: "btnreset",
id: "Audit",
handler: function (button, event) {
this.Audit(button, event);
},
scope: this
},
{
text: "驳回提交", disabled: true,
//iconCls: "btnreset",
id: "AuditBack",
handler: function (button, event) {
this.AuditBack(button, event);
},
scope: this
},
{
text: "",
iconCls: "btn_wenhao",
id: "SHUOMING",
handler: function (button, event) {
var _readme = "总收入目前来自于指定统计期间的业务当中的所有应收;\n";
_readme = _readme + "折旧费和保险费来自于 安全管理-车辆管理 里面的 车辆月度费用管理 选项卡;\n"
_readme = _readme + "工资奖金、社保费、公积金来自于人工录入;\n"
_readme = _readme + "燃油价格目前为本单内总数据中制单人录入的数值燃油费为该价格x额定油耗\n"
_readme = _readme + "修理费、轮胎费、修理车日来自于<机务管理-维修管理-维修派工>当中记录的该车该统计期间的修理费、轮胎费、修理车日;\n"
_readme = _readme + "行车杂支为:路单下的应付当中除了燃油费、路桥费之外的其他费用;\n"
_readme = _readme + "税金为总路单收入x13%\n"
alert(_readme);
},
scope: this
},
{
text: "打印",
iconCls: 'btnprint',
handler: function (menu, event) {
_this.Print();
},
scope: this
},
{
text: "重新生成数据", disabled: true, id: "CXSC",
tooltip: '先保存才能生成。注意,将会将所有数据删除后重新计算,手工填写的数据需要重新填写',
handler: function (button, event) {
this.ReMake(button, event);
},
scope: this
}
,
{
//text: "复制上月折旧费、社保费、公积金",
text: "复制上月折旧费",
disabled: true,
id: "FZSY",
tooltip: '',
handler: function (button, event) {
this.LoadBeforeFee(button, event);
},
scope: this
},
{
text: "导入工资等字段Excel表格",
tooltip: '',
iconCls: "btnexportexcel",
handler: function (button, event) {
this.Save('0');
var winAccess = new DsTruck.FileImport({});
winAccess.StoreList = this.storeDetail;
this.thisGID = this.formEdit.getForm().findField('GID').getValue();
winAccess.show();
},
scope: this
}, {
text: "下载Excel模板",
tooltip: '',
iconCls: "btnexportexcel",
handler: function (button, event) {
printWindow = window.open('/Areas/TruckMng/Files/TruckTemplate.xls');
},
scope: this
}
]
}); //end 按钮Toolbar
//#region 明细表
//明细表表格相关
this.storeLoadTypeRef = Ext.create('DsExt.ux.RefEnumStore', {});
this.storeLoadTypeRef.load({ params: { enumTypeId: 99030} });
this.comboxLoadTypeRef = Ext.create('DsExt.ux.RefEnumCombox', {
store: this.storeLoadTypeRef,
name: 'LoadType'
});
//#endregion
//#region 明细表 车辆统计
this.storeBodyList = Ext.create('Ext.data.Store', {
model: 'TMSRPT_MONTH_TRUCKDETAILmb',
remoteSort: false,
proxy: {
type: 'ajax',
url: '/TruckMng/TMSRPT/GetBodyList',
reader: {
id: 'GID',
root: 'data',
totalProperty: 'totalCount'
}
}
});
//明细表表格
this.gridListCellEditing = Ext.create('Ext.grid.plugin.CellEditing', {
clicksToEdit: 1
});
Ext.grid.RowNumberer = Ext.extend(Ext.grid.RowNumberer, {
width: 50
});
var _this = this;
this.gridList = new Ext.grid.GridPanel({
store: this.storeBodyList,
enableHdMenu: false,
layout: 'border',
region: 'center',
loadMask: { msg: "数据加载中,请稍等..." },
trackMouseOver: true,
disableSelection: false,
plugins: [this.gridListCellEditing],
selType: 'cellmodel',
autoScroll: true,
features: [{
ftype: 'summary'//Ext.grid.feature.Summary表格汇总特性
}],
tbar: [{
text: '增加明细',
tooltip: '增加明细',
iconCls: "btnadddetail",
handler: function (button, event) {
this.onAddDetailClick(button, event);
},
scope: this
}, '-', {
text: '删除明细',
tooltip: '删除明细',
iconCls: "btndeletedetail",
handler: function (button, event) {
this.onDelDetailClick(button, event);
},
scope: this
}/*, {
xtype: 'labelfield',
fieldLabel:'注意,重量区间必须首尾相连(上一个的结束重量应当是下一个的开始重量)'
}*/],
columns: [
new Ext.grid.RowNumberer(),
{
sortable: true, hidden: true,
dataIndex: 'GID',
header: 'GID',
width: 80
},
{
sortable: true, hidden: true,
dataIndex: 'LINKGID',
header: 'LINKGID',
width: 80
},
{
sortable: true, hidden: true,
dataIndex: 'COMPANYID',
header: 'COMPANYID',
width: 80
},
{
sortable: true,
dataIndex: 'COMPANYNAME',
header: '分公司',
width: 80
},
{
sortable: true,
dataIndex: 'TRUCKNO',
header: '车号',
width: 95,
editor: this.comboxTruckNo
},
{
sortable: true, align: 'right',
dataIndex: 'LoadCount',
header: '载重量',
width: 80
},
{
sortable: true,
dataIndex: 'TruckSpec',
header: '车型',
width: 80
},
{
text: '运营核算(单位:元)',
columns: [
{
sortable: true, align: 'right',
dataIndex: 'AMOUNT',
header: '总收入',
width: 80,
editor: {
xtype: 'numberfield',
selectOnFocus: true,
hideTrigger: true,
step: 0
},
summaryType: 'sum',
summaryRenderer: function (value) {
zongshouru = value;
return Ext.util.Format.number(value, '0.00');
}
},
{
text: '固定成本',
columns: [
{
sortable: true, align: 'right',
dataIndex: 'ZJF',
header: '折旧费',
width: 80,
editor: {
xtype: 'numberfield',
selectOnFocus: true,
hideTrigger: true,
step: 0
},
summaryType: 'sum',
summaryRenderer: function (value) {
zongchengben += value;
return Ext.util.Format.number(value, '0.00');
}
},
{
sortable: true, align: 'right',
dataIndex: 'BXF',
header: '车辆保险费',
width: 80,
editor: {
xtype: 'numberfield',
selectOnFocus: true,
hideTrigger: true,
step: 0
},
summaryType: 'sum',
summaryRenderer: function (value) {
zongchengben += value;
return Ext.util.Format.number(value, '0.00');
}
}]
},
{
text: '变动成本',
columns: [
{
sortable: true, align: 'right',
dataIndex: 'GZJZ',
header: '工资奖金',
width: 80,
editor: {
xtype: 'numberfield',
selectOnFocus: true,
hideTrigger: true,
step: 0
},
summaryType: 'sum',
summaryRenderer: function (value) {
zongchengben += value;
return Ext.util.Format.number(value, '0.00');
}
},
{
sortable: true, align: 'right',
dataIndex: 'SBF',
header: '社保费',
width: 80,
editor: {
xtype: 'numberfield',
selectOnFocus: true,
hideTrigger: true,
step: 0
},
summaryType: 'sum',
summaryRenderer: function (value) {
zongchengben += value;
return Ext.util.Format.number(value, '0.00');
}
},
{
sortable: true, align: 'right',
dataIndex: 'GJJ',
header: '公积金',
width: 80,
editor: {
xtype: 'numberfield',
selectOnFocus: true,
hideTrigger: true,
step: 0
},
summaryType: 'sum',
summaryRenderer: function (value) {
zongchengben += value;
return Ext.util.Format.number(value, '0.00');
}
},
{
sortable: true, align: 'right',
dataIndex: 'FUELPRICE',
header: '燃油价格',
width: 80,
editor: {
xtype: 'numberfield',
selectOnFocus: true,
decimalPrecision: 4,
hideTrigger: true,
step: 0
}
},
{
sortable: true, align: 'right',
dataIndex: 'FUELAMOUNT',
header: '燃油费',
width: 80,
editor: {
xtype: 'numberfield',
selectOnFocus: true,
hideTrigger: true,
step: 0
},
summaryType: 'sum',
summaryRenderer: function (value) {
zongchengben += value;
return Ext.util.Format.number(value, '0.00');
}
},
{
sortable: true, align: 'right',
dataIndex: 'LQF',
header: '路桥费',
width: 80,
editor: {
xtype: 'numberfield',
selectOnFocus: true,
hideTrigger: true,
step: 0
},
summaryType: 'sum',
summaryRenderer: function (value) {
zongchengben += value;
return Ext.util.Format.number(value, '0.00');
}
},
{
sortable: true, align: 'right',
dataIndex: 'REPAIRAMOUNT',
header: '修理费',
width: 80,
editor: {
xtype: 'numberfield',
selectOnFocus: true,
hideTrigger: true,
step: 0
},
summaryType: 'sum',
summaryRenderer: function (value) {
zongchengben += value;
return Ext.util.Format.number(value, '0.00');
}
},
{
sortable: true, align: 'right',
dataIndex: 'TYREAMOUNT',
header: '轮胎费',
width: 80,
editor: {
xtype: 'numberfield',
selectOnFocus: true,
hideTrigger: true,
step: 0
},
summaryType: 'sum',
summaryRenderer: function (value) {
zongchengben += value;
return Ext.util.Format.number(value, '0.00');
}
},
{
sortable: true, align: 'right',
dataIndex: 'OTHERAMOUNT',
header: '行车杂支',
width: 80,
editor: {
xtype: 'numberfield',
selectOnFocus: true,
hideTrigger: true,
step: 0
},
summaryType: 'sum',
summaryRenderer: function (value) {
zongchengben += value;
return Ext.util.Format.number(value, '0.00');
}
},
{
sortable: true, align: 'right',
dataIndex: 'TAX',
header: '税金',
width: 80,
editor: {
xtype: 'numberfield',
selectOnFocus: true,
hideTrigger: true,
step: 0
},
summaryType: 'sum',
summaryRenderer: function (value) {
zongchengben += value;
return Ext.util.Format.number(value, '0.00');
}
}]
},
{
sortable: true, align: 'right',
dataIndex: 'TRUCKCOST',
header: '单车成本合计',
width: 80,
editor: {
xtype: 'numberfield',
selectOnFocus: true,
hideTrigger: true,
step: 0
},
summaryType: 'sum',
summaryRenderer: function (value) {
zongchengben += value;
return Ext.util.Format.number(zongchengben, '0.00');
},
renderer: function (value, cellmeta, record, rowIndex, columnIndex, store) {
var ZJF = parseFloat(record.data.ZJF); //折旧费
var BXF = parseFloat(record.data.BXF); //保险费
var GZJZ = parseFloat(record.data.GZJZ); //工资奖金
var SBF = parseFloat(record.data.SBF); //社保费
var GJJ = parseFloat(record.data.GJJ); //公积金
var FUELAMOUNT = parseFloat(record.data.FUELAMOUNT); // 燃油费
var LQF = parseFloat(record.data.LQF); //路桥费
var REPAIRAMOUNT = parseFloat(record.data.REPAIRAMOUNT); //修理费
var TYREAMOUNT = parseFloat(record.data.TYREAMOUNT); //轮胎费
var OTHERAMOUNT = parseFloat(record.data.OTHERAMOUNT); //行车杂支
var TAX = parseFloat(record.data.TAX); //税金
return (ZJF + BXF + GZJZ + SBF + GJJ + FUELAMOUNT + LQF + REPAIRAMOUNT + TYREAMOUNT + OTHERAMOUNT + TAX).toFixed(2); ;
}
},
{
sortable: true, align: 'right',
dataIndex: 'TRUCKPROFIT_M',
header: '单车毛利润',
width: 80,
editor: {
xtype: 'numberfield',
selectOnFocus: true,
hideTrigger: true,
step: 0
},
summaryType: 'sum',
summaryRenderer: function (value) {
return Ext.util.Format.number(zongshouru - zongchengben, '0.00');
},
renderer: function (value, cellmeta, record, rowIndex, columnIndex, store) {
var AMOUNT = parseFloat(record.data.AMOUNT);
var ZJF = parseFloat(record.data.ZJF); //折旧费
var BXF = parseFloat(record.data.BXF); //保险费
var GZJZ = parseFloat(record.data.GZJZ); //工资奖金
var SBF = parseFloat(record.data.SBF); //社保费
var GJJ = parseFloat(record.data.GJJ); //公积金
var FUELAMOUNT = parseFloat(record.data.FUELAMOUNT); // 燃油费
var LQF = parseFloat(record.data.LQF); //路桥费
var REPAIRAMOUNT = parseFloat(record.data.REPAIRAMOUNT); //修理费
var TYREAMOUNT = parseFloat(record.data.TYREAMOUNT); //轮胎费
var OTHERAMOUNT = parseFloat(record.data.OTHERAMOUNT); //行车杂支
var TAX = parseFloat(record.data.TAX); //税金
var v = (AMOUNT - (ZJF + BXF + GZJZ + SBF + GJJ + FUELAMOUNT + LQF + REPAIRAMOUNT + TYREAMOUNT + OTHERAMOUNT + TAX)).toFixed(2);
// record.set('TRUCKPROFIT_M', v);
this.store.data.items[rowIndex].data.TRUCKPROFIT_M = v;
return v;
}
}]
}, {
text: '工作',
columns: [
{
sortable: true, align: 'right',
dataIndex: 'CARDAYS',
header: '总车日',
width: 80,
editor: {
xtype: 'numberfield',
selectOnFocus: true,
hideTrigger: true,
step: 0
},
summaryType: 'sum',
summaryRenderer: Ext.util.Format.numberRenderer('00.00')
},
{
sortable: true, align: 'right',
dataIndex: 'WORKDAYS',
header: '工作车日',
width: 80,
editor: {
xtype: 'numberfield',
selectOnFocus: true,
hideTrigger: true,
step: 0
},
summaryType: 'sum',
summaryRenderer: function (value) {
gongzuocheri = value;
return Ext.util.Format.number(value, '0.00');
}
},
{
sortable: true, align: 'right',
dataIndex: 'USABLEDAYS',
header: '完好车日',
width: 80,
editor: {
xtype: 'numberfield',
selectOnFocus: true,
hideTrigger: true,
step: 0
},
summaryType: 'sum',
summaryRenderer: function (value) {
wanhaocheri = value;
return Ext.util.Format.number(value, '0.00');
}
},
{
sortable: true, align: 'right',
dataIndex: 'USABLERATE',
header: '完好率(%)',
width: 80,
summaryType: 'average',
summaryRenderer: Ext.util.Format.numberRenderer('00.00'),
editor: {
xtype: 'numberfield',
selectOnFocus: true,
hideTrigger: true,
step: 0
}
},
{
sortable: true, align: 'right',
dataIndex: 'WORKRATE',
header: '工作率(%)',
width: 80,
renderer: function (value, cellmeta, record, rowIndex, columnIndex, store) {
var workdays = parseFloat(record.data['WORKDAYS']);
var cardays = parseFloat(record.data['CARDAYS']);
return ((workdays / cardays) * 100).toFixed(2);
},
editor: {
xtype: 'numberfield',
selectOnFocus: true,
hideTrigger: true,
step: 0
},
summaryType: 'average',
summaryRenderer: function (value) {
return Ext.util.Format.number(gongzuocheri / wanhaocheri * 100, '0.00');
}
}]
}, {
text: '停驶',
columns: [
{
sortable: true, align: 'right',
dataIndex: 'REPAIRDAYS',
header: '修理车日',
width: 80,
editor: {
xtype: 'numberfield',
selectOnFocus: true,
hideTrigger: true,
step: 0
},
summaryType: 'sum',
summaryRenderer: Ext.util.Format.numberRenderer('00.00')
},
{
sortable: true, align: 'right',
dataIndex: 'NOGOODDAYS',
header: '无货日',
width: 80,
editor: {
xtype: 'numberfield',
selectOnFocus: true,
hideTrigger: true,
step: 0
},
summaryType: 'sum',
summaryRenderer: Ext.util.Format.numberRenderer('00.00')
},
{
sortable: true, align: 'right',
dataIndex: 'NODRVDAYS',
header: '无人日',
width: 80,
editor: {
xtype: 'numberfield',
selectOnFocus: true,
hideTrigger: true,
step: 0
},
summaryType: 'sum',
summaryRenderer: Ext.util.Format.numberRenderer('00.00')
}]
},
{
text: '行程、运量、费率',
columns: [
{
sortable: true, align: 'right',
dataIndex: 'RATEDMIL',
header: '行驶总里程',
width: 80,
editor: {
xtype: 'numberfield',
selectOnFocus: true,
hideTrigger: true,
step: 0
},
summaryType: 'sum',
summaryRenderer: Ext.util.Format.numberRenderer('00.00')
},
{
sortable: true, align: 'right',
dataIndex: 'OVERLOADMIL',
header: '重驶里程',
width: 80,
editor: {
xtype: 'numberfield',
selectOnFocus: true,
hideTrigger: true,
step: 0
},
summaryType: 'sum',
summaryRenderer: Ext.util.Format.numberRenderer('00.00')
},
{
sortable: true, align: 'right',
dataIndex: 'TEU',
header: '集装箱运量TEU',
width: 80,
editor: {
xtype: 'numberfield',
selectOnFocus: true,
hideTrigger: true,
step: 0
},
summaryType: 'sum',
summaryRenderer: Ext.util.Format.numberRenderer('00.00')
},
{
sortable: true, align: 'right',
dataIndex: 'TONS',
header: '普货运量',
width: 80,
editor: {
xtype: 'numberfield',
selectOnFocus: true,
hideTrigger: true,
step: 0
},
summaryType: 'sum',
summaryRenderer: Ext.util.Format.numberRenderer('00.00')
},
{
sortable: true, align: 'right',
dataIndex: 'MILPERDAY',
header: '车日行程',
width: 80,
editor: {
xtype: 'numberfield',
selectOnFocus: true,
hideTrigger: true,
step: 0
},
summaryType: 'sum',
summaryRenderer: Ext.util.Format.numberRenderer('00.00')
}]
},
{
text: '燃料控制情况',
columns: [
{
sortable: true, align: 'right',
dataIndex: 'REALFUEL',
header: '燃料实耗',
width: 80,
editor: {
xtype: 'numberfield',
selectOnFocus: true,
hideTrigger: true,
step: 0
},
summaryType: 'sum',
summaryRenderer: Ext.util.Format.numberRenderer('00.00')
},
{
sortable: true, align: 'right',
dataIndex: 'RATEDFUEL',
header: '燃料定额',
width: 80,
editor: {
xtype: 'numberfield',
selectOnFocus: true,
hideTrigger: true,
step: 0
},
summaryType: 'sum',
summaryRenderer: Ext.util.Format.numberRenderer('00.00')
},
{
sortable: true, align: 'right',
dataIndex: 'REMAINFUEL',
header: '节约/超额',
width: 80,
editor: {
xtype: 'numberfield',
selectOnFocus: true,
hideTrigger: true,
step: 0
},
summaryType: 'sum',
summaryRenderer: Ext.util.Format.numberRenderer('00.00')
},
{
sortable: true, align: 'right',
dataIndex: 'FUELAMOUNTRATE',
header: '燃料费占收入比',
width: 80,
editor: {
xtype: 'numberfield',
selectOnFocus: true,
hideTrigger: true,
step: 0
}
}]
},
{
sortable: true, align: 'right',
dataIndex: 'OTHERPAY',
header: '其他费用',
width: 80,
editor: {
xtype: 'numberfield',
selectOnFocus: true,
hideTrigger: true,
step: 0
},
summaryType: 'sum',
summaryRenderer: Ext.util.Format.numberRenderer('00.00')
},
{
sortable: true, align: 'right',
dataIndex: 'OTHERPAYREMARK',
header: '其他费用说明',
width: 200,
editor: {
xtype: 'textfield',
selectOnFocus: true,
hideTrigger: true,
step: 0
}
},
{
sortable: true,
dataIndex: 'REMARK',
header: '备注',
width: 200,
editor: {
xtype: 'textfield',
selectOnFocus: true,
hideTrigger: true,
step: 0
}
}
]
});
//#endregion
//#region 明细表 其他费用
this.storeTruckFee = Ext.create('Ext.data.Store', {
pageSize: 50,
model: 'MsWlTruckFeemb',
remoteSort: false,
proxy: {
type: 'ajax',
url: '/TruckMng/MsWlTruckFee/GetDataList',
reader: {
id: 'GID',
root: 'data',
totalProperty: 'totalCount'
}
}
});
this.gridTruckFee = new Ext.grid.GridPanel({
store: this.storeTruckFee,
enableHdMenu: false,
region: 'center',
loadMask: { msg: "数据加载中,请稍等..." },
trackMouseOver: true,
disableSelection: false,
features: [{
ftype: 'summary'//Ext.grid.feature.Summary表格汇总特性
}],
//selModel: this.PCCB,
//plugins: [this.cellEditing],
columns: [new Ext.grid.RowNumberer(), {
sortable: true,
dataIndex: 'GID', hidden: true,
header: 'GID',
width: 130
}, {
sortable: true,
dataIndex: 'TruckNo',
header: '车号',
width: 85
},
{
sortable: true,
dataIndex: 'FeeDate',
header: '费用日期',
width: 85,
renderer: Ext.util.Format.dateRenderer('Y-m-d')
},
{
sortable: true,
dataIndex: 'FeeName',
header: '费用名称',
editor: this.comboxFeeName,
width: 80
},
{
sortable: true,
dataIndex: 'Amount',
header: '金额',
summaryType: 'sum',
width: 70
},
{
sortable: true,
dataIndex: 'Remark',
header: '备注',
width: 120
},
{
sortable: true, hidden: true,
dataIndex: 'Inserted',
header: 'Inserted',
width: 80
}],
// paging bar on the bottom
bbar: Ext.create('Ext.PagingToolbar', {
store: this.storeList,
displayInfo: true,
displayMsg: '当前显示 {0} - {1}条记录 /共 {2}条记录',
emptyMsg: "没有数据"
})
});
//#endregion 明细表
//#region 充值卡
this.storeCardType = Ext.create('DsExt.ux.RefEnumStore', {});
this.storeCardType.load({ params: { enumTypeId: 99045} });
this.comboxCardType = Ext.create('DsExt.ux.RefTableCombox', {
//fieldLabel: '充值卡类型',
forceSelection: true,
store: this.storeCardType,
name: 'CARDTYPE',
valueField: 'EnumValueName',
displayField: 'EnumValueName',
//triggerAction: 'all',
selectOnFocus: true
});
this.storeCard = Ext.create('Ext.data.Store', {
model: 'DsTruckMng.ux.CardModel',
remoteSort: false,
pruneModifiedRecords: true,
proxy: {
type: 'ajax',
url: '/TruckMng/Card/GetDataList',
reader: {
id: 'GID',
root: 'data',
totalProperty: 'totalCount'
}
}
});
//表格
this.CardColumns = [
{
sortable: true, hidden: true,
dataIndex: 'GID',
header: 'GID',
width: 80
},
{
sortable: true,
dataIndex: 'CARDNO',
header: '卡号',
editor: {
xtype: 'textfield',
allowBlank: false,
selectOnFocus: true
},
width: 170
},
{
sortable: true,
dataIndex: 'CARDTYPE',
header: '卡类型',
editor: this.comboxCardType
/*
xtype: 'textfield',
allowBlank: false,
selectOnFocus: true
}*/,
width: 70
},
{
sortable: true, hidden: true,
dataIndex: 'OP',
header: '所有者',
width: 80
},
{
sortable: true, hidden: true,
dataIndex: 'OWNGID',
header: 'OWNGID',
width: 80
},
{
sortable: true, hidden: true,
dataIndex: 'ISDELETE',
header: 'ISDELETE',
width: 80
},
{
sortable: true,
dataIndex: 'REMAIN',
header: '剩余金额',
width: 80
}
];
this.cellEditingCard = Ext.create('Ext.grid.plugin.CellEditing', {
clicksToEdit: 1
});
this.cardCheckBoxModel = Ext.create('Ext.selection.CheckboxModel');
var _this = this;
this.formCard = new Ext.grid.GridPanel({
store: this.storeCard,
enableHdMenu: false,
layout: 'border',
region: 'center',
loadMask: { msg: "数据加载中,请稍等..." },
trackMouseOver: true,
disableSelection: false,
plugins: [this.cellEditingCard],
selModel: this.cardCheckBoxModel,
multiSelect: false,
selType: 'cellmodel',
tbar: [{
text: '增加明细',
tooltip: '增加明细',
iconCls: "btnadddetail",
handler: function (button, event) {
this.onAddCardClick(button, event);
},
scope: this
}, '-', {
text: '删除明细',
tooltip: '删除明细',
iconCls: "btndeletedetail",
handler: function (button, event) {
this.onDelCardClick(button, event);
},
scope: this
}, '-', {
text: "保存",
iconCls: "btnsave",
handler: function (button, event) {
this.Save('0');
},
scope: this
}],
columns: this.CardColumns
});
//#endregion
//选择load
this.formCard.getSelectionModel().on('select', function (model, record, index) {
var CARDGID = record.data.GID;
this.CARDGID = CARDGID;
this.storeCardUse.load({ params: { CARDGID: CARDGID} });
}, this);
//#region 充值卡使用
this.storeCardUse = Ext.create('Ext.data.Store', {
model: 'DsTruckMng.ux.CardUseModel',
remoteSort: false,
pruneModifiedRecords: true,
proxy: {
type: 'ajax',
url: '/TruckMng/Card/GetUseList',
reader: {
id: 'GID',
root: 'data',
totalProperty: 'totalCount'
}
}
});
//表格
this.CardUseColumns = [
{
sortable: true, hidden: true,
dataIndex: 'GID',
header: 'GID',
width: 80
},
{
sortable: true, hidden: true,
dataIndex: 'CARDNO',
header: 'CARDNO',
width: 80
},
{
sortable: true, hidden: true,
dataIndex: 'CARDGID',
header: 'CARDGID',
width: 80
},
{
sortable: true,
dataIndex: 'BILLNO',
header: '业务编号',
width: 150
},
{
sortable: true,
dataIndex: 'OPERATE',
header: '业务操作',
width: 80,
editor: {
xtype: 'textfield',
allowBlank: false,
selectOnFocus: true
}
},
{
sortable: true,
dataIndex: 'INNUM',
header: '充入',
width: 80,
editor: {
xtype: 'numberfield',
allowBlank: false,
selectOnFocus: true
}
},
{
sortable: true,
dataIndex: 'OUTNUM',
header: '支出',
width: 80,
editor: {
xtype: 'numberfield',
allowBlank: false,
selectOnFocus: true
}
},
{
sortable: true,
dataIndex: 'OPTIME',
header: '操作时间',
width: 140,
renderer: Ext.util.Format.dateRenderer('Y-m-d H:i:s'),
editor: {
xtype: 'datetimefield',
selectOnFocus: true
}
},
{
sortable: true,
dataIndex: 'REMARK',
header: '备注',
width: 80,
editor: {
xtype: 'textfield',
allowBlank: false,
selectOnFocus: true
}
}];
this.cellEditingCardUse = Ext.create('Ext.grid.plugin.CellEditing', {
clicksToEdit: 1
});
this.CardUseCheckBoxModel = Ext.create('Ext.selection.CheckboxModel');
var _this = this;
this.formCardUse = new Ext.grid.GridPanel({
store: this.storeCardUse,
enableHdMenu: false,
region: 'center',
loadMask: { msg: "数据加载中,请稍等..." },
trackMouseOver: true,
disableSelection: false,
plugins: [this.cellEditingCardUse],
selModel: this.CardUseCheckBoxModel,
selType: 'cellmodel',
tbar: [{
text: '增加明细',
tooltip: '增加明细',
iconCls: "btnadddetail",
handler: function (button, event) {
var CARDGID = "";
var records = this.formCard.selModel.getSelection();
if (records.length == 0) {
alert("请先选中一个充值卡");
return;
}
OWNGID = records[0].data.OWNGID;
if (OWNGID == "") {
alert("请先保存充值卡信息");
return;
}
this.onAddCardUseClick(records[0].data.GID);
},
scope: this
}, {
text: '删除明细',
tooltip: '删除明细',
iconCls: "btndeletedetail",
handler: function (button, event) {
var records = this.formCard.selModel.getSelection();
var OWNGID = records[0].data.OWNGID;
var CARDGID = records[0].data.GID;
this.onDelCardUseClick(CARDGID, OWNGID);
},
scope: this
}, '-', {
text: '保存充值卡使用信息',
tooltip: '仅可保存修改充值卡的充值信息。',
iconCls: "btnsave",
handler: function (button, event) {
var CARDGID = "";
var records = this.formCard.selModel.getSelection();
var CARDGID = records[0].data.GID;
var OWNGID = records[0].data.OWNGID;
if (OWNGID == "") {
alert("请先保存充值卡信息");
return;
}
this.onSaveCardUseClick(CARDGID, OWNGID);
},
scope: this
}],
columns: this.CardUseColumns
});
//#endregion
//#region 车辆月度信息
this.storeTruckMonth = Ext.create('Ext.data.Store', {
model: 'TruckMonthmb',
remoteSort: false,
proxy: {
type: 'ajax',
url: '/TruckMng/MsWlTruck/GetTruckMonthList',
reader: {
id: 'GID',
root: 'data',
totalProperty: 'totalCount'
}
}
});
//表格
this.TruckMonthColumns = [
{
sortable: true, hidden: true,
dataIndex: 'GID', readOnly: true,
header: 'GID',
width: 80
},
{
sortable: true, hidden: true,
dataIndex: 'TRUCKNO', readOnly: true,
header: 'TRUCKNO',
width: 80
},
{
sortable: true,
dataIndex: 'ACCDATE',
header: '统计期间',
width: 80,
renderer: Ext.util.Format.dateRenderer('Y-m'),
editor: {
xtype: 'monthfield',
selectOnFocus: true,
renderer: Ext.util.Format.dateRenderer('Y-m')
}
},
{
sortable: true,
dataIndex: 'ZJF',
header: '折旧费',
width: 80,
editor: {
xtype: 'numberfield',
allowBlank: false,
selectOnFocus: true,
minValue: 0
}
},
{
sortable: true,
dataIndex: 'BXF',
header: '车辆保险',
width: 80,
editor: {
xtype: 'numberfield',
allowBlank: false,
selectOnFocus: true,
minValue: 0
}
},
{
sortable: true,
dataIndex: 'GZCR',
header: '工作车日',
width: 80,
editor: {
xtype: 'numberfield',
allowBlank: false,
selectOnFocus: true,
minValue: 0
}
},
{
sortable: true,
dataIndex: 'XLCR',
header: '修理车日',
width: 80
},
{
sortable: true,
dataIndex: 'ZCR',
header: '总车日',
width: 80,
editor: {
xtype: 'numberfield',
allowBlank: false,
selectOnFocus: true,
minValue: 0
}
}
];
this.cellEditingTruckMonth = Ext.create('Ext.grid.plugin.CellEditing', {
clicksToEdit: 1
});
this.TruckMonthCheckBoxModel = Ext.create('Ext.selection.CheckboxModel');
var _this = this;
this.formTruckMonth = new Ext.grid.GridPanel({
store: this.storeTruckMonth,
enableHdMenu: false,
layout: 'border',
region: 'center',
loadMask: { msg: "数据加载中,请稍等..." },
trackMouseOver: true,
disableSelection: false,
plugins: [this.cellEditingTruckMonth],
selModel: this.TruckMonthCheckBoxModel,
multiSelect: false,
selType: 'cellmodel',
tbar: [{
text: '增加明细',
tooltip: '增加明细',
iconCls: "btnadddetail",
handler: function (button, event) {
this.onAddTruckMonthClick(button, event);
},
scope: this
}, '-', {
text: '删除明细',
tooltip: '删除明细',
iconCls: "btndeletedetail",
handler: function (button, event) {
this.onDelTruckMonthClick(button, event);
},
scope: this
}, '-', {
text: "保存",
iconCls: "btnsave",
handler: function (button, event) {
this.Save('0');
},
scope: this
}],
columns: this.TruckMonthColumns
});
//#endregion
//#region 布局
//控件布局
this.panelTop = new Ext.Panel({
layout: "border",
region: 'north',
margin: '1 1',
height: 135,
//split: true,
items: [this.panelBtn, this.formEdit]
});
this.panelCardList = new Ext.Panel({
// title: '货物信息和许可证使用',
layout: "border",
region: 'west',
margin: '0 0',
//height: 450,
width: 330,
//split: true,
items: [this.formCard]
});
this.panelCardUse = new Ext.Panel({
// title: '货物信息和许可证使用',
layout: "border",
region: 'center',
margin: '0 0',
//height: 450,
width: 450,
//split: true,
items: [this.formCardUse]
});
this.panelCard = new Ext.Panel({
//
layout: "border",
region: 'center',
margin: '0 0',
//height: 260, //width: 450,
//split: true,
items: [this.panelCardList, this.panelCardUse]
});
this.page_1 = new Ext.Panel({
id: "page_1",
title: "车辆汇总",
//autoScroll: true,
layout: "border",
region: 'center',
//closable:true,
items: [this.gridList]
});
this.page_2 = new Ext.Panel({
id: "page_2",
title: "其他费用查询",
layout: "border",
region: 'center',
items: [this.gridTruckFee]
});
this.page_3 = new Ext.Panel({
id: "page_3",
title: "充值卡管理",
layout: "border",
region: 'center',
items: [this.panelCard]
});
this.page_4 = new Ext.Panel({
id: "page_4",
title: "车辆月度费用管理",
layout: "border",
region: 'center',
items: [this.formTruckMonth]
});
this.MainTab = new Ext.tab.Panel({
layout: "border",
region: "center", split: true,
items: [
this.page_1//, this.page_2, this.page_3, this.page_4
]
});
Ext.apply(this, {
items: [this.panelTop, this.MainTab]
});
//#endregion
//绑定查询窗体
this.ParentWin = window.parent.opener;
//初始化数据
this.InitData();
//绑定事件
this.gridList.on('edit', function (editor, e, eOpts) {
this.gridAfterEdit(editor, e, eOpts);
}, this);
this.cellEditingCardUse.on('beforeedit', function (editor, e) {
return this.CardUseBeforeEdit(editor, e);
}, 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') + "'";
Ext.getCmp("CXSC").enable();
Ext.getCmp("FZSY").enable();
}
this.LoadData(this.opStatus, condition);
}, //end InitData
LoadData: function (opstatus, condition) {
this.serialNo = 0;
this.bodyDel = [];
this.opStatus = opstatus;
Ext.Ajax.request({
waitMsg: '正在查询主表数据...',
url: '/TruckMng/TMSRPT/MONTH_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 (data.OP == "") { data.OP = SHOWNAME; }
//if (data.OPDATE == "") { data.OPDATE = currdate.format('yyyy-MM-dd HH:mm:ss'); }
if (data.ACCDATE == "") {
Ext.getCmp("ACCDATE").readOnly = false;
alert("您的分公司初次制作上报报表,请设定初始上报月份。再次新建月度上报时将自动产生“下个月”的报表。");
}
if (data.BLSTATUS == "0" || data.BLSTATUS == "4") {
//可以提交
Ext.getCmp("StartAudit").enable();
Ext.getCmp("ResetAudit").disable();
Ext.getCmp("Audit").disable();
Ext.getCmp("AuditBack").disable();
} else
if (data.BLSTATUS == "1") {
//可以审核 可以驳回
Ext.getCmp("StartAudit").disable();
Ext.getCmp("ResetAudit").enable();
Ext.getCmp("Audit").enable();
Ext.getCmp("AuditBack").enable();
} else
if (data.BLSTATUS == "2") {
//可以驳回
Ext.getCmp("StartAudit").disable();
Ext.getCmp("ResetAudit").disable();
Ext.getCmp("Audit").disable();
Ext.getCmp("AuditBack").enable();
}
this.formEdit.getForm().reset();
this.formEdit.getForm().setValues(data);
} else {
Ext.MessageBox.alert('请求出现错误,请重试', response.responseText);
}
},
scope: this
});
if (this.opStatus == 'edit') {
LINKGID = this.editRecord.get('GID');
PRTLINKGID = this.editRecord.get('GID');
//this.formEdit.getForm().findField('TruckNo').setDisabled(true);
this.storeTruckFee.load({
params: { start: 0, limit: 50, sort: '', condition: "TruckNo='" + this.editRecord.get('TruckNo') + "'" },
waitMsg: "正在查询数据...",
scope: this
});
this.storeTruckMonth.load({
params: { condition: "TruckNo='" + this.editRecord.get('TruckNo') + "'" },
waitMsg: "正在查询数据...",
scope: this
});
}
RPTLINKGID = LINKGID;
this.storeBodyList.load({ params: { start: 0, limit: 9999, condition: "AMOUNT <> 0 AND LINKGID='" + LINKGID + "'"} });
//this.storeCard.load({ params: { OWNGID: billno} });
//显示充值卡剩余数量
}, // end LoadDate
Save: function (type) {
var basicForm = this.formEdit.getForm();
if (!basicForm.isValid()) {
return;
}
//basicForm.findField('TruckNo').setDisabled(false);
var data = basicForm.getValues();
//basicForm.findField('TruckNo').setDisabled(true);
if (data.TimeMark == "") {
TimeMark = 0;
}
var bodydatas = [];
for (var i = 0; i < this.storeBodyList.getCount(); i += 1) {
var member = this.storeBodyList.getAt(i);
bodydatas.push(member);
}
var jsonBody = ConvertRecordsToJson(bodydatas);
jsonBody = jsonBody.replace(/undefined/g, "0")
var jsonDelBody = ConvertRecordsToJsonAll(this.bodyDel);
/*
var Carddatas = [];
for (var i = 0; i < this.storeCard.getCount(); i += 1) {
var member = this.storeCard.getAt(i);
Carddatas.push(member);
}
var CardjsonBody = ConvertRecordsToJson(Carddatas);
var CardjsonDelBody = ConvertRecordsToJsonAll(this.cardDel);
var TruckMonthdatas = [];
for (var i = 0; i < this.storeTruckMonth.getCount(); i += 1) {
var member = this.storeTruckMonth.getAt(i);
var Y = member.data.ACCDATE.getFullYear();
var M = member.data.ACCDATE.getMonth() + 1;
member.data.ACCDATE = Y + '-' + M;
TruckMonthdatas.push(member);
}
var TruckMonthjsonBody = ConvertRecordsToJson(TruckMonthdatas);
var TruckMonthjsonDelBody = ConvertRecordsToJsonAll(this.TruckMonthDel);
*/
Ext.Msg.wait('正在保存数据, 请稍侯..');
Ext.Ajax.request({
waitMsg: '正在保存数据...',
url: '/TruckMng/TMSRPT/Save',
scope: this,
params: {
opstatus: this.opStatus,
data: Ext.JSON.encode(data),
body: jsonBody,
delbody: jsonDelBody
},
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('TMSRPT_MONTHmb', returnData);
this.editRecord.fields.each(function (field) {
if (field.persist) {
name = field.name;
if (name != 'GID')
this.editRecord.set(name, editp.get(name));
}
}, this);
this.editRecord.commit();
}
if (type == '0') {
this.opStatus = 'edit';
//basicForm.findField('TruckNo').setDisabled(true);
this.storeBodyList.commitChanges();
Ext.getCmp("CXSC").enable();
Ext.getCmp("FZSY").enable();
/*
for (var j = 0; j < this.storeBodyList.getCount(); j += 1) {
var memberbody = this.storeBodyList.getAt(j);
memberbody.set("TruckNo", this.editRecord.get('TruckNo'));
memberbody.commit();
};*/
} else if (type == '1') {
window.close();
} else {
this.LoadData('add', '');
basicForm.findField('TruckNo').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
onDelDetailClick: function (button, event) {
this.deleteDetail();
}, //onDelDetailClick
gridAfterEdit: function (editor, e, eOpts) {
//需要自己实现里面的事件
if (e.field == 'LoadType') {
var records = DsStoreQueryBy(this.storeLoadTypeRef, 'EnumValueId', e.value);
if (records.getCount() > 0) {
var data = records.getAt(0).data;
e.record.set('LoadType_Ref', data.EnumValueName);
} else {
e.record.set('LoadType_Ref', '');
}
}
if (e.field == 'AMOUNT' || e.field == 'ZJF' || e.field == 'BXF' || e.field == 'GZJZ' || e.field == 'GJJ'
|| e.field == 'FUELAMOUNT' || e.field == 'LQF' || e.field == 'REPAIRAMOUNT' || e.field == 'TYREAMOUNT' || e.field == 'OTHERAMOUNT' || e.field == 'TAX') {
var AMOUNT = parseFloat(e.record.get('AMOUNT'));
var ZJF = parseFloat(e.record.get('ZJF'));
var BXF = parseFloat(e.record.get('BXF'));
var GZJZ = parseFloat(e.record.get('GZJZ'));
var GJJ = parseFloat(e.record.get('GJJ'));
var FUELAMOUNT = parseFloat(e.record.get('FUELAMOUNT'));
var LQF = parseFloat(e.record.get('LQF'));
var REPAIRAMOUNT = parseFloat(e.record.get('REPAIRAMOUNT'));
var TYREAMOUNT = parseFloat(e.record.get('TYREAMOUNT'));
var OTHERAMOUNT = parseFloat(e.record.get('OTHERAMOUNT'));
var TAX = parseFloat(e.record.get('TAX'));
var TRUCKCOST = Add((ZJF + BXF + GZJZ + GJJ + FUELAMOUNT), (LQF + REPAIRAMOUNT + TYREAMOUNT + OTHERAMOUNT + TAX));
var TRUCKPROFIT_M = Cut(Mul(AMOUNT, 0.89), TRUCKCOST);
e.record.set('TRUCKCOST', TRUCKCOST);
e.record.set('TRUCKPROFIT_M', TRUCKPROFIT_M);
}
if (e.field == 'REALFUEL') {
var REALFUEL = parseFloat(e.record.get('REALFUEL'));
var RATEDFUEL = parseFloat(e.record.get('RATEDFUEL'));
var REMAINFUEL = Cut(REALFUEL, RATEDFUEL, 2);
e.record.set('REMAINFUEL', REMAINFUEL);
}
if (e.field == 'CARDAYS' || e.field == 'USABLEDAYS') {
var CARDAYS = parseFloat(e.record.get('CARDAYS'));
var USABLEDAYS = parseFloat(e.record.get('USABLEDAYS'));
var USABLERATE = Div(USABLEDAYS, CARDAYS, 2);
e.record.set('USABLERATE', USABLERATE);
}
if (e.field == 'CARDAYS' || e.field == 'WORKDAYS') {
var CARDAYS = parseFloat(e.record.get('CARDAYS'));
var WORKDAYS = parseFloat(e.record.get('WORKDAYS'));
var WORKRATE = Div(WORKDAYS, CARDAYS, 2);
e.record.set('WORKRATE', WORKRATE);
}
},
onAddDetailClick: function () {
var basicForm = this.formEdit.getForm();
if (!basicForm.isValid()) {
return;
}
//basicForm.findField('TruckNo').setDisabled(false);
var data = basicForm.getValues();
var record = Ext.create('TMSRPT_MONTH_TRUCKDETAILmb', {
GID: NewGuid(),
COMPANYID: data.COMPANYID,
COMPANYNAME: data.COMPANYNAME,
TRUCKNO: "",
AMOUNT: "0",
ZJF: "0",
BXF: "0",
GZJZ: "0",
SBF: "0",
GJJ: "0",
FUELPRICE: "0",
FUELAMOUNT: "0",
REPAIRAMOUNT: "0",
TYREAMOUNT: "0",
OTHERAMOUNT: "0",
TAX: "0",
TRUCKCOST: "0",
TRUCKPROFIT_M: "0",
CARDAYS: "0",
WORKDAYS: "0",
USABLEDAYS: "0",
USABLERATE: "0",
WORKRATE: "0",
REPAIRDAYS: "0",
NOGOODDAYS: "0",
NODRVDAYS: "0",
RATEDMIL: "0",
OVERLOADMIL: "0",
TEU: "0",
TONS: "0",
MILPERDAY: "0",
FUEL: "0",
RATEDFUEL: "0",
REMAINFUEL: "0",
FUELAMOUNTRATE: "0",
OTHERPAY: "0",
OTHERPAYREMARK: "无",
REMARK: ""
});
this.storeBodyList.add(record);
var n = this.storeBodyList.getCount();
this.gridListCellEditing.startEditByPosition({ row: n - 1, column: 2 });
},
deleteDetail: function () {
this.serialNo = DsGetCurSerialNo(this.storeBodyList, this.serialNo);
var selectedRecords = this.gridList.selModel.getSelection();
for (var i = 0; i < selectedRecords.length; i++) {
var rec = selectedRecords[i];
if (rec.BillNo != "" || rec.BillNo != "*") //如果是新增但没有保存的数据,没有必要提交到后台
{
this.bodyDel.push(rec);
}
this.storeBodyList.remove(selectedRecords[i]);
}
},
onAddCardClick: function () {
var record = Ext.create('DsTruckMng.ux.CardModel', {
GID: NewGuid(),
CARDNO: "",
CARDTYPE: "",
OP: "",
OWNGID: "",
ISDELETE: "0"
});
this.storeCard.add(record);
var n = this.storeCard.getCount();
this.cellEditingCard.startEditByPosition({ row: n - 1, column: 2 });
},
onDelCardClick: function () {
/*
var selectedRecords = this.formCard.selModel.getSelection();
if (this.storeCardUse.getCount()>0){
alert("包含充值或使用明细的卡片不能删除");
return;
}
*/
var selections = this.formCard.getSelectionModel().getSelection();
if (selections.length == 0) {
Ext.Msg.show({ title: '提示', msg: '请先选择卡片!', icon: Ext.Msg.INFO, buttons: Ext.Msg.OK });
return;
}
var _L = selections.length;
var UseCount = "0";
var OWNGID = this.editRecord.get('TruckNo');
Ext.MessageBox.confirm('提示', '确定删除这' + _L + '条记录吗?', function (btn) {
if (btn == 'yes') {
//var record = selections[0];
for (var i = 0; i < _L; i++) {
var record = selections[i];
var GID = record.data.GID;
Ext.Ajax.request({
waitMsg: '正在查询数据...',
url: '/TruckMng/Card/SearchCardUse',
scope: this,
async: false,
params: { GID: GID },
waitMsg: "正在查询数据...",
callback: function (options, success, response) {
if (success) {
var jsonresult = Ext.JSON.decode(response.responseText);
var returnData = jsonresult.data;
//alert(returnData);
UseCount = returnData;
} else {
Ext.Msg.show({ title: '请重试',
msg: '服务器响应出错',
icon: Ext.Msg.ERROR, buttons: Ext.Msg.OK
});
return;
}
}
});
if (UseCount != "0") {
alert("该卡片下包含未删除的使用/充值明细,不能删除");
return;
} else {
//Ext.Msg.wait('正在删除数据...');
Ext.Ajax.request({
waitMsg: '正在删除数据...',
url: '/TruckMng/Card/DeleteCard',
params: {
GID: GID
},
callback: function (options, success, response) {
if (success) {
var jsonresult = Ext.JSON.decode(response.responseText);
if (jsonresult.Success) {
//this.storeCard.remove(record);
//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 });
},
success: function (response, options) {
},
scope: this
}); //end Ext.Ajax.request
}
}
//this.storeList.remove(record);
//if (i >= _L ) {
// Ext.Msg.show({ title: '提示', msg: "数据删除结束", icon: Ext.Msg.INFO, buttons: Ext.Msg.OK });
//}
this.storeCard.load({ params: { OWNGID: OWNGID} });
};
//Ext.Msg.show({ title: '提示', msg: "数据删除结束", icon: Ext.Msg.INFO, buttons: Ext.Msg.OK });
//this.onRefreshClick(button, event);
}, this);
}
,
onAddCardUseClick: function (CARDGID) {
function GetDateStr(AddDayCount) {
var dd = new Date();
dd.setDate(dd.getDate() + AddDayCount); //获取AddDayCount天后的日期
var y = dd.getFullYear();
var m = dd.getMonth() + 1; //获取当前月份的日期
var d = dd.getDate();
return y + "-" + m + "-" + d;
}
var EnterDate = GetDateStr(0);
var record = Ext.create('DsTruckMng.ux.CardUseModel', {
GID: NewGuid(),
CARDNO: "",
CARDGID: "",
BILLNO: "",
OPERATE: "充值",
INNUM: "0",
OUTNUM: "0",
OPTIME: EnterDate,
REMARK: ""
});
this.storeCardUse.add(record);
var n = this.storeCardUse.getCount();
this.cellEditingCardUse.startEditByPosition({ row: n - 1, column: 2 });
},
onDelCardUseClick: function (CARDGID, OWNGID) {
var selectedRecords = this.formCardUse.selModel.getSelection();
var selections = this.formCardUse.getSelectionModel().getSelection();
if (selections.length == 0) {
Ext.Msg.show({ title: '提示', msg: '请先选择充值卡使用明细!', icon: Ext.Msg.INFO, buttons: Ext.Msg.OK });
return;
}
var _L = selections.length;
for (var i = 0; i < _L; i++) {
var record = selections[i];
if (record.data.OPERATE == "路单使用") {
alert("不能删除由路单生成的充值卡使用明细");
return;
}
}
Ext.MessageBox.confirm('提示', '确定删除这' + _L + '条记录吗?', function (btn) {
if (btn == 'yes') {
//var record = selections[0];
for (var i = 0; i < _L; i++) {
var record = selections[i];
var GID = record.data.GID;
//Ext.Msg.wait('正在删除数据...');
Ext.Ajax.request({
waitMsg: '正在删除数据...',
async: false,
url: '/TruckMng/Card/DeleteCardUse',
params: {
GID: GID
},
callback: function (options, success, response) {
if (success) {
var jsonresult = Ext.JSON.decode(response.responseText);
if (jsonresult.Success) {
this.storeCardUse.remove(record);
//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 });
},
success: function (response, options) {
},
scope: this
}); //end Ext.Ajax.request
}
};
//Ext.Msg.show({ title: '提示', msg: "数据删除结束", icon: Ext.Msg.INFO, buttons: Ext.Msg.OK });
var _this = this;
this.storeCard.load({
async: false,
params: { OWNGID: OWNGID },
callback: function (options, success, response) {
for (var i = 0; i < _this.storeCard.getCount(); i += 1) {
var member = _this.storeCard.getAt(i);
if (member.data.GID == CARDGID) {
_this.formCard.getSelectionModel().select(member);
}
}
}
});
}, this);
},
onSaveCardUseClick: function (CARDGID, OWNGID) {
var bodyCardUse = [];
for (i = 0; i < this.storeCardUse.getCount(); i += 1) {
var memberyf = this.storeCardUse.getAt(i);
bodyCardUse.push(memberyf);
};
var jsonCardUseBody = ConvertRecordsToJson(bodyCardUse);
var jsonCardUseDelBody = ConvertRecordsToJsonAll(this.carduseDel);
if (jsonCardUseBody == "" && jsonCardUseDelBody == "") {
return;
}
Ext.Msg.wait('正在保存数据, 请稍侯..');
Ext.Ajax.request({
waitMsg: '正在保存数据...',
url: '/TruckMng/Card/SaveCardUse',
scope: this,
params: {
CARDGID: CARDGID
, CardUsebody: jsonCardUseBody
, CardUseDelbody: jsonCardUseDelBody
},
callback: function (options, success, response) {
if (success) {
Ext.MessageBox.hide();
var jsonresult = Ext.JSON.decode(response.responseText);
if (jsonresult.Success) {
//alert("保存成功");
var returnData = jsonresult.Data;
this.storeCardUse.commitChanges();
var _this = this;
this.storeCard.load({
async: false,
params: { OWNGID: OWNGID },
callback: function (options, success, response) {
for (var i = 0; i < _this.storeCard.getCount(); i += 1) {
var member = _this.storeCard.getAt(i);
if (member.data.GID == CARDGID) {
_this.formCard.getSelectionModel().select(member);
}
}
}
});
} 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
});
}
//alert('03');
}
});
},
CardUseBeforeEdit: function (editor, e) {
//var OPERATE = e.record.get('OPERATE');
//var canedit = true;
//if (OPERATE == "路单使用") {
// canedit = false;
//}
return canedit;
}
,
onAddTruckMonthClick: function () {
var record = Ext.create('TruckMonthmb', {
GID: NewGuid(),
TRUCKNO: "",
ACCDATE: "",
ZJF: "0",
BXF: "0",
GZCR: "0",
XLCR: "0",
ZCR: "0"
});
this.storeTruckMonth.add(record);
var n = this.storeTruckMonth.getCount();
this.cellEditingTruckMonth.startEditByPosition({ row: n - 1, column: 2 });
},
onDelTruckMonthClick: function () {
var selectedRecords = this.formTruckMonth.selModel.getSelection();
for (var i = 0; i < selectedRecords.length; i++) {
var rec = selectedRecords[i];
if (rec.TRUCKNO != "" || rec.TRUCKNO != "*") //如果是新增但没有保存的数据,没有必要提交到后台
{
this.TruckMonthDel.push(rec);
}
this.storeTruckMonth.remove(selectedRecords[i]);
}
}
, ReMake: function () {
var basicForm = this.formEdit.getForm();
if (!basicForm.isValid()) {
return;
}
var data = basicForm.getValues();
Ext.Ajax.request({
waitMsg: '正在删除数据...',
url: '/TruckMng/TMSRPT/ReMake',
params: {
data: Ext.JSON.encode(data)
},
callback: function (options, success, response) {
if (success) {
alert("重新生成数据已完成!");
this.storeBodyList.load({ params: { start: 0, limit: 9999, condition: "AMOUNT <> 0 AND LINKGID='" + data.GID + "'"} });
}
},
failure: function (response, options) {
Ext.Msg.show({ title: '警告', msg: '服务器响应出错,请重试', icon: Ext.Msg.INFO, buttons: Ext.Msg.OK });
},
success: function (response, options) { },
scope: this
}); //end Ext.Ajax.request
}
, LoadBeforeFee: function () {
var basicForm = this.formEdit.getForm();
if (!basicForm.isValid()) {
return;
}
var data = basicForm.getValues();
Ext.Ajax.request({
waitMsg: '正在删除数据...',
url: '/TruckMng/TMSRPT/LoadBeforeFee',
params: {
data: Ext.JSON.encode(data)
},
callback: function (options, success, response) {
if (success) {
this.storeBodyList.load({ params: { start: 0, limit: 9999, condition: "AMOUNT <> 0 AND LINKGID='" + data.GID + "'"} });
}
},
failure: function (response, options) {
Ext.Msg.show({ title: '警告', msg: '服务器响应出错,请重试', icon: Ext.Msg.INFO, buttons: Ext.Msg.OK });
},
success: function (response, options) { },
scope: this
}); //end Ext.Ajax.request
}
, StartAudit: function () {
var data = this.formEdit.getForm().getValues(false, false, false);
if (data.GID == "") {
return;
}
if (data.BLSTATUS == "1" || data.BLSTATUS == "2") {
alert("已提交或已审核的上报单不需要再次提交");
return;
} else {
bill = data.GID;
}
//var bill = record.data.GID;
Ext.Ajax.request({
waitMsg: '正在提交...',
url: '/TruckMng/TMSRPT/StartAudit',
params: {
USERID: USERID,
bill: bill
},
callback: function (options, success, response) {
if (success) {
condition = " GID='" + bill + "'";
this.LoadData('edit', condition);
}
},
failure: function (response, options) {
Ext.Msg.show({ title: '警告', msg: '服务器响应出错,请重试', icon: Ext.Msg.INFO, buttons: Ext.Msg.OK });
},
success: function (response, options) { },
scope: this
}); //end Ext.Ajax.request
}
, Audit: function () {
var data = this.formEdit.getForm().getValues(false, false, false);
if (data.GID == "") {
return;
}
if (data.BLSTATUS != "1") {
alert("只能审核提交的上报单");
return;
} else {
bill = data.GID;
}
//var bill = record.data.GID;
Ext.Ajax.request({
waitMsg: '正在审核通过...',
url: '/TruckMng/TMSRPT/Audit',
params: {
USERID: USERID,
bill: bill
},
callback: function (options, success, response) {
if (success) {
condition = " GID='" + bill + "'";
this.LoadData('edit', condition);
this.onSendMail2Click();
}
},
failure: function (response, options) {
Ext.Msg.show({ title: '警告', msg: '服务器响应出错,请重试', icon: Ext.Msg.INFO, buttons: Ext.Msg.OK });
},
success: function (response, options) { },
scope: this
}); //end Ext.Ajax.request
}
, ResetAudit: function () {
var data = this.formEdit.getForm().getValues(false, false, false);
if (data.GID == "") {
return;
}
if (data.BLSTATUS != "1") {
alert("只能撤回未审核的报价单");
return;
} else {
bill = data.GID;
}
//var bill = record.data.GID;
Ext.Ajax.request({
waitMsg: '正在撤回...',
url: '/TruckMng/TMSRPT/ResetAudit',
params: {
USERID: USERID,
bill: bill
},
callback: function (options, success, response) {
if (success) {
condition = " GID='" + bill + "'";
this.LoadData('edit', condition);
}
},
failure: function (response, options) {
Ext.Msg.show({ title: '警告', msg: '服务器响应出错,请重试', icon: Ext.Msg.INFO, buttons: Ext.Msg.OK });
},
success: function (response, options) { },
scope: this
}); //end Ext.Ajax.request
}
, AuditBack: function () {
var data = this.formEdit.getForm().getValues(false, false, false);
if (data.GID == "") {
return;
}
if (data.BLSTATUS == "0" || data.BLSTATUS == "4") {
//alert("已提交或已审核的报价不需要再次提交");
return;
} else {
bill = data.GID;
}
//var bill = record.data.GID;
Ext.Ajax.request({
waitMsg: '正在驳回...',
url: '/TruckMng/TMSRPT/AuditBack',
params: {
USERID: USERID,
bill: bill
},
callback: function (options, success, response) {
if (success) {
condition = " GID='" + bill + "'";
this.LoadData('edit', condition);
}
},
failure: function (response, options) {
Ext.Msg.show({ title: '警告', msg: '服务器响应出错,请重试', icon: Ext.Msg.INFO, buttons: Ext.Msg.OK });
},
success: function (response, options) { },
scope: this
}); //end Ext.Ajax.request
}
, ReflashEdt: function (LINKGID) {
this.OpStatus = 'edit';
condition = "AMOUNT <> 0 AND LINKGID='" + LINKGID + "'";
this.storeBodyList.load({ params: { start: 0, limit: 9999, condition: condition} });
}, Print: function () {
var printType = 'TRUCKRPT';
var sql1 = " select GID,LINKGID,COMPANYID,(select name from company where GID=COMPANYID) COMPANYNAME";
sql1 += ",(select ACCDATE from TMSRPT_MONTH where GID=LINKGID) ACCDATE ";
sql1 += ",TRUCKNO,(select LoadCount from tmswltruck where truckno=TMSRPT_MONTH_TRUCKDETAIL.TRUCKNO) LoadCount ";
sql1 += ",(select trunkbrand from tmswltruck where truckno=TMSRPT_MONTH_TRUCKDETAIL.TRUCKNO) TruckSpec ";
sql1 += ",AMOUNT,ZJF,BXF,GZJZ,SBF,GJJ,FUELPRICE,FUELAMOUNT,LQF,REPAIRAMOUNT,TYREAMOUNT,OTHERAMOUNT,TAX,TRUCKCOST,TRUCKPROFIT_M ";
sql1 += " ,CARDAYS,WORKDAYS,USABLEDAYS,USABLERATE,WORKRATE,REPAIRDAYS,NOGOODDAYS,NODRVDAYS,RATEDMIL,OVERLOADMIL,TEU,TONS ";
sql1 += " ,MILPERDAY,REALFUEL,RATEDFUEL,REMAINFUEL,FUELAMOUNTRATE,OTHERPAY,OTHERPAYREMARK,REMARK ";
sql1 += " from TMSRPT_MONTH_TRUCKDETAIL where LINKGID='" + RPTLINKGID + "'";
var sql2 = "";
var sql3 = "";
var sql4 = "";
var sql5 = "";
var sql6 = "";
PrintComm(printType, sql1, sql2, sql3, sql4, sql5, sql6);
}
});