diff --git a/src/views/modules/quote/detail/breakdownCost.vue b/src/views/modules/quote/detail/breakdownCost.vue index 54b4f03..1bda2ac 100644 --- a/src/views/modules/quote/detail/breakdownCost.vue +++ b/src/views/modules/quote/detail/breakdownCost.vue @@ -346,9 +346,16 @@ export default { queryQuoteDetailReportOverall(params).then(({data})=>{ if (data && data.code === 0){ this.dataList = data.rows; + if (this.dataList.length === 0){ + this.subtotalCostStd = 0 + this.subtotalCostQuote = 0 + } }else { this.$message.warning(data.msg) } + this.$nextTick(()=>{ + this.handleQueryQuoteDetailReportRM(); + }) this.queryLoading = false; }).catch((error)=>{ this.$message.error(error) @@ -391,10 +398,10 @@ export default { }, 0); sums[index] = new Decimal(sums[index]).toFixed(6) if (column.property ==='subtotalCostQuote'){ - this.subtotalCostQuote = sums[index]?sums[index]:0 + this.subtotalCostQuote = new Decimal(sums[index]?sums[index]:0).toNumber() } if (column.property ==='subtotalCostStd'){ - this.subtotalCostStd = sums[index]?sums[index]:0 + this.subtotalCostStd = new Decimal(sums[index]?sums[index]:0).toNumber() } if (column.property === 'subPercentageQuote' || column.property ==='subPercentageStd'){ sums[index] = new Decimal(sums[index] * 100).toFixed(2) + '%' @@ -404,16 +411,54 @@ export default { } }); return sums; - } + }, + getRmSummaries(param) { + const { columns, data } = param; + const sums = []; + let totalCostStd = 0; + let totalCostQuote = 0; + columns.forEach((column, index) => { + if (index === 0) { + sums[index] = 'RM total cost'; + return; + } + const values = data.map(item => Number(item[column.property])); + console.log(values) + if (!values.every(value => isNaN(value))) { + sums[index] = values.reduce((prev, curr) => { + const value = Number(curr); + if (!isNaN(value)) { + return prev + curr; + } else { + return prev; + } + }, 0); + sums[index] = new Decimal(sums[index]).toFixed(6) + if (column.property === 'percentageOfRmStd' || column.property === 'percentageOfRmQuote'){ + sums[index] = new Decimal(sums[index] * 100).toFixed(2) + '%' + }else if (column.property === 'rmCostStandard'){ + totalCostStd = new Decimal(sums[index]).toNumber() + }else if (column.property === 'rmCostQuote'){ + totalCostQuote = new Decimal(sums[index]).toNumber() + }else if (column.property === 'totalCostStd'){ + sums[index] = new Decimal(totalCostStd / this.subtotalCostStd * 100).toFixed(0) + '%' + }else if (column.property === 'totalCostQuote'){ + sums[index] = new Decimal(totalCostQuote / this.subtotalCostQuote * 100).toFixed(0) + '%' + } + } else { + sums[index] = 'N/A'; + } + }); + return sums; + }, }, watch:{ quoteDetail(newVal,oldVal){ if (newVal){ this.queryLoading = true; this.handleQueryQuoteDetailReportOverall(); - this.handleQueryQuoteDetailReportRM(); } - } + }, } } @@ -445,7 +490,7 @@ export default { - +