From 5b3cbcef771cd23ef8db1bf29dd15e2ddd98744f Mon Sep 17 00:00:00 2001
From: gongchunyi <deslre0381@gmail.com>
Date: 星期五, 24 四月 2026 14:58:53 +0800
Subject: [PATCH] fix: 库存管理页面修改,领用、冻结与解冻区分

---
 src/views/inventoryManagement/stockManagement/Qualified.vue |   70 +++++++++++++++++++++++++++--------
 1 files changed, 54 insertions(+), 16 deletions(-)

diff --git a/src/views/inventoryManagement/stockManagement/Qualified.vue b/src/views/inventoryManagement/stockManagement/Qualified.vue
index e832d06..34ce8a8 100644
--- a/src/views/inventoryManagement/stockManagement/Qualified.vue
+++ b/src/views/inventoryManagement/stockManagement/Qualified.vue
@@ -10,7 +10,7 @@
           clearable
           filterable
           check-strictly
-          :data="productOptions"
+          :data="displayProductOptions"
           :render-after-expand="false"
           @change="handleParentChange"
         />
@@ -46,27 +46,28 @@
         <el-table-column align="center" label="搴忓彿" type="index" width="60" />
         <el-table-column label="浜у搧澶х被" prop="productName" show-overflow-tooltip />
         <el-table-column label="瑙勬牸鍨嬪彿" prop="model" show-overflow-tooltip />
+        <el-table-column label="鍘氬害(mm)" prop="thickness" show-overflow-tooltip />
         <el-table-column label="鍗曚綅" prop="unit" show-overflow-tooltip />
         <el-table-column label="鍚堟牸搴撳瓨鏁伴噺" prop="qualifiedQuantity" show-overflow-tooltip>
-          <template #default="scope">{{ scope.row.qualifiedQuantity ?? scope.row.qualitity ?? scope.row.unLockedQuantity ?? 0 }}</template>
+          <template #default="scope">{{ getQualifiedStock(scope.row) }}</template>
         </el-table-column>
         <el-table-column label="涓嶅悎鏍煎簱瀛樻暟閲�" prop="unqualifiedQuantity" show-overflow-tooltip>
-          <template #default="scope">{{ scope.row.unqualifiedQuantity ?? 0 }}</template>
+          <template #default="scope">{{ getUnqualifiedStock(scope.row) }}</template>
         </el-table-column>
         <el-table-column label="鍚堟牸鍐荤粨鏁伴噺" prop="qualifiedLockedQuantity" show-overflow-tooltip>
-          <template #default="scope">{{ scope.row.qualifiedLockedQuantity ?? scope.row.lockedQuantity ?? 0 }}</template>
+          <template #default="scope">{{ getQualifiedLockedStock(scope.row) }}</template>
         </el-table-column>
         <el-table-column label="涓嶅悎鏍煎喕缁撴暟閲�" prop="unqualifiedLockedQuantity" show-overflow-tooltip>
-          <template #default="scope">{{ scope.row.unqualifiedLockedQuantity ?? 0 }}</template>
+          <template #default="scope">{{ getUnqualifiedLockedStock(scope.row) }}</template>
         </el-table-column>
         <el-table-column label="搴撳瓨棰勮鏁伴噺" prop="warnNum" show-overflow-tooltip />
         <el-table-column label="澶囨敞" prop="remark"  show-overflow-tooltip />
         <el-table-column label="鏈�杩戞洿鏂版椂闂�" prop="updateTime" show-overflow-tooltip />
         <el-table-column fixed="right" label="鎿嶄綔" min-width="90" align="center">
           <template #default="scope">
-            <el-button link type="primary" @click="showSubtractModal(scope.row)" :disabled="scope.row.unLockedQuantity === 0">棰嗙敤</el-button>
-            <el-button link type="primary" v-if="scope.row.unLockedQuantity > 0" @click="showFrozenModal(scope.row)">鍐荤粨</el-button>
-            <el-button link type="primary" v-if="scope.row.lockedQuantity > 0" @click="showThawModal(scope.row)">瑙e喕</el-button>
+            <el-button link type="primary" @click="showSubtractModal(scope.row)" :disabled="getQualifiedUnLockedStock(scope.row) <= 0">棰嗙敤</el-button>
+            <el-button link type="primary" v-if="getQualifiedUnLockedStock(scope.row) > 0 || getUnqualifiedUnLockedStock(scope.row) > 0" @click="showFrozenModal(scope.row)">鍐荤粨</el-button>
+            <el-button link type="primary" v-if="getQualifiedLockedStock(scope.row) > 0 || getUnqualifiedLockedStock(scope.row) > 0" @click="showThawModal(scope.row)">瑙e喕</el-button>
           </template>
         </el-table-column>
       </el-table>
