Ext.namespace('Shipping'); Shipping.MsChWorkIndex = function (config) { Ext.applyIf(this, config); this.initUIComponents(); window.Shipping.MsChWorkIndex.superclass.constructor.call(this); }; Ext.extend(Shipping.MsChWorkIndex, Ext.Panel, { PageSize: 30, OprationStatus: null, //仅当弹出界面时使用 SelectedRecord: null, sqlcontext: '', sortfield: '', sortdire: '', initUIComponents: function () { //定义数据集 this.formname = "MsChWorkIndex"; //页面名称 this.sqlcontext = ""; this.worksql = getUrlParam('worksql'); this.StoreOpRange = Ext.create('DsExt.ux.RefTableStore', { model: 'MsOP', proxy: { url: '/MvcShipping/MsBaseInfo/GetOpRang' } }); this.StoreOpRange.load({ params: { optype: "modPaySettleAppList"} }); this.storeList = Ext.create('Ext.data.Store', { pageSize: this.PageSize, model: 'MsChWork', remoteSort: true, proxy: { type: 'ajax', url: '/Account/Chfee_payapplication/GetWorkList', reader: { id: 'BILLNO', root: 'data', totalProperty: 'totalCount' } } }); this.GridCheckBoxModel = Ext.create('Ext.selection.CheckboxModel'); this.Pagenum = Ext.create('Ext.form.field.Number', { name: 'bottles', fieldLabel: Zi.LAN.NumberOfpage,//每页记录数 labelAlign: 'right', value: this.PageSize, maxValue: 100000, width: 180, minValue: 0, listeners: { specialkey: function (field, e) { if (e.getKey() == e.ENTER) { _this.onRefreshClick(); } } } }); this.initgirdcolums = [{ sortable: true, dataIndex: 'BILLNO', header: '派工单号', //申请单号 width: 120 }, { sortable: true, dataIndex: 'BILLSTATUS', header: Zi.LAN.status, //状态 width: 60 }, { sortable: true, dataIndex: 'SETTLETIME', header:'申请日期', //结算单位 width: 120 }, { sortable: true, dataIndex: 'APPLYTIME', header:'录入日期', //申请日期 width: 120 }, { sortable: true, dataIndex: 'APPLICANTREF', header: Zi.LAN.Applicant, //申请人 width: 100 }, { sortable: true, dataIndex: 'REMARK', header:'备注', //申请支付日期 width: 200 } ]; this.girdcolums = this.initgirdcolums; //定义Grid this.gridList = new Ext.grid.GridPanel({ store: this.storeList, enableHdMenu: false, region: 'center', loadMask: { msg: Zi.LAN.LoadData }, //数据加载中,请骚等 trackMouseOver: true, selModel: this.GridCheckBoxModel, disableSelection: false, viewConfig: { enableTextSelection: true }, columns: this.girdcolums, // paging bar on the bottom bbar: [Ext.create('Ext.PagingToolbar', { store: this.storeList, displayInfo: true, displayMsg: Zi.LAN.FenYe, //当前显示条数据 emptyMsg: Zi.LAN.Nodata//没有数据 }), this.Pagenum] }); this.gridList.addListener('itemdblclick', function (dataview, record, item, index, e, b) { this.SelectedRecord = record; this.OprationStatus = 'edit'; DsOpenEditWin('/Account/Chfee_payapplication/WorkEdit'); }, this); this.girdcolums = DsTruck.GetGridPanel(USERID, this.formname, this.girdcolums, 1); //使用者id,表名,中间column数组,跳过一开始的几列 this.girdcolums.unshift(new Ext.grid.RowNumberer()); this.gridList.reconfigure(this.storeList, this.girdcolums); this.gridList.addListener('sortchange', function (ct, column, direction, eOpts) { this.sortfield = column.dataIndex; this.sortdire = direction; }, this); //#region formSearch //#region formSearch枚举参照相关 _this = this; this.storeBILLSTATUS = Ext.create('Ext.data.Store', { fields: ['OpLb'] }); this.storeBILLSTATUS.add({ "OpLb": "全部" }); this.storeBILLSTATUS.add({ "OpLb": "新建" }); this.storeBILLSTATUS.add({ "OpLb": "提交审核" }); this.comboxBILLSTATUS = Ext.create('DsExt.ux.RefEnumCombox', { fieldLabel:'状态', //申请单状态 forceSelection: true, valueField: 'OpLb', displayField: 'OpLb', store: this.storeBILLSTATUS, name: 'BILLSTATUS' }); //#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: 'BsNo', enableKeyEvents: true, listeners: { specialkey: function (field, e) { if (e.getKey() == e.ENTER) { _this.onRefreshClick(); } } } }, { fieldLabel: '申请单号', //申请编号 name: 'ShenNo', enableKeyEvents: true, listeners: { specialkey: function (field, e) { if (e.getKey() == e.ENTER) { _this.onRefreshClick(); } } } },this.comboxBILLSTATUS, { fieldLabel: '申请日期', format: 'Y-m-d', xtype: 'datefield', name: 'ExpDateBgn', enableKeyEvents: true, listeners: { specialkey: function (field, e) { if (e.getKey() == e.ENTER) { _this.onRefreshClick(); } } } }, { fieldLabel:'申请日期', format: 'Y-m-d', xtype: 'datefield', name: 'ExpDateEnd', enableKeyEvents: true, listeners: { specialkey: function (field, e) { if (e.getKey() == e.ENTER) { _this.onRefreshClick(); } } } }, { xtype: 'button', width: 90, text: Zi.LAN.ExecuteQuery, //执行查询 iconCls: "btnrefresh", handler: function (button, event) { this.onRefreshClick(button, event); }, scope: this }, { xtype: 'button', width: 90, text: Zi.LAN.AdvancedSearch, //高级查询 iconCls: "btnmore", handler: function (button, event) { var sql = this.getCondition(); var winAccess = new Shipping.DsQuery({ }); winAccess.StoreList = this.storeList; winAccess.formname = this.formname; winAccess.condition = sql; winAccess.show(); return; }, scope: this } ] } ]//end items(fieldset 1) }//end fieldset 1 ]//end root items }); //#endregion formSearch //查询工具条 this.panelBtn = new Ext.Panel({ region: "north", tbar: [ { text: Zi.LAN.xnew, //新建 iconCls: "btnadd", handler: function (button, event) { this.OprationStatus = 'add'; DsOpenEditWin('/Account/Chfee_payapplication/WorkEdit'); }, scope: this }, '-', { text: Zi.LAN.ResetCondition, //重置条件 iconCls: "btnreset", handler: function (button, event) { var form = this.formSearch.getForm(); form.reset(); }, scope: this }, '-', { text: Zi.LAN.tjshe, //提交审核 tooltip: Zi.LAN.tjshe, handler: function (button, event) { this.onSubmitAuditClick(); }, scope: this }, '-', { text: Zi.LAN.cxtijiao, //撤销提交 tooltip: Zi.LAN.cxtijiao, handler: function (button, event) { this.onSubmitAuditBackClick(); }, scope: this }, '-', { text: Zi.LAN.delete1, //删除 id: 'btndelete', iconCls: "btndelete", handler: function (button, event) { this.onDeleteClick(button, event); }, scope: this }, '-', { text: Zi.LAN.ExportExcel, //导出Excel id: "btnExportExcel", iconCls: 'btnexportexcel', handler: function (button, event) { this.onExportClick(button, event); }, scope: this }, '-', { text: Zi.LAN.Saveliststyle, //保存列表样式 id: "btntest", menu: [ { text: Zi.LAN.Save, //保存 handler: function (button, event) { this.girdcolums = DsTruck.SaveGridPanel(USERID, _this.formname, _this.gridList.columns, _this.girdcolums, 1, true); } }, { text: Zi.LAN.Initialization, //初始化 handler: function (menu, event) { _this.girdcolums = DsTruck.SaveGridPanel(USERID, _this.formname, _this.gridList.columns, _this.initgirdcolums, 1, true); } }], 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.sqlcontext; Ext.apply(store.proxy.extraParams, { condition: sql }); }, this); }, //end initUIComponents onRefreshClick: function (button, event) { var sql = this.getCondition(); this.sqlcontext = sql; this.PageSize = this.Pagenum.getValue(); this.storeList.pageSize = this.PageSize; this.storeList.load({ params: { start: 0, limit: this.PageSize, sort: '', condition: sql }, waitMsg: Zi.LAN.onselect, //正在查询数据 scope: this }); }, onDsQuery: function () { var sql = this.sqlcontext; this.PageSize = this.Pagenum.getValue(); this.storeList.pageSize = this.PageSize; this.storeList.load({ params: { start: 0, limit: this.PageSize, sort: '', condition: sql }, waitMsg: Zi.LAN.onselect, //正在查询数据 scope: this }); }, onDeleteClick: function (button, event) { var selections = this.gridList.getSelectionModel().getSelection(); if (selections.length == 0) {//提示 请先选择单据 Ext.Msg.show({ title: Zi.LAN.Prompt, msg: Zi.LAN.SelectDanju, icon: Ext.Msg.INFO, buttons: Ext.Msg.OK }); return; } var record = selections[0]; var billstatus = record.data.BILLSTATUS; if (billstatus != '新建' && billstatus != '提交审核') { // 提示 当前状态无法删除此单据 Ext.Msg.show({ title: Zi.LAN.Prompt, msg: Zi.LAN.nodelete, icon: Ext.Msg.INFO, buttons: Ext.Msg.OK }); return; } //提示', '确定删除该记录吗? Ext.MessageBox.confirm(Zi.LAN.Prompt, Zi.LAN.suredelete, function (btn) { if (btn == 'yes') {//正在删除数据... Ext.Msg.wait(Zi.LAN.nowdelete); Ext.Ajax.request({ waitMsg: Zi.LAN.nowdelete, url: '/Account/Chfee_payapplication/DeleteWork', 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); //Zi.LAN.Prompt, msg: '删除成功!' Ext.Msg.show({ title: Zi.LAN.Prompt, msg: Zi.LAN.truedelete, icon: Ext.Msg.INFO, buttons: Ext.Msg.OK }); } else { Ext.Msg.show({ title: Zi.LAN.Error, msg: jsonresult.Message, icon: Ext.Msg.ERROR, buttons: Ext.Msg.OK }); } } }, failure: function (response, options) {//警告', msg: '服务器响应出错,请重试' Ext.Msg.show({ title: Zi.LAN.Caveat, msg: Zi.LAN.FuWuQiError, icon: Ext.Msg.INFO, buttons: Ext.Msg.OK }); }, success: function (response, options) { }, scope: this }); //end Ext.Ajax.request } }, this); }, //onDeleteClick onSubmitAuditClick: function () { var selections = this.gridList.getSelectionModel().getSelection(); if (selections.length == 0) {//Zi.LAN.Prompt, msg: Zi.LAN.SelectDanju, Ext.Msg.show({ title: Zi.LAN.Prompt, msg: Zi.LAN.SelectDanju, icon: Ext.Msg.INFO, buttons: Ext.Msg.OK }); return; } var bodyAddDatas = []; var BILLNOStr = ''; for (var i = 0; i < selections.length; i++) { var rec = selections[i]; var BILLNO = rec.data.BILLNO; if (rec.data.BILLSTATUS == '新建') { bodyAddDatas.push(rec); } } _this = this; if (bodyAddDatas.length == 0) { } else { var jsonbodyAddDatas = ConvertRecordsToJsonAll(bodyAddDatas); Ext.Ajax.request({// '正在添加数据...', waitMsg: Zi.LAN.addnumnow, url: '/Account/Chfee_payapplication/SubmitAuditWorkList', params: { bills: jsonbodyAddDatas }, callback: function (options, success, response) { if (success) { var result = Ext.JSON.decode(response.responseText); if (!result.Success) { Ext.Msg.show({// Zi.LAN.Prompt title: Zi.LAN.Prompt, msg: result.Message, icon: Ext.MessageBox.ERROR, buttons: Ext.Msg.OK }); return; } else { _this.onRefreshClick(); } } else {//请求出现错误,请重试' Ext.MessageBox.alert(Zi.LAN.FuWuQiError, response.responseText); } }, scope: this }); } }, onSubmitAuditBackClick: function () { var selections = this.gridList.getSelectionModel().getSelection(); if (selections.length == 0) {//提示', msg: '请先选择单据! Ext.Msg.show({ title: Zi.LAN.Prompt, msg: Zi.LAN.SelectDanju, icon: Ext.Msg.INFO, buttons: Ext.Msg.OK }); return; } var bodyAddDatas = []; for (var i = 0; i < selections.length; i++) { var rec = selections[i]; var BILLNO = rec.data.BILLNO; if (rec.data.BILLSTATUS == '提交审核') { bodyAddDatas.push(rec); } } _this = this; if (bodyAddDatas.length == 0) { } else { var jsonbodyAddDatas = ConvertRecordsToJsonAll(bodyAddDatas); Ext.Ajax.request({//正在添加数据.. waitMsg: Zi.LAN.addnumnow, url: '/Account/Chfee_payapplication/SubmitAuditBackWorkList', params: { bills: jsonbodyAddDatas }, callback: function (options, success, response) { if (success) { var result = Ext.JSON.decode(response.responseText); if (!result.Success) { Ext.Msg.show({//提示 title: Zi.LAN.Prompt, msg: result.Message, icon: Ext.MessageBox.ERROR, buttons: Ext.Msg.OK }); return; } else { _this.onRefreshClick(); } } else {//请求出现错误,请重试 Ext.MessageBox.alert(Zi.LAN.FuWuQiError, response.responseText); } }, scope: this }); }; }, getCondition: function () { var form = this.formSearch.getForm(); if (!form.isValid()) {//提示', '查询条件赋值错误,请检查 Ext.Msg.alert(Zi.LAN.Prompt, Zi.LAN.SelectError); return ''; } var sql = ''; var customNo = form.findField('BsNo').getValue(); sql = sql + getAndConSql(sql, customNo, "BILLNO like '%" + customNo + "%'"); var ShenNo = form.findField('ShenNo').getValue(); sql = sql + getAndConSql(sql, ShenNo, " BILLNO in (select WORKBILLNO from ch_fee_payapplication where BILLNO like '%" + ShenNo + "%') "); var expDateBgn = form.findField('ExpDateBgn').getRawValue(); sql = sql + getAndConSql(sql, expDateBgn, "APPLYTIME >='" + expDateBgn + "'"); var expDateEnd = form.findField('ExpDateEnd').getRawValue(); sql = sql + getAndConSql(sql, expDateEnd, "APPLYTIME <='" + expDateEnd + "'"); var BILLSTATUS = form.findField('BILLSTATUS').getValue(); sql = sql + getAndConSql(sql, BILLSTATUS, "BILLSTATUS= " + BILLSTATUS + ""); return sql; }, OprationSwap: function () { var ret = new Array(); ret[0] = this.OprationStatus; ret[1] = this.storeList; ret[2] = this.SelectedRecord; return ret; }, onExportClick: function (button, event) { GridExportExcelPage(this.gridList); } });