diff --git a/src/api/ecss/ecss.js b/src/api/ecss/ecss.js index 6875f48..a60101c 100644 --- a/src/api/ecss/ecss.js +++ b/src/api/ecss/ecss.js @@ -96,6 +96,7 @@ export const searchPalletList = data => createAPI(`/ecss/coDel/searchPalletList` export const searchPackageList = data => createAPI(`/ecss/coDel/searchPackageList`,'post',data) export const getNotifyPartDetail = data => createAPI(`/ecss/coDel/getNotifyPartDetail`,'post',data) +export const getDeclarationPalletPartDetail = data => createAPI(`/ecss/coDel/getDeclarationPalletPartDetail`,'post',data) export const saveOneClickPacking = data => createAPI(`/ecss/coDel/saveOneClickPacking`,'post',data) diff --git a/src/views/modules/ecss/declaration.vue b/src/views/modules/ecss/declaration.vue index e6e69da..e8e34ee 100644 --- a/src/views/modules/ecss/declaration.vue +++ b/src/views/modules/ecss/declaration.vue @@ -379,57 +379,48 @@ - - + label="计算FSC纸重量"> + + label="FSC纸重量(KG)"> @@ -796,13 +787,35 @@ + + + + + + @@ -926,13 +939,35 @@ + + + + + + @@ -1086,7 +1121,7 @@ searchDeclarationDetail, deleteDeclaration, downloadDeclarationElements, - getNotifyPartDetail, + getDeclarationPalletPartDetail, getCustomerInfo, getEcssContactsList, searchTemplateList, @@ -2250,7 +2285,7 @@ this.templateData.buNo = this.currentRow.buNo this.templateData.customName = this.currentRow.customName //this.templateData.shippingMode = this.currentRow.shippingMode - searchTemplateList(this.templateData).then(({data}) => { + return searchTemplateList(this.templateData).then(({data}) => { if (data && data.code === 0){ if (data.rows && data.rows.length > 0) { this.templateRowDblclick(data.rows[0]); @@ -2258,6 +2293,83 @@ } }) }, + loadDeclarationPalletPartDetail() { + return getDeclarationPalletPartDetail(this.currentRow).then(({data}) => { + if (data && data.code === 0) { + this.normalizeNotifyPartDetailList(data.rows) + } else { + this.notifyPartDetailList = [] + } + }).catch(() => { + this.notifyPartDetailList = [] + }) + }, + normalizeNotifyPartDetailList(rows) { + const rowList = Array.isArray(rows) ? rows : [] + this.notifyPartDetailList = rowList.map(item => { + const row = Object.assign({}, item) + row.fscFlag = row.fscFlag ? String(row.fscFlag).toUpperCase() : 'N' + row.calcFscWeight = row.fscFlag === 'Y' && !!row.lossratio + this.refreshNotifyPartDetailRow(row) + return row + }) + }, + applyTemplateFscWeightConfig(enableFscWeight) { + this.notifyPartDetailList.forEach(row => { + if (row.fscFlag === 'Y') { + row.calcFscWeight = !!enableFscWeight + } else { + row.calcFscWeight = false + } + this.refreshNotifyPartDetailRow(row) + }) + }, + handleFscWeightCheckChange(row) { + this.refreshNotifyPartDetailRow(row) + }, + refreshNotifyPartDetailRow(row) { + if (!row) { + return + } + if (row.fscFlag !== 'Y') { + row.calcFscWeight = false + row.lossratio = '' + row.fscWeightValue = '' + return + } + if (!row.calcFscWeight) { + row.lossratio = '' + row.fscWeightValue = '' + return + } + const qty = this.toNumber(row.qty) + const lossRatio = this.getFscLossRatio(qty) + row.lossratio = lossRatio.toFixed(2) + row.fscWeightValue = this.calculateFscWeight(qty, row.fscUnitWeight, lossRatio) + }, + getFscLossRatio(totalQty) { + if (totalQty <= 1000000) { + return 1.05 + } + if (totalQty <= 3000000) { + return 1.03 + } + return 1.01 + }, + calculateFscWeight(totalQty, fscUnitWeight, lossRatio) { + const qty = this.toNumber(totalQty) + const unitWeight = this.toNumber(fscUnitWeight) + if (qty <= 0 || unitWeight <= 0) { + return '0.00' + } + const rawWeight = qty * lossRatio * (unitWeight / 1000) + const roundedDown = Math.floor(rawWeight * 100) / 100 + return roundedDown.toFixed(2) + }, + toNumber(value) { + const num = Number(value) + return Number.isFinite(num) ? num : 0 + }, buildPickupAddressText(item) { const company = item && item.company ? item.company : '' const address = item && item.address ? item.address : '' @@ -2317,7 +2429,7 @@ this.pickupAddressList = [] }) }, - exportInvoiceList() { + async exportInvoiceList() { if (!this.currentRow || !this.currentRow.buNo) { this.$message.warning('请选择报关单!') return @@ -2342,24 +2454,12 @@ this.notifyPartDetailList = []; this.exportInvoiceFlag = true if (this.currentRow.buNo==='03-RFID') { - getNotifyPartDetail(this.currentRow).then(({data}) => { - //区分请求成功和失败的状况 - if (data && data.code == 0) { - this.notifyPartDetailList = data.rows - this.notifyPartDetailList.forEach(o => { - if (!o.lossratio) { - o.lossratio = '1.05'; - } - }); - } else { - this.notifyPartDetailList = []; - } - }); + await this.loadDeclarationPalletPartDetail() } this.templateData.type='发票' this.searchTemplateOne(); }, - exportPakingList() { + async exportPakingList() { if (!this.currentRow || !this.currentRow.buNo) { this.$message.warning('请选择报关单!') return @@ -2390,20 +2490,8 @@ this.exportPaking.templateName='' this.exportPakingFlag = true if (this.currentRow.buNo==='03-RFID') { - getNotifyPartDetail(this.currentRow).then(({data}) => { - //区分请求成功和失败的状况 - if (data && data.code == 0) { - this.notifyPartDetailList = data.rows - this.notifyPartDetailList.forEach(o => { - if (!o.lossratio) { - o.lossratio = '1.05'; - } - }); - } else { - this.notifyPartDetailList = []; - } - }); - } + await this.loadDeclarationPalletPartDetail() + } this.templateData.type='箱单' this.searchTemplateOne(); }, @@ -2757,19 +2845,7 @@ this.exportPaking.templateName='' if (this.currentRow.buNo==='03-RFID') { - await getNotifyPartDetail(this.currentRow).then(({data}) => { - //区分请求成功和失败的状况 - if (data && data.code == 0) { - this.notifyPartDetailList = data.rows - this.notifyPartDetailList.forEach(o => { - if (!o.lossratio) { - o.lossratio = '1.05'; - } - }); - } else { - this.notifyPartDetailList = []; - } - }); + await this.loadDeclarationPalletPartDetail() } this.templateData.type='箱单' await searchTemplateList(this.templateData).then(({data}) => { @@ -2790,22 +2866,7 @@ this.exportPaking.material=this.currentRow.material?this.currentRow.material:row.material this.exportPaking.hsCodeDescType=this.currentRow.hsCodeDescType?this.currentRow.hsCodeDescType:row.hsCodeDescType this.exportPaking.goodsLabel=this.currentRow.goodsLabel?this.currentRow.goodsLabel:row.goodsLabel - this.notifyPartDetailList.forEach(o => { - // 开启fsc损耗则给默认值 - if (o.lossratio) { - if (row.fscWeight) { - o.lossratio = o.lossratio; - } else { - o.lossratio = ''; - } - } else { - if (row.fscWeight) { - o.lossratio = '1.05'; - } else { - o.lossratio = ''; - } - } - }); + this.applyTemplateFscWeightConfig(row.fscWeight) } } }) @@ -3045,22 +3106,7 @@ this.exportGoods.shipper=row.shipper } if (this.templateData.type!=='出口货物委托书') { - this.notifyPartDetailList.forEach(o => { - // 开启fsc损耗则给默认值 - if (o.lossratio) { - if (row.fscWeight) { - o.lossratio = o.lossratio; - } else { - o.lossratio = ''; - } - } else { - if (row.fscWeight) { - o.lossratio = '1.05'; - } else { - o.lossratio = ''; - } - } - }); + this.applyTemplateFscWeightConfig(row.fscWeight) } this.templateFlag = false },