Commit aadee921 by zhangxw

财务管理 嘀加成本/第三方成本 bug修复

1 parent 4f884ccd
...@@ -218,8 +218,9 @@ ...@@ -218,8 +218,9 @@
<td class="lb"> <td class="lb">
商品成本 商品成本
</td> </td>
<!-- 有嘀加成本或第三方成本 商品成本显示- --> <!-- 子订单有嘀加成本或第三方成本 商品成本显示- -->
<td>{{ !filterEmpty(detail.djCost) || !filterEmpty(detail.thirdPartyCost) ? '-' : (detail.goodsCost?('¥ '+detail.goodsCost):'¥0') }}</td> <td v-if="isSubOrder">{{ !filterEmpty(detail.djCost) || !filterEmpty(detail.thirdPartyCost) ? '-' : (detail.goodsCost?('¥ '+detail.goodsCost):'¥0') }}</td>
<td v-else>{{ detail.goodsCost?('¥ '+detail.goodsCost):'-' }}</td>
<td class="lb"> <td class="lb">
回收成本 回收成本
</td> </td>
......
...@@ -1129,16 +1129,17 @@ export default { ...@@ -1129,16 +1129,17 @@ export default {
item.hasOwnProperty('subOrderProfitAllocations') && item.hasOwnProperty('subOrderProfitAllocations') &&
item.subOrderProfitAllocations item.subOrderProfitAllocations
) { ) {
item.goodsCost = ''
item.subOrderProfitAllocations.forEach(subItem => { item.subOrderProfitAllocations.forEach(subItem => {
// 有嘀加成本或第三方成本 商品成本显示- // 有嘀加成本或第三方成本 商品成本显示-
if (!this.filterEmpty(subItem.djCost) || !this.filterEmpty(subItem.thirdPartyCost)) subItem.goodsCost = '' if (!this.filterEmpty(subItem.djCost) || !this.filterEmpty(subItem.thirdPartyCost)) subItem.goodsCost = ''
subItem.uniqueKey = temp++ subItem.uniqueKey = temp++
// 主订单商品成本根据 是否有嘀加成本或商品成本累加计算
item.goodsCost = this.subStr(item.goodsCost, Number(subItem.goodsCost)) > 0 ? (this.subStr(item.goodsCost, Number(subItem.goodsCost)) - 0) : ''
subItem = this.numAddPrefix(subItem) subItem = this.numAddPrefix(subItem)
subItem.positionStr = this.positionTypeList?.filter(val => val.position == subItem.goodsPosition)[0]?.confName || '-' subItem.positionStr = this.positionTypeList?.filter(val => val.position == subItem.goodsPosition)[0]?.confName || '-'
}) })
} }
// 有嘀加成本或第三方成本 商品成本显示-
if (!this.filterEmpty(item.djCost) || !this.filterEmpty(item.thirdPartyCost)) item.goodsCost = ''
item = this.numAddPrefix(item) item = this.numAddPrefix(item)
return item return item
}) })
...@@ -1149,6 +1150,23 @@ export default { ...@@ -1149,6 +1150,23 @@ export default {
} }
}) })
}, },
// 价格计算精度丢失处理
subStr(num1, num2) {
var r1, r2, m, n
try {
r1 = num1.toString().split('.')[1].length
} catch (e) {
r1 = 0
}
try {
r2 = num2.toString().split(".")[1].length
} catch (e) {
r2 = 0
}
m = Math.pow(10, Math.max(r1, r2))
n = (r1 >= r2) ? r1 : r2
return ((num1 * m + num2 * m) / m).toFixed(n)
},
filterEmpty(data) { filterEmpty(data) {
return (data ?? '') === '' return (data ?? '') === ''
}, },
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!