From c6d13e58d85fbaaceb49d4c24401b50143050173 Mon Sep 17 00:00:00 2001
From: zhang_12370 <z2864490065@outlook.com>
Date: 星期四, 26 六月 2025 18:01:24 +0800
Subject: [PATCH] 调整 基础管理煤种生产人 更改采购数计算逻辑 处理供应商数据回显问题
---
src/views/basicInformation/index.vue | 4
src/views/procureMent/index.vue | 2
src/views/procureMent/components/ProductionDialog.vue | 141 +++++++++++++++--------------------
src/views/basicInformation/mould/coal.vue | 31 -------
src/api/tool/publicInterface.js | 2
src/views/production/index.vue | 2
src/components/Table/ETable.vue | 4
src/views/production/components/ProductionDialog.vue | 20 ++--
8 files changed, 81 insertions(+), 125 deletions(-)
diff --git a/src/api/tool/publicInterface.js b/src/api/tool/publicInterface.js
index 0de140d..8af0f82 100644
--- a/src/api/tool/publicInterface.js
+++ b/src/api/tool/publicInterface.js
@@ -3,7 +3,7 @@
// 鑾峰彇璺敱
export const testUserList = () => {
return request({
- url: '/test/user/list',
+ url: '/system/user/listAll',
method: 'get'
})
}
\ No newline at end of file
diff --git a/src/components/Table/ETable.vue b/src/components/Table/ETable.vue
index 66ca0b9..1f8fdfb 100644
--- a/src/components/Table/ETable.vue
+++ b/src/components/Table/ETable.vue
@@ -17,8 +17,8 @@
:row-key="rowKey"
style="width: 100%;"
>
- <el-table-column v-if="showSelection" type="selection" width="55" align="center" />
- <el-table-column v-if="showIndex" label="搴忓彿" width="60" align="center" fixed="left">
+ <el-table-column v-if="showSelection" type="selection" width="55" align="center" :show-overflow-tooltip="false" />
+ <el-table-column v-if="showIndex" label="搴忓彿" width="60" align="center" fixed="left" :show-overflow-tooltip="false">
<template #default="scope">
{{ getRowIndex(scope.$index) }}
</template>
diff --git a/src/views/basicInformation/index.vue b/src/views/basicInformation/index.vue
index 907d60d..26dc9b9 100644
--- a/src/views/basicInformation/index.vue
+++ b/src/views/basicInformation/index.vue
@@ -310,10 +310,12 @@
const getUserList = async () => {
try {
const res = await testUserList();
+ console.log("鑾峰彇鐢ㄦ埛鍒楄〃鏁版嵁:", res);
+ console.log("userMap:", userMap.value);
if (res && res.data) {
userList.value = res.data;
userList.value.forEach((user) => {
- userMap.value[user.userId] = user.username;
+ userMap.value[user.userId] = user.nickName;
});
}
} catch (error) {
diff --git a/src/views/basicInformation/mould/coal.vue b/src/views/basicInformation/mould/coal.vue
index 1063da0..5702bca 100644
--- a/src/views/basicInformation/mould/coal.vue
+++ b/src/views/basicInformation/mould/coal.vue
@@ -23,7 +23,7 @@
</el-form-item>
<el-form-item label="缁存姢浜哄鍚�" prop="maintainerId">
<el-input
- :value="userStore.name || ''"
+ :value="userStore.nickName || ''"
placeholder="缁存姢浜哄鍚�"
disabled
/>
@@ -79,26 +79,6 @@
required: true,
type: Object,
});
-// 鍦ㄧ粍浠舵寕杞芥椂鑾峰彇鐢ㄦ埛淇℃伅
-onMounted(async () => {
- // 濡傛灉store涓病鏈夌敤鎴蜂俊鎭紝鍒欒幏鍙栫敤鎴蜂俊鎭�
- if (!userStore.name) {
- try {
- await userStore.getInfo()
- // 鑷姩濉厖缁存姢浜篒D
- if (props.addOrEdit === 'add') {
- formData.value.maintainerId = userStore.id
- }
- } catch (error) {
- console.error('鑾峰彇鐢ㄦ埛淇℃伅澶辫触:', error)
- }
- } else {
- // 鑷姩濉厖缁存姢浜篒D
- if (props.addOrEdit === 'add') {
- formData.value.maintainerId = userStore.id
- }
- }
-})
const emit = defineEmits(['submit', 'handleBeforeClose', 'update:coalDialogFormVisible'])
// 琛ㄥ崟寮曠敤
@@ -127,7 +107,6 @@
if (!formRef.value) return
await formRef.value.validate(async (valid, fields) => {
if (valid) {
- delete formData.value.maintainerName // 鍒犻櫎鏄剧ず鐢ㄧ殑瀛楁锛屽彧淇濈暀ID
// 纭繚maintainerId鏈夊��
if (!formData.value.maintainerId) {
@@ -166,12 +145,8 @@
emit('update:coalDialogFormVisible', false)
}
const rules = reactive({
- supplierName: [
- {required: true, message: "璇疯緭鍏ヤ緵璐у晢鍚嶇О", trigger: "blur"},
- ],
- identifyNumber: [
- {required: true, message: "璇锋纭緭鍏ョ撼绋庝汉璇嗗埆鍙�", trigger: "blur"},
- {min: 17, max: 20, message: "璇疯緭鍏�17-20浣嶇撼绋庝汉璇嗗埆鍙�", trigger: "blur"},
+ coal: [
+ {required: true, message: "璇疯緭鍏ョ叅绉嶅悕绉�", trigger: "blur"},
],
});
diff --git a/src/views/procureMent/components/ProductionDialog.vue b/src/views/procureMent/components/ProductionDialog.vue
index 014bf2a..3fc0c99 100644
--- a/src/views/procureMent/components/ProductionDialog.vue
+++ b/src/views/procureMent/components/ProductionDialog.vue
@@ -50,10 +50,10 @@
</template>
</el-input>
</el-form-item>
- <el-form-item label="鍗曚环(涓嶅惈绋�)" prop="priceExcludingTax">
+ <el-form-item label="鍗曚环(鍚◣)" prop="priceIncludingTax">
<el-input
- v-model.number="form.priceExcludingTax"
- placeholder="璇疯緭鍏�"
+ v-model.number="form.priceIncludingTax"
+ placeholder="璇疯緭鍏ュ惈绋庡崟浠�"
@blur="handlePriceBlur"
:disabled="isViewMode"
>
@@ -62,9 +62,9 @@
</template>
</el-input>
</el-form-item>
- <el-form-item label="鍗曚环(鍚◣)" prop="priceIncludingTax">
+ <el-form-item label="鍗曚环(涓嶅惈绋�)" prop="priceExcludingTax">
<el-input
- v-model.number="form.priceIncludingTax"
+ v-model.number="form.priceExcludingTax"
placeholder="鑷姩璁$畻"
disabled
>
@@ -180,116 +180,95 @@
defineExpose({
getDropdownData,
});
+// 鏁板�兼牸寮忓寲宸ュ叿鍑芥暟
const toFixed = (num, precision = 2) => {
if (isNaN(num) || num === null || num === undefined || num === "") {
return 0;
}
- return (
- Math.floor(parseFloat(num) * Math.pow(10, precision)) /
- Math.pow(10, precision)
- );
+ return Number((Math.floor(parseFloat(num) * Math.pow(10, precision)) / Math.pow(10, precision)).toFixed(precision));
};
-// 鍚◣鍗曚环璁$畻
-const unitPriceWithTax = computed(() => {
- const priceExcludingTax = parseFloat(form.value.priceExcludingTax) || 0;
- const taxRate = parseFloat(form.value.taxRate) || 0;
- if (!priceExcludingTax || !taxRate) {
- return 0;
- }
- const result = priceExcludingTax * (1 + taxRate / 100);
- return toFixed(result, 2);
-});
-// 鍚◣鎬讳环璁$畻
-const totalUnitPriceWithTax = computed(() => {
- const priceExcludingTax = parseFloat(form.value.priceExcludingTax) || 0;
- const taxRate = parseFloat(form.value.taxRate) || 0;
- const purchaseQuantity = parseFloat(form.value.purchaseQuantity) || 0;
+// 瀹夊叏鑾峰彇鏁板��
+const safeNumber = (value) => {
+ const num = parseFloat(value);
+ return isNaN(num) ? 0 : num;
+};
- if (!priceExcludingTax || !taxRate || !purchaseQuantity) {
- return 0;
- }
+// 璁$畻閫昏緫 - 鍩轰簬鍚◣鍗曚环璁$畻涓嶅惈绋庝环鏍�
+const calculatePrices = () => {
+ const priceIncludingTax = safeNumber(form.value.priceIncludingTax); // 鍚◣鍗曚环
+ const taxRate = safeNumber(form.value.taxRate); // 绋庣巼
+ const quantity = safeNumber(form.value.purchaseQuantity); // 閲囪喘鏁伴噺
- const unitPriceWithTaxValue = priceExcludingTax * (1 + taxRate / 100);
- const result = unitPriceWithTaxValue * purchaseQuantity;
- return toFixed(result, 2);
-});
+ // 1. 鏍规嵁鍚◣鍗曚环鍜岀◣鐜囪绠椾笉鍚◣鍗曚环
+ // 涓嶅惈绋庡崟浠� = 鍚◣鍗曚环 / (1 + 绋庣巼/100)
+ const priceExcludingTax = priceIncludingTax && taxRate
+ ? toFixed(priceIncludingTax / (1 + taxRate / 100), 2)
+ : 0;
-// 涓嶅惈绋庢�讳环璁$畻
-const taxExclusiveTotalPrice = computed(() => {
- const purchaseQuantity = parseFloat(form.value.purchaseQuantity) || 0;
- const priceExcludingTax = parseFloat(form.value.priceExcludingTax) || 0;
+ // 2. 璁$畻涓嶅惈绋庢�讳环 = 涓嶅惈绋庡崟浠� 脳 鏁伴噺
+ const totalPriceExcludingTax = priceExcludingTax && quantity
+ ? toFixed(priceExcludingTax * quantity, 2)
+ : 0;
- if (!purchaseQuantity || !priceExcludingTax) {
- return 0;
- }
+ // 3. 璁$畻鍚◣鎬讳环 = 鍚◣鍗曚环 脳 鏁伴噺
+ const totalPriceIncludingTax = priceIncludingTax && quantity
+ ? toFixed(priceIncludingTax * quantity, 2)
+ : 0;
- const result = purchaseQuantity * priceExcludingTax;
- return toFixed(result, 2);
-});
+ // 鏇存柊琛ㄥ崟鏁版嵁
+ form.value.priceExcludingTax = priceExcludingTax;
+ form.value.totalPriceExcludingTax = totalPriceExcludingTax;
+ form.value.totalPriceIncludingTax = totalPriceIncludingTax;
+};
-// 鐩戝惉璁$畻鍊煎彉鍖栵紝鍚屾鍒� form 瀵硅薄涓�
-watch(unitPriceWithTax, (newValue) => {
- form.value.priceIncludingTax = newValue;
-});
-
-watch(totalUnitPriceWithTax, (newValue) => {
- form.value.totalPriceIncludingTax = newValue;
-});
-
-watch(taxExclusiveTotalPrice, (newValue) => {
- form.value.totalPriceExcludingTax = newValue;
-});
+// 鐩戝惉琛ㄥ崟瀵硅薄鍙樺寲锛岀敤浜庡鐞嗙紪杈戞ā寮忎笅鐨勬暟鎹姞杞藉拰瀹炴椂璁$畻
+watch(
+ () => [form.value.priceIncludingTax, form.value.taxRate, form.value.purchaseQuantity],
+ () => {
+ // 闃叉姈澶勭悊锛岄伩鍏嶉绻佽绠�
+ nextTick(() => {
+ calculatePrices();
+ });
+ },
+ { deep: true }
+);
const userStore = useUserStore();
const userInfo = ref({});
const match = () => {
return userInfo.value.nickName || "鏈煡鐢ㄦ埛";
};
-// 澶勭悊绋庣巼杈撳叆妗嗗け鐒︼紝纭繚绮惧害
+// 澶勭悊绋庣巼杈撳叆妗嗗け鐒︿簨浠�
const handleTaxRateBlur = () => {
- if (
- form.value.taxRate !== null &&
- form.value.taxRate !== undefined &&
- form.value.taxRate !== ""
- ) {
+ if (form.value.taxRate !== null && form.value.taxRate !== undefined && form.value.taxRate !== "") {
form.value.taxRate = toFixed(parseFloat(form.value.taxRate), 2);
+ // watch 浼氳嚜鍔ㄨЕ鍙� calculatePrices锛屼笉闇�瑕佹墜鍔ㄨ皟鐢�
}
};
-// 澶勭悊涓嶅惈绋庡崟浠疯緭鍏ユ澶辩劍锛岀‘淇濈簿搴�
+// 澶勭悊鍚◣鍗曚环杈撳叆妗嗗け鐒︿簨浠�
const handlePriceBlur = () => {
- if (
- form.value.priceExcludingTax !== null &&
- form.value.priceExcludingTax !== undefined &&
- form.value.priceExcludingTax !== ""
- ) {
- form.value.priceExcludingTax = toFixed(
- parseFloat(form.value.priceExcludingTax),
- 2
- );
+ if (form.value.priceIncludingTax !== null && form.value.priceIncludingTax !== undefined && form.value.priceIncludingTax !== "") {
+ form.value.priceIncludingTax = toFixed(parseFloat(form.value.priceIncludingTax), 2);
+ // watch 浼氳嚜鍔ㄨЕ鍙� calculatePrices锛屼笉闇�瑕佹墜鍔ㄨ皟鐢�
}
};
-// 澶勭悊閲囪喘鏁伴噺杈撳叆妗嗗け鐒︼紝纭繚绮惧害
+// 澶勭悊閲囪喘鏁伴噺杈撳叆妗嗗け鐒︿簨浠�
const handleQuantityBlur = () => {
- if (
- form.value.purchaseQuantity !== null &&
- form.value.purchaseQuantity !== undefined &&
- form.value.purchaseQuantity !== ""
- ) {
- form.value.purchaseQuantity = toFixed(
- parseFloat(form.value.purchaseQuantity),
- 3
- ); // 鏁伴噺淇濈暀3浣嶅皬鏁�
+ if (form.value.purchaseQuantity !== null && form.value.purchaseQuantity !== undefined && form.value.purchaseQuantity !== "") {
+ form.value.purchaseQuantity = toFixed(parseFloat(form.value.purchaseQuantity), 3); // 鏁伴噺淇濈暀3浣嶅皬鏁�
+ // watch 浼氳嚜鍔ㄨЕ鍙� calculatePrices锛屼笉闇�瑕佹墜鍔ㄨ皟鐢�
}
};
onMounted(async () => {
let res = await userStore.getInfo();
userInfo.value = res.user;
- getDropdownData()
-
+ await getDropdownData();
+ // 缁勪欢鍔犺浇瀹屾垚鍚庤Е鍙戜竴娆¤绠�
+ calculatePrices();
});
const rules = {
supplierName: [
diff --git a/src/views/procureMent/index.vue b/src/views/procureMent/index.vue
index 763ef87..3881e50 100644
--- a/src/views/procureMent/index.vue
+++ b/src/views/procureMent/index.vue
@@ -201,7 +201,7 @@
form.value = {
supplierName: "",
coal: "",
- unit: "t",
+ unit: "鍚�",
purchaseQuantity: "",
priceExcludingTax: "",
totalPriceExcludingTax: "",
diff --git a/src/views/production/components/ProductionDialog.vue b/src/views/production/components/ProductionDialog.vue
index 955a1aa..c14ca96 100644
--- a/src/views/production/components/ProductionDialog.vue
+++ b/src/views/production/components/ProductionDialog.vue
@@ -165,6 +165,7 @@
getCoalInfoList,
deleteProductionInventory,
} from "@/api/production/index.js";
+import { getSupplyList } from "@/api/procureMent/index.js"
import {validateFormData, validateNumber, deepClone, createDefaultProductionRow} from "@/utils/production";
import {useCoalData} from "./useCoalData";
import useUserStore from "@/store/modules/user";
@@ -218,15 +219,13 @@
];
const formalDatabaseColumns = ref([
- {prop: "supplierName", label: "渚涘簲鍟嗗悕绉�", minwidth: 150
- // ,formatter: (row) => {
- // console.log(row);
- // return supplierList.value[row.supplierId] || "--";
- // }
+ {prop: "supplierId", label: "渚涘簲鍟嗗悕绉�", minwidth: 150
+ ,formatter: (row) => {
+ return supplierList.value.find(supplier => supplier.id === row.supplierId)?.supplierName || "--";
+ }
},
{prop: "coalId", label: "鐓ょ", minwidth: 60,
formatter: (row) => {
- // return coalList.value[row.coalId].coal || "--";
return coalList.value.find(coal => coal.id === row.coalId)?.coal || "--";
}
},
@@ -251,12 +250,13 @@
// 鑾峰彇閰嶇疆鏁版嵁
const handlData = async () => {
innerVisible.value = true;
- let getSupplier = await getOfficialAll();
+ let OfficialAll = await getOfficialAll();
+ let getSupplierList = await getSupplyList();
let getCoalName = await getCoalInfoList();
coalList.value = getCoalName.data || [];
- supplierList.value = getSupplier.data || [];
- if (getSupplier.code === 200) {
- formalDatabaseData.value = getSupplier.data;
+ supplierList.value = getSupplierList.data || [];
+ if (OfficialAll.code === 200) {
+ formalDatabaseData.value = OfficialAll.data;
const existingOfficialIds = tableData.value
.map((item) => item.officialId)
.filter((id) => id);
diff --git a/src/views/production/index.vue b/src/views/production/index.vue
index 0b74dc9..fa77e22 100644
--- a/src/views/production/index.vue
+++ b/src/views/production/index.vue
@@ -1,5 +1,5 @@
<template>
- <div>
+ <div class="app-container">
<!-- 鎼滅储琛ㄥ崟 -->
<el-form :inline="true" :model="queryParams" class="search-form">
<el-form-item label="鎼滅储">
--
Gitblit v1.9.3