|
|
@@ -34,12 +34,12 @@
|
|
|
style="margin-right:10px;"
|
|
|
v-show="!isCheck"
|
|
|
:disabled="$route.query.is_refer == 0?true:btn3_disable">参照质检单</Button> -->
|
|
|
- <Button
|
|
|
+ <!-- <Button
|
|
|
type="primary"
|
|
|
@click="otherPriceTotal"
|
|
|
style="margin-right: 10px"
|
|
|
>运费明细</Button
|
|
|
- >
|
|
|
+ > -->
|
|
|
<Button @click="goBack" type="primary" ghost style="margin-right: 10px"
|
|
|
>取消</Button
|
|
|
>
|
|
|
@@ -111,6 +111,24 @@
|
|
|
</div>
|
|
|
<span v-show="isCheck">{{ searchData.supply_title }}</span>
|
|
|
</FormItem>
|
|
|
+ <FormItem label="运费:">
|
|
|
+ <Input
|
|
|
+ type="text"
|
|
|
+ size="small"
|
|
|
+ v-show="!isCheck"
|
|
|
+ v-model="other_price"
|
|
|
+ style="width: 100px"
|
|
|
+ />
|
|
|
+ <span v-show="isCheck">{{ other_price }}</span>
|
|
|
+ <Button
|
|
|
+ type="primary"
|
|
|
+ size="small"
|
|
|
+ style="margin-left: 10px"
|
|
|
+ @click="averageOtherPrice"
|
|
|
+ >平摊运费</Button
|
|
|
+ >
|
|
|
+ </FormItem>
|
|
|
+
|
|
|
<FormItem label="仓库:" class="red_star">
|
|
|
<Select
|
|
|
v-model="searchData.warehouse_id"
|
|
|
@@ -206,18 +224,18 @@
|
|
|
item
|
|
|
}}</span>
|
|
|
</div>
|
|
|
- <div>
|
|
|
+ <!-- <div>
|
|
|
<span style="font-size: 16px; font-weight: bold"
|
|
|
>运费统计:{{ other_price }}</span
|
|
|
>
|
|
|
- </div>
|
|
|
+ </div> -->
|
|
|
<div>
|
|
|
- <Button
|
|
|
+ <!-- <Button
|
|
|
type="primary"
|
|
|
style="margin-right: 10px"
|
|
|
@click="averageOtherPrice"
|
|
|
>平摊运费</Button
|
|
|
- >
|
|
|
+ > -->
|
|
|
<Button type="primary" ghost @click="btnChangeTaxRate"
|
|
|
>批量修改税率</Button
|
|
|
>
|
|
|
@@ -586,6 +604,19 @@
|
|
|
</div>
|
|
|
</Modal>
|
|
|
<Modal
|
|
|
+ title="分摊运费"
|
|
|
+ v-model="shareFreightModal"
|
|
|
+ width="30"
|
|
|
+ @on-ok="shareFreightOk"
|
|
|
+ >
|
|
|
+ <div style="display: flex; align-items: center; height: 65px">
|
|
|
+ <RadioGroup v-model="shareFreightValue">
|
|
|
+ <Radio style="margin-left: 20px" label="按数量分摊"></Radio>
|
|
|
+ <Radio style="margin-left: 20px" label="按金额分摊"></Radio>
|
|
|
+ </RadioGroup>
|
|
|
+ </div>
|
|
|
+ </Modal>
|
|
|
+ <Modal
|
|
|
width="50"
|
|
|
title="运费明细"
|
|
|
v-model="showOtherPrice"
|
|
|
@@ -636,6 +667,8 @@ export default {
|
|
|
data() {
|
|
|
// 这里存放数据
|
|
|
return {
|
|
|
+ shareFreightModal: false,
|
|
|
+ shareFreightValue: "按数量分摊",
|
|
|
other_price: "0.00",
|
|
|
otherPriceList: [{ name: "", id: 0, price: "" }],
|
|
|
showOtherPrice: false,
|
|
|
@@ -1089,7 +1122,10 @@ export default {
|
|
|
"on-change": (e) => {
|
|
|
currentRow.is_upd = true;
|
|
|
currentRow.no_tax_total_price = e.target.value;
|
|
|
- currentRow.total_cost = (currentRow.transport_price*1+currentRow.no_tax_total_price*1).toFixed(2);
|
|
|
+ currentRow.total_cost = (
|
|
|
+ currentRow.transport_price * 1 +
|
|
|
+ currentRow.no_tax_total_price * 1
|
|
|
+ ).toFixed(2);
|
|
|
currentRow.no_tax_price = currentRow.num
|
|
|
? (
|
|
|
(currentRow.no_tax_total_price * 1) /
|
|
|
@@ -1319,7 +1355,10 @@ export default {
|
|
|
"on-change": (e) => {
|
|
|
currentRow.is_upd = true;
|
|
|
currentRow.transport_price = e.target.value;
|
|
|
- currentRow.total_cost = (currentRow.transport_price*1+currentRow.no_tax_total_price*1).toFixed(2);
|
|
|
+ currentRow.total_cost = (
|
|
|
+ currentRow.transport_price * 1 +
|
|
|
+ currentRow.no_tax_total_price * 1
|
|
|
+ ).toFixed(2);
|
|
|
this.tableData.splice(index, 1, currentRow);
|
|
|
},
|
|
|
"on-focus": () => {
|
|
|
@@ -1722,45 +1761,99 @@ export default {
|
|
|
}
|
|
|
},
|
|
|
methods: {
|
|
|
- averageOtherPrice() {
|
|
|
+ shareFreightOk() {
|
|
|
+ if (this.shareFreightValue == "按数量分摊") {
|
|
|
+ this.shareFreightNum();
|
|
|
+ } else {
|
|
|
+ this.shareFreightMoney();
|
|
|
+ }
|
|
|
+ },
|
|
|
+ shareFreightMoney() {
|
|
|
+ //按金额分摊
|
|
|
+
|
|
|
if (this.tableData.length == 1) {
|
|
|
return this.$Message.warning("没有要平摊运费的物料!");
|
|
|
}
|
|
|
+ let total = 0;
|
|
|
+ this.tableData.forEach((el) => {
|
|
|
+ if (el.total) {
|
|
|
+ total = el.total * 1 + total;
|
|
|
+ }
|
|
|
+ });
|
|
|
+ let lastNum = 0;
|
|
|
this.tableData.forEach((v, index) => {
|
|
|
if (index == this.tableData.length - 2) {
|
|
|
- v.transport_price = (
|
|
|
- this.other_price * 1 -
|
|
|
- ((this.other_price * 1) / (this.tableData.length - 1)) *
|
|
|
- (this.tableData.length - 2)
|
|
|
- ).toFixed(2);
|
|
|
+ v.transport_price = (this.other_price * 1 - lastNum).toFixed(2);
|
|
|
+ // v.transport_price = (
|
|
|
+ // this.other_price * 1 -
|
|
|
+ // ((this.other_price * 1) / (this.tableData.length - 1)) *
|
|
|
+ // (this.tableData.length - 2)
|
|
|
+ // ).toFixed(2);
|
|
|
+ // console.log(this.other_price * 1,this.tableData.length - 1,this.tableData.length - 2, v.transport_price);
|
|
|
} else {
|
|
|
v.transport_price = (
|
|
|
- (this.other_price * 1) /
|
|
|
- (this.tableData.length - 1)
|
|
|
+ ((this.other_price * 1) / total) *
|
|
|
+ v.total
|
|
|
).toFixed(2);
|
|
|
+ lastNum = v.transport_price * 1 + lastNum * 1;
|
|
|
}
|
|
|
this.tableData.splice(index, 1, v);
|
|
|
});
|
|
|
- let lastObj = {};
|
|
|
- lastObj = this.tableData.slice(-1);
|
|
|
- let last = [];
|
|
|
- let lastSum = 0;
|
|
|
- this.tableData.forEach((e) => {
|
|
|
- last.push(e.transport_price);
|
|
|
+ },
|
|
|
+ shareFreightNum() {
|
|
|
+ if (this.tableData.length == 1) {
|
|
|
+ return this.$Message.warning("没有要平摊运费的物料!");
|
|
|
+ }
|
|
|
+ console.log(this.tableData, "这是tableData");
|
|
|
+ let numAll = 0;
|
|
|
+ this.tableData.forEach((el) => {
|
|
|
+ if (el.num) {
|
|
|
+ numAll = el.num * 1 + numAll;
|
|
|
+ }
|
|
|
});
|
|
|
- //这是全部的和
|
|
|
- lastSum = eval(last.slice(0, -1).join("+"));
|
|
|
- lastSum = lastSum - lastObj[0].transport_price * 1;
|
|
|
- lastSum = this.other_price - lastSum;
|
|
|
- this.tableData.forEach((e, index) => {
|
|
|
- console.log(e, index, this.tableData.length - 2);
|
|
|
+ let lastNum = 0;
|
|
|
+ this.tableData.forEach((v, index) => {
|
|
|
if (index == this.tableData.length - 2) {
|
|
|
- e.transport_price = lastSum.toFixed(2);
|
|
|
+ console.log(lastNum);
|
|
|
+ v.transport_price = (this.other_price * 1 - lastNum).toFixed(2);
|
|
|
+ // v.transport_price = (
|
|
|
+ // this.other_price * 1 -
|
|
|
+ // ((this.other_price * 1) / (this.tableData.length - 1)) *
|
|
|
+ // (this.tableData.length - 2)
|
|
|
+ // ).toFixed(2);
|
|
|
+ // console.log(this.other_price * 1,this.tableData.length - 1,this.tableData.length - 2, v.transport_price);
|
|
|
+ } else {
|
|
|
+ v.transport_price = (
|
|
|
+ ((this.other_price * 1) / numAll) *
|
|
|
+ v.num
|
|
|
+ ).toFixed(2);
|
|
|
+ lastNum = v.transport_price * 1 + lastNum * 1;
|
|
|
}
|
|
|
+ this.tableData.splice(index, 1, v);
|
|
|
});
|
|
|
- this.tableData.slice(0, -1).forEach((e) => {
|
|
|
- e.total_cost = e.transport_price*1 + e.no_tax_total_price*1;
|
|
|
- });
|
|
|
+ // let lastObj = {};
|
|
|
+ // lastObj = this.tableData.slice(-1);
|
|
|
+ // let last = [];
|
|
|
+ // let lastSum = 0;
|
|
|
+ // this.tableData.forEach((e) => {
|
|
|
+ // last.push(e.transport_price);
|
|
|
+ // });
|
|
|
+ // //这是全部的和
|
|
|
+ // lastSum = eval(last.slice(0, -1).join("+"));
|
|
|
+ // lastSum = lastSum - lastObj[0].transport_price * 1;
|
|
|
+ // lastSum = this.other_price - lastSum;
|
|
|
+ // this.tableData.forEach((e, index) => {
|
|
|
+ // console.log(e, index, this.tableData.length - 2);
|
|
|
+ // if (index == this.tableData.length - 2) {
|
|
|
+ // e.transport_price = lastSum.toFixed(2);
|
|
|
+ // }
|
|
|
+ // });
|
|
|
+ // this.tableData.slice(0, -1).forEach((e) => {
|
|
|
+ // e.total_cost = e.transport_price * 1 + e.no_tax_total_price * 1;
|
|
|
+ // });
|
|
|
+ },
|
|
|
+ averageOtherPrice() {
|
|
|
+ this.shareFreightModal = true;
|
|
|
},
|
|
|
sureOtherPrice() {
|
|
|
const values = this.otherPriceList.map((item) => Number(item.price));
|
|
|
@@ -2002,8 +2095,8 @@ export default {
|
|
|
key === "no_tax_total_price" ||
|
|
|
key === "tax_total_price" ||
|
|
|
key === "total" ||
|
|
|
- key === "total_cost"||
|
|
|
- key === 'transport_price'
|
|
|
+ key === "total_cost" ||
|
|
|
+ key === "transport_price"
|
|
|
) {
|
|
|
const v = values.reduce((prev, curr) => {
|
|
|
const value = Number(curr);
|
|
|
@@ -2112,9 +2205,12 @@ export default {
|
|
|
data: { order_in_no: [order_in_no], merge_state: 0 },
|
|
|
})
|
|
|
.then((res) => {
|
|
|
- res.data.list.data.forEach(v=>{
|
|
|
- v.total_cost = (v.no_tax_total_price*1+v.transport_price*1).toFixed(2);
|
|
|
- })
|
|
|
+ res.data.list.data.forEach((v) => {
|
|
|
+ v.total_cost = (
|
|
|
+ v.no_tax_total_price * 1 +
|
|
|
+ v.transport_price * 1
|
|
|
+ ).toFixed(2);
|
|
|
+ });
|
|
|
this.tableData = res.data.list.data;
|
|
|
this.otherPriceList =
|
|
|
res.data.price_list.length != 0
|
|
|
@@ -2205,8 +2301,15 @@ export default {
|
|
|
if (v.title == "选择物料") {
|
|
|
children.splice(index, 1);
|
|
|
}
|
|
|
+ this.otherPriceList = [{
|
|
|
+ name:"",
|
|
|
+ price:this.other_price
|
|
|
+ }]
|
|
|
});
|
|
|
if (this.$route.query.order_in_no == "" || this.$route.query.type == 6) {
|
|
|
+ // console.log(...obj, "obj");
|
|
|
+ // console.log(children);
|
|
|
+ // debugger
|
|
|
// 新增
|
|
|
this.axios({
|
|
|
method: "post",
|
|
|
@@ -2220,6 +2323,7 @@ export default {
|
|
|
},
|
|
|
})
|
|
|
.then((res) => {
|
|
|
+ debugger
|
|
|
if (res.code == 200) {
|
|
|
this.$Message.success(res.msg);
|
|
|
this.goBack();
|