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/TMSRPT/TMSRPT_MONTHIndex.js

633 lines
21 KiB
JavaScript

Ext.namespace('DsTruck');
DsTruck.TMSRPT_MONTHIndex = function (config) {
Ext.applyIf(this, config);
this.initUIComponents();
window.DsTruck.TMSRPT_MONTHIndex.superclass.constructor.call(this);
};
Ext.extend(DsTruck.TMSRPT_MONTHIndex, Ext.Panel, {
PageSize: 100,
OprationStatus: null, //仅当弹出界面时使用
SelectedRecord: null,
initUIComponents: function () {
/*
this.storeProperty = Ext.create('DsExt.ux.RefEnumStore', {});
this.storeProperty.load({ params: { enumTypeId: 99033} });
this.comboxProperty = Ext.create('DsExt.ux.RefEnumCombox', {
fieldLabel: '车辆性质',
store: this.storeProperty,
name: 'Property'
});*/
//#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: 1,
width: 500,
labelWidth: 90,
store: this.storeProperty,
queryMode: 'local',
triggerOnClick: false,
name: 'Property',
valueField: 'EnumValueId',
displayField: 'EnumValueName'
});
var _this = this;
this.storeCompany = Ext.create('DsExt.ux.RefTableStore', {
model: 'DsTruckMng.ux.CompanyModel',
proxy: { url: '/CommMng/BasicDataRef/GetcompanyList' }
});
this.storeCompany.load({ params: { condition: "" }
, callback: function (options, success, response) {
if (success) {
var record = Ext.create('DsTruckMng.ux.CompanyModel', {
'gid': '',
'code': '',
'name': ''
});
_this.storeCompany.add(record);
//Ext.getCmp("PS_ORGCODE").setValue("");
}
}
});
this.comboxCompany = Ext.create('DsExt.ux.RefTableCombox', {
fieldLabel: '分公司',
store: this.storeCompany,
name: 'gid',
valueField: 'gid',
displayField: 'name'
});
//#endregion
//定义数据集
this.storeList = Ext.create('Ext.data.Store', {
pageSize: this.PageSize,
model: 'TMSRPT_MONTHmb',
remoteSort: true,
proxy: {
type: 'ajax',
url: '/TruckMng/TMSRPT/MONTH_GetDataList',
reader: {
id: 'GID',
root: 'data',
totalProperty: 'totalCount'
}
}
});
//定义Grid
this.gridList = new Ext.grid.GridPanel({
store: this.storeList,
enableHdMenu: false,
region: 'center',
loadMask: { msg: "数据加载中,请稍等..." },
trackMouseOver: true,
disableSelection: false,
columns: [
{
sortable: true, hidden: true,
dataIndex: 'GID',
header: 'GID',
width: 80
},
{
sortable: true, hidden: true,
dataIndex: 'COMPANYID',
header: 'COMPANYID',
width: 80
},
{
sortable: true,
dataIndex: 'COMPANYNAME',
header: '分公司',
width: 80
},
{
sortable: true,
dataIndex: 'ACCDATE',
header: '统计期间',
width: 80
},
{
sortable: true,
dataIndex: 'EXPDATEBGN',
header: '从..业务日期',
width: 80
},
{
sortable: true,
dataIndex: 'EXPDATEEND',
header: '到..业务日期',
width: 80
},
{
sortable: true,
dataIndex: 'FUELPRICE',
header: '统计油价',
width: 80
},
{
sortable: true,
dataIndex: 'REMARK',
header: '备注',
width: 80
},
{
sortable: true,
dataIndex: 'OP',
header: '制单人',
width: 80
},
{
sortable: true,
dataIndex: 'OPDATE',
header: '制单时间',
width: 80
},
{
sortable: true,
dataIndex: 'AUDITOR',
header: '审核人',
width: 80
},
{
sortable: true,
dataIndex: 'AUDITTIME',
header: '审核时间',
width: 80
},
{
sortable: true, hidden: true,
dataIndex: 'BLSTATUS',
header: 'BLSTATUS',
width: 80
},
{
sortable: true,
dataIndex: 'BLSTATUS_REF',
header: '统计表审核状态',
width: 80
},
{
sortable: true, hidden: true,
dataIndex: 'ISDELETE',
header: 'ISDELETE',
width: 80
},
{
sortable: true, hidden: true,
dataIndex: 'DELETEUSER',
header: 'DELETEUSER',
width: 80
},
{
sortable: true, hidden: true,
dataIndex: 'DELETETIME',
header: 'DELETETIME',
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/TMSRPT/MONTH_Edit');
}, this);
//#region formSearch
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: [this.comboxCompany
, {
fieldLabel: '车牌号',
name: 'TruckNo'
}, {
fieldLabel: '统计期间',
name: 'ACCDATE',
flex: 1,
xtype: 'monthfield',
format: 'Y-m',
editable: false
}, this.comboxProperty
]
}
]//end items(fieldset 1)
}//end fieldset 1
]//end root items
});
//#endregion formSearch
//查询工具条
this.panelBtn = new Ext.Panel({
region: "north",
tbar: [
{
text: "新建",
iconCls: "btnadd",
handler: function (button, event) {
this.OprationStatus = 'add';
DsOpenEditWin('/TruckMng/TMSRPT/MONTH_Edit');
},
scope: this
},
{
text: "删除",
iconCls: "btndelete",
handler: function (button, event) {
this.onDeleteClick(button, event);
},
scope: this
},
'-',
{
text: "执行查询",
iconCls: "btnrefresh",
handler: function (button, event) {
this.onRefreshClick(button, event);
},
scope: this
},
{
text: "重置条件",
iconCls: "btnreset",
handler: function (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: 'btnprint',
menu: [
{ text: "全部",
handler: function (menu, event) {
_this.Print();
}
}, { text: "选择打印",
handler: function (menu, event) {
_this.PrintSelect();
}
}],
scope: this
}
]
});
this.panelTop = new Ext.Panel({
layout: "border",
region: "north",
height: 80,
items: [this.formSearch, this.panelBtn]
});
Ext.apply(this, {
items: [this.panelTop, this.gridList]
});
this.storeList.on('beforeload', function (store) {
var sql = this.getCondition();
Ext.apply(store.proxy.extraParams, { condition: sql });
}, this);
this.storeList.on('edit', function (editor, e, eOpts) {
this.TruckAfterEdit(editor, e, eOpts);
}, this);
//#region 选择load
this.gridList.getSelectionModel().on('select', function (model, record, index) {
//this.CHILDEGID = record.data.GID;
if (record.data.BLSTATUS == "0" || record.data.BLSTATUS == "4") {
//可以提交
Ext.getCmp("StartAudit").enable();
Ext.getCmp("ResetAudit").disable();
Ext.getCmp("Audit").disable();
Ext.getCmp("AuditBack").disable();
} else
if (record.data.BLSTATUS == "1") {
//可以审核 可以驳回
Ext.getCmp("StartAudit").disable();
Ext.getCmp("ResetAudit").enable();
Ext.getCmp("Audit").enable();
Ext.getCmp("AuditBack").enable();
} else
if (record.data.BLSTATUS == "2") {
//可以驳回
Ext.getCmp("StartAudit").disable();
Ext.getCmp("ResetAudit").disable();
Ext.getCmp("Audit").disable();
Ext.getCmp("AuditBack").enable();
}
//
}, this);
//#endregion
}, //end initUIComponents
onRefreshClick: function (button, event) {
var sql = this.getCondition();
this.storeList.load({
params: { start: 0, limit: this.PageSize, sort: '', condition: sql },
waitMsg: "正在查询数据...",
scope: this
});
},
onDeleteClick: 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 record = selections[0];
Ext.MessageBox.confirm('提示', '确定删除该记录吗?', function (btn) {
if (btn == 'yes') {
Ext.Msg.wait('正在删除数据...');
Ext.Ajax.request({
waitMsg: '正在删除数据...',
url: '/TruckMng/TMSRPT/Delete',
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);
}, //onDeleteClick
getCondition: function () {
var form = this.formSearch.getForm();
if (!form.isValid()) {
Ext.Msg.alert('提示', '查询条件赋值错误,请检查。');
return '';
}
var sql = " isnull(isdelete,0)=0 ";
var gid = form.findField('gid').getValue();
sql = sql + getAndConSql(sql, gid, " COMPANYID = '" + gid + "'");
var truckNo = form.findField('TruckNo').getValue();
sql = sql + getAndConSql(sql, truckNo, " ( TruckNo like '%" + truckNo + "%' )");
var ACCDATE = form.findField('ACCDATE').getRawValue();
sql = sql + getAndConSql(sql, ACCDATE, " ( ACCDATE like '%" + ACCDATE + "%' )");
return sql;
},
OprationSwap: function () {
var ret = new Array();
ret[0] = this.OprationStatus;
ret[1] = this.storeList;
ret[2] = this.SelectedRecord;
return ret;
}
, StartAudit: function () {
var selections = this.gridList.getSelectionModel().getSelection();
var bill = "";
for (var i = 0; i < selections.length; i++) {
record = selections[i];
if (record.data.BLSTATUS != "0") {
alert("只能提交未提交的上报单");
}
if (bill == "") {
bill = record.data.GID;
} else {
bill = bill + "," + record.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) {
this.onRefreshClick();
}
},
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 selections = this.gridList.getSelectionModel().getSelection();
var bill = "";
for (var i = 0; i < selections.length; i++) {
record = selections[i];
if (record.data.BLSTATUS != "1") {
alert("只能撤回未审核的上报单");
}
if (bill == "") {
bill = record.data.GID;
} else {
bill = bill + "," + record.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) {
this.onRefreshClick();
}
},
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 selections = this.gridList.getSelectionModel().getSelection();
var bill = "";
for (var i = 0; i < selections.length; i++) {
record = selections[i];
if (record.data.BLSTATUS != "1") {
alert("只能审批通过提交状态的上报单");
}
if (bill == "") {
bill = record.data.GID;
} else {
bill = bill + "," + record.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) {
this.onRefreshClick();
}
},
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 selections = this.gridList.getSelectionModel().getSelection();
var bill = "";
for (var i = 0; i < selections.length; i++) {
record = selections[i];
if (record.data.BLSTATUS != "2") {
alert("只能驳回已提交或已审核的上报单");
}
if (bill == "") {
bill = record.data.GID;
} else {
bill = bill + "," + record.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) {
this.onRefreshClick();
}
},
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
}
});