//集运管理-路单查询 Ext.namespace('DsImportRpt'); DsImportRpt.RptImportKcIndex = function (config) { Ext.applyIf(this, config); this.initUIComponents(); window.DsImportRpt.RptImportKcIndex.superclass.constructor.call(this); }; Ext.extend(DsImportRpt.RptImportKcIndex, Ext.Panel, { PageSize: 500, OprationStatus: null, //仅当弹出界面时使用 SelectedRecord: null, initUIComponents: function () { //定义数据集 this.storeList = Ext.create('Ext.data.Store', { pageSize: this.PageSize, fields: [ { name: 'Billno', type: 'string' }, { name: 'ContractNo', type: 'string' }, { name: 'HTH', type: 'string' }, { name: 'CZRf', type: 'string' }, { name: 'KFRf', type: 'string' }, { name: 'CZdate', type: 'string' }, { name: 'text', type: 'string' }, { name: 'seller', type: 'string' }, { name: 'buyer', type: 'string' }, { name: 'Vessel', type: 'string' }, { name: 'Voyage', type: 'string' }, { name: 'Sailingdate', type: 'string' }, { name: 'ArrivalDate', type: 'string' }, { name: 'ContainerNo', type: 'string' }, { name: 'SealNo', type: 'string' }, { name: 'goodname', type: 'string' }, { name: 'cargoinfoRf', type: 'string' }, { name: 'cargociqRf', type: 'string' }, { name: 'InNum', type: 'number' }, { name: 'OutNum', type: 'number' }, { name: 'FactoryNo', type: 'string' }, { name: 'Weight', type: 'number' }, { name: 'Weight_Out', type: 'number' }, { name: 'CompanyName', type: 'string' }, { name: 'PLEDGE', type: 'string' } ], remoteSort: false, groupField: 'HTH', proxy: { type: 'ajax', url: '/Import/RptImportKc/GetDataList', reader: { id: '', root: 'data', totalProperty: 'totalCount' } } }); this.storeWMSList = Ext.create('Ext.data.Store', { pageSize: this.PageSize, fields: [ { name: 'cargo_id', type: 'string' }, { name: 'ContractNo', type: 'string' }, { name: 'HTH', type: 'string' }, { name: 'ContainerNo', type: 'string' }, { name: 'seller', type: 'string' }, { name: 'buyer', type: 'string' }, { name: 'CompanyName', type: 'string' }, { name: 'KFstate', type: 'string' }, { name: 'goodname', type: 'string' }, { name: 'InDate', type: 'string' }, { name: 'InNum', type: 'number' }, { name: 'OutDate', type: 'string' }, { name: 'OutNum', type: 'number' }, { name: 'RemainNum', type: 'number' }, { name: 'Weight', type: 'number' }, { name: 'Weight_Out', type: 'number' }, { name: 'RemainWeight', type: 'number' } ], remoteSort: false, groupField: 'HTH', proxy: { type: 'ajax', url: '/Import/RptImportKc/GetWMSList', reader: { id: '', root: 'data', totalProperty: 'totalCount' } } }); //#region 相关参照 Ext.define('companymb', { extend: 'Ext.data.Model', fields: [ { name: 'gid', type: 'string' }, { name: 'name', type: 'string' } ] }); this.formname = "RptImportKC"; this.storeport = Ext.create('DsExt.ux.RefEnumStore', {}); this.storeport.load({ params: { enumTypeId: 10} }); this.comboxport = Ext.create('DsExt.ux.RefEnumCombox', { fieldLabel: '目的港', store: this.storeport, name: 'port' }); 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: '客户', name: 'buyer', autosize: true, bodyPadding: 7, flex: 2, labelWidth: 90, store: this.storeBuyer, queryMode: 'local', triggerOnClick: false, valueField: 'name', displayField: 'codename' }); this.storeKF = Ext.create('DsExt.ux.RefTableStore', { model: 'Tradermb', proxy: { url: '/CommMng/BasicDataRef/GetTrader' } }); this.storeKF.load({ params: { condition: " ISWAREHOUSE=1 "} }); this.comboxKF = Ext.create('Ext.ux.form.field.BoxSelect', { fieldLabel: '仓库', name: 'KFstate', autosize: true, bodyPadding: 7, flex: 2, labelWidth: 90, store: this.storeKF, queryMode: 'local', triggerOnClick: false, valueField: 'name', displayField: 'codename' }); this.storeCZState = Ext.create('DsExt.ux.RefEnumStore', {}); this.storeCZState.load({ params: { enumTypeId: 8} }); this.comboxCZState = Ext.create('Ext.ux.form.field.BoxSelect', { fieldLabel: '操作状态', name: 'CZState', autosize: true, bodyPadding: 7, flex: 3, labelWidth: 90, store: this.storeCZState, queryMode: 'local', triggerOnClick: false, valueField: 'EnumValueId', displayField: 'EnumValueName' }); this.storeCompany = Ext.create('DsExt.ux.RefTableStore', { model: 'companymb', proxy: { url: '/CommMng/BasicDataRef/GetcompanyList' } }); this.storeCompany.load({ params: { condition: ""} }); this.comboxCompany = Ext.create('DsExt.ux.RefTableCombox', { fieldLabel: '用证公司', store: this.storeCompany, name: 'company', valueField: 'gid', displayField: 'name' }); this.comboxInputCompany = Ext.create('DsExt.ux.RefTableCombox', { fieldLabel: '录入公司', store: this.storeCompany, name: 'InputCompany', valueField: 'gid', displayField: 'name' }); this.storePLEDGE = Ext.create('DsExt.ux.RefTableStore', { model: 'Tradermb', proxy: { url: '/CommMng/BasicDataRef/GetTrader' } }); this.storePLEDGE.load({ params: { condition: " 1=1 "} }); this.comboxPLEDGE = Ext.create('DsExt.ux.RefTableCombox', { fieldLabel: '质押权', forceSelection: true, store: this.storePLEDGE, name: 'PLEDGE', valueField: 'name', displayField: 'codename', flex: 2 }); Ext.define('ISKCClearEmb', { extend: 'Ext.data.Model', fields: [ { name: 'Name', type: 'string' } ] }); var ISKCClearData = [{ "Name": "全部" }, { "Name": "不含货物已清空的业务" }, { "Name": "只包括货物已清空的业务"}]; var storeISKCClear = Ext.create('Ext.data.Store', { model: 'ISKCClearEmb', data: ISKCClearData }); this.comboxISKCClear = Ext.create('DsExt.ux.RefTableCombox', { fieldLabel: '是否含已清空', forceSelection: true, store: storeISKCClear, name: 'ISKCClear', valueField: 'Name', displayField: 'Name' }); //#endregion 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(); } } } }); Ext.grid.RowNumberer = Ext.extend(Ext.grid.RowNumberer, { width: 30 }); //定义Grid var groupingFeature = Ext.create('Ext.grid.feature.Grouping'); var SummaryFeature = Ext.create('Ext.grid.feature.Summary'); this.gridList = new Ext.grid.GridPanel({ store: this.storeList, enableHdMenu: false, region: 'center', loadMask: { msg: "数据加载中,请稍等..." }, trackMouseOver: true, disableSelection: false, features: [{ id: 'group', //ftype: 'grouping', ftype: 'groupingsummary', groupHeaderTpl: '{name}', hideGroupedHeader: false, enableGroupingMenu: true }], viewConfig: { enableTextSelection: true }, columns: [ new Ext.grid.RowNumberer(), { sortable: true, dataIndex: 'Billno', header: '提单号', width: 130 }, { sortable: true, dataIndex: 'ContractNo', header: '合同序列号', width: 65, hidden: true }, { sortable: true, dataIndex: 'HTH', header: '合同号', width: 100 }, { sortable: true, id: '', dataIndex: 'CompanyName', header: '用证公司', width: 80 }, { sortable: true, dataIndex: 'buyer', header: '客户名称', width: 65 }, { sortable: true, dataIndex: 'ArrivalDate', header: '到港日期', width: 70 }, { sortable: true, dataIndex: 'goodname', header: '商品名称', width: 65 }, { sortable: true, dataIndex: 'FactoryNo', header: '厂号', width: 90 }, { sortable: true, dataIndex: 'InNum', header: '入库数量', summaryType: 'sum', width: 76 }, { sortable: true, dataIndex: 'OutNum', header: '出库数量', summaryType: 'sum', width: 60 }, { sortable: true, dataIndex: 'Weight', header: '入库数量(吨)', summaryType: 'sum', width: 60 }, { sortable: true, dataIndex: 'Weight_Out', header: '出库数量(吨)', summaryType: 'sum', width: 60 }, { sortable: true, dataIndex: 'CZRf', header: '库存状态', width: 60 }, { sortable: true, dataIndex: 'KFRf', header: '库房', width: 60 }, { sortable: true, dataIndex: 'CZdate', header: '操作日期', width: 60 }, { sortable: true, dataIndex: 'Vessel', header: '船名', width: 60 }, { sortable: true, dataIndex: 'Voyage', header: '航次', width: 60 }, { sortable: true, dataIndex: 'ContainerNo', header: '箱号', width: 80 }, { sortable: true, dataIndex: 'SealNo', header: '封号', width: 80 }, { sortable: true, dataIndex: 'cargoinfoRf', header: 'HS编码', width: 80 }, { sortable: true, dataIndex: 'cargociqRf', header: 'CIQ编码', width: 80 }, { sortable: true, dataIndex: 'text', header: '备注', width: 80 } ], // paging bar on the bottom bbar: [Ext.create('Ext.PagingToolbar', { store: this.storeList, displayInfo: true, displayMsg: '当前显示 {0} - {1}条记录 /共 {2}条记录', emptyMsg: "没有数据" }), this.Pagenum] }); this.gridList.addListener('itemdblclick', function (dataview, record, item, index, e, b) { this.SelectedRecord = record; this.OprationStatus = 'view'; DsOpenEditWin('/Import/PortOperate/Edit', record.data.ContractNo, "750", "1000"); }, this); this.gridList_WMS = new Ext.grid.GridPanel({ store: this.storeWMSList, enableHdMenu: false, region: 'center', loadMask: { msg: "数据加载中,请稍等..." }, trackMouseOver: true, disableSelection: false, features: [{ ftype: 'summary'//Ext.grid.feature.Summary表格汇总特性 }], viewConfig: { enableTextSelection: true }, columns: [ new Ext.grid.RowNumberer(), { sortable: true, hidden: true, dataIndex: 'cargo_id', header: 'cargo_id', width: 80 }, { sortable: true, hidden: true, dataIndex: 'ContractNo', header: '合同序列号', width: 80 }, { sortable: true, dataIndex: 'HTH', header: '合同号', width: 120 }, { sortable: true, dataIndex: 'ContainerNo', header: '箱号', width: 120 }, { sortable: true, dataIndex: 'seller', header: '贸易商', width: 80 }, { sortable: true, dataIndex: 'buyer', header: '购货方', width: 80 }, { sortable: true, dataIndex: 'CompanyName', header: '用证公司', width: 80 }, { sortable: true, dataIndex: 'KFstate', header: '库房', width: 110 }, { sortable: true, dataIndex: 'goodname', header: '货物名称', width: 120 }, { sortable: true, dataIndex: 'InDate', header: '入库日期', width: 90 }, { sortable: true, dataIndex: 'InNum', header: '入库件数', width: 80, summaryType: 'sum' }, { sortable: true, dataIndex: 'OutDate', header: '出库日期', width: 90 }, { sortable: true, dataIndex: 'OutNum', header: '出库件数', width: 80, summaryType: 'sum' }, { sortable: true, dataIndex: 'RemainNum', header: '剩余件数', width: 80, summaryType: 'sum' }, { sortable: true, dataIndex: 'Weight', header: '入库重量', width: 80, summaryType: 'sum' }, { sortable: true, dataIndex: 'Weight_Out', header: '出库重量', width: 80, summaryType: 'sum' }, { sortable: true, dataIndex: 'RemainWeight', header: '剩余重量', width: 80, summaryType: 'sum' } ], // paging bar on the bottom bbar: [Ext.create('Ext.PagingToolbar', { store: this.storeList, displayInfo: true, displayMsg: '当前显示 {0} - {1}条记录 /共 {2}条记录', emptyMsg: "没有数据" }), this.Pagenum] }); this.gridList_WMS.addListener('itemdblclick', function (dataview, record, item, index, e, b) { this.SelectedRecord = record; alert(record.data.ContractNo); this.OprationStatus = 'view'; DsOpenEditWin('/Import/PortOperate/Edit', record.data.ContractNo, "750", "1000"); }, this); var _this = this; 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.comboxport, this.comboxCompany, { fieldLabel: '从..到港日', format: 'Y-m-d', xtype: 'datefield', name: 'ExpDateBgn', listeners: { specialkey: function (field, e) { if (e.getKey() == e.ENTER) { _this.onRefreshClick(); } } } }, { fieldLabel: '到..到港日', format: 'Y-m-d', xtype: 'datefield', name: 'ExpDateEnd', listeners: { specialkey: function (field, e) { if (e.getKey() == e.ENTER) { _this.onRefreshClick(); } } } }, { fieldLabel: '从..操作日', format: 'Y-m-d', xtype: 'datefield', name: 'CZDateBgn', listeners: { specialkey: function (field, e) { if (e.getKey() == e.ENTER) { _this.onRefreshClick(); } } } }, { fieldLabel: '到..操作日', format: 'Y-m-d', xtype: 'datefield', name: 'CZDateEnd', listeners: { specialkey: function (field, e) { if (e.getKey() == e.ENTER) { _this.onRefreshClick(); } } } } ] }, {//fieldset 2 xtype: 'container', defaultType: 'textfield', layout: 'anchor', defaults: { anchor: '100%' }, items: [{ xtype: 'container', layout: 'hbox', defaultType: 'textfield', items: [{ fieldLabel: '合同号', name: 'HTH', listeners: { specialkey: function (field, e) { if (e.getKey() == e.ENTER) { _this.onRefreshClick(); } } } }, { fieldLabel: '箱号', name: 'ContainerNo', listeners: { specialkey: function (field, e) { if (e.getKey() == e.ENTER) { _this.onRefreshClick(); } } } }, this.comboxBuyer, this.comboxKF] }] }, {//fieldset 3 xtype: 'container', defaultType: 'textfield', layout: 'anchor', defaults: { anchor: '100%' }, items: [{ xtype: 'container', layout: 'hbox', defaultType: 'textfield', items: [this.comboxCZState, this.comboxPLEDGE, this.comboxISKCClear ] }] } //end items(fieldset 3) , {//fieldset 4 xtype: 'container', defaultType: 'textfield', layout: 'anchor', defaults: { anchor: '100%' }, items: [{ xtype: 'container', layout: 'hbox', defaultType: 'textfield', items: [this.comboxInputCompany, { xtype: 'hiddenfield', flex: 4 } ] }] } ] } ]//end root items }); //#endregion formSearch var menu1 = new Ext.menu.Menu({ id: 'basicMenu', items: [{ text: '打印库存统计表', handler: clickHandler }, { text: '库存流水', handler: clickHandler_1 } ] }); function clickHandler() { window.pnlRptImportKcIndex.Print(); }; function clickHandler_1() { window.pnlRptImportKcIndex.Print_LX(); }; //查询工具条 this.panelBtn = new Ext.Panel({ region: "north", tbar: [ { text: "执行查询", iconCls: "btnrefresh", handler: function (button, event) { this.onRefreshClick(button, event); }, scope: this }, { text: "导出Excel", id: "btnExportExcel", iconCls: 'btnexportexcel', handler: function (button, event) { this.onExportClick(button, event); }, scope: this }, { text: "打印报表", menu: menu1, scope: this }, ] }); //#region 布局 this.page_1 = new Ext.Panel({ id: "page_1", layout: "border", region: "center", title: "出入库明细", items: [this.gridList ] }); this.page_2 = new Ext.Panel({ id: "page_2", layout: "border", region: "center", title: "当前库存情况", items: [this.gridList_WMS ] }); this.MainTab = new Ext.tab.Panel({ layout: "border", region: "center", items: [this.page_1, this.page_2] }) this.panelTop = new Ext.Panel({ layout: "border", region: "north", height: 145, items: [this.formSearch, this.panelBtn] }); Ext.apply(this, { items: [this.panelTop, this.MainTab] }); //#endregion 布局end this.storeList.on('beforeload', function (store) { if (!this.checkSearchCondition()) return; var sql = this.getCondition(); Ext.apply(store.proxy.extraParams, { condition: sql }); }, this); }, //end initUIComponents onRefreshClick: function (button, event) { if (!this.checkSearchCondition()) return; var sql = this.getCondition(); this.PageSize = this.Pagenum.getValue(); this.storeList.pageSize = this.PageSize; var _p = this.MainTab.getActiveTab().id; if (_p == "page_1") { this.storeList.load({ params: { start: 0, limit: this.PageSize, condition: sql }, waitMsg: "正在查询数据...", scope: this }); } else { this.storeWMSList.load({ params: { start: 0, limit: this.PageSize, condition: sql }, waitMsg: "正在查询数据...", scope: this }); } }, getStrValue: function (list) { var _list = []; for (var _i = 0; _i < list.length; _i++) { _list.push("'" + list[_i] + "'"); } return _list; }, getCondition: function () { var form = this.formSearch.getForm(); if (!form.isValid()) { Ext.Msg.alert('提示', '查询条件赋值错误,请检查。'); return ''; } var sql = ' M.ISDELETE=0 '; var port = form.findField('port').getValue(); sql = sql + getAndConSql(sql, port, "m.port = " + port + ""); var HTH = form.findField('HTH').getValue(); sql = sql + getAndConSql(sql, HTH, "m.HTH like '%" + HTH + "%'"); var ContainerNo = form.findField('ContainerNo').getValue(); sql = sql + getAndConSql(sql, ContainerNo, "m.ContainerNo like '%" + ContainerNo + "%'"); var custDate_Min = form.findField('ExpDateBgn').getRawValue(); sql = sql + getAndConSql(sql, custDate_Min, "m.ArrivalDate >= '" + custDate_Min + "'"); var custDate_Max = form.findField('ExpDateEnd').getRawValue(); sql = sql + getAndConSql(sql, custDate_Max, "m.ArrivalDate <= '" + custDate_Max + " 23:59:59'"); var CZDate_Min = form.findField('CZDateBgn').getRawValue(); sql = sql + getAndConSql(sql, CZDate_Min, "k.czdate >= '" + CZDate_Min + "'"); var CZDate_Max = form.findField('CZDateEnd').getRawValue(); sql = sql + getAndConSql(sql, CZDate_Max, "k.czdate <= '" + CZDate_Max + " 23:59:59'"); var buyer = this.getStrValue(this.comboxBuyer.getValue()); sql = sql + getAndConSql(sql, buyer, "M.buyer in (" + buyer + ")"); var KF = this.getStrValue(this.comboxKF.getValue()); sql = sql + getAndConSql(sql, KF, "k.KFstate in (" + KF + ")"); var CZState = this.getStrValue(this.comboxCZState.getValue()); sql = sql + getAndConSql(sql, CZState, "K.CZState in (" + CZState + ")"); /* var KCClear = form.findField("KCClear").getValue(); if (KCClear) { sql = sql + getAndConSql(sql, KCClear, " m.KCClear = 1 "); } else { sql = sql + getAndConSql(sql, "True", " m.KCClear = 0 "); } */ var ISKCClear = form.findField('ISKCClear').getValue(); if (ISKCClear == '全部') { } if (ISKCClear == '不含货物已清空的业务') { sql = sql + getAndConSql(sql, ISKCClear, " m.KCClear = 0 "); } if (ISKCClear == '只包括货物已清空的业务') { sql = sql + getAndConSql(sql, ISKCClear, " m.KCClear = 1 "); } var company = form.findField('company').getValue(); sql = sql + getAndConSql(sql, company, "M.company = '" + company + "'"); var InputCompany = form.findField('InputCompany').getValue(); sql = sql + getAndConSql(sql, InputCompany, "K.CORPID = '" + InputCompany + "'"); var PLEDGE = form.findField('PLEDGE').getValue(); sql = sql + getAndConSql(sql, PLEDGE, "k.PLEDGE = '" + PLEDGE + "'"); return sql; }, checkSearchCondition: function () { var form = this.formSearch.getForm(); if (!form.isValid()) { Ext.Msg.alert('提示', '查询条件赋值错误,请检查。'); return false; } return true; }, onExportClick: function (button, event) { GridExportExcelPage(this.gridList); }, OprationSwap: function () { var ret = new Array(); ret[0] = this.OprationStatus; ret[1] = this.storeList; ret[2] = this.SelectedRecord; return ret; }, Print: function () { var printType = 'KCRpt_1'; //船期 var T = this.getCondition(); if (T != "") { T = " where " + T; }; if (T.indexOf("m.KCClear = 0")) { //T=T.replace("m.KCClear = 0"," isnull((select sum(quantity) from import_kc where contractno=m.contractno and CZState=1),0)<>isnull((select sum(quantity) from import_kc where contractno=m.contractno and CZState=3),0) "); } if (T.indexOf("m.KCClear = 1")) { //T = T.replace("m.KCClear = 1", " isnull((select sum(quantity) from import_kc where contractno=m.contractno and CZState=1),0)=isnull((select sum(quantity) from import_kc where contractno=m.contractno and CZState=3),0) "); } var sql1 = " select t.hth,t.contractno,m.buyer,t.KFstate "; sql1 = sql1 + ",(select EnumValueName from tSysEnumValue where EnumTypeID=10 and EnumValueID=m.port) Port "; sql1 = sql1 + ",(select name from company where gid=m.company) company "; sql1 = sql1 + ",substring(cc.country,0,(charindex('(',cc.country)) ) country "; sql1 = sql1 + ",(select codename from code_currency where gid=c.currid) currency "; sql1 = sql1 + ",c.name,c.BoxCount ,dbo.trimdate(m.ArrivalDate) ArrivalDate,c.FactoryNo,m.ContainerNo,m.remark,m.Overfilled,c.[weight]/1000 [weight] "; sql1 = sql1 + ",case m.Inspection_Storage when 0 then '' when 1 then '商检慢检' else '' end Inspection_Storage "; sql1 = sql1 + ",case(select codename from code_currency where gid=c.currid) when 'RMB' then c.Amount else 0 end RMBAmount "; sql1 = sql1 + ",case(select codename from code_currency where gid=c.currid) when 'USD' then c.Amount else 0 end USDAmount "; sql1 = sql1 + ",case(select codename from code_currency where gid=c.currid) when 'RMB' then 0 when 'USD' then 0 else c.Amount end CurrAmount "; sql1 = sql1 + ",case(select codename from code_currency where gid=c.currid) when 'RMB' then convert(numeric(18,2),c.Amount/(case c.BoxCount when 0 then 1 else c.BoxCount end)) else 0 end RMBboxprice "; sql1 = sql1 + ",case(select codename from code_currency where gid=c.currid) when 'USD' then convert(numeric(18,2),c.Amount/(case c.BoxCount when 0 then 1 else c.BoxCount end)) else 0 end USDboxprice "; sql1 = sql1 + ",case(select codename from code_currency where gid=c.currid) when 'RMB' then 0 when 'USD' then 0 else convert(numeric(18,2),c.Amount/c.BoxCount) end Currboxprice "; sql1 = sql1 + ",case(select codename from code_currency where gid=c.currid) when 'RMB' then convert(numeric(18,2),c.Amount/(case c.Weight when 0 then 1 else c.Weight end)) else 0 end RMBWeightprice "; sql1 = sql1 + ",case(select codename from code_currency where gid=c.currid) when 'USD' then convert(numeric(18,2),c.Amount/(case c.Weight when 0 then 1 else c.Weight end)) else 0 end USDWeightprice "; sql1 = sql1 + ",case(select codename from code_currency where gid=c.currid) when 'RMB' then 0 when 'USD' then 0 else convert(numeric(18,2),c.Amount/c.Weight) end CurrWeightprice "; sql1 = sql1 + ",t.innum,t.outnum "; sql1 = sql1 + ",t.innum-t.outnum remain "; sql1 = sql1 + ",isnull((select sum(quantity) from import_kc where cargo_id=t.cargo_id and CZState=1),0) inweight "; sql1 = sql1 + ",isnull((select sum(quantity) from import_kc where cargo_id=t.cargo_id and CZState=3),0) outweight "; sql1 = sql1 + ",case(select codename from code_currency where gid=c.currid) when 'RMB' then "; sql1 = sql1 + "(isnull((select sum(quantity) from import_kc where cargo_id=t.cargo_id and CZState=1),0)- "; sql1 = sql1 + "isnull((select sum(quantity) from import_kc where cargo_id=t.cargo_id and CZState=3),0))*1000* "; sql1 = sql1 + "(case(select codename from code_currency where gid=c.currid) when 'RMB' then convert(numeric(18,2),c.Amount/(case c.Weight when 0 then 1 else c.Weight end)) else 0 end) "; sql1 = sql1 + " else 0 end RMBRemainAmount "; sql1 = sql1 + ",case (select codename from code_currency where gid=c.currid) when 'USD' then "; sql1 = sql1 + "(isnull((select sum(quantity) from import_kc where cargo_id=t.cargo_id and CZState=1),0)- "; sql1 = sql1 + "isnull((select sum(quantity) from import_kc where cargo_id=t.cargo_id and CZState=3),0))*1000* "; sql1 = sql1 + "(case(select codename from code_currency where gid=c.currid) when 'USD' then convert(numeric(18,2),c.Amount/(case c.Weight when 0 then 1 else c.Weight end)) else 0 end) "; sql1 = sql1 + " else 0 end USDRemainAmount "; sql1 = sql1 + ",case (select codename from code_currency where gid=c.currid) when 'RMB' then 0 when 'USD' then 0 else "; sql1 = sql1 + "(isnull((select sum(quantity) from import_kc where cargo_id=t.cargo_id and CZState=1),0)- "; sql1 = sql1 + "isnull((select sum(quantity) from import_kc where cargo_id=t.cargo_id and CZState=3),0))*1000* "; sql1 = sql1 + "(case(select codename from code_currency where gid=c.currid) when 'USD' then convert(numeric(18,2),c.Amount/(case c.Weight when 0 then 1 else c.Weight end)) else 0 end) "; sql1 = sql1 + " end CurrRemainAmount "; sql1 = sql1 + ",dbo.f_kcdate(cargo_id, 3) IOINFO,入库日期 "; sql1 = sql1 + " from (select hth,m.contractno "; sql1 = sql1 + " ,(select EnumValueName from tSysEnumValue where EnumTypeID=3 and EnumValueID=m.MainState) mainstate "; sql1 = sql1 + " ,k.cargo_id,sum(isnull(k.InNum,0)) innum,sum(isnull(k.outnum,0)) outnum "; sql1 = sql1 + " ,k.KFstate,(select min(czdate) from import_kc where cargo_id=k.cargo_id and czstate=1) 入库日期 "; sql1 = sql1 + " from import_main m "; sql1 = sql1 + " left join import_kc k on k.ContractNo=m.ContractNo and k.CZState in(1,3) "; sql1 = sql1 + T; sql1 = sql1 + " and K.id is not null"; sql1 = sql1 + " group by m.hth,m.contractno,k.cargo_id,m.MainState,k.KFstate)t "; sql1 = sql1 + " left join import_cargo c on c.id =t.cargo_id "; sql1 = sql1 + " left join import_main m on m.ContractNo=t.ContractNo "; sql1 = sql1 + " left join code_country cc on cc.countryid=m.countryid "; sql1 = sql1 + " Order by m.ArrivalDate, m.buyer,t.hth "; var sql2 = ""; var sql3 = ""; var sql4 = ""; var sql5 = ""; var sql6 = ""; PrintComm(printType, sql1, sql2, sql3, sql4, sql5, sql6); } , Print_LX: function () { var printType = 'KCRpt_LX'; //库存流水 var T = this.getCondition(); if (T != "") { T = " where " + T; }; if (T.indexOf("m.KCClear = 0")) { //T=T.replace("m.KCClear = 0"," isnull((select sum(quantity) from import_kc where contractno=m.contractno and CZState=1),0)<>isnull((select sum(quantity) from import_kc where contractno=m.contractno and CZState=3),0) "); } if (T.indexOf("m.KCClear = 1")) { //T = T.replace("m.KCClear = 1", " isnull((select sum(quantity) from import_kc where contractno=m.contractno and CZState=1),0)=isnull((select sum(quantity) from import_kc where contractno=m.contractno and CZState=3),0) "); } var sql1 = " select m.HTH 合同号,m.ContainerNo 柜号,c.name 品名,c.[weight] 净重,kfstate 库房,m.buyer 购货方 "; sql1 = sql1 + " ,(select enumvaluename from tsysenumvalue where enumtypeid=8 and enumvalueid=K.czstate) as 库存动作 "; sql1 = sql1 + " ,innum [入库数量(件)],outnum [出库数量(件)],k.[weight] 重量,dbo.trimdate(czdate) 操作时间 "; sql1 = sql1 + " ,[days] 在库天数,unitprice 单价,k.Quantity 数量 ,k.Amount 金额 "; sql1 = sql1 + " from import_kc k "; sql1 = sql1 + " left join import_cargo c on convert(varchar(50),c.id)=k.cargo_id "; sql1 = sql1 + " left join Import_main m on m.ContractNo=k.ContractNo "; sql1 = sql1 + " left join company comp on comp.gid=M.company "; sql1 = sql1 + T; sql1 = sql1 + " order by m.buyer,m.ContractNo,m.ArrivalDate,k.CZdate "; var sql2 = " select _t.contractno,m.HTH 合同号,m.ContainerNo 柜号,dbo.f_str(_t.contractno) 品名 "; sql2 = sql2 + " ,dbo.F_weight_KG(_t.contractno) 净重,m.buyer 购货方 "; sql2 = sql2 + " ,(select sum(amount) from ch_fee where bsno=_t.ContractNo and feename='抄码费') 抄码费 "; sql2 = sql2 + " ,(select sum(amount) from ch_fee where bsno=_t.ContractNo and feename='分色费') 分色费 "; sql2 = sql2 + " ,(select sum(amount) from ch_fee where bsno=_t.ContractNo and feename='看货费') 看货费 "; sql2 = sql2 + " from "; sql2 = sql2 + " (select distinct k.contractno from import_kc k "; sql2 = sql2 + " left join import_cargo c on convert(varchar(50),c.id)=k.cargo_id "; sql2 = sql2 + " left join Import_main m on m.ContractNo=k.ContractNo "; sql2 = sql2 + " left join company comp on comp.gid=M.company "; sql2 = sql2 + T; sql2 = sql2 + " )_t "; sql2 = sql2 + " left join import_main m on m.contractno=_t.contractno "; sql2 = sql2 + " order by m.buyer,m.ContractNo,m.ArrivalDate "; var sql3 = ""; var sql4 = ""; var sql5 = ""; var sql6 = ""; PrintComm(printType, sql1, sql2, sql3, sql4, sql5, sql6); } }); /* select distinct cargo_id into #cargo from import_kc left join import_cargo c on convert(varchar(50),c.id)=import_kc.cargo_id left join Import_main m on m.ContractNo=import_kc.ContractNo left join company comp on comp.gid=M.company where kfstate='海港城冷库' and czdate BETWEEN '2015-10-1' and '2015-11-1' --drop table #cargo select import_kc.* into #KC from import_kc left join import_cargo c on convert(varchar(50),c.id)=import_kc.cargo_id left join Import_main m on m.ContractNo=import_kc.ContractNo left join company comp on comp.gid=M.company where kfstate='海港城冷库' and czdate BETWEEN '2015-10-1' and '2015-11-1' --drop table #KC Select m.HTH 合同号,m.ContainerNo 柜号,c.name 品名,c.[weight] 净重 ,(select top 1 kfstate from #KC where #KC.cargo_id=_t.cargo_id ) 库房 ,(select top 1 dbo.trimdate(CZdate) from #KC where #KC.cargo_id=_t.cargo_id and CZState=1) 入库日期 ,(select sum(quantity) from #KC where #KC.cargo_id=_t.cargo_id and CZState=1) 入库件数 ,(select top 1 dbo.trimdate(CZdate) from #KC where #KC.cargo_id=_t.cargo_id and CZState=3) 出库日期 ,(select sum(quantity) from #KC where #KC.cargo_id=_t.cargo_id and CZState=3) 出库件数 ,(select top 1 dbo.trimdate(CZdate) from #KC where #KC.cargo_id=_t.cargo_id and CZState=6) 结费未出库日期 ,(select sum(quantity) from #KC where #KC.cargo_id=_t.cargo_id and CZState=6) 结费未出库日期 ,(select sum(days) from #KC where #KC.cargo_id=_t.cargo_id and CZState=3) 在库天数 from #cargo _t --left join [Import_KC] K on left join import_cargo c on convert(varchar(50),c.id)=_t.cargo_id left join Import_main m on m.ContractNo=c.ContractNo left join company comp on comp.gid=M.company */ function OprationSwap() { return window.pnlRptImportKcIndex.OprationSwap(); }