
- 小计 = 报价单价 * 需求数量 + 运费
- 含税总金额 = 所有小计总和



<template v-slot:unitPrice="slot">
<el-input
v-if="routeQueryType == 'offer'"
type="number"
min="0"
oninput="value=value.replace(/[^0-9.]/g,'')"
class="input-style"
style="width:100%;"
v-model.trim="slot.scope.row.price"
@change="calFee(slot.scope.row, 'price')"
></el-input>
<span v-else>{{ slot.scope.row.price }}</span>
</template>
<template v-slot:taxRate="slot">
<el-select
v-if="routeQueryType == 'offer'"
v-model="slot.scope.row.taxRate"
clearable
value-key="taxRateId"
@change="taxRateChange(slot.scope.row)"
placeholder="请选择税率"
>
<el-option
v-for="taxItem in taxList"
:key="taxItem.taxRateId"
:label="taxItem.taxRate"
:value="taxItem"
></el-option>
</el-select>
<span v-else>{{ slot.scope.row.taxRate }}</span>
</template>
<template v-slot:unit="slot">
<el-input
v-if="routeQueryType == 'offer'"
type="number"
min="0"
oninput="value=value.replace(/[^0-9.]/g,'')"
class="input-style"
style="width:100%;"
v-model.trim="slot.scope.row.freight"
@change="calFee(slot.scope.row, 'freight')"
></el-input>
<span v-else>{{ slot.scope.row.freight }}</span>
</template>
calFee(data, flag) {
if (flag == "price") {
let totalPrice = calRoundNum(Number(data.price).toFixed(2), data.requiredQuantity);
let total = calRoundNum(totalPrice, 100)
this.tableData.map(item => item)
this.tableData.forEach(item => {
if (item.enquiryDetailId == data.enquiryDetailId) {
item.price = Number(data.price).toFixed(2);
if (item.freight) {
let subNum = Number(Number(Math.round(total) / 100).toFixed(2)) + Number(item.freight)
this.$set(item, "totalPrice", Number(subNum).toFixed(2));
} else {
this.$set(item, "totalPrice", Number(Math.round(total) / 100).toFixed(2));
}
}
})
}
if (flag == "freight") {
this.tableData.forEach(item => {
if (item.enquiryDetailId == data.enquiryDetailId) {
item.freight = Number(data.freight).toFixed(2);
if (item.totalPrice && item.price) {
let totalPrice = calRoundNum(Number(data.price).toFixed(2), data.requiredQuantity);
let total = calRoundNum(totalPrice, 100)
let subNum = Number(Number(Math.round(total) / 100).toFixed(2)) + Number(item.freight);
this.$set(item, "totalPrice", Number(subNum).toFixed(2));
} else {
this.$set(item, "totalPrice", item.freight);
}
}
})
}
},
export function calRoundNum(data1, data2) {
let m = 0,
s1 = data1.toString(),
s2 = data2.toString();
try {
m += s1.split(".")[1].length
} catch (e) {
}
try {
m += s2.split(".")[1].length
} catch (e) {
}
return Number(s1.replace(".", "")) * Number(s2.replace(".", "")) / Math.pow(10, m);
}
computed: {
allPrice() {
let totalPrice = 0
this.tableData.forEach(item => {
if (item.totalPrice) {
totalPrice += Number(item.totalPrice)
}
})
return totalPrice.toFixed(2)
}
},