Ext.namespace('Shipping'); Shipping.MsChInvoiceIndex = function (config) { Ext.applyIf(this, config); this.initUIComponents(); window.Shipping.MsChInvoiceIndex.superclass.constructor.call(this); }; Ext.extend(Shipping.MsChInvoiceIndex, Ext.Panel, { PageSize: 30, OprationStatus: null, //仅当弹出界面时使用 SelectedRecord: null, sqlcontext: '', sortfield: '', sortdire: '', initUIComponents: function () { this.formname = "formChInvoiceIndex"; //页面名称 this.StoreLockOp = Ext.create('DsExt.ux.RefTableStore', { model: 'MsFeeOP', proxy: { url: '/MvcShipping/MsBaseInfo/GetOpIDRang' } }); this.StoreLockOp.load({ params: { optype: "modInvLock"} }); this.StoreUnLockOp = Ext.create('DsExt.ux.RefTableStore', { model: 'MsFeeOP', proxy: { url: '/MvcShipping/MsBaseInfo/GetOpIDRang' } }); this.StoreUnLockOp.load({ params: { optype: "modInvUnLock"} }); this.StoreOpRange = Ext.create('DsExt.ux.RefTableStore', { model: 'MsFeeOP', proxy: { url: '/MvcShipping/MsBaseInfo/GetOpIDRang' } }); this.StoreOpRange.load({ params: { optype: "modInvoiceManagement"} }); //定义数据集 this.storeList = Ext.create('Ext.data.Store', { pageSize: this.PageSize, model: 'MsChInvoice', remoteSort: true, proxy: { type: 'ajax', url: '/Account/Chfee_invoice/GetDataList', reader: { id: 'BILLNO', root: 'data', totalProperty: 'totalCount' } } }); //定义Grid _this = this; 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: 'INVOICETYPEREF', header: Zi.LAN.INVOICETYPEREF, width: 120 }, { sortable: true, dataIndex: 'BILLSTATUS', header: Zi.LAN.BILLSTATUS, width: 60, renderer: function (value, meta, record) { return record.data.BILLSTATUSREF; } }, { sortable: true, dataIndex: 'BILLNO', header: Zi.LAN.BILLNO, width: 120 }, { sortable: true, dataIndex: 'INVOICENO', header: Zi.LAN.INVOICENO, width: 120 }, { sortable: true, dataIndex: 'CUSTOMERNAME', header: Zi.LAN.INVCUSTOMERNAME, width: 120 }, { sortable: true, dataIndex: 'INVOICECUSTNAME', header: Zi.LAN.INVOICECUSTNAME, width: 160 }, { sortable: true, dataIndex: 'CURRENCY', header: Zi.LAN.Currency, width: 60 }, { sortable: true, dataIndex: 'INVAMOUNT', header: Zi.LAN.INVAMOUNT, align: 'right', width: 100, summaryType: 'sum', align: 'right', summaryRenderer: function (value, cellmeta, record, rowIndex, columnIndex, store) { var delvalu = _this.sumDelInv(record); value = Add(value, -delvalu); value = usMoney(value, 2, '', true); return value; }, renderer: function (value, cellmeta, record, rowIndex, columnIndex, store) { try { var lsValue = usMoney(value, 2, '', false); if (lsValue != "NaN") { value = lsValue; if (parseFloat(lsValue) < 0) { return '' + lsValue + ''; } } else { return value; } } catch (e) { return value; } return value; } }, { sortable: true, dataIndex: 'AMOUNT', header: Zi.LAN.APPLYAMOUNT, align: 'right', width: 100, summaryType: 'sum', align: 'right', summaryRenderer: function (value, cellmeta, record, rowIndex, columnIndex, store) { var delvalu = _this.sumDelInv(record); value = Add(value, -delvalu); value = usMoney(value, 2, '', true); return value; }, renderer: function (value, cellmeta, record, rowIndex, columnIndex, store) { try { var lsValue = usMoney(value, 2, '', false); if (lsValue != "NaN") { value = lsValue; if (parseFloat(lsValue) < 0) { return '' + lsValue + ''; } } else { return value; } } catch (e) { return value; } return value; } }, { sortable: true, dataIndex: 'ISNEEDPRINT', header: Zi.LAN.ISNEEDPRINT, width: 60 }, { sortable: true, dataIndex: 'NOSTL', header: Zi.LAN.NOSTL , width: 120 }, { sortable: true, dataIndex: 'RECVCURR', header: Zi.LAN.RECVCURR, width: 60 }, { sortable: true, dataIndex: 'FEEAMOUNT', header: Zi.LAN.FEEAMOUNT, width: 120, renderer: function (value, cellmeta, record, rowIndex, columnIndex, store) { try { var lsValue = usMoney(value, 2, '', false); if (lsValue != "NaN") { value = lsValue; if (parseFloat(lsValue) < 0) { return '' + lsValue + ''; } } else { return value; } } catch (e) { return value; } return value; } }, { sortable: true, dataIndex: 'INVOICEMAKETIME', header: Zi.LAN.INVDATE, width: 100 }, { sortable: true, dataIndex: 'OPERATORNAME', header: Zi.LAN.OPERATORNAME, width: 100 }, { sortable: true, dataIndex: 'APPLICANT', header: Zi.LAN.APPLICANTNAME, width: 100 }, { sortable: true, dataIndex: 'APPLICANTDEPT', header: Zi.LAN.APPLICANTDEPT, width: 100 }, { sortable: true, dataIndex: 'SALECORP', header: Zi.LAN.COMPANYNAME , width: 100 }, { sortable: true, dataIndex: 'INVOICECATEGORYREF', header: Zi.LAN.INVOICECATEGORYREF, width: 80 }, { sortable: true, dataIndex: 'REMARK', header: Zi.LAN.REMARK, width: 160 }, { sortable: true, dataIndex: 'EXCHANGERATE', header: Zi.LAN.TAXRATE, width: 80 }, { sortable: true, dataIndex: 'TAX', header: Zi.LAN.TAX, width: 80, summaryType: 'sum', align: 'right', summaryRenderer: function (value, cellmeta, record, rowIndex, columnIndex, store) { var delvalu = _this.sumDelInv(record); value = Add(value, -delvalu); value = usMoney(value, 2, '', true); return value; }, }, { sortable: true, dataIndex: 'NOTAXAMOUNT', header: Zi.LAN.NOTAXAMOUNT , width: 80, renderer: function (value, meta, record) { var notaxamount = (parseFloat(record.data.INVAMOUNT).add(parseFloat(-record.data.TAX))).toFixed(2) try { var lsValue = usMoney(notaxamount, 2, '', false); if (lsValue != "NaN") { value = lsValue; if (parseFloat(lsValue) < 0) { return '' + lsValue + ''; } } else { return lsValue; } } catch (e) { return notaxamount; } return notaxamount; } }, { sortable: true, dataIndex: 'ISDELETE', header: Zi.LAN.ISDELETE, width: 80 }, { sortable: true, dataIndex: 'DZSTATUS', header: Zi.LAN.DZSTATUS, width: 80 }, { sortable: true, dataIndex: 'DELOPERATORNAME', header: Zi.LAN.DELOPERATORNAME, width: 100 }, { sortable: true, dataIndex: 'DELETETIME', header: Zi.LAN.DELETETIME, width: 100 }, { sortable: true, dataIndex: 'LOCKUSER', header: Zi.LAN.LOCKUSER, width: 100 }, { sortable: true, dataIndex: 'APPLYTIME', header: Zi.LAN.LOCKTIME, width: 100 }, { sortable: true, dataIndex: 'INVSHENNO', header: Zi.LAN.INVSHENNO , width: 100 }, { sortable: true, dataIndex: 'VOUCHERNO', header: Zi.LAN.VOUCHERNO, width: 0 }, { sortable: true, dataIndex: 'VOUNO', header: Zi.LAN.VOUNO , width: 0 }, { sortable: true, dataIndex: 'CREATEUSERREF', header: Zi.LAN.INPUTBY, width: 100 }, { sortable: true, dataIndex: 'ACTUALCUSTOMERNAME', header: Zi.LAN.ACTUALCUSTOMERNAME , width: 100 } ]; this.CheckIsDelete = new Ext.form.Checkbox({ fieldLabel: Zi.LAN.CheckIsDelete, checked: false, width: 160, listeners: { change: function (field, e) { _this.onRefreshClick(); } } }); this.girdcolums = this.initgirdcolums; this.GridCheckBoxModel = Ext.create('Ext.selection.CheckboxModel'); this.gridList = new Ext.grid.GridPanel({ store: this.storeList, enableHdMenu: false, region: 'center', loadMask: { msg: Zi.LAN.LoadData }, trackMouseOver: true, disableSelection: false, selModel: this.GridCheckBoxModel, viewConfig: { enableTextSelection: true, autoFill: true, getRowClass: function (record, rowIndex, rowParams, store) { var ISDELETE = record.get('ISDELETE'); if (ISDELETE == 'True') return 'feestatus_Del'; if (record.get('PTORRED') == "2") return 'text_red'; if (record.get('SETRED') == "1" || record.get('SETRED') == "True") return 'text_blue'; var BILLSTATUSREF = record.get('BILLSTATUSREF'); if (BILLSTATUSREF == '已锁定') return 'feestatus_settle'; } }, features: [{ ftype: 'summary'//Ext.grid.feature.Summary表格汇总特性 }], 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.CheckIsDelete] }); this.gridList.addListener('itemdblclick', function (dataview, record, item, index, e, b) { this.SelectedRecord = record; this.OprationStatus = 'edit'; if (record.data.INVOICETYPE == 2) DsOpenEditWin('/Account/Chfee_invoice/AppEdit', record.data.BILLNO); else DsOpenEditWin('/Account/Chfee_invoice/BLEdit', record.data.BILLNO); }, 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 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: Zi.LAN.INVCUSTOMERNAME, store: this.storeCompany, labelWidth: 60, name: 'companyid', valueField: 'gid', displayField: 'name' }); this.storeCust = Ext.create('DsExt.ux.RefTableStore', { model: 'DsShipping.ux.CustomRefModel', proxy: { url: '/CommMng/BasicDataRef/GetCustomRefList' } }); this.storeCust.load({ params: { condition: ""} }); this.comboxCust = Ext.create('DsExt.ux.RefTableCombox', { fieldLabel: Zi.LAN.INVOICECUSTNAME, store: this.storeCust, labelWidth: 60, // forceSelection: true, name: 'CustName', valueField: 'CustName', displayField: 'CodeAndName', enableKeyEvents: true, listeners: { keyup: function (field, e) { if (e.getKey() == e.ENTER) { _this.onRefreshClick(); } } } }); this.formSearch = Ext.widget('form', { frame: true, region: 'center', bodyPadding: 5, fieldDefaults: { margins: '2 2 2 2', labelAlign: 'right', flex: 1, labelWidth: 50, msgTarget: 'qtip' }, items: [ {//fieldset 1 xtype: 'container', defaultType: 'textfield', layout: 'anchor', defaults: { anchor: '100%' }, items: [{ xtype: 'container', layout: 'hbox', defaultType: 'textfield', items: [{ fieldLabel: Zi.LAN.BIANHAO, name: 'BsNo', enableKeyEvents: true, listeners: { specialkey: function (field, e) { if (e.getKey() == e.ENTER) { _this.onRefreshClick(); } } } }, { fieldLabel: Zi.LAN.INVOICENO, name: 'InvNo', enableKeyEvents: true, listeners: { specialkey: function (field, e) { if (e.getKey() == e.ENTER) { _this.onRefreshClick(); } } } }, { fieldLabel: Zi.LAN.INVSHENNO, name: 'ShenNo', labelWidth: 60, enableKeyEvents: true, listeners: { specialkey: function (field, e) { if (e.getKey() == e.ENTER) { _this.onRefreshClick(); } } } }, { fieldLabel: Zi.LAN.INVOICECUSTNAME, name: 'CustName', labelWidth: 60, enableKeyEvents: true, listeners: { specialkey: function (field, e) { if (e.getKey() == e.ENTER) { _this.onRefreshClick(); } } } }, this.comboxCompany , { fieldLabel: Zi.LAN.FMINVDATE, format: 'Y-m-d', xtype: 'datefield', labelWidth: 65, name: 'ExpDateBgn', enableKeyEvents: true, listeners: { specialkey: function (field, e) { if (e.getKey() == e.ENTER) { _this.onRefreshClick(); } } } }, { fieldLabel: Zi.LAN.TOINVDATE , format: 'Y-m-d', xtype: 'datefield', labelWidth: 65, 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.FREEINVOICE, iconCls: "btnadd", handler: function (button, event) { this.OprationStatus = 'add'; DsOpenEditWin('/Account/Chfee_invoice/BLEdit', Zi.LAN.FREEINVOICE); }, scope: this }, '-', { text: Zi.LAN.COPYADD, iconCls: "btnadd", handler: 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]; this.SelectedRecord = record; this.OprationStatus = 'copyadd'; if (record.data.INVOICETYPE == 2) DsOpenEditWin('/Account/Chfee_invoice/AppEdit', Zi.LAN.SHENINVOICE); else DsOpenEditWin('/Account/Chfee_invoice/BLEdit', Zi.LAN.FREEINVOICE); }, scope: this }, '-', { text: Zi.LAN.SHENINVOICE, iconCls: "btnadd", handler: function (button, event) { this.OprationStatus = 'add'; DsOpenEditWin('/Account/Chfee_invoice/AppEdit', Zi.LAN.SHENINVOICE); }, scope: this }, { text: Zi.LAN.ResetCondition, iconCls: "btnreset", handler: function (button, event) { var form = this.formSearch.getForm(); form.reset(); }, scope: this }, '-', { text: Zi.LAN.delete1, iconCls: "btndelete", id: "btndelete", handler: function (button, event) { this.onDeleteClick(button, event); }, scope: this }, '-', { text: Zi.LAN.ZUOFEI, iconCls: "btndelete", id: "btndeleteUp", menu: [ { text: Zi.LAN.ZUOFEI, handler: function (menu, event) { _this.onDeleteUpClick(menu, event); } }, { text: Zi.LAN.CANCELZUOFEI, handler: function (menu, event) { _this.onCancelDeleteUpClick(menu, event); } }], scope: this }, '-', { text: Zi.LAN.TIJIAOSUODING , tooltip: Zi.LAN.TIJIAOSUODING , id: 'btnSubmitAudit', handler: function (button, event) { this.onSubmitAuditClick(); }, scope: this }, '-', { text: Zi.LAN.CANCELSUODING, tooltip: Zi.LAN.CANCELSUODING, id: 'btnSubmitAuditBack', handler: function (button, event) { this.onSubmitAuditBackClick(); }, scope: this }, '-', { text: Zi.LAN.print , tooltip: Zi.LAN.print , menu: [ { text: Zi.LAN.printList , handler: function (menu, event) { _this.Print(menu, event, 1); } }, { text: Zi.LAN.printSelect, handler: function (menu, event) { _this.PrintSelect(menu, event, 1); } }], scope: this }, '-', { text: Zi.LAN.ExportExcel, 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 }, '-', { text: Zi.LAN.onExpInvClick, iconCls: 'btnexportexcel', handler: function (button, event) { _this.onExpInvClick(); }, scope: this }, '-', { text: Zi.LAN.onExpDZInvClick, iconCls: 'btnexportexcel', handler: function (button, event) { _this.onExpDZInvClick(); }, scope: this }, '-', { text: Zi.LAN.onExpRYTInvClick, iconCls: 'btnexportexcel', handler: function (button, event) { _this.onExpRYTInvClick(); }, 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: _this.sqlcontext }); }, this); var sql = ' isnull(cm.billstatus,0)=0 '; 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.NowSelect, scope: this }); this.CheckSaveQuery = new Ext.form.Checkbox({ fieldLabel: Zi.LAN.CheckSaveQuery, checked: true, width: 20 }); LoadQueryData(this.formname, this.formSearch, this.CheckSaveQuery); this.gridList.getSelectionModel().on('select', function (model, record, index) { var ISNEEDPRINT = record.data.ISNEEDPRINT; var btnEDeleteDetail = Ext.getCmp('btndelete'); var btnEDeleteUpDetail = Ext.getCmp('btndeleteUp'); var op = record.data.OPERATOR; var bsstatus = record.data.BILLSTATUS; var records = DsStoreQueryBy(this.StoreOpRange, 'OPID', op); if (records.getCount() > 0) { if (bsstatus == 1) { btnEDeleteDetail.disable(); btnEDeleteUpDetail.disable(); } else { btnEDeleteDetail.enable(); btnEDeleteUpDetail.enable(); } } else { btnEDeleteDetail.disable(); btnEDeleteUpDetail.disable(); } var btnESubmitAudit = Ext.getCmp('btnSubmitAudit'); var btnESubmitAuditBack = Ext.getCmp('btnSubmitAuditBack'); var records = DsStoreQueryBy(this.StoreLockOp, 'OPID', op); if (records.getCount() > 0) { if (bsstatus == 1) { btnESubmitAudit.disable(); } else { btnESubmitAudit.enable(); } } else { btnESubmitAudit.disable(); } var records = DsStoreQueryBy(this.StoreUnLockOp, 'OPID', op); if (records.getCount() > 0) { if (bsstatus == 1) { btnESubmitAuditBack.enable(); } else { btnESubmitAuditBack.disable(); } } else { btnESubmitAuditBack.disable(); } }, this); //#region 下载窗体 this.formDownloadShow = Ext.widget('form', { frame: true, region: 'center', height: 100, 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', id: 'downloadfile', defaults: { anchor: '100%' }, items: [{ xtype: 'label', html: '', width: 120, text: '' } ]//end items(fieldset 1) }//end fieldset 1 ]//end root items }); me = this; this.winDownloadShow = Ext.create('Ext.window.Window', { title: Zi.LAN.DowloadFile, width: 450, height: 120, //plain : true, iconCls: "addicon", resizable: false, // 是否可以拖动 // draggable:false, collapsible: true, // 允许缩放条 closeAction: 'close', closable: true, modal: 'true', buttonAlign: "center", bodyStyle: "padding:0 0 0 0", items: [this.formDownloadShow], buttons: [{ text: Zi.LAN.close, minWidth: 70, handler: function () { me.winDownloadShow.close(); } }] }); //#endregion }, //end initUIComponents onRefreshClick: function (button, event) { saveQuerySetting(this.formname, this.formSearch, true, true); 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.NowSelect, scope: this }); }, onDsQuery: function (button, event) { 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.NowSelect, scope: this }); }, sumDelInv: function (Fieldname) { var result = 0; if (this.CheckIsDelete.checked == true) return 0; for (i = 0; i < this.storeList.getCount(); i += 1) { var memberyf = this.storeList.getAt(i); if (memberyf.data.ISDELETE == 'True') { result = Add(result, memberyf.get(Fieldname)); } }; return result; }, 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 ISNEEDPRINT = record.data.ISNEEDPRINT; var ISNEEDFEE = record.data.ISNEEDFEE; var VOUCHERNO = record.data.VOUCHERNO; var ISDELETE = record.data.ISDELETE; var BILLSTATUS = record.data.BILLSTATUS; if (BILLSTATUS == 1) { Ext.Msg.show({ title: Zi.LAN.Prompt, msg: Zi.LAN.YISUODING, icon: Ext.Msg.INFO, buttons: Ext.Msg.OK }); return; } if (VOUCHERNO != '') { Ext.Msg.show({ title: Zi.LAN.Prompt, msg: Zi.LAN.YISHENGCHENGPINGZHENG, icon: Ext.Msg.INFO, buttons: Ext.Msg.OK }); return; } if (ISDELETE == 'True') { Ext.Msg.show({ title: Zi.LAN.Prompt, msg: Zi.LAN.YIZUOFEI, icon: Ext.Msg.INFO, buttons: Ext.Msg.OK }); return; } if (ISNEEDFEE == 'True') { Ext.Msg.show({ title: Zi.LAN.Prompt, msg: Zi.LAN.YIJIESUAN, icon: Ext.Msg.INFO, buttons: Ext.Msg.OK }); return; } Ext.MessageBox.confirm(Zi.LAN.Prompt, Zi.LAN.suredelete, function (btn) { if (btn == 'yes') { Ext.Ajax.request({ waitMsg: Zi.LAN.nowdelete, url: '/Account/Chfee_invoice/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: 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) { 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 onDeleteUpClick: 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 ISNEEDPRINT = record.data.ISNEEDPRINT; var ISNEEDFEE = record.data.ISNEEDFEE; var VOUCHERNO = record.data.VOUCHERNO; var ISDELETE = record.data.ISDELETE; var BILLSTATUS = record.data.BILLSTATUS; if (BILLSTATUS == 1) { Ext.Msg.show({ title: Zi.LAN.Prompt, msg: Zi.LAN.YISUODING, icon: Ext.Msg.INFO, buttons: Ext.Msg.OK }); return; } if (VOUCHERNO != '') { Ext.Msg.show({ title: Zi.LAN.Prompt, msg: Zi.LAN.YISHENGCHENGPINGZHENG, icon: Ext.Msg.INFO, buttons: Ext.Msg.OK }); return; } if (ISDELETE == 'True') { Ext.Msg.show({ title: Zi.LAN.Prompt, msg: Zi.LAN.YIZUOFEI, icon: Ext.Msg.INFO, buttons: Ext.Msg.OK }); return; } Ext.MessageBox.confirm(Zi.LAN.Prompt, Zi.LAN.suredelete, function (btn) { if (btn == 'yes') { Ext.Ajax.request({ waitMsg: Zi.LAN.nowdelete, url: '/Account/Chfee_invoice/DeleteUp', 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.reload(); } else { Ext.Msg.show({ title: Zi.LAN.Error, msg: jsonresult.Message, icon: Ext.Msg.ERROR, buttons: Ext.Msg.OK }); } } }, failure: function (response, options) { 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 onCancelDeleteUpClick: 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 ISNEEDPRINT = record.data.ISNEEDPRINT; var ISNEEDFEE = record.data.ISNEEDFEE; var VOUCHERNO = record.data.VOUCHERNO; var ISDELETE = record.data.ISDELETE; if (ISDELETE != 'True') { Ext.Msg.show({ title: Zi.LAN.Prompt, msg: Zi.LAN.DANQIANZHUANGTAIWUFAZUOFEI, icon: Ext.Msg.INFO, buttons: Ext.Msg.OK }); return; } Ext.MessageBox.confirm(Zi.LAN.Prompt, Zi.LAN.QUESHIYAOZUOFEI, function (btn) { if (btn == 'yes') { Ext.Ajax.request({ waitMsg: Zi.LAN.nowdelete, url: '/Account/Chfee_invoice/CancelDeleteUp', 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.reload(); } else { Ext.Msg.show({ title: Zi.LAN.Error, msg: jsonresult.Message, icon: Ext.Msg.ERROR, buttons: Ext.Msg.OK }); } } }, failure: function (response, options) { 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) { Ext.Msg.show({ title: Zi.LAN.Prompt, msg: Zi.LAN.SelectDanju, icon: Ext.Msg.INFO, buttons: Ext.Msg.OK }); return; } var BILLNOStr = ''; for (var i = 0; i < selections.length; i++) { var rec = selections[i]; var BILLNO = rec.data.BILLNO; if (rec.data.BILLSTATUS == '0') { if (BILLNOStr == '') BILLNOStr = BILLNO; else { BILLNOStr = BILLNOStr + ',' + BILLNO; } } } if (BILLNOStr == '') { } else { Ext.Ajax.request({ waitMsg: Zi.LAN.NowSelect, url: '/Account/Chfee_invoice/LockList', params: { bills: BILLNOStr }, 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.storeList.reload(); } } else { Ext.MessageBox.alert(Zi.LAN.qqerror, response.responseText); } }, scope: this }); } }, onSubmitAuditBackClick: function () { 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; } //#region 判断是否生成过凭证 var sError1 = ""; var sError2 = ""; for (var i = 0; i < selections.length; i++) { var rec = selections[i]; var BILLNO = rec.data.BILLNO; //接口凭证 var sVOUCHERNO = rec.data.VOUCHERNO; if (sVOUCHERNO != "") { if (sError1 == "") sError1 = BILLNO; else { sError1 = sError1 + ',' + BILLNO; } } //总账凭证 var sVOUNO = rec.data.VOUNO; if (sVOUNO != "") { if (sError2 == "") sError2 = BILLNO; else { sError2 = sError2 + ',' + BILLNO; } } } if (sError1 != "") { Ext.Msg.show({ title: Zi.LAN.Prompt , msg: '单据 “' + sError1 + '” 已经生成接口凭证,不允许解除锁定!', icon: Ext.Msg.INFO, buttons: Ext.Msg.OK }); return; } if (sError2 != "") { Ext.Msg.show({ title: Zi.LAN.Prompt , msg: '单据 “' + sError2 + '” 已经生成总账凭证,不允许解除锁定!', icon: Ext.Msg.INFO, buttons: Ext.Msg.OK }); return; } //#endregion var BILLNOStr = ''; for (var i = 0; i < selections.length; i++) { var rec = selections[i]; var BILLNO = rec.data.BILLNO; if ((rec.data.BILLSTATUS == '1')) { if (BILLNOStr == '') BILLNOStr = BILLNO; else { BILLNOStr = BILLNOStr + ',' + BILLNO; } } } if (BILLNOStr == '') { } else { Ext.Ajax.request({ waitMsg: Zi.LAN.NowSelect, url: '/Account/Chfee_invoice/UnLockList', params: { bills: BILLNOStr }, 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.storeList.reload(); } } else { Ext.MessageBox.alert(Zi.LAN.qqerror, response.responseText); } }, scope: this }); }; }, onExpInvClick: function () { 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 bodyAddDatas = []; for (var i = 0; i < selections.length; i++) { var rec = selections[i]; bodyAddDatas.push(rec); } var jsonbodyAddDatas = ConvertRecordsToJsonAll(bodyAddDatas); Ext.Ajax.request({ waitMsg: Zi.LAN.NowSelect, url: '/Account/Chfee_invoice/ExpInv', 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 { // var downloadfile = Ext.getCmp('downloadfile'); // var children = downloadfile.items; // if (children) { // for (var i = 0, len = children.length; i < len; i++) { // downloadfile.remove(children.items[i], true); // } // } // var downloadfiles = '' + result.Message + ''; // var htmla = Ext.widget('label', { // html: downloadfiles, // width: 120, // text: '' // }); // downloadfile.items.add(htmla); // this.winDownloadShow.show(); // return; var openSet = "height=300, width=600, toolbar=no, menubar=no,scrollbars=no, resizable=no,location=no, status=no,Top=" + (screen.height - 200) / 2 + ",Left=" + (screen.width - 200) / 2; var openType = "_blank"; var openUrl = "../../Reports/FileExport.aspx?filename=" + result.Data; window.open(openUrl, openType, openSet); _this.storeList.reload(); } } else { Ext.MessageBox.alert(Zi.LAN.qqerror, response.responseText); } }, scope: this }); }, onExpDZInvClick: function () { 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 bodyAddDatas = []; for (var i = 0; i < selections.length; i++) { var rec = selections[i]; bodyAddDatas.push(rec); } var jsonbodyAddDatas = ConvertRecordsToJsonAll(bodyAddDatas); Ext.Ajax.request({ waitMsg: Zi.LAN.NowSelect, url: '/Account/Chfee_invoice/ExpDZInv', 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 { // var downloadfile = Ext.getCmp('downloadfile'); // var children = downloadfile.items; // if (children) { // for (var i = 0, len = children.length; i < len; i++) { // downloadfile.remove(children.items[i], true); // } // } // var downloadfiles = '' + result.Message + ''; // var htmla = Ext.widget('label', { // html: downloadfiles, // width: 120, // text: '' // }); // downloadfile.items.add(htmla); // this.winDownloadShow.show(); // return; var openSet = "height=300, width=600, toolbar=no, menubar=no,scrollbars=no, resizable=no,location=no, status=no,Top=" + (screen.height - 200) / 2 + ",Left=" + (screen.width - 200) / 2; var openType = "_blank"; var openUrl = "../../Reports/FileExport.aspx?filename=" + result.Data; window.open(openUrl, openType, openSet); _this.storeList.reload(); } } else { Ext.MessageBox.alert(Zi.LAN.qqerror, response.responseText); } }, scope: this }); }, onExpRYTInvClick: function () { 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 rec = selections[0]; var cust = rec.data.CUSTOMERNAME; var DZSTATUS = rec.data.DZSTATUS; if (DZSTATUS == '已开票') { Ext.Msg.show({ title: Zi.LAN.Prompt , msg: '已开电子发票!', icon: Ext.Msg.INFO, buttons: Ext.Msg.OK }); return; } this.formDZInvShow = Ext.widget('form', { frame: true, title: '电子开票', 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: [ { fieldLabel:'客户邮箱', //'编号', name: 'email', labelWidth: 60, enableKeyEvents: true } ] } ]//end root items }); var selectrecords = DsStoreQueryBy(this.storeCust, 'CustName', cust); if (selectrecords.getCount() > 0) { var selectdata = selectrecords.getAt(0).data; this.formDZInvShow.getForm().findField('email').setValue(selectdata.EMAIL); } this.winDZInvShow = Ext.create('Ext.window.Window', { title: "", // closeAction: 'hide', width: 400, height: 150, layout: 'border', resizable: true, modal: true, closeAction: 'close', closable: true, items: [this.formDZInvShow], buttons: [{ text: "确定", minWidth: 70, handler: function () { // var remarkstr = formRemarkShow.getForm().findField('INVREMARK').getValue(); // var cgFILEROLE = Ext.getCmp('hjFILEROLEGet'); // var FILEROLE = cgFILEROLE.getValue(); var email = _this.formDZInvShow.getForm().findField('email').getValue(); Ext.Ajax.request({ waitMsg: Zi.LAN.NowSelect, url: '/Account/Chfee_invoice/ExpRYDInv', params: { gid: rec.data.GID, email: email }, 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.storeList.reload(); _this.winDZInvShow.close(); } } else { Ext.MessageBox.alert(Zi.LAN.qqerror, response.responseText); } }, scope: this }); } }, { text: Zi.LAN.close, minWidth: 70, handler: function () { _this.winDZInvShow.close(); } }] }); _this.winDZInvShow.show(); }, //onExpDZInvClick: function (email) { // 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 rec = selections[0]; // Ext.Ajax.request({ // waitMsg: '正在添加数据...', // url: '/Account/Chfee_invoice/ExpDZInv', // params: { // gid: rec.data.GID, // email: email // }, // 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; // } else { // _this.storeList.reload(); // } // } else { // Ext.MessageBox.alert('请求出现错误,请重试', 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 CustNo = form.findField('BsNo').getValue(); // sql = sql + getAndConSql(sql, customNo, "BILLNO like '%" + customNo + "%'"); sql = sql + getAndConSql(sql, CustNo, "EXISTS (SELECT 1 FROM CH_FEE_DO d left join v_op_bill b on (b.BSNO=D.BSNO) WHERE D.BILLNO=CM.BILLNO AND b.CUSTNO+b.MBLNO+B.HBLNO+B.ORDERNO like '%" + CustNo+"%' )"); var invoiceNo = form.findField('InvNo').getValue(); sql = sql + getAndConSql(sql, invoiceNo, " INVOICENO like '%" + invoiceNo + "%' "); var custName = form.findField('CustName').getValue(); sql = sql + getAndConSql(sql, custName, " INVOICECUSTNAME like '%" + custName + "%' "); var expDateBgn = form.findField('ExpDateBgn').getRawValue(); sql = sql + getAndConSql(sql, expDateBgn, "INVOICEMAKETIME >='" + expDateBgn + "'"); var expDateEnd = form.findField('ExpDateEnd').getRawValue(); sql = sql + getAndConSql(sql, expDateEnd, "INVOICEMAKETIME <='" + expDateEnd + " 23:59:59'"); var companyid = form.findField('companyid').getValue(); sql = sql + getAndConSql(sql, companyid, "companyid = '" + companyid + "'"); var ShenNo = form.findField('ShenNo').getValue(); sql = sql + getAndConSql(sql, ShenNo, " BILLNO IN (SELECT INVBILLNO FROM ch_fee_invoiceapplication WHERE BILLNO like '%" + ShenNo + "%')"); 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) { _this = this; if (this.storeList.getCount() == 0) { return; } var sortstr = ' OPERATETIME DESC '; if (this.sortfield != '' && this.sortdire != '') { sortstr = this.sortfield + ' ' + this.sortdire; } Ext.Msg.wait(Zi.LAN.NowSelect); Ext.Ajax.request({ waitMsg: Zi.LAN.NowSelect, url: '/Account/Chfee_invoice/GetDataListStr', //(int start, int limit, string sort, string condition, int billtype) scope: this, params: { start: 0, limit: 10000000, billtype: 1, sort: sortstr, condition: _this.sqlcontext }, callback: function (options, success, response) { if (success) { Ext.MessageBox.hide(); var jsonresult = Ext.JSON.decode(response.responseText); if (jsonresult.Success) { var returnstr = jsonresult.data; var condition = jsonresult.Message; if (condition != '') condition = ' where ' + condition; var printType = 'MSINVOICELIST'; var sql1 = returnstr; sql1 = sql1.replace(/\+/g, "@@@") if (sql1 != '') { GridExportBySql(sql1, this.formname, '发票开出列表.xls'); } } else { Ext.Msg.show({ title: Zi.LAN.Error, msg: jsonresult.Message, icon: Ext.Msg.ERROR, buttons: Ext.Msg.OK }); } } else { Ext.Msg.show({ title: '请重试', msg: Zi.LAN.FuWuQiError, icon: Ext.Msg.ERROR, buttons: Ext.Msg.OK }); } } }); }, Print: function () { _this = this; if (this.storeList.getCount() == 0) { return; } var sortstr = ' OPERATETIME DESC '; if (this.sortfield != '' && this.sortdire != '') { sortstr = this.sortfield + ' ' + this.sortdire; } Ext.Msg.wait(Zi.LAN.NowSelect); Ext.Ajax.request({ waitMsg: Zi.LAN.NowSelect, url: '/Account/Chfee_invoice/GetDataListStr', //(int start, int limit, string sort, string condition, int billtype) scope: this, params: { start: 0, limit: 10000000, billtype:1, sort: sortstr, condition: _this.sqlcontext }, callback: function (options, success, response) { if (success) { Ext.MessageBox.hide(); var jsonresult = Ext.JSON.decode(response.responseText); if (jsonresult.Success) { var returnstr = jsonresult.data; var printType = 'MSINVOICELIST'; var sql1 = returnstr; var sql2 = ""; var sql3 = ""; var sql4 = ""; var sql5 = ""; var sql6 = ""; PrintComm(printType, sql1, sql2, sql3, sql4, sql5, sql6); } else { Ext.Msg.show({ title: Zi.LAN.Error, msg: jsonresult.Message, icon: Ext.Msg.ERROR, buttons: Ext.Msg.OK }); } } else { Ext.Msg.show({ title: '请重试', msg: Zi.LAN.FuWuQiError, icon: Ext.Msg.ERROR, buttons: Ext.Msg.OK }); } } }); }, PrintSelect: function () { 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 feeGidSql = ''; for (var i = 0; i < selections.length; i++) { var record = selections[i]; var feeGId = "'" + record.get('BILLNO') + "'"; if (feeGidSql == '') { feeGidSql = feeGId; } else { feeGidSql = feeGidSql + "," + feeGId; } }; var record = selections[0]; var billNo = record.data.BILLNO; var printType = 'MSCHFEINVOICESEL'; var sql1 = "SELECT p.*,(select ShowName from [user] where GID=p.OPERATOR) as OPERATORNAME"; sql1 = sql1 + ",dbo.GetFeeNoStlByInvNo(p.BILLNO) as NOSTL FROM ch_fee_invoice p WHERE BILLNO IN (" + feeGidSql + ") "; var sql2 = ""; var sql3 = ""; var sql4 = ""; var sql5 = ""; var sql6 = ""; PrintComm(printType, sql1, sql2, sql3, sql4, sql5, sql6); } });