Ext.namespace('DsTruck'); DsTruck.Chfee_managementIndex = function (config) { Ext.applyIf(this, config); this.initUIComponents(); window.DsTruck.Chfee_managementIndex.superclass.constructor.call(this); }; Ext.extend(DsTruck.Chfee_managementIndex, Ext.Panel, { PageSize: 500, OprationStatus: null, //仅当弹出界面时使用 SelectedRecord: null, VISIBLERANGE: 0, OPERATERANGE: 0, initUIComponents: function () { //定义数据集 this.storeList = Ext.create('Ext.data.Store', { model: 'Baoxiaomb', remoteSort: false, pageSize: this.PageSize, proxy: { type: 'ajax', url: '/OA/Baoxiao2/GetDataList', reader: { idProperty: 'BXGID', root: 'data', totalProperty: 'totalCount' } } }); this.formname = "OA_Baoxiao2"; this.WorkFlowName = "BaoxiaoMod"; _this = this; //this.InWorkFlow=false; //枚举参照 this.initgirdcolums= [{ sortable: true, //hidden: true, dataIndex: 'BXGID', id: "BXGID", header: '报销单序列号', width: 100 }, { sortable: true, hidden: true, dataIndex: 'BXNO', id: "BXNO", header: '报销单号', width: 100 }, { sortable: true, hidden: true, dataIndex: 'BSNO', id: "BSNO", header: '委托编号', width: 80 }, { sortable: true, hidden: true, dataIndex: 'COMPANY', id: "COMPANY", header: '所属公司', width: 80 }, { sortable: true, dataIndex: 'DEPTNAME', header: '所属部门', width: 80 }, { sortable: true, dataIndex: 'SALECORP', header: '所属分部', width: 80 }, { sortable: true, dataIndex: 'CREATEUSER', id: "CREATEUSER", header: '报销人', width: 80 }, { sortable: true, dataIndex: 'CREATEDATE', id: "CREATEDATE", header: '报销日期', width: 80 }, { sortable: true, dataIndex: 'RMBAMOUNT', header: 'RMB金额', width: 80, 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; }, summaryRenderer: function (value, cellmeta, record, rowIndex, columnIndex, store) { value = usMoney(value, 2, '', true); return value; }, summaryType: 'sum' }, { sortable: true, dataIndex: 'USDAMOUNT', header: 'USD金额', width: 80, 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; }, summaryRenderer: function (value, cellmeta, record, rowIndex, columnIndex, store) { value = usMoney(value, 2, '', true); return value; }, summaryType: 'sum' }, { sortable: true, dataIndex: 'OTHERAMOUNT', header: '其他金额', width: 80, 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; }, summaryRenderer: function (value, cellmeta, record, rowIndex, columnIndex, store) { value = usMoney(value, 2, '', true); return value; }, summaryType: 'sum' }, { sortable: true, hidden: true, dataIndex: 'ISDELETE', id: "ISDELETE", header: 'ISDELETE', width: 80 }, { sortable: true, hidden: true, dataIndex: 'DELETEUSER', id: "DELETEUSER", header: 'DELETEUSER', width: 80 }, { sortable: true, hidden: true, dataIndex: 'DELETETIME', id: "DELETETIME", header: 'DELETETIME', width: 80 }, { sortable: true, hidden: true, dataIndex: 'BXSTATUS', id: "BXSTATUS", header: 'BXSTATUS', width: 80 }, /*{ sortable: true, dataIndex: 'CHEQUENO', id: "CHEQUENO", header: '支票号', width: 80 }, { sortable: true, dataIndex: 'CHEQUEAMOUNT', id: "CHEQUEAMOUNT", header: '支票额度', width: 80 },*/{ sortable: true, dataIndex: 'BXSTATUS_REF', id: "BXSTATUS_REF", header: '报销状态', width: 80, renderer: function (value, meta) { if (value == '审核通过') { meta.tdCls = 'feestatus_pass'; } else if (value == '录入状态') { } else if (value == '提交审核') { meta.tdCls = 'feestatus_refer'; } else if (value == '驳回提交') { meta.tdCls = 'feestatus_nopass'; } else if (value == '报销完成') { meta.tdCls = 'feestatus_settle'; } return value; } }, { sortable: true, dataIndex: 'REMARK', id: "REMARK", header: '备注', width: 80 }, { sortable: true, dataIndex: 'ISVOU_REF', id: "ISVOU_REF", header: '已生成凭证', width: 80 }, { sortable: true, dataIndex: 'VOUCHERNO', header: '接口凭证号', width: 100 }, { sortable: true, dataIndex: 'VOUALLNO', header: '总账凭证号', width: 100 }, { sortable: true, dataIndex: 'ISJK', id: "ISJK", header: '费用来源', width: 60 }, { sortable: true, dataIndex: 'AUDITOR', id: "AUDITOR", header: '审核人', width: 100 }, { sortable: true, dataIndex: 'AUDITTIME', id: "AUDITTIME", header: '审核时间', width: 100 }, { sortable: true, dataIndex: 'SUBMITOP', header: '提交人', width: 100 }, { sortable: true, dataIndex: 'SUBMITTIME', header: '提交时间', width: 100 }, { sortable: true, dataIndex: 'FEEREMARK', id: "FEEREMARK", header: '报销事由', width: 200 }]; this.column = this.initgirdcolums; //定义Grid this.BXCB = Ext.create('Ext.selection.CheckboxModel', { checkOnly: true }); Ext.grid.RowNumberer = Ext.extend(Ext.grid.RowNumberer, { width: 45 }); this.gridList = new Ext.grid.GridPanel({ store: this.storeList, enableHdMenu: false, region: 'center', loadMask: { msg: "数据加载中,请稍等..." }, trackMouseOver: true, disableSelection: false, stripeRows: true, viewConfig: { enableTextSelection: true }, stateful: true, selModel: this.BXCB, features: [{ ftype: 'summary' }], columns: [new Ext.grid.RowNumberer()], bbar: Ext.create('Ext.PagingToolbar', { store: this.storeList, displayInfo: true, displayMsg: '当前显示 {0} - {1}条记录 /共 {2}条记录', emptyMsg: "没有数据" }) }); /////////////以下部分为获取存储的gridpanel显示样式 this.column = DsTruck.GetGridPanel(USERID, this.formname, this.column); //使用者id,表名 ,中间column数组,跳过一开始的几列 this.column.unshift(new Ext.grid.RowNumberer()); this.gridList.reconfigure(this.storeList, this.column); //////////////////////////// this.gridList.addListener('itemdblclick', function (dataview, record, item, index, e, b) { this.SelectedRecord = record; this.OprationStatus = 'edit'; DsOpenEditWin("/OA/Baoxiao2/Edit", "", "750", "900", "200", "400"); }, this); /* this.gridList.addListener('itemdblclick', function (dataview, record, item, index, e, b) { alert(record.get("ContractNo")) }, this);*/ //#region formSearch this.storeDEPT = Ext.create('DsExt.ux.RefTableStore', { model: 'DsTruckMng.ux.DEPTRefModel', proxy: { url: '/CommMng/BasicDataRef/GetDeptList' } }); this.storeDEPT.load({ params: { condition: ""} }); this.comboxDEPT = Ext.create('DsExt.ux.RefTableCombox', { fieldLabel: '部门', store: this.storeDEPT, name: 'DEPTID', id: "DEPTID", valueField: 'DeptName', displayField: 'DeptName' }); this.storeUser = Ext.create('DsExt.ux.RefTableStore', { model: 'DsTruckMng.ux.UserRefModel', proxy: { url: '/CommMng/BasicDataRef/GetUserRefList' } }); this.storeUser.load({ params: { condition: ""} }); this.comboxUser = Ext.create('DsExt.ux.RefTableCombox', { fieldLabel: '制单人', store: this.storeUser, name: 'CREATEUSER', valueField: 'UserCode', displayField: 'CodeAndName', value: SHOWNAME }); this.comboxUser_1 = Ext.create('DsExt.ux.RefTableCombox', { fieldLabel: '报销人', store: this.storeUser, name: 'CREATEUSER', id: "CREATEUSER_1", valueField: 'UserName', displayField: 'CodeAndName' }); Ext.define('BXSTATUSmb', { extend: 'Ext.data.Model', fields: [ { name: 'status', type: 'string' }, { name: 'statusRef', type: 'string' } ] }); var StatusData = [{ "status": "0", "statusRef": "审核通过" }, { "status": "1", "statusRef": "录入状态" }, { "status": "2", "statusRef": "提交审核" }, { "status": "6", "statusRef": "驳回提交"}]; this.storeStauts = Ext.create('Ext.data.Store', { model: 'BXSTATUSmb', data: StatusData }); this.comboxStatus = Ext.create('Ext.ux.form.field.BoxSelect', { fieldLabel: '报销单状态', autosize: true, bodyPadding: 5, flex: 1, name: 'BXSTATUS', //width: 500, labelWidth: 90, store: this.storeStauts, queryMode: 'local', triggerOnClick: false, valueField: 'status', displayField: 'statusRef' }); Ext.define('ISPAYEDmb', { extend: 'Ext.data.Model', fields: [ { name: 'ID', type: 'string' }, { name: 'ISPAYED', type: 'string' } ] }); var ISPAYEDData = [{ "ID": "0", "ISPAYED": "全部" }, { "ID": "1", "ISPAYED": "已支付" }, { "ID": "2", "ISPAYED": "未支付"}]; this.storeISPAYED = Ext.create('Ext.data.Store', { model: 'ISPAYEDmb', data: ISPAYEDData }); this.comboxISPAYED = Ext.create('DsExt.ux.RefTableCombox', { fieldLabel: '支付状态', store: this.storeISPAYED, name: 'ISPAYED', //id: "ISPAYED", valueField: 'ID', displayField: 'ISPAYED' }); this.storeWorkFlowStep = Ext.create('DsExt.ux.RefTableStore', { model: 'WorkFlowStepmb', proxy: { url: '/CommMng/WorkFlow/GetWorkFlowStep' } }); this.storeWorkFlowStep.load({ params: { WorkFlowName: this.WorkFlowName} }); this.comboxWorkFlowStep = Ext.create('DsExt.ux.RefTableCombox', { fieldLabel: '可操作的审批步骤', store: this.storeWorkFlowStep, name: 'WorkFlowStep', id: "WorkFlowStep", valueField: 'GID', displayField: 'NAME', values: 1 }); 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.formSearch = Ext.widget('form', { frame: true, region: 'center', bodyPadding: 5, fieldDefaults: { margins: '2 2 2 2', labelAlign: 'right', flex: 1, labelWidth: 90, msgTarget: 'qtip' }, items: [ {//fieldset 1 xtype: 'container', defaultType: 'textfield', layout: 'anchor', defaults: { anchor: '100%' }, items: [{ xtype: 'container', layout: 'hbox', defaultType: 'textfield', items: [this.comboxDEPT, { fieldLabel: '报销单号', name: 'BXGID', id: "BXGID_S" }, this.comboxUser_1, { fieldLabel: '从..报销日', format: 'Y-m-d', xtype: 'datefield', name: 'CREATEDATE_min' }, { fieldLabel: '到..报销日', format: 'Y-m-d', xtype: 'datefield', name: 'CREATEDATE_max' }] }] }, //end items(fieldset 1) {//fieldset 2 xtype: 'container', defaultType: 'textfield', layout: 'anchor', defaults: { anchor: '100%' }, items: [{ xtype: 'container', layout: 'hbox', defaultType: 'textfield', items: [this.comboxISPAYED, { fieldLabel: '费用金额', name: 'Fee_Amount', 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; } }, { fieldLabel: '支票号', name: 'CHEQUENUM' }, this.comboxStatus, this.comboxSaleCompany] }] }, //end fieldset 2 {//fieldset 3 xtype: 'container', defaultType: 'textfield', layout: 'anchor', defaults: { anchor: '100%' }, items: [{ xtype: 'container', layout: 'hbox', defaultType: 'textfield', items: [{ fieldLabel: '提单号/船名', name: 'MBLNO', id: "MBLNO" }, { fieldLabel: '客户名称', name: 'CUSTOMERNAME', id: "CUSTOMERNAME" }, { fieldLabel: '费用名称/备注包含', name: 'FEENAME', id: "FEENAME" }, { fieldLabel: '从..金额', name: 'Amount_min', 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; } }, { fieldLabel: '到..金额', name: 'Amount_max', 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; } } ] }] }, //end items(fieldset 3) {//fieldset 5 xtype: 'container', defaultType: 'textfield', layout: 'anchor', defaults: { anchor: '100%' }, items: [] } //end items(fieldset 5) ]//end root items }); //#endregion formSearch //_this = this; this.CBMWorkFlow = new Ext.form.Checkbox({ fieldLabel: '只显示待处理业务', labelwidth: 200 }); //查询工具条 this.panelBtn = new Ext.Panel({ region: "north", tbar: [ { text: "新建", iconCls: "btnadd", id: "NEW", handler: function (button, event) { this.OprationStatus = 'add'; DsOpenEditWin("/OA/Baoxiao2/Edit", "新建报销单", "650", "800", "200", "500"); }, scope: this }, { text: "删除", iconCls: "btndelete", id: "DEL", handler: function (button, event) { this.onDeleteClick(button, event); }, scope: this }, '-', { text: "执行查询", iconCls: "btnrefresh", handler: function (button, event) { this.onRefreshClick(button, event); }, scope: this }, { text: "重置条件", iconCls: "btnreset", handler: function (button, event) { var form = this.formSearch.getForm(); form.reset(); }, scope: this }, '-', { text: "打开", iconCls: "btnright", id: "OPEN", handler: function (button, event) { this.onOpenClick(button, event); }, scope: this }, '-', { text: "保存列表样式", //"保存列表样式", id: "btntest", menu: [ { text: "保存", //"保存", handler: function (button, event) { _this.column = DsTruck.SaveGridPanel(USERID, _this.formname, _this.gridList.columns, _this.girdcolums, 1, true); } }, { text: "初始化", //"初始化", handler: function (menu, event) { _this.gridList.reconfigure(_this.storeList, _this.initgirdcolums); _this.column = DsTruck.SaveGridPanel(USERID, _this.formname, _this.gridList.columns, _this.initgirdcolums, 1, true); } } ], scope: this }, '-', { // id: "saveandclose", text: "提交审核", id: "Submit", handler: function (button, event) { this.onSubmitAuditClick(); }, scope: this }, { // id: "saveandclose", text: "撤回提交", id: "CallBack", handler: function (button, event) { this.onCallBackClick(); }, scope: this }, { // id: "saveandclose", text: "审核通过", id: "Pass", handler: function (button, event) { this.onAuditPassClick(); }, scope: this }, { // id: "saveandclose", text: "驳回提交", id: "Refuse", handler: function (button, event) { this.onAuditRefuseClick(); }, scope: this }, '-', { text: "导出Excel", id: "btnExportExcel", iconCls: 'btnexportexcel', handler: function (button, event) { this.onExportClick(button, event); }, scope: this }, { // id: "saveandclose", text: "报销完成", id: "Over", handler: function (button, event) { this.onAuditOverClick(); }, scope: this }, { // id: "saveandclose", text: "撤销报销完成", id: "ReOver", handler: function (button, event) { this.onAuditReOverClick(); }, scope: this }, '-', { text: "生成接口凭证", iconCls: "btnadd", id: "VOUCHER", handler: function (button, event) { var form = this.formVoucherShow.getForm(); var VoucherDate = form.findField('VoucherDate'); this.thisday = this.getToday(); VoucherDate.setRawValue(this.thisday) this.winVoucherShow.show(); }, scope: this }, { text: "生成总账凭证", id: "btnAddCwVouchers", iconCls: "btnadd", handler: function (button, event) { this.onAddCwVouchers(); }, scope: this } ] }); /////////////生成凭证对话框 this.CheckRate = new Ext.form.Checkbox({ fieldLabel: '显示已生成凭证', checked: true }); this.formVoucherShow = Ext.widget('form', { frame: true, region: 'center', bodyPadding: 5, fieldDefaults: { margins: '2 2 2 2', labelAlign: 'right', flex: 1, labelWidth: 90, msgTarget: 'qtip' }, items: [ {//fieldset 1 xtype: 'container', defaultType: 'textfield', layout: 'anchor', defaults: { anchor: '100%' }, items: [{ xtype: 'container', layout: 'hbox', defaultType: 'textfield', items: [{ fieldLabel: '凭证日期', format: 'Y-m-d', xtype: 'datefield', name: 'VoucherDate' }, this.comboxUser ] }, { xtype: 'container', layout: 'hbox', defaultType: 'textfield', items: [{ fieldLabel: '美元汇率', xtype: 'numberfield', name: 'UsdExrate' }, this.CheckRate ] } ]//end items(fieldset 1) }//end fieldset 1 ]//end root items }); me = this; this.winVoucherShow = Ext.create('Ext.window.Window', { title: "添加凭证", width: 450, //height : 120, //plain : true, iconCls: "addicon", resizable: true, // 是否可以拖动 // draggable:false, collapsible: true, // 允许缩放条 closeAction: 'close', closable: true, modal: 'true', buttonAlign: "center", bodyStyle: "padding:0 0 0 0", items: [this.formVoucherShow], buttons: [{ text: "生成凭证", minWidth: 70, handler: function () { var selectedRecords = me.gridList.selModel.getSelection(); if (selectedRecords.length == 0) { Ext.Msg.show({ title: '提示', msg: '没有选择要生成凭证的业务!', icon: Ext.Msg.INFO, buttons: Ext.Msg.OK }); return; }; var form = me.formVoucherShow.getForm(); var VoucherDate = form.findField('VoucherDate').getRawValue(); if (VoucherDate == '' || VoucherDate == null || VoucherDate == undefined) { Ext.Msg.show({ title: '提示', msg: '必须填凭证日期!', icon: Ext.Msg.INFO, buttons: Ext.Msg.OK }); return; }; var UsdExrate = form.findField('UsdExrate').getValue(); if (!me.CheckRate.checked) { if (UsdExrate == '' || UsdExrate == null || UsdExrate == undefined) { Ext.Msg.show({ title: '提示', msg: '必须填凭证汇率!', icon: Ext.Msg.INFO, buttons: Ext.Msg.OK }); return; }; }; var User = me.comboxUser.getValue(); if (User == '' || User == null || User == undefined) { Ext.Msg.show({ title: '提示', msg: '必须填凭证制单人!', icon: Ext.Msg.INFO, buttons: Ext.Msg.OK }); return; }; me.onCreateVoucherClick(); } }, { text: "关闭", minWidth: 70, handler: function () { me.winVoucherShow.close(); } }] }); this.panelTop = new Ext.Panel({ layout: "border", region: "north", height: 125, items: [this.formSearch, this.panelBtn] }); Ext.apply(this, { items: [this.panelTop, this.gridList] }); this.InitData(); //集中绑定事件 this.storeList.on('beforeload', function (store) { var sql = this.getCondition(); Ext.apply(store.proxy.extraParams, { condition: sql }); }, this); //#region 生成凭证_汇率列表 //#region 加载数据 //制单人 this.storePREPAREDCode = Ext.create('DsExt.ux.RefTableStore', { model: 'DsShipping.ux.UserRefModel', proxy: { url: '/CommMng/BasicDataRef/GetUserRefList' } }); this.storePREPAREDCode.load(); this.comboxPREPARED = Ext.create('DsExt.ux.RefTableCombox', { fieldLabel: '制单人', store: this.storePREPAREDCode, forceSelection: true, id: 'PREPARED', name: 'PREPARED', valueField: 'UserName', displayField: 'CodeAndName', value: SHOWNAME }); //#endregion //#region 定义数据集 this.storeListCw = Ext.create('Ext.data.Store', { pageSize: this.PageSize, model: 'MsCodeCurrencyList', remoteSort: true, proxy: { type: 'ajax', url: '/OA/Baoxiao2/GetCodeCurrencyList', reader: { id: 'CURR', root: 'data', totalProperty: 'totalCount' } } }); //#endregion //#region 列定义 this.girdcolums = [{ sortable: false, text: '币别', dataIndex: 'CURR', width: 100, align: 'center' }, { sortable: false, text: '调整汇率', dataIndex: 'FCYEXRATE', width: 118, align: 'right', renderer: function (value, cellmeta, record, rowIndex, columnIndex, store) { try { var lsValue = usMoney(value, 5, '', false); if (lsValue != "NaN") { value = lsValue; if (parseFloat(lsValue) < 0) { return '' + lsValue + ''; } } else { return value; } } catch (e) { return value; } return value; }, editor: { xtype: 'numberfield', selectOnFocus: true, //得到焦点时自动选择文本 allowDecimals: true, //允许输入小数 decimalPrecision: 5, //允许保留的小数位数,并四舍五入 nanText: '请输入有效数值', hideTrigger: true //是否隐藏上下调节按钮 } }]; //#endregion //#region gridList列表显示信息 this.gridListCellEditing = Ext.create('Ext.grid.plugin.CellEditing', { clicksToEdit: 1 //1单击,2双击 }); this.gridListCw = new Ext.grid.GridPanel({ region: 'center', width: 220, store: this.storeListCw, enableHdMenu: false, //是否显示表格列的菜单 hideHeaders: false, //是否隐藏表头 rowLines: true, columnLines: true, loadMask: { msg: "数据加载中,请稍等..." }, plugins: [this.gridListCellEditing], selType: 'cellmodel', columns: this.girdcolums }); //#endregion //#endregion }, //end initUIComponents onCreateVoucherClick: function (button, event) { var feeBSNOSql = ''; var selectedRecords = this.gridList.selModel.getSelection(); var form = this.formVoucherShow.getForm(); var zhaiyao = ""; if (selectedRecords.length != 1) { Ext.Msg.show({ title: '提示', msg: '只能每报销单生成一个凭证', icon: Ext.Msg.INFO, buttons: Ext.Msg.OK }); return; }; var this_deptid = ""; for (var i = 0; i < selectedRecords.length; i++) { var rec = selectedRecords[i]; if (rec.data.BXSTATUS_REF == '审核通过') { if (rec.data.ISVOU_REF != '是') { var feeBSNO = "'" + rec.data.BXGID + "'"; if (feeBSNOSql == '') { feeBSNOSql = feeBSNO; } else { feeBSNOSql = feeBSNOSql + "," + feeBSNO; } if (zhaiyao == "") { if (rec.data.BXNO != "") { zhaiyao = "报销单(" + rec.data.BXNO + "/" + rec.data.BXGID + ")"; } else { zhaiyao = "报销单(" + rec.data.BXGID + ")"; } } else { //zhaiyao = " 等"; } this_deptid = rec.data.DEPTNAME; } } } if (feeBSNOSql == '') { Ext.Msg.show({ title: '提示', msg: '没有选择要生成凭证的业务,必须是没有生成凭证的业务!', icon: Ext.Msg.INFO, buttons: Ext.Msg.OK }); return; }; feeBSNOSql = " (" + feeBSNOSql + ")"; var VoucherDate = form.findField('VoucherDate').getRawValue(); var UsdExrate = form.findField('UsdExrate').getValue(); var User = this.comboxUser.getValue(); var useRate = 1; if (!this.CheckRate.checked) { useRate = 0 }; Ext.Ajax.request({ waitMsg: '正在添加数据...', url: '/OA/Baoxiao/CreateVoucher', params: { VoucherDate: VoucherDate, UsdExrate: UsdExrate, User: User, useRate: useRate, feesql: feeBSNOSql, DEPTGID: this_deptid, zhaiyao: zhaiyao }, 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.winVoucherShow.close(); this.onRefreshClick(); } } else { Ext.MessageBox.alert('请求出现错误,请重试', response.responseText); } }, scope: this }); }, checkHandler: function () { alert('Checked a menu item'); }, onRefreshClick: function (button, event) { var sql = this.getCondition(); this.storeList.load({ params: { start: 0, limit: this.PageSize, sort: '', condition: sql }, waitMsg: "正在查询数据...", scope: this }); //alert(this.storeList.getCount()); }, InitData: function () { Ext.Ajax.request({ waitMsg: '正在查询用户权限...', url: '/CommMng/BasicDataRef/GetAuthorityRange', params: { modName: "mod_Baoxiao", USERID: USERID }, callback: function (options, success, response) { if (success) { var result = Ext.JSON.decode(response.responseText); rec = result.data; //alert(rec.VISIBLERANGE); //alert(rec.OPERATERANGE); //可操作为0则全都可见,3为可提交/驳回,2为可审核/驳回,1为只能看 this.VISIBLERANGE = rec.VISIBLERANGE; this.OPERATERANGE = rec.OPERATERANGE; if (this.OPERATERANGE == "0") { Ext.getCmp("Submit").enable(); Ext.getCmp("Pass").enable(); Ext.getCmp("Refuse").enable(); Ext.getCmp("NEW").enable(); Ext.getCmp("DEL").enable(); Ext.getCmp("VOUCHER").enable(); //Ext.getCmp("Over").enable(); //Ext.getCmp("ReOver").enable(); } else if (this.OPERATERANGE == "1") { Ext.getCmp("Submit").disable(); Ext.getCmp("Pass").disable(); Ext.getCmp("Refuse").disable(); Ext.getCmp("NEW").disable(); Ext.getCmp("DEL").disable(); Ext.getCmp("VOUCHER").disable(); //Ext.getCmp("Over").disable(); //Ext.getCmp("ReOver").disable(); } else if (this.OPERATERANGE == "2") { Ext.getCmp("Submit").disable(); Ext.getCmp("Pass").enable(); Ext.getCmp("Refuse").enable(); Ext.getCmp("NEW").disable(); Ext.getCmp("DEL").enable(); Ext.getCmp("VOUCHER").enable(); //Ext.getCmp("Over").enable(); //Ext.getCmp("ReOver").enable(); } else { Ext.getCmp("Submit").enable(); Ext.getCmp("Pass").disable(); Ext.getCmp("Refuse").disable(); Ext.getCmp("NEW").enable(); Ext.getCmp("DEL").enable(); Ext.getCmp("VOUCHER").disable(); //Ext.getCmp("Over").disable(); //Ext.getCmp("ReOver").disable(); } } else { Ext.MessageBox.alert('请求出现错误,请重试', response.responseText); } }, scope: this }); //request over var btnaddbs = Ext.getCmp('Over'); var btncopyaddbs = Ext.getCmp('ReOver'); Ext.Ajax.request({ waitMsg: Zi.LAN.ZhengZaiCaoZuoShuJu, url: '/MvcShipping/MsBaseInfo/GetUserModuleEnable', params: { modulename: 'BAOXIAOOVER' }, callback: function (options, success, response) { if (success) { var result = Ext.JSON.decode(response.responseText); if (result.Success) { btnaddbs.show(); btncopyaddbs.show(); } else { btnaddbs.hide(); btncopyaddbs.hide(); } } }, scope: this }); //var STEPNO=this.storeWorkFlowStep.getAt(index).get("STEPNO"); }, //end InitData 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 selectedRecords = []; selectedRecords = this.gridList.selModel.getSelection(); var candelete = DsTruck.CheckBaoxiaoDelete(selectedRecords); if (candelete == false) { return; } var record = selections[0]; Ext.MessageBox.confirm('提示', '确定删除该记录吗?', function (btn) { if (btn == 'yes') { Ext.Msg.wait('正在删除数据...'); Ext.Ajax.request({ waitMsg: '正在删除数据...', url: '/OA/Baoxiao2/Delete', params: { data: Ext.JSON.encode(record.data), USERID: USERID }, callback: function (options, success, response) { if (success) { var jsonresult = Ext.JSON.decode(response.responseText); if (jsonresult.Success) { this.storeList.remove(record); Ext.Msg.show({ title: '提示', msg: jsonresult.Message, icon: Ext.Msg.INFO, buttons: Ext.Msg.OK }); } else { Ext.Msg.show({ title: '错误', msg: jsonresult.Message, icon: Ext.Msg.ERROR, buttons: Ext.Msg.OK }); } } }, failure: function (response, options) { Ext.Msg.show({ title: '警告', msg: '服务器响应出错,请重试', icon: Ext.Msg.INFO, buttons: Ext.Msg.OK }); }, success: function (response, options) { }, scope: this }); //end Ext.Ajax.request } }, this); InitData(); }, //onDeleteClick onOpenClick: 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; } if (selections.length > 1) { Ext.Msg.show({ title: '提示', msg: '请注意,将打开所选内容的第一条!', icon: Ext.Msg.INFO, buttons: Ext.Msg.OK }); } var selectedRecords = []; selectedRecords = this.gridList.selModel.getSelection(); this.SelectedRecord = selectedRecords[0]; this.OprationStatus = 'edit'; DsOpenEditWin("/OA/Baoxiao/Edit", "", "620", "1000"); }, //onDeleteClick getToday: function () { var now = new Date(); var year = now.getFullYear(); //年 var month = now.getMonth() + 1; //月 var day = now.getDate(); //日 var clock = year + "-"; if (month < 10) clock += "0"; clock += month + "-"; if (day < 10) clock += "0"; clock += day + " "; return (clock); }, onResetClick: function (button, event) { this.formSearch.getForm().reset(); }, getCondition: function () { var form = this.formSearch.getForm(); if (!form.isValid()) { Ext.Msg.alert('提示', '查询条件赋值错误,请检查。'); return ''; } if (this.VISIBLERANGE == "0")//查看权限 全部 { var sql = ''; } else if (this.VISIBLERANGE == "1")//分公司 { var sql = " BX.company='" + COMPANYID + "'"; } else if (this.VISIBLERANGE == "2")//部门 { var sql = " BX.DEPTNAME ='" + DEPTGID + "'"; } else if (this.VISIBLERANGE == "3")//个人 { var sql = " BX.createuser='" + SHOWNAME + "'"; } else { sql = " 1<0"; } //OPERATERANGE var SALECORPID = form.findField('SALECORPID').getValue(); sql = sql + getAndConSql(sql, SALECORPID, "BX.SALECORPID='" + SALECORPID + "'"); var DEPTID = Ext.getCmp("DEPTID").getValue(); sql = sql + getAndConSql(sql, DEPTID, "BX.DEPTNAME like '%" + DEPTID + "%'"); var BXGID = Ext.getCmp("BXGID_S").getValue(); sql = sql + getAndConSql(sql, BXGID, "BX.BXGID like '%" + BXGID + "%' or BX.BXNO like '%" + BXGID + "%'"); var CREATEUSER = Ext.getCmp("CREATEUSER_1").getValue(); sql = sql + getAndConSql(sql, CREATEUSER, "BX.CREATEUSER = '" + CREATEUSER + "'"); var CREATEDATE_min = form.findField('CREATEDATE_min').getRawValue(); sql = sql + getAndConSql(sql, CREATEDATE_min, "BX.CREATEDATE >= '" + CREATEDATE_min + "'"); var CREATEDATE_max = form.findField('CREATEDATE_max').getRawValue(); sql = sql + getAndConSql(sql, CREATEDATE_max, "BX.CREATEDATE <= '" + CREATEDATE_max + " 23:59:59'"); var Status = this.comboxStatus.getValue(); if (Status != "") { sql = sql + getAndConSql(sql, Status, "bx.bxstatus in (" + Status + ")"); } var Amount_min = form.findField('Amount_min').getValue(); sql = sql + getAndConSql(sql, Amount_min, "BX.amount >= " + Amount_min); var Amount_max = form.findField('Amount_max').getValue(); sql = sql + getAndConSql(sql, Amount_max, "BX.amount <= " + Amount_max); var Fee_Amount = form.findField('Fee_Amount').getValue(); sql = sql + getAndConSql(sql, Fee_Amount, "BX.BXGID in (select bxgid from ch_fee where amount =" + Fee_Amount + ")"); var CHEQUENUM = form.findField('CHEQUENUM').getValue(); sql = sql + getAndConSql(sql, CHEQUENUM, "BX.BXGID in (select bxgid from ch_fee where CHEQUENUM like '%" + CHEQUENUM + "%')"); var ISPAYED = this.comboxISPAYED.getValue(); var CUSTOMERNAME = Ext.getCmp("CUSTOMERNAME").getValue(); sql = sql + getAndConSql(sql, CUSTOMERNAME, "BX.BXGID in (select bxgid from ch_fee where customername like '%" + CUSTOMERNAME + "%')"); var FEENAME = Ext.getCmp("FEENAME").getValue(); sql = sql + getAndConSql(sql, FEENAME, "(BX.BXGID in (select bxgid from ch_fee where FEENAME like '%" + FEENAME + "%' or remark like '%" + FEENAME + "%') or BX.Remark like '%" + FEENAME + "%')"); var MBLNO = Ext.getCmp("MBLNO").getValue(); sql = sql + getAndConSql(sql, MBLNO, "BX.BXGID in (select bxgid from ch_fee where bsno in( select bsno from vw_settlement where mblno like '%" + MBLNO + "%'))"); if (ISPAYED == "1") {//已支付 sql = sql + getAndConSql(sql, ISPAYED, " (select isnull(sum(obp.amount),0) from OA_Baoxiao_Pay obp where obp.BXGID=bx.BXGID)=isnull(bx.amount,0) "); //alert("1"); }; if (ISPAYED == "2") { sql = sql + getAndConSql(sql, ISPAYED, " (select isnull(sum(obp.amount),0) from OA_Baoxiao_Pay obp where obp.BXGID=bx.BXGID)<>isnull(bx.amount,0) "); //alert("2"); }; /* var WorkFlow = form.findField("WorkFlow").getValue(); if (WorkFlow) { sql = sql + getAndConSql(sql, WorkFlow, " (m.ReceiptStatus is null or m.ReceiptStatus=0 )"); } */ /* var WorkFlowStep=form.findField("WorkFlowStep").getValue(); if (WorkFlowStep!="" && WorkFlowStep!=null ){ var index=this.storeWorkFlowStep.find("GID",WorkFlowStep); //alert (this.storeWorkFlowStep.getAt(index).get("NAME")); var STEPNO=this.storeWorkFlowStep.getAt(index).get("STEPNO"); var STEPID=this.storeWorkFlowStep.getAt(index).get("GID"); var BSNOList=""; var returnData=[]; Ext.Ajax.request({ waitMsg: '正在查询数据...', url: '/CommMng/WorkFlow/GetWorkFlowBSNO', scope: this, async:false, params: {WorkFlowName:this.WorkFlowName, STEPNO:STEPNO }, waitMsg: "正在查询数据...", callback: function (options, success, response) { if (success) { var jsonresult = Ext.JSON.decode(response.responseText); returnData = jsonresult.data; for (var i = 0; i < returnData.length; i++) { var rec = returnData[i]; if (BSNOList == "") { BSNOList = "'" + rec.BSNO + "'"; } else { BSNOList = BSNOList + ",'" + rec.BSNO + "'"; } } sql = sql + getAndConSql(sql, BSNOList, " BX.BXGID in ("+BSNOList+") "); //this.InWorkFlow=true; } else { Ext.Msg.show({ title: '请重试', msg: '服务器响应出错', icon: Ext.Msg.ERROR, buttons: Ext.Msg.OK }); return; } } }); }else{ //this.InWorkFlow=false; }*/ return sql; }, onExportClick: function () { _this = this; if (this.storeList.getCount() == 0) { return; } Ext.Msg.wait('正在组织数据, 请稍侯..'); Ext.Ajax.request({ waitMsg: '正在组织数据...', url: '/OA/Baoxiao2/GetDataListStr', scope: this, params: { 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 = 'MSBAOXIAOLIST'; var sql1 = returnstr; 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 }); } } }); }, onGetremind: function (field, newValue, oldValue) { if (newValue != null) { this.storeList.load({ params: { start: 0, limit: this.PageSize, sort: '', condition: newValue }, waitMsg: "正在查询数据...", scope: this }); } }, OprationSwap: function () { var ret = new Array(); ret[0] = this.OprationStatus; ret[1] = this.storeList; ret[2] = this.SelectedRecord; return ret; }, onSubmitAuditClick: function (button, event) { //提交审核 var records = this.gridList.selModel.getSelection(); if (records.length > 0) { DsTruck.BaoxiaoAudit(records, 2, "BaoxiaoMod", '正在审核数据, 请稍侯..'); InitData(); } }, onCallBackClick: function (button, event) { //提交审核 var records = this.gridList.selModel.getSelection(); if (records.length > 0) { DsTruck.BaoxiaoAudit(records, 1, "BaoxiaoMod", '正在审核数据, 请稍侯..'); InitData(); } }, onAuditPassClick: function (button, event) { //审核通过 //var records = this.MainCB.selected.items; var records = this.gridList.selModel.getSelection(); if (records.length > 0) { DsTruck.BaoxiaoAudit(records, 0, "BaoxiaoMod", '正在审核数据, 请稍侯..'); this.onRefreshClick(button, event); } }, onAuditRefuseClick: function (button, event) { //驳回提交 var records = this.gridList.selModel.getSelection(); if (records.length > 0) { if (records[0].data.VOUALLNO.toString() != "") { alert("已生成总账凭证,无法驳回"); return; } DsTruck.BaoxiaoAudit(records, 6, "BaoxiaoMod", '正在审核数据, 请稍侯..'); this.onRefreshClick(button, event); } }, onAuditOverClick: 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.BXGID; if ((rec.data.BXSTATUS_REF == '审核通过')) { if (BILLNOStr == '') BILLNOStr = BILLNO; else { BILLNOStr = BILLNOStr + ',' + BILLNO; } } else { Ext.Msg.show({ title: '提示', msg: '当前状态不允许报销完成!', icon: Ext.Msg.INFO, buttons: Ext.Msg.OK }); return; } } _this = this; if (BILLNOStr == '') { } else { Ext.Ajax.request({ waitMsg: '正在添加数据...', url: '/OA/Baoxiao2/AuditOverList', 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.storeList.reload(); } } else { Ext.MessageBox.alert('请求出现错误,请重试', response.responseText); } }, scope: this }); } }, onAuditReOverClick: 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.BXGID; if (rec.data.BXSTATUS_REF == '报销完成') { if (BILLNOStr == '') BILLNOStr = BILLNO; else { BILLNOStr = BILLNOStr + ',' + BILLNO; } } else { Ext.Msg.show({ title: '提示', msg: '当前状态不允许取消报销完成!', icon: Ext.Msg.INFO, buttons: Ext.Msg.OK }); return; } } _this = this; if (BILLNOStr == '') { } else { Ext.Ajax.request({ waitMsg: '正在添加数据...', url: '/OA/Baoxiao2/AuditReOverList', 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.storeList.reload(); } } else { Ext.MessageBox.alert('请求出现错误,请重试', response.responseText); } }, scope: this }); }; }, //#region 生成凭证 onAddCwVouchers: 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 strError = ""; var strGids = ""; var iGids = 0; for (var i = 0; i < selections.length; i++) { var rec = selections[i]; if (strGids == "") strGids = rec.data.BXGID; else { strGids += "," + rec.data.BXGID; } } // if (strGids.trim() != "") { Ext.Ajax.request({ waitMsg: '正在预读数据,请稍候...', url: '/OA/Baoxiao2/GetIsVoucher', params: { strGids: strGids }, 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; } this.storeListCw.load({ params: { strGids: strGids }, waitMsg: "正在刷新数据...", scope: this }); this.showContactForm(false, strGids, this, selections.length); } else { Ext.MessageBox.alert('请求出现错误,请重试', response.responseText); } }, scope: this }); } // }, //#region 层_显示信息 showContactForm: function (win, strGids, _this, iGids) { var required = '*'; if (!win) { //#region 编辑formDiv 基本信息 var formDiv = Ext.widget('form', { border: false, bodyPadding: 10, fieldDefaults: { labelAlign: 'right', labelWidth: 60, labelStyle: 'font-weight:bold' }, items: [this.comboxPREPARED, { fieldLabel: '记账日期', format: 'Y-m-d', xtype: 'datefield', allowBlank: false, name: 'VOUDATE', value: Ext.util.Format.date(Ext.Date.add(new Date(), Ext.Date.MONTH - 1, 1), "Y-m-d") }, { xtype: "checkbox", //checkbox控件 name: "ISRATE", boxLabel: "是否按照系统录入汇率", width: 200, inputValue: "true", //选中的值 uncheckedValue: "false", //未选中的值 checked: true, //绘制时的选中状态, listeners: { 'change': function (field, newValue, oldValue, eOpts) { if (field.checked.toString() == "false") { this.gridListCw.show(); } else { this.gridListCw.hide(); } }, scope: this } }, this.gridListCw ], buttons: [{ text: '生成凭证', handler: function (options, success, response) { if (!this.up('form').getForm().isValid()) { return; } var dataDiv = this.up('form').getForm().getValues(false, false, false); // var j = 0; var bodydatas = []; for (var i = 0; i < _this.storeListCw.getCount(); i += 1) { var member = _this.storeListCw.getAt(i); bodydatas.push(member); } var jsonBody; if (bodydatas.length > 0) { jsonBody = ConvertRecordsToJsonAll(bodydatas); } // Ext.Msg.wait('正在生成' + iGids + '票结算单数据, 请稍侯...'); Ext.Ajax.request({ waitMsg: '正在生成' + iGids + '票结算单数据, 请稍侯...', url: '/OA/Baoxiao2/onAddCwVouchers', scope: this, params: { strGids: strGids, dataDiv: Ext.JSON.encode(dataDiv), jsonBody: jsonBody }, callback: function (options, success, response) { if (success) { Ext.MessageBox.hide(); var jsonresult = Ext.JSON.decode(response.responseText); if (jsonresult.Success) { Ext.Msg.show({ title: '提示', msg: jsonresult.Message, icon: Ext.MessageBox.INFO, buttons: Ext.Msg.OK }); _this.onRefreshClick(); return; } 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 }); } }, timeout: 3000000//30秒 }); // this.up('form').getForm().reset(); this.up('window').hide(); } }, { text: '取消', handler: function () { this.up('form').getForm().reset(); this.up('window').hide(); } }], listeners: { scope: this, 'render': function (thisDiv, thisExtend) { this.gridListCw.hide(); // Ext.Ajax.request({ waitMsg: '正在查询委托编号状态...', url: '/MvcShipping/MsBaseInfo/GetCwVOUNO', params: { VKNO: "记" }, 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.INFO, buttons: Ext.Msg.OK }); return; } // data = result.data; var arrayList = new Array(); arrayList = data.split("~"); var strY = arrayList[0].toString(); var strM = arrayList[1].toString(); var sVOUNO = arrayList[2].toString(); var strVOUNO = arrayList[3].toString(); var strVOUDATE = arrayList[4].toString(); var strACCDATE = arrayList[5].toString(); // thisDiv.form.findField('VOUDATE').setValue(strVOUDATE); thisDiv.form.findField('VOUDATE').setMinValue(strACCDATE + "-01"); } else { Ext.MessageBox.alert('请求出现错误,请重试', response.responseText); } }, scope: this }); } } }); //#endregion win = Ext.widget('window', { title: '辅助核算', closeAction: 'hide', width: 250, height: 250, layout: 'fit', resizable: true, modal: true, closable: false, items: formDiv }); } win.show(); } //#endregion //#endregion });