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: '每页记录数', 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: '发票类别', width: 120 }, { sortable: true, dataIndex: 'BILLSTATUS', header: '发票锁定', width: 60, renderer: function (value, meta, record) { return record.data.BILLSTATUSREF; } }, { sortable: true, dataIndex: 'BILLNO', header: '发票业务编号', width: 120 }, { sortable: true, dataIndex: 'INVOICENO', header: '发票号', width: 120 }, { sortable: true, dataIndex: 'CUSTOMERNAME', header: '开票单位', width: 120 }, { sortable: true, dataIndex: 'CUSTOMERFULLNAME', header: '开票单位全称', width: 200 }, { sortable: true, dataIndex: 'INVOICECUSTNAME', header: '发票抬头', width: 160 }, { sortable: true, dataIndex: 'CURRENCY', header: '币别', width: 60 }, { sortable: true, dataIndex: 'INVAMOUNT', header: '开票金额', 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: '申请金额', 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: '是否打印', width: 60 }, { sortable: true, dataIndex: 'NOSTL', header: '未结算', width: 120 }, { sortable: true, dataIndex: 'RECVCURR', header: '实收币别', width: 60 }, { sortable: true, dataIndex: 'FEEAMOUNT', header: '原币金额', 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: '开票日期', width: 100 }, { sortable: true, dataIndex: 'OPERATORNAME', header: '开票人', width: 100 }, { sortable: true, dataIndex: 'APPLICANT', header: '申请人', width: 100 }, { sortable: true, dataIndex: 'APPLICANTDEPT', header: '所属部门', width: 100 }, { sortable: true, dataIndex: 'SALECORP', header: '所属分部', width: 100 }, { sortable: true, dataIndex: 'INVOICECATEGORYREF', header: '发票类别', width: 80 }, { sortable: true, dataIndex: 'REMARK', header: '备注', width: 160 }, { sortable: true, dataIndex: 'EXCHANGERATE', header: '开票税率', width: 80 }, { sortable: true, dataIndex: 'TAX', header: '税额', width: 80 }, { sortable: true, dataIndex: 'NOTAXAMOUNT', header: '不含税金额', 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: '是否作废', width: 80 }, { sortable: true, dataIndex: 'DZSTATUS', header: '电子发票', width: 80 }, { sortable: true, dataIndex: 'DELOPERATORNAME', header: '作废人', width: 100 }, { sortable: true, dataIndex: 'DELETETIME', header: '作废时间', width: 100 }, { sortable: true, dataIndex: 'INVSHENNO', header: '发票申请单号', width: 100 }, { sortable: true, dataIndex: 'VOUCHERNO', header: '接口凭证', width: 0 }, { sortable: true, dataIndex: 'VOUNO', header: '总账凭证', width: 0 }, { sortable: true, dataIndex: 'CREATEUSERREF', header: '录入人', width: 100 } ]; this.CheckIsDelete = new Ext.form.Checkbox({ fieldLabel: '合计含作废金额', 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: "数据加载中,请稍等..." }, 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: '当前显示 {0} - {1}条记录 /共 {2}条记录', emptyMsg: "没有数据" }), 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: '开票公司', 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/GetCustomRefListRmAll' } }); this.storeCust.load({ params: { condition: "" } }); this.comboxCust = Ext.create('DsExt.ux.RefTableCombox', { fieldLabel: '发票抬头', 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: '编号', name: 'BsNo', enableKeyEvents: true, listeners: { specialkey: function (field, e) { if (e.getKey() == e.ENTER) { _this.onRefreshClick(); } } } }, { fieldLabel: '申请编号', name: 'ShenNo', labelWidth: 60, enableKeyEvents: true, listeners: { specialkey: function (field, e) { if (e.getKey() == e.ENTER) { _this.onRefreshClick(); } } } }, { fieldLabel: '发票号', name: 'InvNo', enableKeyEvents: true, listeners: { specialkey: function (field, e) { if (e.getKey() == e.ENTER) { _this.onRefreshClick(); } } } }, { fieldLabel: '发票抬头', name: 'CustName', labelWidth: 60, enableKeyEvents: true, listeners: { specialkey: function (field, e) { if (e.getKey() == e.ENTER) { _this.onRefreshClick(); } } } }, this.comboxCompany , { fieldLabel: '从开票日期', 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: '到开票日期', 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: "执行查询", iconCls: "btnrefresh", handler: function (button, event) { this.onRefreshClick(button, event); }, scope: this }, { xtype: 'button', width: 90, text: "高级查询", 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: "自由开票", iconCls: "btnadd", handler: function (button, event) { this.OprationStatus = 'add'; DsOpenEditWin('/Account/Chfee_invoice/BLEdit', '新建自由发票'); }, scope: this }, '-', { text: "复制添加", iconCls: "btnadd", handler: 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]; this.SelectedRecord = record; this.OprationStatus = 'copyadd'; if (record.data.INVOICETYPE == 2) DsOpenEditWin('/Account/Chfee_invoice/AppEdit', '新建申请发票'); else DsOpenEditWin('/Account/Chfee_invoice/BLEdit', '新建自由发票'); }, scope: this }, '-', { text: "申请开票", iconCls: "btnadd", handler: function (button, event) { this.OprationStatus = 'add'; DsOpenEditWin('/Account/Chfee_invoice/AppEdit', '新建申请发票'); }, scope: this }, { text: "重置条件", iconCls: "btnreset", handler: function (button, event) { var form = this.formSearch.getForm(); form.reset(); }, scope: this }, '-', { text: "删除", iconCls: "btndelete", id: "btndelete", handler: function (button, event) { this.onDeleteClick(button, event); }, scope: this }, '-', { text: "作废", iconCls: "btndelete", id: "btndeleteUp", menu: [ { text: "作废", handler: function (menu, event) { _this.onDeleteUpClick(menu, event); } }, { text: "取消作废", handler: function (menu, event) { _this.onCancelDeleteUpClick(menu, event); } }], scope: this }, '-', { text: '提交锁定', tooltip: '提交锁定', id: 'btnSubmitAudit', handler: function (button, event) { this.onSubmitAuditClick(); }, scope: this }, '-', { text: '撤销锁定', tooltip: '撤销锁定', id: 'btnSubmitAuditBack', handler: function (button, event) { this.onSubmitAuditBackClick(); }, scope: this }, '-', { text: '打印', tooltip: '打印报表', menu: [ { text: "打印列表", handler: function (menu, event) { _this.Print(menu, event, 1); } }, { text: "打印选中", handler: function (menu, event) { _this.PrintSelect(menu, event, 1); } }], scope: this }, '-', { text: "导出Excel", id: "btnExportExcel", iconCls: 'btnexportexcel', handler: function (button, event) { this.onExportClick(button, event); }, scope: this }, '-', { text: "保存列表样式", id: "btntest", menu: [ { text: "保存", handler: function (button, event) { this.girdcolums = DsTruck.SaveGridPanel(USERID, _this.formname, _this.gridList.columns, _this.girdcolums, 1, true); } }, { text: "初始化", handler: function (menu, event) { _this.girdcolums = DsTruck.SaveGridPanel(USERID, _this.formname, _this.gridList.columns, _this.initgirdcolums, 1, true); } }], scope: this }, '-', { text: "发票接口文件导出", iconCls: 'btnexportexcel', handler: function (button, event) { _this.onExpInvClick(); }, scope: this }, '-', { text: "发票接口(电子)文件导出", iconCls: 'btnexportexcel', handler: function (button, event) { _this.onExpDZInvClick(); }, scope: this }, '-', { text: "荣e通", 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: "正在查询数据...", scope: this }); this.CheckSaveQuery = new Ext.form.Checkbox({ fieldLabel: '记忆查询条件', 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: "下载文件", 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: "关闭", 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: "正在查询数据...", 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: "正在查询数据...", 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: '提示', msg: '请先选择单据!', 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: '提示', msg: '已锁定,无法删除或作废!', icon: Ext.Msg.INFO, buttons: Ext.Msg.OK }); return; } if (VOUCHERNO != '') { Ext.Msg.show({ title: '提示', msg: '已生成凭证无法删除此发票,只能作废!', icon: Ext.Msg.INFO, buttons: Ext.Msg.OK }); return; } if (ISDELETE == 'True') { Ext.Msg.show({ title: '提示', msg: '此发票已作废,不能删除!', icon: Ext.Msg.INFO, buttons: Ext.Msg.OK }); return; } if (ISNEEDFEE == 'True') { Ext.Msg.show({ title: '提示', msg: '此发票已结算,不能删除!', icon: Ext.Msg.INFO, buttons: Ext.Msg.OK }); return; } Ext.MessageBox.confirm('提示', '确定删除该记录吗?', function (btn) { if (btn == 'yes') { Ext.Ajax.request({ waitMsg: '正在删除数据...', 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: '提示', msg: '删除成功!', 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 onDeleteUpClick: 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]; 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: '提示', msg: '已锁定,无法删除或作废!', icon: Ext.Msg.INFO, buttons: Ext.Msg.OK }); return; } if (VOUCHERNO != '') { Ext.Msg.show({ title: '提示', msg: '已生成凭证无法删除此发票!', icon: Ext.Msg.INFO, buttons: Ext.Msg.OK }); return; } if (ISDELETE == 'True') { Ext.Msg.show({ title: '提示', msg: '此发票已作废!', icon: Ext.Msg.INFO, buttons: Ext.Msg.OK }); return; } Ext.MessageBox.confirm('提示', '确定要作废该记录吗?', function (btn) { if (btn == 'yes') { Ext.Ajax.request({ waitMsg: '正在删除数据...', 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: '错误', 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 onCancelDeleteUpClick: 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]; 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: '提示', msg: '当前状态无法取消作废!', icon: Ext.Msg.INFO, buttons: Ext.Msg.OK }); return; } Ext.MessageBox.confirm('提示', '确定要取消作废吗?', function (btn) { if (btn == 'yes') { Ext.Ajax.request({ waitMsg: '正在删除数据...', 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: '错误', 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 onSubmitAuditClick: 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 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: '正在添加数据...', 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: '提示', msg: result.Message, icon: Ext.MessageBox.ERROR, buttons: Ext.Msg.OK }); return; } else { _this.onRefreshClick(); } } else { Ext.MessageBox.alert('请求出现错误,请重试', response.responseText); } }, scope: this }); } }, onSubmitAuditBackClick: 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; } //#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: '提示', msg: '单据 “' + sError1 + '” 已经生成接口凭证,不允许解除锁定!', icon: Ext.Msg.INFO, buttons: Ext.Msg.OK }); return; } if (sError2 != "") { Ext.Msg.show({ title: '提示', 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: '正在添加数据...', 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: '提示', msg: result.Message, icon: Ext.MessageBox.ERROR, buttons: Ext.Msg.OK }); return; } else { _this.onRefreshClick(); } } else { Ext.MessageBox.alert('请求出现错误,请重试', response.responseText); } }, scope: this }); }; }, onExpInvClick: 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 bodyAddDatas = []; for (var i = 0; i < selections.length; i++) { var rec = selections[i]; bodyAddDatas.push(rec); } var jsonbodyAddDatas = ConvertRecordsToJsonAll(bodyAddDatas); Ext.Ajax.request({ waitMsg: '正在添加数据...', 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: '提示', 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('请求出现错误,请重试', response.responseText); } }, scope: this }); }, onExpDZInvClick: 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 bodyAddDatas = []; for (var i = 0; i < selections.length; i++) { var rec = selections[i]; bodyAddDatas.push(rec); } var jsonbodyAddDatas = ConvertRecordsToJsonAll(bodyAddDatas); Ext.Ajax.request({ waitMsg: '正在添加数据...', 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: '提示', 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('请求出现错误,请重试', response.responseText); } }, scope: this }); }, onExpRYTInvClick: 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 rec = selections[0]; var cust = rec.data.CUSTOMERNAME; var DZSTATUS = rec.data.DZSTATUS; if (DZSTATUS == '已开票') { Ext.Msg.show({ title: '提示', 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: '正在添加数据...', 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: '提示', msg: result.Message, icon: Ext.MessageBox.ERROR, buttons: Ext.Msg.OK }); return; } else { _this.storeList.reload(); _this.winDZInvShow.close(); } } else { Ext.MessageBox.alert('请求出现错误,请重试', response.responseText); } }, scope: this }); } }, { text: "关闭", 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('提示', '查询条件赋值错误,请检查。'); 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('正在组织数据, 请稍侯..'); Ext.Ajax.request({ waitMsg: '正在组织数据...', 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: '错误', 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 }); } } }); }, 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('正在组织数据, 请稍侯..'); Ext.Ajax.request({ waitMsg: '正在组织数据...', 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: '错误', 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 }); } } }); }, 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); } });