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/MsWlTruck/MsWlTruckFeeIndex.js

682 lines
24 KiB
JavaScript

3 years ago
//集运管理
Ext.namespace('DsTruck');
DsTruck.MsWlTruckFeeIndex = function (config) {
Ext.applyIf(this, config);
this.initUIComponents();
window.DsTruck.MsWlTruckFeeIndex.superclass.constructor.call(this);
};
//#region 当前时间
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);
//#endregion
Ext.extend(DsTruck.MsWlTruckFeeIndex, Ext.Panel, {
PageSize: 100,
OprationStatus: null, //仅当弹出界面时使用
SelectedRecord: null,
initUIComponents: function () {
//定义数据集
this.storeList = Ext.create('Ext.data.Store', {
pageSize: this.PageSize,
model: 'MsWlTruckFeemb',
remoteSort: false,
proxy: {
type: 'ajax',
url: '/TruckMng/MsWlTruckFee/GetDataList',
reader: {
id: 'GID',
root: 'data',
totalProperty: 'totalCount'
}
}
});
//#region 表参照
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
}
});
this.storeDrvName = Ext.create('DsExt.ux.RefTableStore', {
model: 'MsWlBsHeadRefMsWlDriver',
proxy: { url: '/TruckMng/MsWlPc/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.storeFeeName = Ext.create('DsExt.ux.RefTableStore', {
model: 'DsTruckMng.ux.FeeTypeRefModel',
proxy: { url: '/CommMng/BasicDataRef/GetFeeTypeRefList' }
});
this.storeFeeName.load({ params: { condition: ""} });
this.comboxFeeName = Ext.create('DsExt.ux.RefTableCombox', {
store: this.storeFeeName,
name: 'FeeName',
valueField: 'Name',
displayField: 'CodeAndName'
});
//#endregion
this.cellEditing = Ext.create('Ext.grid.plugin.CellEditing', {
clicksToEdit: 1
});
this.PCCB = Ext.create('Ext.selection.CheckboxModel', { checkOnly: true });
Ext.grid.RowNumberer = Ext.extend(Ext.grid.RowNumberer, {
width: 45
});
//定义Grid
this.gridList = new Ext.grid.GridPanel({
store: this.storeList,
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: '车号',
editor: this.comboxTruckNo,
width: 85
},
{
sortable: true,
dataIndex: 'FeeDate',
header: '费用日期',
width: 85,
renderer: Ext.util.Format.dateRenderer('Y-m-d'),
editor: {
format: 'Y-m-d',
xtype: 'datefield',
selectOnFocus: true
}
},
{
sortable: true,
dataIndex: 'FeeName',
header: '费用名称',
editor:this.comboxFeeName,
width: 80
},
{
sortable: true,
dataIndex: 'Amount',
header: '金额',
summaryType: 'sum',
width: 70,
editor: {
xtype: 'numberfield', //numberfield textfield
selectOnFocus: true
}
},
{
sortable: true,
dataIndex: 'Remark',
header: '备注',
width: 120,
editor: {
xtype: 'textfield', //numberfield textfield
selectOnFocus: true
}
},
{
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: "没有数据"
})
});
/*
this.gridList.addListener('itemdblclick', function (dataview, record, item, index, e, b) {
this.SelectedRecord = record;
this.OprationStatus = 'edit';
DsOpenEditWin("/TruckMng/MsWlPc/Edit");
}, this);
*/
//#region formSearch
//#region formSearch枚举参照相关
//#endregion
this.formSearch = Ext.widget('form', {
frame: true,
region: 'center',
bodyPadding: 5,
fieldDefaults: {
margins: '2 2 2 2',
labelAlign: 'right',
flex: 1,
labelWidth: 90,
msgTarget: 'qtip'
},
items: [
{//fieldset 1
xtype: 'container',
defaultType: 'textfield',
layout: 'anchor',
defaults: {
anchor: '100%'
},
items: [{
xtype: 'container',
layout: 'hbox',
defaultType: 'textfield',
items: [{
fieldLabel: '提单号',
name: 'PS_MBLNO'
}, {
fieldLabel: '司机姓名',
name: 'PS_DRVNAME'
}, {
fieldLabel: '车牌号',
name: 'PS_TRUCKNO'
}
]
}, {
xtype: 'container',
layout: 'hbox',
defaultType: 'textfield',
items: [{
fieldLabel: '托单号',
name: 'PS_REFBILLNO'
}, {
fieldLabel: '单据号',
name: 'PS_BILLNO'
}, {
fieldLabel: '组织编码',
name: 'OrgCode'
}
]
}, {
xtype: 'container',
layout: 'hbox',
defaultType: 'textfield',
items: [{
fieldLabel: '从派车日期',
format: 'Y-m-d',
xtype: 'datefield',
name: 'PS_EXPDATEBGN'
}, {
fieldLabel: '到派车日期',
format: 'Y-m-d',
xtype: 'datefield',
name: 'PS_EXPDATEEND'
}, { xtype: 'hiddenfield' }
]
}
]//end items(fieldset 1)
}//end fieldset 1
]//end root items
});
//#endregion formSearch
//菜单
var menu_SetFee = new Ext.menu.Menu({
id: 'PriceMenu',
items: [{
text: '设定超重费用',
handler: clickHandler_1
}, {
text: '超重费用取消',
handler: clickHandler_2
}, {
text: '设定重回额外费用',
handler: clickHandler_3
}, {
text: '重回额外费用取消',
handler: clickHandler_4
}]
});
me = this;
function clickHandler_1() {
me.SetFee("超重费", "150", "1");
};
function clickHandler_2() {
me.SetFee("超重费", "150", "0");
};
function clickHandler_3() {
me.SetFee("双背附加费", "600", "1");
};
function clickHandler_4() {
me.SetFee("双背附加费", "600", "0");
};
//查询工具条
this.panelBtn = new Ext.Panel({
region: "north",
tbar: [
{
text: "执行查询",
iconCls: "btnrefresh",
handler: function (button, event) {
this.onRefreshClick(button, event);
},
scope: this
}, '-', {
text: '新建费用',
tooltip: '新建费用',
iconCls: "btnadddetail",
handler: function (button, event) {
this.onAddTruckFeeClick(button, event);
},
scope: this
}, {
text: '删除费用',
tooltip: '删除费用',
iconCls: "btndeletedetail",
handler: function (button, event) {
this.onDelTruckFeeClick(button, event);
},
scope: this
}, {
text: "保存修改",
iconCls: "btnrefresh",
handler: function (button, event) {
this.onSaveClick(button, event);
},
scope: this
}, '-', {
text: "导出Excel",
id: "btnExportExcel",
iconCls: 'btnexportexcel',
handler: function (button, event) {
this.onExportClick(button, event);
},
scope: this
}/*, '-', { text: "批量设置费用", menu: menu_SetFee, scope: this }
, '-', {
id: "btnFeeAuditReject",
text: '驳回提交费用业务',
tooltip: '驳回提交费用业务',
iconCls: "btnrefuse",
handler: function (button, event) {
this.onAuditRefuseClick(button, event);
},
scope: this
}*/
]
});
//布局
this.panelTop = new Ext.Panel({
layout: "border",
region: "north",
height: 125,
items: [this.formSearch, this.panelBtn]
});
Ext.apply(this, {
items: [this.panelTop, this.gridList]
});
this.storeList.on('beforeload', function (store) {
if (!this.checkSearchCondition())
return;
var sql = this.getCondition();
Ext.apply(store.proxy.extraParams, { condition: sql });
}, this);
this.gridList.on('edit', function (editor, e, eOpts) {
this.HaierAfterEdit(editor, e, eOpts);
}, this);
}, //end initUIComponents
HaierAfterEdit: function (editor, e, eOpts) {
if (e.value == e.originalValue) { return; }
function decimal(str, length) {
var _r = round2(str, length);
return (_r);
}
if (e.field == 'DrvCode') {
var records = DsStoreQueryBy(this.storeDrvName, 'DrvCode', e.value);
if (records.getCount() > 0) {
var recorddata = records.getAt(0).data;
e.record.set('DrvName', recorddata.DrvName);
} else {
e.record.set('DrvName', '');
}
}
//OverLoadMil NoLoadMil
if (e.field == 'OverLoadMil' || e.field == 'NoLoadMil') {
var OverLoadMil = e.record.get('OverLoadMil');
var NoLoadMil = e.record.get('NoLoadMil');
var RealMil = Add(OverLoadMil, NoLoadMil);
e.record.set('RealMil', RealMil);
}
},
onAuditRefuseClick: function (button, event) {
var sql = " A.GID in (select bsno from ch_fee where FEESTATUS=6)";
this.storeList.load({
params: { start: 0, limit: this.PageSize, sort: "", condition: sql },
waitMsg: "正在查询数据...",
scope: this
});
},
onRefreshClick: function (button, event) {
if (!this.checkSearchCondition())
return;
var sql = this.getCondition();
this.storeList.load({
//GetDataList(int start, int limit, string sort, string condition)
params: { start: 0, limit: this.PageSize, sort: "", condition: sql },
waitMsg: "正在查询数据...",
scope: this
});
},
getCondition: function () {
var form = this.formSearch.getForm();
var sql = "";
/*
var sqldata = form.getValues();
sql = Ext.JSON.encode(sqldata);
*/
var mblNo = form.findField('PS_MBLNO').getValue();
sql = sql + getAndConSql(sql, mblNo, "A.MblNo like '%" + mblNo + "%'");
var drvName = form.findField('PS_DRVNAME').getValue();
sql = sql + getAndConSql(sql, drvName, " A.DrvName='" + drvName + "'");
var truckNo = form.findField('PS_TRUCKNO').getValue();
sql = sql + getAndConSql(sql, truckNo, " A.TruckNo='" + truckNo + "'");
var pcBillNo = form.findField('PS_BILLNO').getValue();
sql = sql + getAndConSql(sql, pcBillNo, " A.BillNo like '%" + pcBillNo + "%'");
var billNo = form.findField('PS_REFBILLNO').getValue();
sql = sql + getAndConSql(sql, billNo, " A.RefBillNo like '%" + billNo + "%'");
var expDate_Min = form.findField('PS_EXPDATEBGN').getRawValue();
sql = sql + getAndConSql(sql, expDate_Min, " A.ExpDate>='" + expDate_Min + "'");
var expDate_Max = form.findField('PS_EXPDATEEND').getRawValue();
sql = sql + getAndConSql(sql, expDate_Max, " A.ExpDate<='" + expDate_Max + " 23:59:59'");
var orgCode = form.findField('OrgCode').getValue();
sql = sql + getAndConSql(sql, orgCode, "OrgCode like '%" + orgCode + "%'");
return sql;
},
checkSearchCondition: function () {
var form = this.formSearch.getForm();
if (!form.isValid()) {
Ext.Msg.alert('提示', '查询条件赋值错误,请检查。');
return false;
}
return true;
},
OprationSwap: function () {
var ret = new Array();
ret[0] = this.OprationStatus;
ret[1] = this.storeList;
ret[2] = this.SelectedRecord;
ret[3] = this.SelectedRecord.data.REFBILLNO;
ret[4] = "MsRptPcHeadQryIndex";
return ret;
},
onExportClick: function (button, event) {
GridExportExcelPage(this.gridList);
},
onAddTruckFeeClick: function (button, event, type) {
var store = null;
store = this.storeList;
//var truckno = Ext.getCmp('S_TRUCKNO').getValue();
record = Ext.create('MsWlTruckFeemb', {
GID:"",
TruckNo:"",
FeeDate: currdate.format('yyyy-MM-dd'),
FeeName:"管理费",
Amount:"0",
Remark:"",
Inserted:""
});
var _this = this;
var data = record.data;
Ext.Msg.wait('正在保存数据, 请稍侯..');
Ext.Ajax.request({
waitMsg: '正在保存数据...',
url: '/TruckMng/MsWlTruckFee/CreateTruckFee',
scope: this,
async: true,
params: {
data: Ext.JSON.encode(data)
},
callback: function (options, success, response) {
if (success) {
Ext.MessageBox.hide();
var jsonresult = Ext.JSON.decode(response.responseText);
if (jsonresult.Success) {
record = jsonresult.Data;
store.add(record);
cellediting = this.cellEditing;
var n = store.getCount();
cellediting.startEditByPosition({ row: n - 1, column: 2 });
} 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');
}
});
},
onDelTruckFeeClick: function (button, event) {
var selections = this.gridList.getSelectionModel().getSelection();
if (selections.length == 0) {
Ext.Msg.show({ title: '提示', msg: '请先选择路单!', icon: Ext.Msg.INFO, buttons: Ext.Msg.OK });
return;
}
var selectedRecords = [];
selectedRecords = this.gridList.selModel.getSelection();
/*
var candelete = DsTruck.CheckBaoxiaoDelete(selectedRecords);
if (candelete == false) {
return;
}*/
var record = selections[0];
Ext.MessageBox.confirm('提示', '确定删除该记录吗?', function (btn) {
if (btn == 'yes') {
Ext.Msg.wait('正在删除数据...');
Ext.Ajax.request({
waitMsg: '正在删除数据...',
url: '/TruckMng/MsWlTruckFee/DeleteTruckFee',
params: {
data: Ext.JSON.encode(record.data)
},
callback: function (options, success, response) {
if (success) {
var jsonresult = Ext.JSON.decode(response.responseText);
if (jsonresult.Success) {
this.storeList.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);
InitData();
} //onDeleteClick
,
onSaveClick: function (button, event) {
for (var i = 0; i < this.storeList.getCount(); i += 1) {
var record = this.storeList.getAt(i);
if (record.dirty) {
Ext.Ajax.request({
waitMsg: '正在保存数据...',
url: '/TruckMng/MsWlTruckFee/SaveTruckFee',
scope: this,
async: false,
params: {
data: Ext.JSON.encode(record.data)
},
callback: function (options, success, response) {
if (success) {
//Ext.MessageBox.hide();
var jsonresult = Ext.JSON.decode(response.responseText);
if (jsonresult.Success) {
var returnData = jsonresult.Data;
var editp = Ext.create('MsWlTruckFeemb', returnData);
this.storeList.getAt(i).fields.each(function (field) {
if (field.persist) {
name = field.name;
//alert(name + ' -- ' + editp.get(name));
if (name != 'GID')
this.storeList.getAt(i).set(name, editp.get(name));
}
}, this);
this.storeList.getAt(i).commit();
} 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
});
}
}
});
}
}
}
});