@@ -101,7 +102,7 @@
 
 <script setup>
 import pagination from '@/components/PIMTable/Pagination.vue'
-import { ref, reactive, toRefs, onMounted, getCurrentInstance, watch } from 'vue'
+import { ref, reactive, toRefs, onMounted, getCurrentInstance, watch, computed } from 'vue'
 import {ElMessage, ElMessageBox} from "element-plus";
 import { getStockInventoryListPage } from "@/api/inventoryManagement/stockInventory.js";
 import { modelList, productTreeList } from "@/api/basicData/product.js";
@@ -147,6 +148,12 @@
 })
 const { searchForm } = toRefs(data)
 
+const displayProductOptions = computed(() => {
+  if (!props.parentId) return productOptions.value
+  const currentParentNode = findNodeById(productOptions.value, props.parentId)
+  return Array.isArray(currentParentNode?.children) ? currentParentNode.children : []
+})
+
 // 鏌ヨ鍒楄〃
 /** 鎼滅储鎸夐挳鎿嶄綔 */
 const handleQuery = () => {
@@ -160,11 +167,12 @@
 }
 const getList = () => {
   tableLoading.value = true
-  const queryParentId = searchForm.value.parentId || props.parentId
+  const queryParentId = props.parentId || searchForm.value.parentId
   getStockInventoryListPage({
-    ...searchForm.value,
     ...page,
-    parentId: queryParentId,
+    topParentProductId: queryParentId,
+    productName: searchForm.value.productName,
+    model: searchForm.value.model,
   }).then(res => {
     tableLoading.value = false
     tableData.value = res.data.records
@@ -270,9 +278,38 @@
 }
 const expandedRowKeys = ref([])
 
+const toNumber = (value) => {
+  const num = Number(value)
+  return Number.isFinite(num) ? num : 0
+}
+
+const getQualifiedStock = (row) => {
+  return toNumber(row?.qualifiedQuantity ?? row?.qualitity ?? row?.unLockedQuantity)
+}
+
+const getUnqualifiedStock = (row) => {
+  return toNumber(row?.unQualifiedQuantity ?? row?.unqualifiedQuantity ?? row?.unQualifiedUnLockedQuantity ?? row?.unqualifiedUnLockedQuantity)
+}
+
+const getQualifiedLockedStock = (row) => {
+  return toNumber(row?.qualifiedLockedQuantity ?? row?.lockedQuantity)
+}
+
+const getUnqualifiedLockedStock = (row) => {
+  return toNumber(row?.unQualifiedLockedQuantity ?? row?.unqualifiedLockedQuantity)
+}
+
+const getQualifiedUnLockedStock = (row) => {
+  return toNumber(row?.qualifiedUnLockedQuantity ?? row?.unLockedQuantity ?? row?.qualifiedQuantity ?? row?.qualitity)
+}
+
+const getUnqualifiedUnLockedStock = (row) => {
+  return toNumber(row?.unQualifiedUnLockedQuantity ?? row?.unqualifiedUnLockedQuantity ?? row?.unQualifiedQuantity ?? row?.unqualifiedQuantity)
+}
+
 // 琛ㄦ牸琛岀被鍚�
 const tableRowClassName = ({ row }) => {
-  const stock = Number(row?.unLockedQuantity ?? 0);
+  const stock = getQualifiedUnLockedStock(row);
   const warn = Number(row?.warnNum ?? 0);
   if (!Number.isFinite(stock) || !Number.isFinite(warn)) {
     return '';
@@ -290,7 +327,7 @@
     type: 'warning',
   }
   ).then(() => {
-    proxy.download("/stockInventory/exportStockInventory", {}, '鍚堟牸搴撳瓨淇℃伅.xlsx')
+    proxy.download("/stockInventory/exportStockInventory", {}, '搴撳瓨淇℃伅.xlsx')
   }).catch(() => {
     proxy.$modal.msg("宸插彇娑�")
   })
@@ -304,10 +341,11 @@
 watch(
   () => props.parentId,
   async () => {
-    searchForm.value.parentId = props.parentId
+    searchForm.value.parentId = undefined
+    searchForm.value.productName = ''
     searchForm.value.productModelId = undefined
     searchForm.value.model = ''
-    await loadModelOptions(props.parentId)
+    await loadModelOptions(undefined)
     handleQuery()
   },
   { immediate: true }

--
Gitblit v1.9.3