From e6d720a5ce9a278dc0855183eef292e11fb45651 Mon Sep 17 00:00:00 2001
From: gaoluyang <2820782392@qq.com>
Date: 星期二, 10 六月 2025 15:26:58 +0800
Subject: [PATCH] 1.库存管理页面联调

---
 src/views/warehouseManagement/index.vue |   66 +++++++++++++++++++++++----------
 1 files changed, 46 insertions(+), 20 deletions(-)

diff --git a/src/views/warehouseManagement/index.vue b/src/views/warehouseManagement/index.vue
index cac372d..734e33c 100644
--- a/src/views/warehouseManagement/index.vue
+++ b/src/views/warehouseManagement/index.vue
@@ -56,8 +56,8 @@
           <el-table-column label="鐓よ川" align="center" v-if="activeTab=== 'officialInventory'" width="600">
             <el-table-column v-for="col in columnTitle" :key="col.prop" :prop="col.prop" :label="col.label" align="center" sortable min-width="200"/>
           </el-table-column>
-          <el-table-column prop="registrant" label="鐧昏浜�" width="180"/>
-          <el-table-column prop="registrationTime" label="鐧昏鏃ユ湡" width="180"/>
+          <el-table-column prop="registrantId" label="鐧昏浜�" width="180"/>
+          <el-table-column prop="registrationDate" label="鐧昏鏃ユ湡" width="180"/>
           <el-table-column fixed="right" label="鎿嶄綔" min-width="60" align="center" v-if="activeTab !== 'officialInventory'">
             <template #default="scope">
               <el-button link type="primary" size="small" @click="reviewDia(scope.row)">瀹℃牳</el-button>
@@ -97,7 +97,7 @@
           </el-col>
           <el-col :span="12">
             <el-form-item label="搴撳瓨鏁伴噺" prop="inventoryQuantity">
-              <el-input v-model="form.inventoryQuantity" placeholder="璇疯緭鍏ュ簱瀛樻暟閲�" maxlength="30" />
+              <el-input v-model="form.inventoryQuantity" placeholder="璇疯緭鍏ュ簱瀛樻暟閲�" :max="inventoryQuantity" type="number"/>
             </el-form-item>
           </el-col>
         </el-row>
@@ -121,7 +121,7 @@
           </el-col>
           <el-col :span="12">
             <el-form-item label="鐓よ川鏂规" prop="qualityPlan">
-              <el-select v-model="form.qualityPlan" placeholder="璇烽�夋嫨" @change="coalFieldListOption" clearable>
+              <el-select v-model="form.qualityPlan" placeholder="璇烽�夋嫨" @change="coalPlanByIdList" clearable>
                 <el-option
                     v-for="dict in qualityPlanOption"
                     :key="dict.id"
@@ -204,7 +204,7 @@
 import Pagination from "@/components/Pagination/index.vue";
 import {
   addOrEditCoalValue,
-  coalFieldList,
+  coalFieldList, coalPlanById,
   coalPlanList, officialInventoryList,
   pendingInventoryList
 } from "@/api/warehouseManagement/index.js";
@@ -220,6 +220,7 @@
 const total = ref(0);
 const pageNum = ref(1);
 const pageSize = ref(10);
+const inventoryQuantity = ref(0);
 // 瀹℃牳寮规
 const reviewVisible = ref(false);
 // 鍚堝苟寮规
@@ -234,7 +235,7 @@
     totalPriceIncludingTax: '',
     costPerUnit: '',
     qualityPlan: '',
-    planId: '',
+    pId: '',
   },
   rules: {
     supplierName: [{ required: true, message: "璇疯緭鍏ヤ緵搴斿晢鍚嶇О", trigger: "blur" }],
@@ -260,7 +261,7 @@
 })
 const columnTitle = ref([])
 onMounted(() => {
-  handleTabClick({ props: { name: "supplier" } });
+  handleTabClick({ props: { name: "pendingInbound" } });
 });
 // 鏍囩椤电偣鍑�
 const handleTabClick = (tab) => {
@@ -277,24 +278,37 @@
 const getList = () => {
   tableLoading.value = true;
   // 璧嬪�肩叅璐ㄨ〃澶村睍绀哄瓧娈�
-  columnTitle.value = [
-    {prop: 'value1', label: '鐧惧垎姣�1'},
-    {prop: 'value2', label: '鐧惧垎姣�2'},
-    {prop: 'value3', label: '鐧惧垎姣�3'},
-  ]
   if (tabName.value === "pendingInbound") {
-    pendingInventoryList({ ...queryParams }).then(res => {
+    pendingInventoryList({ ...queryParams, current: pageNum.value, size: pageSize.value }).then(res => {
       tableLoading.value = false;
       tableData.value = res.data.records;
       total.value = res.data.total;
     })
   } else {
-    officialInventoryList({ ...queryParams }).then(res => {
+    officialInventoryList({ ...queryParams, current: pageNum.value, size: pageSize.value }).then(res => {
       tableLoading.value = false;
-      tableData.value = res.data.records;
+      const result = flattenFields(res.data.records);
+      tableData.value = result;
       total.value = res.data.total;
+      coalFieldListOption()
     })
   }
+};
+// 鎵佸钩鍖栧鐞嗗嚱鏁�
+const flattenFields = (data) => {
+  return data.map(item => {
+    const mergedFields = item.fields.reduce((acc, obj) => {
+      const key = Object.keys(obj)[0];
+      acc[key] = obj[key];
+      return acc;
+    }, {});
+    
+    // 鍚堝苟涓诲璞′笌鎻愬彇鍑虹殑 fields 瀛楁
+    return {
+      ...item,
+      ...mergedFields
+    };
+  });
 };
 // 閲嶇疆鏌ヨ
 const resetQuery = () => {
@@ -313,7 +327,8 @@
 const reviewDia = (row) => {
   reviewVisible.value = true
   form.value = {...row}
-  form.value.planId = form.value.id
+  form.value.pId = row.id
+  inventoryQuantity.value = row.inventoryQuantity
   coalPlanListOptions()
 }
 // 鏌ヨ鐓よ川鏂规涓嬫媺妗�
@@ -323,12 +338,24 @@
   })
 }
 // 鏌ヨ鐓よ川鏂规瀛楁
-const coalFieldListOption = (id) => {
-  coalFieldList({id: id}).then(res => {
+const coalPlanByIdList = (id) => {
+  coalPlanById({id: id}).then(res => {
     filteredList.value = res.data
-    if (!id) {
+    if(!id) {
       filteredList.value = []
     }
+  })
+}
+// 鏌ヨ鐓よ川瀛楁
+const coalFieldListOption = () => {
+  coalFieldList().then(res => {
+    filteredList.value = res.data
+    columnTitle.value = res.data.map(item => {
+      return {
+        prop: item.fields,
+        label: item.fieldName // 浣跨敤 fieldName 浣滀负 label
+      };
+    });
   })
 }
 // 鍚堝苟搴撳瓨鏁版嵁鏂规硶
@@ -354,7 +381,6 @@
       delete form.value.registrationTime
       delete form.value.createTime
       delete form.value.updateTime
-      delete form.value.id
       form.value.fieldValue = filteredList.value.map(item => ({
         [item.fields]: form.value[item.fields]
       }))

--
Gitblit v1.9.3