|
@@ -103,7 +103,7 @@
|
|
|
<el-input-number
|
|
|
onmousewheel="return false;"
|
|
|
v-model="row.count"
|
|
|
- :precision="4"
|
|
|
+ :precision="2"
|
|
|
:controls="false"
|
|
|
:min="0"
|
|
|
@change="handleChangeAmount"
|
|
@@ -121,7 +121,7 @@
|
|
|
<el-input-number
|
|
|
onmousewheel="return false;"
|
|
|
v-model="row.price"
|
|
|
- :precision="4"
|
|
|
+ :precision="2"
|
|
|
:controls="false"
|
|
|
:min="0"
|
|
|
@change="handleChangeAmount"
|
|
@@ -188,7 +188,7 @@
|
|
|
>
|
|
|
<el-input-number
|
|
|
v-model="row.price"
|
|
|
- :precision="4"
|
|
|
+ :precision="2"
|
|
|
:controls="false"
|
|
|
@change="handleChangeAmount"
|
|
|
/>
|
|
@@ -349,6 +349,10 @@ const pushGoods = (goods) => {
|
|
|
formData.data.purchaseDetailList =
|
|
|
formData.data.purchaseDetailList.concat(arr);
|
|
|
openProduct.value = false;
|
|
|
+ const ids = formData.data.purchaseDetailList.map((x) => x.bussinessId);
|
|
|
+ if (formData.data.supplyId && ids.length > 0) {
|
|
|
+ handleChangeSupplier(formData.data.supplyId);
|
|
|
+ }
|
|
|
return ElMessage({
|
|
|
message: "添加成功!",
|
|
|
type: "success",
|
|
@@ -411,35 +415,6 @@ const handleSubmit = async () => {
|
|
|
|
|
|
return false;
|
|
|
};
|
|
|
-// 获取用户信息并赋默认值
|
|
|
-const userInfo = useUserStore().user;
|
|
|
-onMounted(() => {
|
|
|
- formData.data.purchaseTime = proxy.parseTime(new Date());
|
|
|
- formData.data.deptName = userInfo.dept.deptName;
|
|
|
- formData.data.purchaseName = userInfo.nickName;
|
|
|
- getSupplierList();
|
|
|
- if (props.queryData.ids) {
|
|
|
- ids.value = props.queryData.ids.split(",") || [];
|
|
|
- getDetails();
|
|
|
- }
|
|
|
-});
|
|
|
-
|
|
|
-// onActivated(() => {
|
|
|
-// formData.data = {
|
|
|
-// purchaseTime: "",
|
|
|
-// purchaseDetailList: [],
|
|
|
-// otherFeeList: [],
|
|
|
-// };
|
|
|
-// formData.data.purchaseTime = proxy.parseTime(new Date());
|
|
|
-// formData.data.deptName = userInfo.dept.deptName;
|
|
|
-// formData.data.purchaseName = userInfo.nickName;
|
|
|
-// getSupplierList();
|
|
|
-// if (props.queryData.ids) {
|
|
|
-// ids.value = props.queryData.ids.split(",") || [];
|
|
|
-// getDetails();
|
|
|
-// }
|
|
|
-// });
|
|
|
-
|
|
|
const ids = ref([]);
|
|
|
const getDetails = () => {
|
|
|
if (props.queryData.type && props.queryData.type === "handoverSlip") {
|
|
@@ -493,87 +468,54 @@ let auxiliaryData = ref([
|
|
|
[
|
|
|
{
|
|
|
label: "合同编号",
|
|
|
- value: "12312312312456",
|
|
|
- fn: () => {
|
|
|
- console.log(formData.data);
|
|
|
- },
|
|
|
- style: {
|
|
|
- color: "red",
|
|
|
- },
|
|
|
+ value: "",
|
|
|
+ fn: () => {},
|
|
|
num: 1,
|
|
|
},
|
|
|
{
|
|
|
label: "下单日期",
|
|
|
- value: "123456",
|
|
|
- fn: () => {
|
|
|
- alert("点击事件");
|
|
|
- },
|
|
|
+ value: "",
|
|
|
num: 1,
|
|
|
},
|
|
|
{
|
|
|
label: "合同金额",
|
|
|
- value: "123456",
|
|
|
- fn: () => {
|
|
|
- alert("点击事件");
|
|
|
- },
|
|
|
+ value: "",
|
|
|
num: 1,
|
|
|
},
|
|
|
],
|
|
|
[
|
|
|
{
|
|
|
label: "合同编号",
|
|
|
- value: "12312312312456",
|
|
|
- fn: () => {
|
|
|
- console.log(formData.data);
|
|
|
- },
|
|
|
- style: {
|
|
|
- color: "red",
|
|
|
- },
|
|
|
+ value: "",
|
|
|
+ fn: () => {},
|
|
|
num: 1,
|
|
|
},
|
|
|
{
|
|
|
label: "下单日期",
|
|
|
- value: "123456",
|
|
|
- fn: () => {
|
|
|
- alert("点击事件");
|
|
|
- },
|
|
|
+ value: "",
|
|
|
num: 1,
|
|
|
},
|
|
|
{
|
|
|
label: "合同金额",
|
|
|
- value: "123456",
|
|
|
- fn: () => {
|
|
|
- alert("点击事件");
|
|
|
- },
|
|
|
+ value: "",
|
|
|
num: 1,
|
|
|
},
|
|
|
],
|
|
|
[
|
|
|
{
|
|
|
label: "合同编号",
|
|
|
- value: "12312312312456",
|
|
|
- fn: () => {
|
|
|
- console.log(formData.data);
|
|
|
- },
|
|
|
- style: {
|
|
|
- color: "red",
|
|
|
- },
|
|
|
+ value: "",
|
|
|
+ fn: () => {},
|
|
|
num: 1,
|
|
|
},
|
|
|
{
|
|
|
label: "下单日期",
|
|
|
- value: "123456",
|
|
|
- fn: () => {
|
|
|
- alert("点击事件");
|
|
|
- },
|
|
|
+ value: "",
|
|
|
num: 1,
|
|
|
},
|
|
|
{
|
|
|
label: "合同金额",
|
|
|
- value: "123456",
|
|
|
- fn: () => {
|
|
|
- alert("点击事件");
|
|
|
- },
|
|
|
+ value: "",
|
|
|
num: 1,
|
|
|
},
|
|
|
],
|
|
@@ -581,45 +523,7 @@ let auxiliaryData = ref([
|
|
|
},
|
|
|
{
|
|
|
label: "产品价格",
|
|
|
- data: [
|
|
|
- [
|
|
|
- {
|
|
|
- label: "产品名称",
|
|
|
- value: "12312312312456",
|
|
|
- fn: () => {
|
|
|
- console.log(formData.data);
|
|
|
- },
|
|
|
- style: {
|
|
|
- color: "red",
|
|
|
- },
|
|
|
- num: 1,
|
|
|
- },
|
|
|
- {
|
|
|
- label: "最近价格",
|
|
|
- value: "123456",
|
|
|
- fn: () => {
|
|
|
- alert("点击事件");
|
|
|
- },
|
|
|
- num: 1,
|
|
|
- },
|
|
|
- {
|
|
|
- label: "历史最高",
|
|
|
- value: "123456",
|
|
|
- fn: () => {
|
|
|
- alert("点击事件");
|
|
|
- },
|
|
|
- num: 1,
|
|
|
- },
|
|
|
- {
|
|
|
- label: "历史最低",
|
|
|
- value: "123456",
|
|
|
- fn: () => {
|
|
|
- alert("点击事件");
|
|
|
- },
|
|
|
- num: 1,
|
|
|
- },
|
|
|
- ],
|
|
|
- ],
|
|
|
+ data: [],
|
|
|
},
|
|
|
]);
|
|
|
const auxiliaryChange = (data) => {
|
|
@@ -627,92 +531,150 @@ const auxiliaryChange = (data) => {
|
|
|
};
|
|
|
|
|
|
const getAuxiliaryData = (supplyId, productIdList) => {
|
|
|
- if (supplyId && productIdList) {
|
|
|
+ if (supplyId && productIdList.length > 0) {
|
|
|
proxy
|
|
|
.post("/subscribe/decisionAid", {
|
|
|
supplyId: supplyId,
|
|
|
productIdList: productIdList,
|
|
|
})
|
|
|
.then((res) => {
|
|
|
- auxiliaryData.value[0].data = auxiliaryData.value[0].data.map(
|
|
|
+ // 获取数组长度
|
|
|
+ let dataLength = auxiliaryData.value.length;
|
|
|
+ // 供应商最近采购
|
|
|
+ auxiliaryData.value[dataLength - 2].data = auxiliaryData.value[
|
|
|
+ dataLength - 2
|
|
|
+ ].data.map((x, index) => {
|
|
|
+ return x.map((y, sonIndex) => {
|
|
|
+ let obj = { ...y };
|
|
|
+ let value = "";
|
|
|
+ if (sonIndex === 0) {
|
|
|
+ value = res.purchaseList[index].code;
|
|
|
+ } else if (sonIndex === 1) {
|
|
|
+ value = res.purchaseList[index].createTime;
|
|
|
+ } else {
|
|
|
+ value =
|
|
|
+ res.purchaseList[index].currency +
|
|
|
+ " " +
|
|
|
+ proxy.moneyFormat(res.purchaseList[index].amount, 2);
|
|
|
+ }
|
|
|
+ obj.value = value;
|
|
|
+ return obj;
|
|
|
+ });
|
|
|
+ });
|
|
|
+ // 产品价格
|
|
|
+ const arrConfig = [
|
|
|
+ {
|
|
|
+ label: "产品名称",
|
|
|
+ value: "",
|
|
|
+ num: 1,
|
|
|
+ },
|
|
|
+ {
|
|
|
+ label: "最近价格",
|
|
|
+ value: "",
|
|
|
+ num: 1,
|
|
|
+ },
|
|
|
+ {
|
|
|
+ label: "历史最高",
|
|
|
+ value: "",
|
|
|
+ num: 1,
|
|
|
+ },
|
|
|
+ {
|
|
|
+ label: "历史最低",
|
|
|
+ value: "",
|
|
|
+ num: 1,
|
|
|
+ },
|
|
|
+ ];
|
|
|
+ auxiliaryData.value[dataLength - 1].data = res.productPriceList.map(
|
|
|
(x, index) => {
|
|
|
- return x.map((y, sonIndex) => {
|
|
|
+ return arrConfig.map((y, sonIndex) => {
|
|
|
let obj = { ...y };
|
|
|
let value = "";
|
|
|
if (sonIndex === 0) {
|
|
|
- value = res.purchaseList[index].code;
|
|
|
+ value = x.name;
|
|
|
} else if (sonIndex === 1) {
|
|
|
- value = res.purchaseList[index].createTime;
|
|
|
+ value = x.lastPrice;
|
|
|
+ } else if (sonIndex === 2) {
|
|
|
+ value = x.maxPrice;
|
|
|
} else {
|
|
|
- value =
|
|
|
- res.purchaseList[index].currency +
|
|
|
- " " +
|
|
|
- proxy.moneyFormat(res.purchaseList[index].amount, 2);
|
|
|
+ value = x.minPrice;
|
|
|
}
|
|
|
obj.value = value;
|
|
|
return obj;
|
|
|
});
|
|
|
}
|
|
|
);
|
|
|
- const arr = auxiliaryData.value[1].data[0];
|
|
|
- auxiliaryData.value[1].data = res.productPriceList.map((x, index) => {
|
|
|
- return arr.map((y, sonIndex) => {
|
|
|
- let obj = { ...y };
|
|
|
- let value = "";
|
|
|
- if (sonIndex === 0) {
|
|
|
- value = x.name;
|
|
|
- } else if (sonIndex === 1) {
|
|
|
- value = x.lastPrice;
|
|
|
- } else if (sonIndex === 2) {
|
|
|
- value = x.maxPrice;
|
|
|
- } else {
|
|
|
- value = x.minPrice;
|
|
|
- }
|
|
|
- obj.value = value;
|
|
|
- return obj;
|
|
|
- });
|
|
|
- });
|
|
|
- console.log(auxiliaryData.value, "aaa");
|
|
|
auxiliaryChange(auxiliaryData.value);
|
|
|
});
|
|
|
+ } else {
|
|
|
+ if (props.queryData.type === "handoverSlip" && props.queryData.arr) {
|
|
|
+ let arrConfig = [
|
|
|
+ {
|
|
|
+ label: "合同编号",
|
|
|
+ value: "",
|
|
|
+ fn: () => {},
|
|
|
+ num: 1,
|
|
|
+ },
|
|
|
+ {
|
|
|
+ label: "下单日期",
|
|
|
+ value: "",
|
|
|
+ num: 1,
|
|
|
+ },
|
|
|
+ ];
|
|
|
+ auxiliaryData.value[0].data = contractData.value.map((x, index) => {
|
|
|
+ return arrConfig.map((y, sonIndex) => {
|
|
|
+ let obj = { ...y };
|
|
|
+ let value = "";
|
|
|
+ if (sonIndex === 0) {
|
|
|
+ value = contractData.value[index].contractCode;
|
|
|
+ } else if (sonIndex === 1) {
|
|
|
+ value = contractData.value[index].claimTime;
|
|
|
+ }
|
|
|
+ obj.value = value;
|
|
|
+ return obj;
|
|
|
+ });
|
|
|
+ });
|
|
|
+ auxiliaryChange(auxiliaryData.value);
|
|
|
+ }
|
|
|
}
|
|
|
};
|
|
|
// 供应商改变逻辑
|
|
|
const handleChangeSupplier = (val) => {
|
|
|
const ids = formData.data.purchaseDetailList.map((x) => x.bussinessId);
|
|
|
- getAuxiliaryData(val, ids);
|
|
|
- proxy
|
|
|
- .post("/supplierPrice/getSupplierPriceByProductIds", {
|
|
|
- supplierInfoId: val,
|
|
|
- productIdList: ids,
|
|
|
- })
|
|
|
- .then((res) => {
|
|
|
- if (res && Object.keys(res).length > 0) {
|
|
|
- for (let i = 0; i < formData.data.purchaseDetailList.length; i++) {
|
|
|
- const e = formData.data.purchaseDetailList[i];
|
|
|
- for (const key in res) {
|
|
|
- if (e.bussinessId === key) {
|
|
|
- e.price = Number(res[key]);
|
|
|
+ if (val && ids.length > 0) {
|
|
|
+ getAuxiliaryData(val, ids);
|
|
|
+ proxy
|
|
|
+ .post("/supplierPrice/getSupplierPriceByProductIds", {
|
|
|
+ supplierInfoId: val,
|
|
|
+ productIdList: ids,
|
|
|
+ })
|
|
|
+ .then((res) => {
|
|
|
+ if (res && Object.keys(res).length > 0) {
|
|
|
+ for (let i = 0; i < formData.data.purchaseDetailList.length; i++) {
|
|
|
+ const e = formData.data.purchaseDetailList[i];
|
|
|
+ for (const key in res) {
|
|
|
+ if (e.bussinessId === key) {
|
|
|
+ e.price = Number(res[key]);
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
+ } else {
|
|
|
+ for (let i = 0; i < formData.data.purchaseDetailList.length; i++) {
|
|
|
+ const e = formData.data.purchaseDetailList[i];
|
|
|
+ e.price = 0;
|
|
|
+ }
|
|
|
}
|
|
|
- } else {
|
|
|
- for (let i = 0; i < formData.data.purchaseDetailList.length; i++) {
|
|
|
- const e = formData.data.purchaseDetailList[i];
|
|
|
- e.price = 0;
|
|
|
- }
|
|
|
- }
|
|
|
- handleChangeAmount();
|
|
|
- });
|
|
|
+ handleChangeAmount();
|
|
|
+ });
|
|
|
+ }
|
|
|
};
|
|
|
const handleChangeProductAmount = () => {
|
|
|
let sum = 0;
|
|
|
for (let i = 0; i < formData.data.purchaseDetailList.length; i++) {
|
|
|
const e = formData.data.purchaseDetailList[i];
|
|
|
- e.amount = parseFloat(e.count * e.price).toFixed(4);
|
|
|
+ e.amount = parseFloat(e.count * e.price).toFixed(2);
|
|
|
sum += Number(e.amount);
|
|
|
}
|
|
|
- formData.data.productAmount = parseFloat(sum).toFixed(4);
|
|
|
+ formData.data.productAmount = parseFloat(sum).toFixed(2);
|
|
|
};
|
|
|
|
|
|
const handleChangeOtherAmount = () => {
|
|
@@ -721,7 +683,7 @@ const handleChangeOtherAmount = () => {
|
|
|
const e = formData.data.otherFeeList[i];
|
|
|
sum += Number(e.price);
|
|
|
}
|
|
|
- formData.data.otherAmount = parseFloat(sum).toFixed(4);
|
|
|
+ formData.data.otherAmount = parseFloat(sum).toFixed(2);
|
|
|
};
|
|
|
|
|
|
// 计算采购总金额
|
|
@@ -731,14 +693,14 @@ const handleChangeAmount = () => {
|
|
|
let sum = 0;
|
|
|
for (let i = 0; i < formData.data.purchaseDetailList.length; i++) {
|
|
|
const e = formData.data.purchaseDetailList[i];
|
|
|
- e.amount = parseFloat(e.count * e.price).toFixed(4);
|
|
|
+ e.amount = parseFloat(e.count * e.price).toFixed(2);
|
|
|
sum += Number(e.amount);
|
|
|
}
|
|
|
for (let i = 0; i < formData.data.otherFeeList.length; i++) {
|
|
|
const e = formData.data.otherFeeList[i];
|
|
|
sum += Number(e.price);
|
|
|
}
|
|
|
- formData.data.amount = parseFloat(sum).toFixed(4);
|
|
|
+ formData.data.amount = parseFloat(sum).toFixed(2);
|
|
|
};
|
|
|
|
|
|
const productUnit = ref([]);
|
|
@@ -803,6 +765,27 @@ const judgeStatus = () => {
|
|
|
}
|
|
|
return false;
|
|
|
};
|
|
|
+// 获取用户信息并赋默认值
|
|
|
+const userInfo = useUserStore().user;
|
|
|
+const contractData = ref([]);
|
|
|
+onMounted(() => {
|
|
|
+ formData.data.purchaseTime = proxy.parseTime(new Date());
|
|
|
+ formData.data.deptName = userInfo.dept.deptName;
|
|
|
+ formData.data.purchaseName = userInfo.nickName;
|
|
|
+ getSupplierList();
|
|
|
+ if (props.queryData.ids) {
|
|
|
+ ids.value = props.queryData.ids.split(",") || [];
|
|
|
+ getDetails();
|
|
|
+ }
|
|
|
+ if (props.queryData.type === "handoverSlip" && props.queryData.arr) {
|
|
|
+ contractData.value = JSON.parse(props.queryData.arr);
|
|
|
+ auxiliaryData.value.unshift({
|
|
|
+ label: "关联销售合同",
|
|
|
+ data: [],
|
|
|
+ });
|
|
|
+ getAuxiliaryData();
|
|
|
+ }
|
|
|
+});
|
|
|
|
|
|
const getFormData = () => {
|
|
|
return formData.data;
|