Ext.namespace('DsTruck'); DsTruck.CostRevenueIndex = function (config) { Ext.applyIf(this, config); this.initUIComponents(); window.DsTruck.CostRevenueIndex.superclass.constructor.call(this); }; Date.prototype.format = function (format) { var o = { "M+": this.getMonth() + 1, //month "d+": this.getDate(), //day "h+": this.getHours(), //hour "m+": this.getMinutes(), //minute "s+": this.getSeconds(), //second "q+": Math.floor((this.getMonth() + 3) / 3), //quarter "S": this.getMilliseconds() //millisecond } if (/(y+)/.test(format)) format = format.replace(RegExp.$1, (this.getFullYear() + "").substr(4 - RegExp.$1.length)); for (var k in o) if (new RegExp("(" + k + ")").test(format)) format = format.replace(RegExp.$1, RegExp.$1.length == 1 ? o[k] : ("00" + o[k]).substr(("" + o[k]).length)); return format; } var isReqOn = 0; var xhr = new XMLHttpRequest(); var currdate = new Date(); if (!xhr) { //...其他生成xmlhttprequest方法 } xhr.open("HEAD", location.href, true); xhr.onreadystatechange = function () { if (xhr.readyState == 4 && xhr.status == 200) { var datestr = xhr.getResponseHeader("Date"); currdate = new Date(datestr); // alert(currdate.format('yyyy-MM-dd')); } } xhr.send(null); Ext.define('CWLockmb', { extend: 'Ext.data.Model', idProperty: 'GId', fields: [ { name: 'GId', type: 'string' }, { name: 'ContractNo', type: 'string' }, { name: 'HTH', type: 'string' }, { name: 'seller', type: 'string' }, { name: 'buyer', type: 'string' }, { name: 'FEENAME', type: 'string' }, { name: 'CUSTOMERNAME', type: 'string' }, { name: 'AMOUNT', type: 'string' }, { name: 'country', type: 'string' }, { name: 'creator', type: 'string' }, { name: 'MainState', type: 'string' }, { name: 'BillNo', type: 'string' }, { name: 'Vessel', type: 'string' }, { name: 'Voyage', type: 'string' }, { name: 'Ex_Sailingdate', type: 'string' }, { name: 'Sailingdate', type: 'string' }, { name: 'ArrivalDate', type: 'string' }, { name: 'creattime', type: 'string' }, { name: 'MainstateRef', type: 'string' }, { name: 'portRef', type: 'string' }, { name: 'FEESTATUSREF', type: 'string' }, { name: 'FEETYPEREF', type: 'string' }, { name: 'remark', type: 'string' }, { name: 'ACCDATE', type: 'string' }, { name: 'ISVOU', type: 'string' }, { name: 'VOUCHERNO', type: 'string' }, { name: 'AC', type: 'string' }, //{ name: 'AD', type: 'string' }, { name: 'CR', type: 'string' }, { name: 'DR', type: 'string' } ] }); Ext.extend(DsTruck.CostRevenueIndex, Ext.Panel, { PageSize: 100, OprationStatus: null, //仅当弹出界面时使用 SelectedRecord: null, thisday: '2014-01-01', initUIComponents: function () { //定义数据集 this.storeList = Ext.create('Ext.data.Store', { model: 'CWLockmb', remoteSort: true, pageSize: this.PageSize, proxy: { type: 'ajax', url: '/Import/CostRevenue/GetDataList', reader: { idProperty: 'GId', root: 'data', totalProperty: 'totalCount' } } }); var formname = 'CostRevenue_Index'; Ext.grid.RowNumberer = Ext.extend(Ext.grid.RowNumberer, { width: 30 }); this.column = [{ sortable: true, id: '', dataIndex: 'GId', header: 'GId', width: 80 }, { sortable: true, id: '', dataIndex: 'ContractNo', header: '合同序列号', width: 80 }, { sortable: true, id: '', dataIndex: 'HTH', header: '合同号', width: 80 }, { sortable: true, id: '', dataIndex: 'seller', header: '贸易商', width: 80 }, { sortable: true, id: '', dataIndex: 'buyer', header: '购货方', width: 80 }, { sortable: true, id: '', dataIndex: 'FEENAME', header: '费用名称', width: 80 }, { sortable: true, id: '', dataIndex: 'CUSTOMERNAME', header: '结算对象', width: 80 }, { sortable: true, id: '', dataIndex: 'portRef', header: '目的港', width: 80 }, { sortable: true, id: '', dataIndex: 'MainstateRef', header: '合同状态', width: 80 }, { sortable: true, id: '', dataIndex: 'FEESTATUSREF', header: '费用状态', width: 80 }, { sortable: true, id: '', dataIndex: 'AMOUNT', header: '金额', width: 80 }, { sortable: true, dataIndex: 'AC', header: '付费/收费申请', width: 140 }/*, { sortable: true, dataIndex: 'AD', header: '收费申请', width: 140 }*/, { sortable: true, dataIndex: 'CR', header: '付费结算', width: 140 }, { sortable: true, dataIndex: 'DR', header: '收费结算', width: 140 }, { sortable: true, id: '', dataIndex: 'country', header: '进口国', width: 80 }, { sortable: true, id: '', dataIndex: 'creator', header: '接单人', width: 80 }, { sortable: true, id: '', dataIndex: 'MainState', header: 'mainstate', width: 80 }, { sortable: true, id: '', dataIndex: 'BillNo', header: '提单号', width: 80 }, { sortable: true, id: '', dataIndex: 'Vessel', header: '船名', width: 80 }, { sortable: true, dataIndex: 'Voyage', header: '航次', width: 80 }, { sortable: true, id: '', dataIndex: 'Ex_Sailingdate', header: '预计开船日', width: 80 }, { sortable: true, id: '', dataIndex: 'Sailingdate', header: '开船日', width: 80 }, { sortable: true, id: '', dataIndex: 'ArrivalDate', header: '到港日', width: 80 }, { sortable: true, id: '', dataIndex: 'creattime', header: '接单日期', width: 80 }, { sortable: true, id: '', dataIndex: 'FEETYPEREF', header: '收付方向', width: 80 }, { sortable: true, id: '', dataIndex: 'remark', header: '备注', width: 80 }, { sortable: true, id: '', dataIndex: 'ACCDATE', header: '会计期间', width: 80 }, { sortable: true, id: '', dataIndex: 'ISVOU', header: '是否生成凭证', width: 80 }, { sortable: true, id: '', dataIndex: 'VOUCHERNO', header: '凭证号', width: 80 }]; //定义Grid var _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.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, stripeRows: true, viewConfig: { enableTextSelection: true }, selModel: this.GridCheckBoxModel, columns: [new Ext.grid.RowNumberer()], bbar: [Ext.create('Ext.PagingToolbar', { store: this.storeList, displayInfo: true, displayMsg: '当前显示 {0} - {1}条记录 /共 {2}条记录', emptyMsg: "没有数据" }), this.Pagenum] }); /////////////以下部分为获取存储的gridpanel显示样式 if (GID == '') { alert('未检测到用户信息,请重新登陆') } else { this.column = DsTruck.GetGridPanel(GID, formname, this.column); this.column.unshift(new Ext.grid.RowNumberer()); this.gridList.reconfigure(this.storeList, this.column); } //////////////////////////// //明细表-数据集 this.storeBodyChFee = Ext.create('Ext.data.Store', { model: 'MsChFee', remoteSort: false, proxy: { type: 'ajax', url: '/Import/XXH/GetFeeList', reader: { id: 'GId', root: 'data', totalProperty: 'totalCount' } } }); this.storeBodyChFee_YF = Ext.create('Ext.data.Store', { model: 'MsChFee', remoteSort: false, proxy: { type: 'ajax', url: '/Import/XXH/GetFeeList', reader: { id: 'GId', root: 'data', totalProperty: 'totalCount' } } }); //明细表表格 this.cellEditingChFee = Ext.create('Ext.grid.plugin.CellEditing', { clicksToEdit: 1 }); this.feeGridCheckBoxModel = Ext.create('Ext.selection.CheckboxModel', { checkOnly: true }); this.gridListChFee = new Ext.grid.GridPanel({ store: this.storeBodyChFee, enableHdMenu: false, region: 'center', //height: 600, loadMask: { msg: "数据加载中,请稍等..." }, trackMouseOver: true, disableSelection: false, //plugins: [this.cellEditingChFee], //selModel: this.feeGridCheckBoxModel, selType: 'cellmodel', viewConfig: { autoFill: true, enableTextSelection: true, getRowClass: function (record, rowIndex, rowParams, store) { var feeStatus = record.get('FeeStatus'); return DsTruck.MsChFeeGetRowClass(feeStatus); } }, tbar: [{ xtype: 'label', id: 'label2', text: "应收费用" }, ], columns: [{ sortable: true, dataIndex: 'GId', header: '惟一编号', hidden: true, width: 160 }, { sortable: true, dataIndex: 'BsNo', header: '业务编号', hidden: true, width: 200 }, { sortable: true, dataIndex: 'FeeStatus', header: '费用状态', renderer: function (value, p, record) { return record.data.FeeStatus_Ref; }, width: 66 }, { sortable: true, dataIndex: 'FeeName', header: '费用名称', width: 75 }, { sortable: true, dataIndex: 'FeeDescription', header: '费用英文名称', hidden: true, width: 200 }, { sortable: true, dataIndex: 'CustomerType', header: '客户类别', hidden: true, width: 200 }, { sortable: true, dataIndex: 'CustomerName', header: '结算对象', width: 100 }, { sortable: true, dataIndex: 'UnitPrice', header: '单价', editor: { xtype: 'numberfield', selectOnFocus: true }, width: 85, 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: 'Quantity', header: '数量(税率)', width: 60 }, { sortable: true, dataIndex: 'Amount', header: '金额', width: 85, 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: 'Currency', header: '币别', editor: this.comboxcurr, width: 60 }, { sortable: true, dataIndex: 'ExChangerate', header: '汇率', editor: { xtype: 'textfield', selectOnFocus: true }, width: 60 }, { sortable: true, dataIndex: 'SettlementDate', header: '结算情况', width: 150 }, { sortable: true, dataIndex: 'Remark', header: '备注', editor: { xtype: 'textfield', selectOnFocus: true }, width: 150 }, { sortable: true, dataIndex: 'Auditoperator', header: '审核人', hidden: true, width: 200 }, { sortable: true, dataIndex: 'AuditDate', header: '审核时间', hidden: true, width: 200 }, { sortable: true, dataIndex: 'EnteroPerator', header: '录入人', hidden: true, width: 200 }, { sortable: true, dataIndex: 'EnterDate', header: '录入时间', hidden: true, width: 200 }, { sortable: true, dataIndex: 'AuditStatus', header: '审核状态', hidden: true, width: 100 }, { sortable: true, dataIndex: 'ACCDATE', header: '会计期间', //hidden: true, width: 100 }, { sortable: true, dataIndex: 'VOUCHERNO', header: '凭证号', //hidden: true, width: 100 } ] }); /////--////// this.cellEditingChFee_YF = Ext.create('Ext.grid.plugin.CellEditing', { clicksToEdit: 1 }); this.feeGridCheckBoxModel_YF = Ext.create('Ext.selection.CheckboxModel', { checkOnly: true }); this.gridListChFee_YF = new Ext.grid.GridPanel({ store: this.storeBodyChFee_YF, enableHdMenu: false, region: 'center', //height: 600, loadMask: { msg: "数据加载中,请稍等..." }, trackMouseOver: true, disableSelection: false, //plugins: [this.cellEditingChFee_YF], //selModel: this.feeGridCheckBoxModel_YF, selType: 'cellmodel', viewConfig: { autoFill: true, enableTextSelection: true, getRowClass: function (record, rowIndex, rowParams, store) { var feeStatus = record.get('FeeStatus'); return DsTruck.MsChFeeGetRowClass(feeStatus); } }, tbar: [{ xtype: 'label', id: 'label1', text: "应付费用" } ], columns: [{ sortable: true, dataIndex: 'GId', header: '惟一编号', hidden: true, width: 160 }, { sortable: true, dataIndex: 'BsNo', header: '业务编号', hidden: true, width: 200 }, { sortable: true, dataIndex: 'FeeStatus', header: '费用状态', renderer: function (value, p, record) { return record.data.FeeStatus_Ref; }, width: 66 }, { sortable: true, dataIndex: 'FeeName', header: '费用名称', width: 75 }, { sortable: true, dataIndex: 'FeeDescription', header: '费用英文名称', hidden: true, width: 200 }, { sortable: true, dataIndex: 'CustomerType', header: '客户类别', hidden: true, width: 200 }, { sortable: true, dataIndex: 'CustomerName', header: '结算对象', width: 100 }, { sortable: true, dataIndex: 'UnitPrice', header: '单价', editor: { xtype: 'numberfield', selectOnFocus: true }, width: 85, 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: 'Quantity', header: '数量(税率)', width: 60 }, { sortable: true, dataIndex: 'Amount', header: '金额', width: 85, 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: 'Currency', header: '币别', editor: this.comboxcurr, width: 60 }, { sortable: true, dataIndex: 'ExChangerate', header: '汇率', editor: { xtype: 'textfield', selectOnFocus: true }, width: 60 }, { sortable: true, dataIndex: 'SettlementDate', header: '结算情况', width: 150 }, { sortable: true, dataIndex: 'Remark', header: '备注', editor: { xtype: 'textfield', selectOnFocus: true }, width: 150 }, { sortable: true, dataIndex: 'Auditoperator', header: '审核人', hidden: true, width: 200 }, { sortable: true, dataIndex: 'AuditDate', header: '审核时间', hidden: true, width: 200 }, { sortable: true, dataIndex: 'EnteroPerator', header: '录入人', hidden: true, width: 200 }, { sortable: true, dataIndex: 'EnterDate', header: '录入时间', hidden: true, width: 200 }, { sortable: true, dataIndex: 'AuditStatus', header: '审核状态', hidden: true, width: 100 }, { sortable: true, dataIndex: 'ACCDATE', header: '会计期间', //hidden: true, width: 100 }, { sortable: true, dataIndex: 'VOUCHERNO', header: '凭证号', //hidden: true, width: 100 } ] }); //选择load //this.gridList.getSelectionModel().on('select', function (model, record, index) { this.gridList.addListener('itemdblclick', function (dataview, record, item, index, e, b) { this.ContractNo = record.data.ContractNo; //this.storeBodyChFee.load({ params: { billno: ContractNo} }); this.storeBodyChFee.load({ params: { billno: this.ContractNo, Feetype: '1'} }); this.storeBodyChFee_YF.load({ params: { billno: this.ContractNo, Feetype: '2'} }); Ext.Ajax.request({ waitMsg: '正在查询毛利数据...', url: '/Import/XXH/GetML', params: { contractno: this.ContractNo }, 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.formML.getForm().setValues(data); } else { Ext.MessageBox.alert('请求出现错误,请重试', response.responseText); } }, scope: this }); //request over }, this); //#region formSearch枚举参照相关 /////////////////////////////////////////////////// this.storeBuyer = Ext.create('DsExt.ux.RefTableStore', { model: 'Tradermb', proxy: { url: '/CommMng/BasicDataRef/GetTrader' } }); this.storeBuyer.load({ params: { condition: " isagentcn=1 "} }); this.comboxBuyer = Ext.create('Ext.ux.form.field.BoxSelect', { fieldLabel: '客户', //renderTo: 'basicBoxselect',height:60,pinList: false, //autoHeight:true,width: 500,stacked: true, autosize: true, bodyPadding: 7, flex: 1, labelWidth: 90, store: this.storeBuyer, queryMode: 'local', triggerOnClick: false, valueField: 'name', displayField: 'codename' }); this.storeCUSTOMERNAME = Ext.create('DsExt.ux.RefTableStore', { model: 'Tradermb', proxy: { url: '/CommMng/BasicDataRef/GetTrader' } }); this.storeCUSTOMERNAME.load({ params: { condition: " 1=1 "} }); this.comboxCUSTOMERNAME = Ext.create('Ext.ux.form.field.BoxSelect', { fieldLabel: '结算对象', //renderTo: 'basicBoxselect',height:60,pinList: false, //autoHeight:true,width: 500,stacked: true, autosize: true, bodyPadding: 7, flex: 1, labelWidth: 90, store: this.storeCUSTOMERNAME, queryMode: 'local', triggerOnClick: false, valueField: 'name', displayField: 'codename' }); this.storeMainstate = Ext.create('DsExt.ux.RefEnumStore', {}); this.storeMainstate.load({ params: { enumTypeId: 3} }); //comboxMainstate this.comboxMainstate = Ext.create('Ext.ux.form.field.BoxSelect', { fieldLabel: '合同状态', //renderTo: 'basicBoxselect',height:60,pinList: false, //autoHeight:true,width: 500,stacked: true, autosize: true, bodyPadding: 7, flex: 1, labelWidth: 90, store: this.storeMainstate, queryMode: 'local', triggerOnClick: false, valueField: 'EnumValueId', displayField: 'EnumValueName' }); this.CheckAll = new Ext.form.Checkbox({ fieldLabel: '显示已生成凭证', flex: 1 }); this.CheckACCDATE = new Ext.form.Checkbox({ fieldLabel: '显示会计期间为空', flex: 1 }); this.storeport = Ext.create('DsExt.ux.RefEnumStore', {}); this.storeport.load({ params: { enumTypeId: 10} }); this.comboxPort = Ext.create('Ext.ux.form.field.BoxSelect', { fieldLabel: '目的港', //renderTo: 'basicBoxselect', //autoHeight:true, autosize: true, bodyPadding: 1, flex: 2, //height:60, width: 80, labelWidth: 90, store: this.storeport, queryMode: 'local', //stacked: true, //pinList: false, triggerOnClick: false, valueField: 'EnumValueId', displayField: 'EnumValueName' //,value: ['TX', 'CA'] }); 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.comboxBuyer, { id: "S_HTH", fieldLabel: "合同号", labelWidth: 55, xtype: 'textfield', name: 'HTH', listeners: { specialkey: function (field, e) { if (e.getKey() == e.ENTER) { _this.onRefreshClick(); } } } }, { fieldLabel: '从到港日', format: 'Y-m-d', xtype: 'datefield', name: 'ArrivalDate_min', listeners: { specialkey: function (field, e) { if (e.getKey() == e.ENTER) { _this.onRefreshClick(); } } } }, { fieldLabel: '至到港日', format: 'Y-m-d', xtype: 'datefield', name: 'ArrivalDate_max', listeners: { specialkey: function (field, e) { if (e.getKey() == e.ENTER) { _this.onRefreshClick(); } } } }] }] }, //end items(fieldset 1) {//fieldset 4 xtype: 'container', defaultType: 'textfield', layout: 'anchor', defaults: { anchor: '100%' }, items: [{ xtype: 'container', layout: 'hbox', defaultType: 'textfield', items: [{ fieldLabel: '从.凭证序号', name: 'FrVouNo', listeners: { specialkey: function (field, e) { if (e.getKey() == e.ENTER) { _this.onRefreshClick(); } } } }, { fieldLabel: '至.凭证序号', name: 'ToVouNo', listeners: { specialkey: function (field, e) { if (e.getKey() == e.ENTER) { _this.onRefreshClick(); } } } }, { fieldLabel: '从会计期间', format: 'Y-m', xtype: 'monthfield', name: 'AccDate_min', listeners: { specialkey: function (field, e) { if (e.getKey() == e.ENTER) { _this.onRefreshClick(); } } } }, { fieldLabel: '至会计期间', format: 'Y-m', xtype: 'monthfield', name: 'AccDate_max', listeners: { specialkey: function (field, e) { if (e.getKey() == e.ENTER) { _this.onRefreshClick(); } } } }, this.comboxPort ] }] }, {//fieldset 4 xtype: 'container', defaultType: 'textfield', layout: 'anchor', defaults: { anchor: '100%' }, items: [{ xtype: 'container', layout: 'hbox', defaultType: 'textfield', items: [this.comboxCUSTOMERNAME, this.comboxMainstate, this.CheckAll, this.CheckACCDATE] }] } ]//end root items }); 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: 'OP', valueField: 'UserCode', displayField: 'CodeAndName', value: username }); 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: false, // 是否可以拖动 // 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; }; if (selectedRecords.length > 200) { Ext.Msg.show({ title: '提示', msg: '选中的费用项目超过200条,请重新选择!', 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.formACCDATEShow = 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', xtype: 'datefield', name: 'ACCDATE' }//, this.comboxUser ] }, { xtype: 'container', layout: 'hbox', defaultType: 'textfield', items: [//this.CheckRate ] } ]//end items(fieldset 1) }//end fieldset 1 ]//end root items }); this.winACCDATEShow = Ext.create('Ext.window.Window', { title: "设定会计期间", width: 450, //height : 120, //plain : true, iconCls: "addcomm", resizable: false, // 是否可以拖动 // draggable:false, collapsible: true, // 允许缩放条 closeAction: 'close', closable: true, modal: 'true', buttonAlign: "center", bodyStyle: "padding:0 0 0 0", items: [this.formACCDATEShow], 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.onSetACCDATEClick(); } }, { text: "关闭", minWidth: 70, handler: function () { me.winACCDATEShow.close(); } }] }); //#endregion formSearch ////////--------显示毛利 begin this.formML = Ext.widget('form', { // layout: "border", region: 'south', frame: true, bodyPadding: 2, fieldDefaults: { margins: '1 1 1 1', labelAlign: 'right', flex: 5, //labelWidth: 90,//label标签宽度 msgTarget: 'qtip', sourcelabelWidth: '100' }, items: [ { //fieldset 1 xtype: 'fieldset', defaultType: 'textfield', layout: 'anchor', defaults: { anchor: '100%' }, items: [{ //1 //container_1 xtype: 'container', layout: 'hbox', defaultType: 'textfield', items: [{//0 fieldLabel: '人民币应收', // allowBlank: false, readOnly: true, name: 'RMBYS' }, { fieldLabel: '人民币应付', // allowBlank: false, readOnly: true, name: 'RMBYF' }, { fieldLabel: '人民币毛利', // allowBlank: false, readOnly: true, name: 'RMBML' }, { fieldLabel: '美元应收', // allowBlank: false, readOnly: true, name: 'USDYS' }, { fieldLabel: '美元应付', // allowBlank: false, readOnly: true, name: 'USDYF' }, { fieldLabel: '美元毛利', // allowBlank: false, readOnly: true, name: 'USDML' }]//0 }, { xtype: 'container', layout: 'hbox', defaultType: 'textfield', items: [] }, { xtype: 'container', layout: 'hbox', defaultType: 'textfield', items: [ { fieldLabel: '付汇利润', // allowBlank: false, readOnly: true, name: 'FHPROFIT' }, { fieldLabel: '冷藏利润', // allowBlank: false, readOnly: true, name: 'LCPROFIT' }, { fieldLabel: '代理/其他利润', // allowBlank: false, readOnly: true, name: 'OTPROFIT' }, { fieldLabel: '毛利', // allowBlank: false, readOnly: true, name: 'ML' }] } ]//container_1 //1 }//fieldset 1 ] }); //end this.formEdit ////////--------显示毛利 end var menu1 = new Ext.menu.Menu({ id: 'basicMenu', items: [/*{ text: "设定此业务内费用的会计期间", iconCls: "btncomm", handler: clickHandler },*/{ text: "设定选定费用的会计期间", iconCls: "btncomm", handler: clickHandler_2 }, { text: "清空选定费用的会计期间", iconCls: "btndel", handler: clickHandler_3 }] }); /* function clickHandler() { panelTest.onSetBusinessACCDATEClick(); //var ACCDATE = Ext.getCmp('ACCDATE').getRawValue(); //alert(ACCDATE); };*/ function clickHandler_2() { panelTest.onSetACCDATEClick(); }; function clickHandler_3() { panelTest.DELACCDATE(); }; _this = this; //查询工具条 this.panelBtn = new Ext.Panel({ region: "north", tbar: [ { text: "执行查询", iconCls: "btnrefresh", handler: function (button, event) { this.onRefreshClick(button, event); }, scope: this }, { text: "重置条件", iconCls: "btnreset", handler: function (button, event) { this.onResetClick(button, event); }, scope: this }, '-', { xtype: 'monthfield', format: 'Y-m', id: "ACCDATE", width: 80 }, //panelTest.onSetBusinessACCDATEClick(); { text: "设定此业务内费用的会计期间", iconCls: "btncomm", handler: function (button, event) { this.onSetBusinessACCDATEClick(); }, scope: this }, { text: "设定选定费用的会计期间", menu: menu1, scope: this }, '-', { text: "将指定利润数额以上的业务全部签收", iconCls: "btnaccount", handler: function (button, event) { this.onSetAllACCDATEClick(button, event); }, scope: this }, '-', { text: "生成凭证", iconCls: "btnadd", 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: "导出Excel", id: "btnExportExcel", iconCls: 'btnexportexcel', handler: function (button, event) { this.onExportClick(button, event); }, scope: this }, { text: "保存列表样式", id: "btntest", //iconCls: 'btnexportexcel', handler: function (button, event) { //this.column = DsTruck.SaveGridPanel(GID, formname, this.gridList.columns, this.column, 1, true); var tempcolumns = this.gridList.columns; DsTruck.SaveGridPanel(GID, formname, tempcolumns, this.column, 1, true); }, scope: this } ] }); this.panelTop = new Ext.Panel({ layout: "border", region: "north", height: 30, items: [this.panelBtn] }); this.panelSearch = new Ext.Panel({ layout: "border", region: "north", height: 100, autoSize: true, items: [this.formSearch] }); this.panelChFee_YS = new Ext.Panel({ // title: '货物信息和许可证使用', layout: "border", region: 'west', margin: '0 0', //height: 450, width: 530, split: true, items: [this.gridListChFee] }); this.panelChFee_YF = new Ext.Panel({ // title: '货物信息和许可证使用', layout: "border", region: 'center', margin: '0 0', //height: 450, width: 450, split: true, items: [this.gridListChFee_YF] }); this.panelChFee = new Ext.Panel({ // layout: "border", region: 'south', margin: '0 0', height: 200, //width: 450, split: true, items: [this.panelChFee_YS, this.panelChFee_YF] }); this.panelContract = new Ext.Panel({ //title: '', layout: "border", region: 'center', //height: 550, margin: '1 2', split: true, items: [this.gridList, this.panelChFee, this.formML] }); Ext.apply(this, { items: [this.panelTop, this.panelSearch, this.panelContract] }); this.storeList.on('beforeload', function (store) { var sql = this.getCondition(); Ext.apply(store.proxy.extraParams, { condition: sql }); }, this); Ext.getCmp('ACCDATE').setValue(currdate.format('yyyy-MM')); }, //end initUIComponents onRefreshClick: function (button, event) { var sql = this.getCondition(); 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 }); }, onCreateVoucherClick: function (button, event) { var feeGIdSql = ''; var selectedRecords = this.gridList.selModel.getSelection(); var form = this.formVoucherShow.getForm(); for (var i = 0; i < selectedRecords.length; i++) { var rec = selectedRecords[i]; if (rec.data.ISVOU != '是' && rec.data.ACCDATE != "") { var feeGId = "'" + rec.data.GId + "'"; if (feeGIdSql == '') { feeGIdSql = feeGId; } else { feeGIdSql = feeGIdSql + "," + feeGId; } } } if (feeGIdSql == '') { Ext.Msg.show({ title: '提示', msg: '没有选择要生成凭证的业务!', icon: Ext.Msg.INFO, buttons: Ext.Msg.OK }); return; }; feeGIdSql = " (" + feeGIdSql + ")"; 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: '/Import/CostRevenue/CreateVoucher', params: { VoucherDate: VoucherDate, UsdExrate: UsdExrate, User: User, useRate: useRate, feesql: feeGIdSql }, 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 }); }, onSetACCDATEClick: function (button, event) { var feeGIdSql = ''; var selectedRecords = this.gridList.selModel.getSelection(); var ACCDATE = Ext.getCmp('ACCDATE').getRawValue(); for (var i = 0; i < selectedRecords.length; i++) { var rec = selectedRecords[i]; if (rec.data.ISVOU != '是') { var feeGId = "'" + rec.data.GId + "'"; if (feeGIdSql == '') { feeGIdSql = feeGId; } else { feeGIdSql = feeGIdSql + "," + feeGId; } } } if (feeGIdSql == '') { Ext.Msg.show({ title: '提示', msg: '没有选择要设定会计期间的业务!', icon: Ext.Msg.INFO, buttons: Ext.Msg.OK }); return; }; feeGIdSql = " (" + feeGIdSql + ")"; Ext.Ajax.request({ waitMsg: '正在添加数据...', url: '/Import/CostRevenue/SetACCDATE', params: { ACCDATE: ACCDATE, feesql: feeGIdSql }, 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.winACCDATEShow.close(); this.onRefreshClick(); } } else { Ext.MessageBox.alert('请求出现错误,请重试', response.responseText); } }, scope: this }); }, DELACCDATE: function (button, event) { var feeGIdSql = ''; var selectedRecords = this.gridList.selModel.getSelection(); //var form = this.formACCDATEShow.getForm(); for (var i = 0; i < selectedRecords.length; i++) { var rec = selectedRecords[i]; if (rec.data.ISVOU != '是' && rec.data.ACCDATE != "") { var feeGId = "'" + rec.data.GId + "'"; if (feeGIdSql == '') { feeGIdSql = feeGId; } else { feeGIdSql = feeGIdSql + "," + feeGId; } } } if (feeGIdSql == '') { Ext.Msg.show({ title: '提示', msg: '没有选择要设定会计期间的业务!', icon: Ext.Msg.INFO, buttons: Ext.Msg.OK }); return; }; feeGIdSql = " (" + feeGIdSql + ")"; var ACCDATE = ''; var _this = this; Ext.MessageBox.confirm('提示', '确定清空选定费用的会计期间吗?', function (btn) { if (btn == 'yes') { Ext.Ajax.request({ waitMsg: '正在添加数据...', url: '/Import/CostRevenue/SetACCDATE', params: { ACCDATE: ACCDATE, feesql: feeGIdSql }, 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.winACCDATEShow.close(); _this.onRefreshClick(); } } else { Ext.MessageBox.alert('请求出现错误,请重试', response.responseText); } }, scope: this }); } }); }, onSetBusinessACCDATEClick: function (button, event) { var feeGIdSql = ''; var selectedRecords = this.gridList.selModel.getSelection(); var ACCDATE = Ext.getCmp('ACCDATE').getRawValue(); for (var i = 0; i < selectedRecords.length; i++) { var rec = selectedRecords[i]; if (rec.data.ISVOU != '是') { var CONTRACTNO = "'" + rec.data.ContractNo + "'"; if (feeGIdSql == '') { feeGIdSql = CONTRACTNO; } else { if (feeGIdSql.indexOf(CONTRACTNO) <= 0) { feeGIdSql = feeGIdSql + "," + CONTRACTNO; } } } } if (feeGIdSql == '') { Ext.Msg.show({ title: '提示', msg: '没有选择要设定会计期间的业务!', icon: Ext.Msg.INFO, buttons: Ext.Msg.OK }); return; }; feeGIdSql = " (" + feeGIdSql + ")"; Ext.Ajax.request({ waitMsg: '正在添加数据...', url: '/Import/CostRevenue/SetBusinessACCDATE', params: { ACCDATE: ACCDATE, feesql: feeGIdSql }, 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.winACCDATEShow.close(); this.onRefreshClick(); } } else { Ext.MessageBox.alert('请求出现错误,请重试', response.responseText); } }, scope: this }); }, onSetAllACCDATEClick: function (button, event) { if (isReqOn == 1) { Ext.MessageBox.alert('提示','正在与服务器交互,请等待当前操作完成!'); return; } else { isReqOn = 1; } var feeGIdSql = ''; var selectedRecords = this.gridList.selModel.getSelection(); var ACCDATE = Ext.getCmp('ACCDATE').getRawValue(); if (ACCDATE == "") { Ext.Msg.show({ title: '提示', msg: '没有设定会计期间!', icon: Ext.Msg.INFO, buttons: Ext.Msg.OK }); return; }; condition = this.getCondition(); Ext.Ajax.request({ waitMsg: '正在添加数据...', url: '/Import/CostRevenue/SetAllACCDATE', params: { ACCDATE: ACCDATE, condition: condition }, callback: function (options, success, response) { isReqOn = 0; 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.winACCDATEShow.close(); this.onRefreshClick(); } } else { Ext.MessageBox.alert('请求出现错误,请重试', response.responseText); } }, scope: this }); }, 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); }, getToMonth: function () { var now = new Date(); var year = now.getFullYear(); //年 var month = now.getMonth() + 1; //月 var clock = year + "-"; if (month < 10) clock += "0"; return (clock); }, onResetClick: function (button, event) { this.formSearch.getForm().reset(); }, getCondition: function () { var sql = ' cf.feestatus in (0,8,9,11) '; var form = this.formSearch.getForm(); if (!form.isValid()) { Ext.Msg.alert('提示', '查询条件赋值错误,请检查。'); return ''; } var HTH = Ext.getCmp('S_HTH').getValue(); sql = sql + getAndConSql(sql, HTH, "M.HTH like '%" + HTH + "%'"); var SailingDate_min = form.findField('AccDate_min').getRawValue(); sql = sql + getAndConSql(sql, SailingDate_min, "cf.AccDate>= '" + SailingDate_min + "'"); var SailingDate_max = form.findField('AccDate_max').getRawValue(); sql = sql + getAndConSql(sql, SailingDate_max, "cf.AccDate<= '" + SailingDate_max + "'"); var buyer = this.getStrValue(this.comboxBuyer.getValue()); sql = sql + getAndConSql(sql, buyer, "M.buyer in (" + buyer + ")"); var CUSTOMERNAME = this.getStrValue(this.comboxCUSTOMERNAME.getValue()); sql = sql + getAndConSql(sql, CUSTOMERNAME, "cf.CUSTOMERNAME in (" + CUSTOMERNAME + ")"); var Mainstate = this.comboxMainstate.getValue(); sql = sql + getAndConSql(sql, Mainstate, "m.Mainstate in (" + Mainstate + ")"); var ArrivalDate_min = form.findField('ArrivalDate_min').getRawValue(); sql = sql + getAndConSql(sql, ArrivalDate_min, "m.ArrivalDate >= '" + ArrivalDate_min + "'"); var ArrivalDate_max = form.findField('ArrivalDate_max').getRawValue(); sql = sql + getAndConSql(sql, ArrivalDate_max, "m.ArrivalDate <= '" + ArrivalDate_max + " 23:59:59'"); if (this.CheckAll.checked) { } else { sql = sql + getAndConSql(sql, '1111', "(cf.ISVOU<>1 or cf.ISVOU is null)"); } if (this.CheckACCDATE.checked) { sql = sql + getAndConSql(sql, '1111', "(cf.accdate='' or cf.accdate is null)"); } else { } var port = this.comboxPort.getValue(); if (port != "") { sql = sql + getAndConSql(sql, port, "m.port in (" + port + ")"); } var FrVouNo = form.findField('FrVouNo').getRawValue(); sql = sql + getAndConSql(sql, FrVouNo, "cf.VOUCHERNO >= '" + FrVouNo + "'"); var ToVouNo = form.findField('ToVouNo').getRawValue(); sql = sql + getAndConSql(sql, ToVouNo, "cf.VOUCHERNO <= '" + ToVouNo + "'"); //FrVouNo ToVouNo return sql; }, getStrValue: function (list) { var _list = []; for (var _i = 0; _i < list.length; _i++) { _list.push("'" + list[_i] + "'"); } return _list; }, 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; }, // alert(this.OprationStatus.ToString()); // alert(this.storeList.toString()); // alert(this.SelectedRecord.toString()); onExportClick: function (button, event) { GridExportExcelPage(this.gridList); } });