Ext.namespace('Shipping'); Shipping.MsChWorkEdit = function (config) { Ext.applyIf(this, config); this.initUIComponents(); window.Shipping.MsChWorkEdit.superclass.constructor.call(this); }; Ext.extend(Shipping.MsChWorkEdit, Ext.Panel, { ParentWin: null, OpStatus: 'add', StoreList: null, EditRecord: null, addstore: false, PageSize: 30, sqlcontext: '', OprationStatus: null, //仅当弹出界面时使用 SelectedRecord: null, initUIComponents: function () { this.serialNo = 0; this.workSerialNo = 0; this.bodyDel = []; this.FeeSql = ''; this.BillSql = ''; this.DuiBillSql = ''; this.IsDebit = '0'; this.sortfield = ''; this.sortdire = ''; this.formname = "MsChWorkEdit"; //页面名称 this.sqlcontext = ' 1=2 '; //#region 编辑form //枚举参照相关(编辑form) //表参照相关(编辑form) //编辑form this.formEdit = Ext.widget('form', { region: 'center', frame: true, bodyPadding: 3, trackResetOnLoad: true, // autoScroll: true, fieldDefaults: { margins: '2 2 2 2', labelAlign: 'right', flex: 1, labelWidth: 90, msgTarget: 'qtip' }, items: [ {//fieldset 1 xtype: 'fieldset', defaultType: 'textfield', layout: 'anchor', defaults: { anchor: '100%' }, items: [{ xtype: 'container', layout: 'hbox', defaultType: 'textfield', items: [{ fieldLabel: 'GID', name: 'GID', flex: 0, hidden: true, margins: '0' }, { fieldLabel: 'APPLICANT', name: 'APPLICANT', flex: 0, hidden: true, margins: '0' }, { fieldLabel: 'COMPANYID', name: 'COMPANYID', flex: 0, hidden: true, margins: '0' }, { fieldLabel: '派工单编号', readOnly: true, name: 'BILLNO' }, { fieldLabel: '状态', readOnly: true, name: 'BILLSTATUS' }, { fieldLabel: '最晚支付日期',//申请支付日期 format: 'Y-m-d', xtype: 'datefield', allowBlank: false, name: 'SETTLETIME' }, { fieldLabel: '申请人', readOnly: true, name: 'APPLICANTREF' }, { fieldLabel: '申请时间', readOnly: true, name: 'APPLYTIME' } ] }, { xtype: 'container', layout: 'hbox', defaultType: 'textfield', items: [{ fieldLabel: '备注', flex: 4, name: 'REMARK' }] } ]//end items(fieldset 1) }//end fieldset 1 ]//end root items }); //end this.formEdit //#endregion //#region 按钮Toolbar this.panelBtn = new Ext.Panel({ region: "north", tbar: [ { id: 'btnEPrev', text: "上一票", // iconCls: "btnsave", handler: function (button, event) { this.PrevRecord(); }, scope: this }, { id: 'btnENext', text: "下一票", // iconCls: "btnsave", handler: function (button, event) { this.NextRecord(); }, scope: this }, { id: 'btnESave', text: "保存", iconCls: "btnsave", handler: function (button, event) { this.Save('0'); }, scope: this }, '-', { text: "打印", handler: function (button, event) { this.Print(); }, scope: this }, '-', { id: 'btnESaveAndClose', text: "保存并关闭", handler: function (button, event) { this.Save('1'); }, scope: this }, '-', { id: 'btnESaveAndNew', text: "保存并新建", handler: function (button, event) { this.Save('2'); this.GetEditStatus(); }, scope: this }, '-', { id: 'btnENew', text: "新建", handler: function (button, event) { this.LoadData('add', '*'); }, scope: this }, '-', { id: 'btnSubmitAudit', text: '提交审核', tooltip: '提交审核', handler: function (button, event) { this.onSubmitAuditClick(); }, scope: this }, '-', { id: 'btnSubmitAuditBack', text: '撤销审核', tooltip: '撤销审核', handler: function (button, event) { this.onSubmitAuditBackClick(); }, scope: this } ] }); //end 按钮Toolbar //#endregion //#region 明细表 //明细表表格相关 //#region 入账申请明细 this.GridBalCheckBoxModel = Ext.create('Ext.selection.CheckboxModel'); //明细表-数据集 this.storeBodyBalList = Ext.create('Ext.data.Store', { model: 'MsChPayapplication', remoteSort: true, proxy: { type: 'ajax', url: '/Account/Chfee_payapplication/GetDataList', reader: { id: 'BILLNO', root: 'data', totalProperty: 'totalCount' } } }); this.gridBalList = new Ext.grid.GridPanel({ store: this.storeBodyBalList, enableHdMenu: false, region: 'center', loadMask: { msg: "数据加载中,请稍等..." }, trackMouseOver: true, disableSelection: false, viewConfig: { enableTextSelection: true }, selModel: this.GridBalCheckBoxModel, tbar: [{ text: '删除申请明细', tooltip: '删除申请明细', id: 'btndeldetail', iconCls: "btndeletedetail", handler: function (button, event) { this.onDeleteClick(button, event, 1); }, scope: this }], columns: [{ sortable: true, dataIndex: 'BILLNO', header: Zi.LAN.RequisitionNumber, //申请单号 width: 120 }, { sortable: true, dataIndex: 'BILLSTATUS', header: Zi.LAN.status, //状态 width: 60, renderer: function (value, p, record) { return record.data.BILLSTATUSREF; } }, { sortable: true, dataIndex: 'CUSTOMERNAME', header: Zi.LAN.SettlementUnit, //结算单位 width: 120 }, { sortable: true, dataIndex: 'SETTLETYPEREF', header: '结算方式', //结算单位 width: 120 }, { sortable: true, dataIndex: 'CURR', header: Zi.LAN.Currency, //币别 width: 50 }, { sortable: true, dataIndex: 'AMOUNTRMB', header: 'RMB', 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; }, align: 'right', width: 120 }, { sortable: true, dataIndex: 'AMOUNTUSD', header: 'USD', 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; }, align: 'right', width: 120 }, { sortable: true, dataIndex: 'AMOUNTOT', header: Zi.LAN.OtherBi, //其他外币 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; }, align: 'right', width: 120 }, { sortable: true, dataIndex: 'SETTLERMB', header: Zi.LAN.jsuan + 'RMB', //结算RMB 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; }, align: 'right', width: 120 }, { sortable: true, dataIndex: 'SETTLEUSD', header: Zi.LAN.jsuan + 'USD', //结算USD 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; }, align: 'right', width: 120 }, { sortable: true, dataIndex: 'SETTLEOT', header: Zi.LAN.jsuanOther, //结算其他币别 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; }, align: 'right', width: 120 }, { sortable: true, dataIndex: 'APPLYTIME', header: Zi.LAN.DateApplication, //申请日期 width: 100 }, { sortable: true, dataIndex: 'APPLICANTNAME', header: Zi.LAN.Applicant, //申请人 width: 100 }, { sortable: true, dataIndex: 'PAYABLETIME', header: Zi.LAN.ApplyPaymentDate, //申请支付日期 width: 100 }, { sortable: true, dataIndex: 'AUDITTIME', header: Zi.LAN.FinalReviewDate, //最后审核日期 width: 100 }, { sortable: true, dataIndex: 'AUDITUSER', header: Zi.LAN.lastReviewer, //最后审核人 width: 100 }, { sortable: true, dataIndex: 'CUSTBANKNAME', header: Zi.LAN.jsuanBank, //结算对象银行 width: 80 }, { sortable: true, dataIndex: 'CUSTACCOUNT', header: Zi.LAN.jsuanzh, //结算对象账户 width: 140 }, { sortable: true, dataIndex: 'REMARK', header: Zi.LAN.Remarks, //备注 width: 160 }, { sortable: true, dataIndex: 'ISINVOICE', header: Zi.LAN.Invoiced, //已开发票 width: 80 }, { sortable: true, dataIndex: 'INVNO', header: Zi.LAN.InvoiceNumber, //发票号 width: 80 }, { sortable: true, dataIndex: 'PREAMOUNTRMB', header: Zi.LAN.yjsuan + 'RMB', //预计结算RMB 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; }, align: 'right', width: 120 }, { sortable: true, dataIndex: 'PREAMOUNTUSD', header: Zi.LAN.yjsuan + 'USD',//预计结算USD 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; }, align: 'right', width: 120 }, { sortable: true, dataIndex: 'PREAMOUNTOT', header: Zi.LAN.yjsuanOther, //预计结算其他 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; }, align: 'right', width: 120 }, { sortable: true, dataIndex: 'BALAMOUNTRMB', header: Zi.LAN.weisq + 'RMB', //未申请RMB 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; }, align: 'right', width: 120 }, { sortable: true, dataIndex: 'BALAMOUNTUSD', header: Zi.LAN.weisq + 'USD', //未申请USD 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; }, align: 'right', width: 120 }, { sortable: true, dataIndex: 'BALAMOUNTOT', header: Zi.LAN.weisqOther, //未申请其他 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; }, align: 'right', width: 120 }, { sortable: true, dataIndex: 'BS_CUSTOMERNAME', header: Zi.LAN.Requester, //委托单位 width: 160 }, { sortable: true, dataIndex: 'PAYTYPE', header: Zi.LAN.shfsi, //申请方式 width: 80 }, { sortable: true, id: '', dataIndex: 'ISPRINT', header: Zi.LAN.printy, //'应收费用', align: 'center', width: 60, renderer: function (value, meta) { if (value == '1') return '是'; //是 else return ''; } }, { sortable: true, dataIndex: 'BALBILLNO', header: Zi.LAN.ruzsq, //入账申请编号 width: 80 }, { sortable: true, dataIndex: 'REASON', header: Zi.LAN.REASON, //驳回原因 width: 80 } ] }); this.gridBalList.addListener('sortchange', function (ct, column, direction, eOpts) { }, this); this.gridBalList.addListener('itemdblclick', function (dataview, record, item, index, e, b) { this.SelectedRecord = record; this.OprationStatus = 'edit'; DsOpenEditWin('/Account/Chfee_payapplication/BLEdit', record.data.BILLNO); }, this); //#endregion //#region 添加业务列表 this.storeBodyAddList = Ext.create('Ext.data.Store', { pageSize: this.PageSize, model: 'MsChPayapplication', remoteSort: true, proxy: { type: 'ajax', url: '/Account/Chfee_payapplication/GetDataList', reader: { id: 'BILLNO', root: 'data', totalProperty: 'totalCount' } } }); 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.cellEditingBal = Ext.create('Ext.grid.plugin.CellEditing', { clicksToEdit: 1, listeners: { 'edit': function (editor, e) { } } }); this.AddGridCheckBoxModel = Ext.create('Ext.selection.CheckboxModel'); this.gridAddList = new Ext.grid.GridPanel({ store: this.storeBodyAddList, enableHdMenu: false, region: 'center', loadMask: { msg: "数据加载中,请稍等..." }, trackMouseOver: true, disableSelection: false, plugins: [this.cellEditingBal], selModel: this.AddGridCheckBoxModel, tbar: [{ text: '添加申请明细', tooltip: '添加申请明细', id: 'btnaddbill', iconCls: "btnadddetail", handler: function (button, event) { this.onAddClick(button, event); }, scope: this }], columns: [{ sortable: true, dataIndex: 'BILLNO', header: Zi.LAN.RequisitionNumber, //申请单号 width: 120 }, { sortable: true, dataIndex: 'BILLSTATUS', header: Zi.LAN.status, //状态 width: 60, renderer: function (value, p, record) { return record.data.BILLSTATUSREF; } }, { sortable: true, dataIndex: 'CUSTOMERNAME', header: Zi.LAN.SettlementUnit, //结算单位 width: 120 }, { sortable: true, dataIndex: 'SETTLETYPEREF', header: '结算方式', //结算单位 width: 120 }, { sortable: true, dataIndex: 'CURR', header: Zi.LAN.Currency, //币别 width: 50 }, { sortable: true, dataIndex: 'AMOUNTRMB', header: 'RMB', 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; }, align: 'right', width: 120 }, { sortable: true, dataIndex: 'AMOUNTUSD', header: 'USD', 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; }, align: 'right', width: 120 }, { sortable: true, dataIndex: 'AMOUNTOT', header: Zi.LAN.OtherBi, //其他外币 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; }, align: 'right', width: 120 }, { sortable: true, dataIndex: 'SETTLERMB', header: Zi.LAN.jsuan + 'RMB', //结算RMB 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; }, align: 'right', width: 120 }, { sortable: true, dataIndex: 'SETTLEUSD', header: Zi.LAN.jsuan + 'USD', //结算USD 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; }, align: 'right', width: 120 }, { sortable: true, dataIndex: 'SETTLEOT', header: Zi.LAN.jsuanOther, //结算其他币别 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; }, align: 'right', width: 120 }, { sortable: true, dataIndex: 'APPLYTIME', header: Zi.LAN.DateApplication, //申请日期 width: 100 }, { sortable: true, dataIndex: 'APPLICANTNAME', header: Zi.LAN.Applicant, //申请人 width: 100 }, { sortable: true, dataIndex: 'PAYABLETIME', header: Zi.LAN.ApplyPaymentDate, //申请支付日期 width: 100 }, { sortable: true, dataIndex: 'AUDITTIME', header: Zi.LAN.FinalReviewDate, //最后审核日期 width: 100 }, { sortable: true, dataIndex: 'AUDITUSER', header: Zi.LAN.lastReviewer, //最后审核人 width: 100 }, { sortable: true, dataIndex: 'CUSTBANKNAME', header: Zi.LAN.jsuanBank, //结算对象银行 width: 80 }, { sortable: true, dataIndex: 'CUSTACCOUNT', header: Zi.LAN.jsuanzh, //结算对象账户 width: 140 }, { sortable: true, dataIndex: 'REMARK', header: Zi.LAN.Remarks, //备注 width: 160 }, { sortable: true, dataIndex: 'ISINVOICE', header: Zi.LAN.Invoiced, //已开发票 width: 80 }, { sortable: true, dataIndex: 'INVNO', header: Zi.LAN.InvoiceNumber, //发票号 width: 80 }, { sortable: true, dataIndex: 'PREAMOUNTRMB', header: Zi.LAN.yjsuan + 'RMB', //预计结算RMB 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; }, align: 'right', width: 120 }, { sortable: true, dataIndex: 'PREAMOUNTUSD', header: Zi.LAN.yjsuan + 'USD',//预计结算USD 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; }, align: 'right', width: 120 }, { sortable: true, dataIndex: 'PREAMOUNTOT', header: Zi.LAN.yjsuanOther, //预计结算其他 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; }, align: 'right', width: 120 }, { sortable: true, dataIndex: 'BALAMOUNTRMB', header: Zi.LAN.weisq + 'RMB', //未申请RMB 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; }, align: 'right', width: 120 }, { sortable: true, dataIndex: 'BALAMOUNTUSD', header: Zi.LAN.weisq + 'USD', //未申请USD 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; }, align: 'right', width: 120 }, { sortable: true, dataIndex: 'BALAMOUNTOT', header: Zi.LAN.weisqOther, //未申请其他 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; }, align: 'right', width: 120 }, { sortable: true, dataIndex: 'BS_CUSTOMERNAME', header: Zi.LAN.Requester, //委托单位 width: 160 }, { sortable: true, dataIndex: 'PAYTYPE', header: Zi.LAN.shfsi, //申请方式 width: 80 }, { sortable: true, id: '', dataIndex: 'ISPRINT', header: Zi.LAN.printy, //'应收费用', align: 'center', width: 60, renderer: function (value, meta) { if (value == '1') return '是'; //是 else return ''; } }, { sortable: true, dataIndex: 'BALBILLNO', header: Zi.LAN.ruzsq, //入账申请编号 width: 80 }, { sortable: true, dataIndex: 'REASON', header: Zi.LAN.REASON, //驳回原因 width: 80 } ], // paging bar on the bottom bbar: [Ext.create('Ext.PagingToolbar', { store: this.storeBodyAddList, displayInfo: true, displayMsg: '当前显示 {0} - {1}条记录 /共 {2}条记录', emptyMsg: "没有数据" }), this.Pagenum] }); this.gridAddList.on('edit', function (editor, e, eOpts) { this.gridAddBalListAfterEdit(editor, e, eOpts); }, this); _this = this; //#endregion //#region 添加费用列表 //#endregion _this = this; this.storeCustCodefee = Ext.create('DsExt.ux.RefTableStore', { model: 'DsShipping.ux.CustomRefModel', proxy: { url: '/CommMng/BasicDataRef/GetCustomRefList' } }); this.storeCustCodefee.load({ params: { condition: ""} }); this.comboxAddCustCode = Ext.create('DsExt.ux.RefTableCombox', { fieldLabel: '费用对象', store: this.storeCustCodefee, forceSelection: true, name: 'CUSTNAME', valueField: 'CustName', displayField: 'CodeAndName' }); this.comboxCurr2 = Ext.create('DsExt.ux.RefTableCombox', { fieldLabel: '币别', store: this.StoreCurr, forceSelection: true, name: 'Currency', valueField: 'CURR', displayField: 'CURR' }); this.storeIsDebit = Ext.create('Ext.data.Store', { fields: ['DC', 'NAME'] }); this.storeIsDebit.add({ "DC": "1", "NAME": "是" }); this.storeIsDebit.add({ "DC": "2", "NAME": "否" }); this.comboxIsDebit = Ext.create('DsExt.ux.RefTableCombox', { fieldLabel: '仅未结申请', store: this.storeIsDebit, valueField: 'DC', displayField: 'NAME', forceSelection: true, value: "1", name: 'ISDEBIT' }); this.storeCurrExrate = Ext.create('Ext.data.Store', { fields: ['CURR', 'EXRATE', 'DFEXRATE'] }); this.storeSaleCompany = Ext.create('DsExt.ux.RefTableStore', { model: 'MsCompanysEntity', proxy: { url: '/MvcShipping/MsCompanys/GetNoPicDataList' } }); this.storeSaleCompany.load({ params: { condition: "" } }); this.comboxSaleCompany = Ext.create('DsExt.ux.RefTableCombox', { fieldLabel:'所属分部', //'委托分公司', store: this.storeSaleCompany, forceSelection: true, name: 'SALECORPID', valueField: 'GID', displayField: 'NAME' }); this.StoreStlMode = Ext.create('DsExt.ux.RefTableStore', { model: 'STLMODE', proxy: { url: '/MvcShipping/MsBaseInfo/GetStlModeList' } }); this.StoreStlMode.load({ params: { condition: "" } }); this.comboxStlMode = Ext.create('DsExt.ux.RefTableCombox', { fieldLabel:'结算方式', //结算方式 store: this.StoreStlMode, forceSelection: true, name: 'SETTLETYPE', valueField: 'STLCODE', displayField: 'STLNAME' }); this.formSearch = Ext.widget('form', { frame: true, region: 'north', 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: 'PARAMVALUE', name: 'PARAMVALUE', value: '0', hidden: true }, this.comboxAddCustCode, { fieldLabel: '申请单号', name: 'CustomNo' }, { fieldLabel: '从申请日期', format: 'Y-m-d', xtype: 'datefield', name: 'ExpDateBgn' }, { fieldLabel: '到申请日期', format: 'Y-m-d', xtype: 'datefield', name: 'ExpDateEnd' }, this.comboxStlMode, this.comboxSaleCompany,{ xtype: 'button', width: 90, text: "检索", iconCls: "btnrefresh", handler: function (button, event) { this.onRefreshClick(); }, scope: this } ] } ]//end items(fieldset 1) }//end fieldset 1 ]//end root items }); this.paneldetail = new Ext.Panel({ title: '申请明细', layout: "border", height: 240, region: "north", split: true, items: [ this.gridBalList ] }); this.panelAddService = new Ext.Panel({ layout: "border", region: 'center', margin: '2 2', items: [this.gridAddList] }); this.paneladddetail = new Ext.Panel({ layout: "border", region: 'center', height: 300, items: [this.panelAddService ] }); this.paneladd = new Ext.Panel({ title: '添加支付申请明细', layout: "border", // region: 'south', region: "center", // height: 420, items: [ this.formSearch, this.paneladddetail ] }); //#endregion 明细表 //#region 布局 //控件布局 this.panelTop = new Ext.Panel({ layout: "border", region: "north", height: 125, items: [this.panelBtn, this.formEdit] }); Ext.apply(this, { items: [this.panelTop, this.paneldetail, this.paneladd] }); //#endregion //绑定查询窗体 this.ParentWin = window.parent.opener; //初始化数据 this.InitData(); //绑定事件 var billno = '*'; if (this.opStatus == 'edit') { billno = this.editRecord.get('BILLNO'); }; this.storeBodyBalList.on('beforeload', function (store) { var billno = _this.formEdit.getForm().findField('BILLNO').getValue(); var sql = "WORKBILLNO='" + billno + "'"; Ext.apply(store.proxy.extraParams, { condition: sql }); }, this); this.storeBodyAddList.on('beforeload', function (store) { // var sql = this.getCondition(); Ext.apply(store.proxy.extraParams, { condition: this.sqlcontext }); }, this); _this = this; }, //end initUIComponents InitData: function () { this.opStatus = 'add'; var condition = ''; if (this.ParentWin) { var ret = this.ParentWin.OprationSwap(); this.opStatus = ret[0]; this.StoreList = ret[1]; this.editRecord = ret[2]; } if (this.opStatus == 'edit') condition = " BILLNO='" + this.editRecord.get('BILLNO') + "'"; this.LoadData(this.opStatus, condition); }, //end InitData LoadData: function (opstatus, condition) { this.serialNo = 0; this.workSerialNo = 0; this.bodyDel = []; this.opStatus = opstatus; _this = this; Ext.Ajax.request({ waitMsg: '正在查询主表数据...', url: '/Account/Chfee_payapplication/GetWorkData', params: { handle: opstatus, condition: condition }, 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; } var data = result.data; _this.formEdit.getForm().reset(); _this.formEdit.getForm().setValues(data); //_this.GetEditStatus(); } else { Ext.MessageBox.alert('请求出现错误,请重试', response.responseText); } }, scope: this }); var billno = '*'; if (this.opStatus == 'edit') { billno = this.editRecord.get('BILLNO'); }; var sql = "WORKBILLNO='" + billno + "'"; this.storeBodyBalList.load({ params: { condition: sql} }); // this.storeFeeList.load({ params: { condition: " DUINO='" + billno + "'"} }); }, // end LoadDate Save: function (type) { var basicForm = this.formEdit.getForm(); if (!basicForm.isValid()) { return; } this.formEdit.getForm().findField('APPLICANT').setDisabled(false); this.formEdit.getForm().findField('COMPANYID').setDisabled(false); var data = basicForm.getValues(); this.formEdit.getForm().findField('APPLICANT').setDisabled(true); this.formEdit.getForm().findField('COMPANYID').setDisabled(true); Ext.Msg.wait('正在保存数据, 请稍侯..'); Ext.Ajax.request({ waitMsg: '正在保存数据...', url: '/Account/Chfee_payapplication/SaveWork', scope: this, params: { opstatus: this.opStatus, data: Ext.JSON.encode(data) }, callback: function (options, success, response) { if (success) { Ext.MessageBox.hide(); var jsonresult = Ext.JSON.decode(response.responseText); if (jsonresult.Success) { var returnData = jsonresult.Data; this.formEdit.getForm().setValues(returnData); if (this.opStatus == 'add') { var arrNewRecords = this.StoreList.insert(0, returnData); this.editRecord = this.StoreList.getAt(0); } else if (this.opStatus == 'edit') { var editp = Ext.create('MsChWork', returnData); this.editRecord.fields.each(function (field) { if (field.persist) { name = field.name; if (name != 'id') this.editRecord.set(name, editp.get(name)); } }, this); this.editRecord.commit(); } if (type == '0') { this.opStatus = 'edit'; } else if (type == '1') { window.close(); } else { this.LoadData('add', ''); } } 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 }); } } }); }, //end save onAddDetailClick: function (button, event) { this.addstore = true; this.addDetail(); }, //end onAddDetailClick onAddBillClick: function (button, event) { this.addstore = true; this.addBill(); }, //end onAddDetailClick onDelDetailClick: function (button, event, type) { this.deleteDetail(); }, //onDelDetailClick onAddClick: function (button, event) { this.addstore = true; this.addBill(); }, //end onAddDetailClick onDeleteClick: function (button, event) { this.deleteBill(); }, //end onAddDetailClick addBill: function () { var basicForm = this.formEdit.getForm(); var btnEAddbill = Ext.getCmp('btnaddbill'); btnEAddbill.disable(); var Duino = this.formEdit.getForm().findField('BILLNO').getValue(); _this = this; if ((Duino == '*') || basicForm.isDirty()) { if (!basicForm.isValid()) { return; } var type = 0; var data = basicForm.getValues(); Ext.Msg.wait('正在保存数据, 请稍侯..'); Ext.Ajax.request({ waitMsg: '正在保存数据...', url: '/Account/Chfee_payapplication/SaveWork', scope: this, params: { opstatus: this.opStatus, data: Ext.JSON.encode(data) }, callback: function (options, success, response) { if (success) { Ext.MessageBox.hide(); var jsonresult = Ext.JSON.decode(response.responseText); if (jsonresult.Success) { var returnData = jsonresult.Data; this.formEdit.getForm().setValues(returnData); if (this.opStatus == 'add') { var arrNewRecords = this.StoreList.insert(0, returnData); this.editRecord = this.StoreList.getAt(0); } else if (this.opStatus == 'edit') { var editp = Ext.create('MsChWork', returnData); this.editRecord.fields.each(function (field) { if (field.persist) { name = field.name; if (name != 'id') this.editRecord.set(name, editp.get(name)); } }, this); this.editRecord.commit(); } this.opStatus = 'edit'; _this.addBillfn(); } else { btnEAddbill.enable(); Ext.Msg.show({ title: '错误', msg: jsonresult.Message, icon: Ext.Msg.ERROR, buttons: Ext.Msg.OK }); } } else { btnEAddbill.enable(); Ext.Msg.show({ title: '请重试', msg: '服务器响应出错', icon: Ext.Msg.ERROR, buttons: Ext.Msg.OK }); } } }); } else { this.addBillfn(); } }, //end save addBillfn: function () { var btnEAddbill = Ext.getCmp('btnaddbill'); var billstatus = this.formEdit.getForm().findField('BILLSTATUS').getValue(); if ((billstatus !='新建')) { btnEAddbill.enable(); Ext.Msg.show({ title: '提示', msg: '当前状态无法添加付费申请明细!', icon: Ext.Msg.INFO, buttons: Ext.Msg.OK }); return; } var billno = this.formEdit.getForm().findField('BILLNO').getValue(); var feeBSNOSql = ''; var sql = ''; var selectedRecords = this.gridAddList.selModel.getSelection(); if (selectedRecords.length == 0) { btnEAddbill.enable(); Ext.Msg.show({ title: '提示', msg: '没有选择要添加的业务!', icon: Ext.Msg.INFO, buttons: Ext.Msg.OK }); return; }; var bodyAddDatas = []; _this = this; for (var i = 0; i < selectedRecords.length; i++) { var rec = selectedRecords[i]; bodyAddDatas.push(rec); } if (bodyAddDatas.length == 0) { Ext.Msg.show({ title: '提示', msg: '没有要添加的申请明细!', icon: Ext.Msg.INFO, buttons: Ext.Msg.OK }); return; }; var jsonbodyAddDatas = ConvertRecordsToJsonAll(bodyAddDatas); _this = this; var data = this.formEdit.getForm().getValues(); Ext.Ajax.request({ waitMsg: '正在添加数据...', url: '/Account/Chfee_payapplication/AddWorkList', params: { head: Ext.JSON.encode(data), data: jsonbodyAddDatas }, callback: function (options, success, response) { if (success) { var result = Ext.JSON.decode(response.responseText); if (!result.Success) { btnEAddbill.enable(); Ext.Msg.show({ title: '提示', msg: result.Message, icon: Ext.MessageBox.ERROR, buttons: Ext.Msg.OK }); return; } else { btnEAddbill.enable(); dataList = result.Data; if (dataList == null) { var sql = this.sqlcontext; this.storeBodyAddList.load({ params: { start: 0, limit: _this.PageSize, sort: '', condition: sql } }); this.storeBodyBalList.load({ params: { condition: "WORKBILLNO='" + billno + "'" } }); } else { } } } else { btnEAddbill.enable(); Ext.MessageBox.alert('请求出现错误,请重试', response.responseText); } }, scope: this }); }, deleteBill: function (type) { var billno = this.formEdit.getForm().findField('BILLNO').getValue(); var selectedRecords = this.gridBalList.selModel.getSelection(); if (selectedRecords.length == 0) { Ext.Msg.show({ title: '提示', msg: '没有要删除的申请明细!', icon: Ext.Msg.INFO, buttons: Ext.Msg.OK }); return; }; var billstatus = this.formEdit.getForm().findField('BILLSTATUS').getValue(); if ((billstatus !='新建')) { Ext.Msg.show({ title: '提示', msg: '当前状态无法删除付费申请明细!', icon: Ext.Msg.INFO, buttons: Ext.Msg.OK }); return; } var data = this.formEdit.getForm().getValues(); var bodyAddDatas = []; for (var i = 0; i < selectedRecords.length; i++) { var rec = selectedRecords[i]; bodyAddDatas.push(rec); } var jsonbodyAddDatas = ConvertRecordsToJsonAll(bodyAddDatas); var sql = this.sqlcontext; _this = this; Ext.Ajax.request({ waitMsg: '正在删除数据...', url: '/Account/Chfee_payapplication/DelWorkList', params: { data: jsonbodyAddDatas, head: Ext.JSON.encode(data) }, 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 sql = this.sqlcontext; this.storeBodyAddList.load({ params: { start: 0, limit: _this.PageSize, sort: '', condition: sql} }); this.storeBodyBalList.load({ params: { condition: "WORKBILLNO='" + billno + "'" } }); } } else { Ext.MessageBox.alert('请求出现错误,请重试', response.responseText); } }, scope: this }); }, onSubmitAuditClick: function () { var Duino = this.formEdit.getForm().findField('BILLNO').getValue(); var billstatus = this.formEdit.getForm().findField('BILLSTATUS').getValue(); if (Duino == '*') { Ext.Msg.show({ title: '提示', msg: '请先保存派工单,然后才能提交审核!', icon: Ext.Msg.INFO, buttons: Ext.Msg.OK }); return; }; if ((billstatus !='新建')) { Ext.Msg.show({ title: '提示', msg: '当前状态无法提交审核!', icon: Ext.Msg.INFO, buttons: Ext.Msg.OK }); return; } _this = this; Ext.Ajax.request({ waitMsg: '正在添加数据...', url: '/Account/Chfee_payapplication/SubmitAuditWork', params: { bill: Duino }, 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 { Ext.Ajax.request({ waitMsg: '正在查询主表数据...', url: '/Account/Chfee_payapplication/GetWorkData', params: { handle: 'edit', condition: " BILLNO='" + Duino + "'" }, 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; } var data = result.data; _this.formEdit.getForm().reset(); _this.formEdit.getForm().setValues(data); var editp = Ext.create('MsChWork', data); this.editRecord.fields.each(function (field) { if (field.persist) { name = field.name; if (name != 'id') this.editRecord.set(name, editp.get(name)); } }, this); this.editRecord.commit(); _this.GetEditStatus(); } else { Ext.MessageBox.alert('请求出现错误,请重试', response.responseText); } }, scope: this }); } } else { Ext.MessageBox.alert('请求出现错误,请重试', response.responseText); } }, scope: this }); }, onSubmitAuditBackClick: function () { var Duino = this.formEdit.getForm().findField('BILLNO').getValue(); var billstatus = this.formEdit.getForm().findField('BILLSTATUS').getValue(); if (Duino == '*') { Ext.Msg.show({ title: '提示', msg: '请先保存派工单,然后才能提交审核!', icon: Ext.Msg.INFO, buttons: Ext.Msg.OK }); return; }; if (billstatus != '提交审核') { Ext.Msg.show({ title: '提示', msg: '当前状态无法撤销提交!', icon: Ext.Msg.INFO, buttons: Ext.Msg.OK }); return; } _this = this; Ext.Ajax.request({ waitMsg: '正在添加数据...', url: '/Account/Chfee_payapplication/SubmitAuditBackWork', params: { bill: Duino }, 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 { Ext.Ajax.request({ waitMsg: '正在查询主表数据...', url: '/Account/Chfee_payapplication/GetWorkData', params: { handle: 'edit', condition: " BILLNO='" + Duino + "'" }, 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; } var data = result.data; _this.formEdit.getForm().reset(); _this.formEdit.getForm().setValues(data); var editp = Ext.create('MsChWork', data); this.editRecord.fields.each(function (field) { if (field.persist) { name = field.name; if (name != 'id') this.editRecord.set(name, editp.get(name)); } }, this); this.editRecord.commit(); _this.GetEditStatus(); } else { Ext.MessageBox.alert('请求出现错误,请重试', response.responseText); } }, scope: this }); } } else { Ext.MessageBox.alert('请求出现错误,请重试', response.responseText); } }, scope: this }); }, onRefreshClick: function (button, event) { var sql = this.getCondition(); this.sqlcontext = sql; this.PageSize = this.Pagenum.getValue(); this.storeBodyAddList.pageSize = this.PageSize; this.storeBodyAddList.load({ params: { start: 0, limit: this.PageSize, sort: '', condition: sql} }); }, onDsQuery: function () { //var girdcolums = this.gridList.getColumnMode(); var sql = this.sqlcontext; this.storeBodyAddList.load({ params: { start: 0, limit: this.PageSize, sort: '', condition: sql} }); }, onClearSql: function () { var form = this.formSearch.getForm(); form.reset(); }, getCondition: function () { var form = this.formSearch.getForm(); if (!form.isValid()) { Ext.Msg.alert('提示', '查询条件赋值错误,请检查。'); return ''; } var sql = " isnull(WORKBILLNO,'')='' and BILLSTATUS=0 "; var customNo = form.findField('CustomNo').getValue(); sql = sql + getAndConSql(sql, customNo, " BILLNO like '%" + customNo + "%'"); var CUSTNAME = form.findField('CUSTNAME').getValue(); sql = sql + getAndConSql(sql, CUSTNAME, " CUSTOMERNAME='" + CUSTNAME + "'"); var SALECORPID = form.findField('SALECORPID').getValue(); sql = sql + getAndConSql(sql, SALECORPID, " SALECORPID='" + SALECORPID + "'"); var SETTLETYPE = form.findField('SETTLETYPE').getValue(); sql = sql + getAndConSql(sql, SETTLETYPE, " SETTLETYPE='" + SETTLETYPE + "'"); 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 + "'"); // this.FeeSqlStr = this.getFeeCondition(); // sql = sql + getAndConSql(sql, this.FeeSqlStr, this.FeeSqlStr); // sql = sql + getAndConSql(sql, feesql, feesql); // this.BillSql = sql; return sql; }, // #region 根据权限和状态判断是否允许修改 GetEditStatus: function () { }, setSaveBtnStatus: function (enable) { var btnESave = Ext.getCmp('btnESave'); var btnESaveAndClose = Ext.getCmp('btnESaveAndClose'); var btnESaveAndNew = Ext.getCmp('btnESaveAndNew'); var btnEAddDetail = Ext.getCmp('btnadddetail'); var btnEAddbill = Ext.getCmp('btnaddbill'); var btnEDeleteDetail = Ext.getCmp('btndeldetail'); if (enable) { btnESave.enable(); btnESaveAndClose.enable(); btnESaveAndNew.enable(); btnEAddDetail.enable(); btnEDeleteDetail.enable(); btnEAddbill.enable(); } else { btnESave.disable(); btnESaveAndClose.disable(); btnESaveAndNew.disable(); btnEAddDetail.disable(); btnEDeleteDetail.disable(); btnEAddbill.disable(); } }, // #endregion OprationSwap: function () { var ret = new Array(); ret[0] = this.OprationStatus; ret[1] = this.storeBodyBalList; ret[2] = this.SelectedRecord; return ret; }, PrevRecord: function () { // var modifystr = this.getIsModify(); // if (modifystr != "") { // Ext.Msg.show({ title: '警告', msg: modifystr + '未保存,如果离开此页,将丢失未保存的更改 !!!', icon: Ext.Msg.ERROR, buttons: Ext.Msg.OK }); // return; // } var j = this.StoreList.indexOf(this.editRecord); if (j == 0) { Ext.Msg.show({ title: '警告', msg: '已是最前一票', icon: Ext.Msg.ERROR, buttons: Ext.Msg.OK }); return; } if (j == this.StoreList.count) { Ext.Msg.show({ title: '警告', msg: '已是最后一票', icon: Ext.Msg.ERROR, buttons: Ext.Msg.OK }); return; } j = j - 1; this.editRecord = this.StoreList.getAt(j); if (this.opStatus == 'edit') condition = " BILLNO='" + this.editRecord.get('BILLNO') + "'"; this.LoadData(this.opStatus, condition); }, NextRecord: function () { // var modifystr = this.getIsModify(); // if (modifystr != "") { // Ext.Msg.show({ title: '警告', msg: modifystr + '未保存,如果离开此页,将丢失未保存的更改 !!!', icon: Ext.Msg.ERROR, buttons: Ext.Msg.OK }); // return; // } var j = this.StoreList.indexOf(this.editRecord); if (j == (this.StoreList.data.length - 1)) { Ext.Msg.show({ title: '警告', msg: '已是最后一票', icon: Ext.Msg.ERROR, buttons: Ext.Msg.OK }); return; } j = j + 1; this.editRecord = this.StoreList.getAt(j); if (this.opStatus == 'edit') condition = " BILLNO='" + this.editRecord.get('BILLNO') + "'"; this.LoadData(this.opStatus, condition); }, Print: function () { var basicForm = this.formEdit.getForm(); var billNo = basicForm.findField('BILLNO').value; if (billNo == '*' || billNo == '') { Ext.Msg.show({ title: '错误', msg: '单据还没有保存,请保存后再打印', icon: Ext.Msg.ERROR, buttons: Ext.Msg.OK }); return; } var printType = 'MSCHFEEWORK'; var sql1 = "SELECT p.*,(select ShowName from [user] where GID=p.APPLICANT) as APPLICANTREF FROM ch_fee_work p WHERE BILLNO='" + billNo + "'"; var sql2 = "SELECT * FROM ch_fee_payapplication where WORKBILLNO='" + billNo+"' "; var sql3 = ""; var sql4 = ""; var sql5 = ""; var sql6 = ""; PrintComm(printType, sql1, sql2, sql3, sql4, sql5, sql6); } });