From 07f9f8657d057a38792c3822acc9b08d83478967 Mon Sep 17 00:00:00 2001
From: gaoluyang <2820782392@qq.com>
Date: 星期四, 07 五月 2026 14:23:10 +0800
Subject: [PATCH] 合并代码

---
 src/views/inventoryManagement/receiptManagement/index.vue |   59 +++++++++++++++++++++++++++++++++++++++--------------------
 1 files changed, 39 insertions(+), 20 deletions(-)

diff --git a/src/views/inventoryManagement/receiptManagement/index.vue b/src/views/inventoryManagement/receiptManagement/index.vue
index 8ca110f..17a0823 100644
--- a/src/views/inventoryManagement/receiptManagement/index.vue
+++ b/src/views/inventoryManagement/receiptManagement/index.vue
@@ -1,36 +1,55 @@
 <template>
   <div class="app-container">
-    <el-tabs v-model="activeTab" @tab-change="handleTabChange">
+    <div v-loading="loading" element-loading-text="鍔犺浇涓�..." style="min-height: 80vh;">
+    <el-tabs v-model="activeTab" @tab-change="handleTabChange" v-if="!loading">
       <el-tab-pane v-for="tab in tabs"
-                   :label="tab.label"
-                   :name="tab.name"
-                   :key="tab.name">
-        <record :type="tab.type" v-if="activeTab === tab.name" />
+                   :label="tab.productName"
+                   :name="tab.id"
+                   :key="tab.id">
+        <Record v-bind="{ type: tab.type, topParentProductId: activeTab }" v-if="tab.id === activeTab" />
       </el-tab-pane>
     </el-tabs>
+    </div>
   </div>
 </template>
 
 <script setup>
+import { ref, onMounted } from 'vue';
+import { productTreeList } from "@/api/basicData/product.js";
 import Record from "@/views/inventoryManagement/receiptManagement/Record.vue";
 
-const activeTab = ref('qualified')
-const type = ref(0)
-const tabs = ref([
-  {
-    label: '鍚堟牸鍏ュ簱',
-    name: 'qualified',
-    type: '0'
-  },
-  {
-    label: '涓嶅悎鏍煎叆搴�',
-    name: 'unqualified',
-    type: '1'
-  }
-])
+const activeTab = ref(null)
+const tabs = ref([])
+const loading = ref(false)
+
+const resolveTypeByName = (name) => {
+  return String(name || "").includes("涓嶅悎鏍�") ? "1" : "0";
+};
 
 const handleTabChange = (tabName) => {
   activeTab.value = tabName;
-  type.value = tabName === 'qualified' ? 0 : 1
 }
+
+const fetchProducts = async () => {
+  loading.value = true;
+  try {
+    const res = await productTreeList();
+    tabs.value = res
+      .filter((item) => item.parentId === null)
+      .map(({ id, productName }) => ({
+        id,
+        productName,
+        type: resolveTypeByName(productName),
+      }));
+    if (tabs.value.length > 0) {
+      activeTab.value = tabs.value[0].id;
+    }
+  } finally {
+    loading.value = false;
+  }
+}
+
+onMounted(() => {
+  fetchProducts();
+})
 </script>

--
Gitblit v1.9.3