From 83ffea5d8c89dcd46c31a5e905c565f5eb46c2a6 Mon Sep 17 00:00:00 2001
From: yyb <995253665@qq.com>
Date: 星期三, 22 四月 2026 11:40:23 +0800
Subject: [PATCH] 添加入库审批功能,包含入库详情和产品列表的查询逻辑
---
src/views/collaborativeApproval/approvalProcess/components/approvalDia.vue | 162 +++++++++++++++++++++++++++++++++++++++++++++++++++++
1 files changed, 161 insertions(+), 1 deletions(-)
diff --git a/src/views/collaborativeApproval/approvalProcess/components/approvalDia.vue b/src/views/collaborativeApproval/approvalProcess/components/approvalDia.vue
index 173a375..7ce5b4d 100644
--- a/src/views/collaborativeApproval/approvalProcess/components/approvalDia.vue
+++ b/src/views/collaborativeApproval/approvalProcess/components/approvalDia.vue
@@ -33,7 +33,7 @@
</el-form-item>
</el-col>
</el-row>
- <el-row v-if="!isQuotationApproval && !isPurchaseApproval">
+ <el-row v-if="!isQuotationApproval && !isPurchaseApproval && !isInboundApproval">
<el-col :span="24">
<el-form-item :label="props.approveType == 5 ? '閲囪喘鍚堝悓鍙凤細' : '瀹℃壒浜嬬敱锛�'"
prop="approveReason">
@@ -198,6 +198,39 @@
</template>
</el-skeleton>
</div>
+ <!-- 鍏ュ簱瀹℃壒锛氬睍绀哄叆搴撹鎯� -->
+ <div v-if="isInboundApproval"
+ style="margin: 10px 0 18px;">
+ <el-divider content-position="left">鍏ュ簱璇︽儏</el-divider>
+ <el-skeleton :loading="stockInLoading"
+ animated>
+ <template #template>
+ <el-skeleton-item variant="h3"
+ style="width: 30%" />
+ <el-skeleton-item variant="text"
+ style="width: 100%" />
+ <el-skeleton-item variant="text"
+ style="width: 100%" />
+ </template>
+ <template #default>
+ <el-empty v-if="!currentStockInOrder || !Object.keys(currentStockInOrder).length"
+ description="鏈煡璇㈠埌瀵瑰簲鍏ュ簱璇︽儏" />
+ <template v-else>
+ <el-descriptions :column="2"
+ border>
+ <el-descriptions-item label="閿�鍞悎鍚屽彿">{{ currentStockInOrder.salesContractNo || "-" }}</el-descriptions-item>
+ <el-descriptions-item label="瀹㈡埛鍚嶇О">{{ currentStockInOrder.customerName || "-" }}</el-descriptions-item>
+ <el-descriptions-item label="椤圭洰鍚嶇О">{{ currentStockInOrder.projectName || "-" }}</el-descriptions-item>
+ <el-descriptions-item label="浜у搧鍚嶇О">{{ inboundProductSummary.productName }}</el-descriptions-item>
+ <el-descriptions-item label="瑙勬牸鍨嬪彿">{{ inboundProductSummary.specification }}</el-descriptions-item>
+ <el-descriptions-item label="鍗曚綅">{{ inboundProductSummary.unit }}</el-descriptions-item>
+ <el-descriptions-item label="鏁伴噺">{{ inboundProductSummary.quantity }}</el-descriptions-item>
+ <el-descriptions-item label="涓氬姟鍛�">{{ currentStockInOrder.salesman || "-" }}</el-descriptions-item>
+ </el-descriptions>
+ </template>
+ </template>
+ </el-skeleton>
+ </div>
<el-form :model="{ activities }"
ref="formRef"
label-position="top">
@@ -288,6 +321,8 @@
} from "vue";
import {
approveProcessDetails,
+ getStockInOrderInfo,
+ getStockInProductList,
getDept,
updateApproveNode,
} from "@/api/collaborativeApproval/approvalProcess.js";
@@ -322,8 +357,97 @@
const currentQuotation = ref({});
const purchaseLoading = ref(false);
const currentPurchase = ref({});
+ const stockInLoading = ref(false);
+ const currentStockInOrder = ref({});
+ const stockInProductList = ref([]);
const isQuotationApproval = computed(() => Number(props.approveType) === 6);
const isPurchaseApproval = computed(() => Number(props.approveType) === 5);
+ const isInboundApproval = computed(() => Number(props.approveType) === 9);
+ const inboundProductSummary = computed(() => {
+ if (!stockInProductList.value.length) {
+ return {
+ productName: "-",
+ specification: "-",
+ unit: "-",
+ quantity: "-",
+ };
+ }
+ const pickUniqueJoin = key => {
+ const values = stockInProductList.value
+ .map(item => item[key])
+ .filter(v => v !== undefined && v !== null && v !== "" && v !== "-");
+ const uniqueValues = [...new Set(values)];
+ return uniqueValues.length ? uniqueValues.join("銆�") : "-";
+ };
+ let hasNumericQuantity = false;
+ const quantityTotal = stockInProductList.value.reduce((sum, item) => {
+ const raw = item.quantityDisplay;
+ const num = Number(raw);
+ if (Number.isFinite(num)) {
+ hasNumericQuantity = true;
+ return sum + num;
+ }
+ return sum;
+ }, 0);
+ return {
+ productName: pickUniqueJoin("productNameDisplay"),
+ specification: pickUniqueJoin("specificationDisplay"),
+ unit: pickUniqueJoin("unitDisplay"),
+ quantity: hasNumericQuantity ? String(quantityTotal) : "-",
+ };
+ });
+
+ const getFirstValidValue = (item, keys) => {
+ for (const key of keys) {
+ const value = item?.[key];
+ if (value !== undefined && value !== null && value !== "") {
+ return value;
+ }
+ }
+ return "-";
+ };
+
+ const formatStockInProductItem = item => {
+ const unitPrice = getFirstValidValue(item, [
+ "unitPrice",
+ "taxInclusiveUnitPrice",
+ "price",
+ "purchasePrice",
+ "inPrice",
+ ]);
+ const amount = getFirstValidValue(item, [
+ "amount",
+ "totalPrice",
+ "taxInclusiveTotalPrice",
+ "totalAmount",
+ "subtotal",
+ ]);
+ return {
+ ...item,
+ productNameDisplay: getFirstValidValue(item, [
+ "productName",
+ "productCategory",
+ "materialName",
+ "name",
+ ]),
+ specificationDisplay: getFirstValidValue(item, [
+ "specificationModel",
+ "specification",
+ "model",
+ ]),
+ unitDisplay: getFirstValidValue(item, ["unit"]),
+ quantityDisplay: getFirstValidValue(item, [
+ "quantity",
+ "stockedQuantity",
+ "inboundQuantity",
+ "stockInQuantity",
+ "num",
+ ]),
+ priceDisplay:
+ unitPrice === "-" ? "-" : `楼${Number(unitPrice || 0).toFixed(2)}`,
+ amountDisplay: amount === "-" ? "-" : `楼${Number(amount || 0).toFixed(2)}`,
+ };
+ };
const data = reactive({
form: {
@@ -364,6 +488,8 @@
dialogFormVisible.value = true;
currentQuotation.value = {};
currentPurchase.value = {};
+ currentStockInOrder.value = {};
+ stockInProductList.value = [];
approveUserList({ approveType: props.approveType }).then(res => {
userList.value = res.data;
});
@@ -430,6 +556,37 @@
}
}
+ // 鍏ュ簱瀹℃壒锛氶�氳繃娴佺▼缂栧彿鏌ヨ鍏ュ簱璇︽儏涓庢槑缁�
+ if (isInboundApproval.value) {
+ const approveId = row?.approveId;
+ if (approveId) {
+ stockInLoading.value = true;
+ Promise.all([
+ getStockInOrderInfo({ approveId }),
+ getStockInProductList({ approveId }),
+ ])
+ .then(([orderRes, productRes]) => {
+ currentStockInOrder.value = orderRes?.data?.orderInfo || {};
+ const list = productRes?.data;
+ const rawList = Array.isArray(list)
+ ? list
+ : Array.isArray(list?.records)
+ ? list.records
+ : [];
+ stockInProductList.value = rawList.map(item =>
+ formatStockInProductItem(item)
+ );
+ })
+ .catch(err => {
+ console.error("鏌ヨ鍏ュ簱璇︽儏澶辫触:", err);
+ proxy.$modal.msgError("鏌ヨ鍏ュ簱璇︽儏澶辫触");
+ })
+ .finally(() => {
+ stockInLoading.value = false;
+ });
+ }
+ }
+
approveProcessDetails(row.approveId).then(res => {
activities.value = res.data;
// 澧炲姞isApproval瀛楁
@@ -485,6 +642,9 @@
currentQuotation.value = {};
purchaseLoading.value = false;
currentPurchase.value = {};
+ stockInLoading.value = false;
+ currentStockInOrder.value = {};
+ stockInProductList.value = [];
emit("close");
};
defineExpose({
--
Gitblit v1.9.3