From ba65f3383951a27ee44163aea36d48f5c22b8fff Mon Sep 17 00:00:00 2001
From: 张诺 <zhang_12370@163.com>
Date: 星期五, 24 四月 2026 15:37:43 +0800
Subject: [PATCH] feat(PIMTable): 支持列动态显示控制

---
 src/components/PIMTable/PIMTable.vue                    |   21 +++++++++++++++++++--
 src/views/qualityManagement/metricMaintenance/index.vue |    3 ++-
 2 files changed, 21 insertions(+), 3 deletions(-)

diff --git a/src/components/PIMTable/PIMTable.vue b/src/components/PIMTable/PIMTable.vue
index b79cd91..bfb3c4e 100644
--- a/src/components/PIMTable/PIMTable.vue
+++ b/src/components/PIMTable/PIMTable.vue
@@ -30,7 +30,7 @@
     <el-table-column align="center" label="搴忓彿" type="index" width="60" />
 
     <el-table-column
-      v-for="(item, index) in column"
+      v-for="(item, index) in visibleColumns"
       :key="index"
       :column-key="item.columnKey"
       :filter-method="item.filterHandler"
@@ -226,7 +226,7 @@
 
 <script setup>
 import pagination from "./Pagination.vue";
-import { ref, inject, getCurrentInstance } from "vue";
+import { ref, inject, getCurrentInstance, computed, unref } from "vue";
 import { ElMessage } from "element-plus";
 
 // 鑾峰彇鍏ㄥ眬鐨� uploadHeader
@@ -334,6 +334,23 @@
   },
 });
 
+const resolveColumnVisible = (visible) => {
+  if (visible === undefined) return true;
+  if (typeof visible === "function") {
+    try {
+      return !!visible();
+    } catch (error) {
+      console.warn("PIMTable column visible function error:", error);
+      return true;
+    }
+  }
+  return !!unref(visible);
+};
+
+const visibleColumns = computed(() => {
+  return (props.column || []).filter((item) => resolveColumnVisible(item?.visible));
+});
+
 // Data
 const uploadRefs = ref([]);
 const currentFiles = ref({});
diff --git a/src/views/qualityManagement/metricMaintenance/index.vue b/src/views/qualityManagement/metricMaintenance/index.vue
index 6ea4afd..89cc08f 100644
--- a/src/views/qualityManagement/metricMaintenance/index.vue
+++ b/src/views/qualityManagement/metricMaintenance/index.vue
@@ -303,6 +303,7 @@
     prop: 'inspectType',
     align: 'center',
     dataType: 'tag',
+    minWidth: 120,
     formatData: (val) => {
       const map = {
         0: '鍘熸潗鏂欐楠�',
@@ -317,6 +318,7 @@
     prop: 'processId',
     align: 'center',
     dataType: 'tag',
+    visible: visible => activeTab.value === '1',
     formatData: (val) => {
       const target = processOptions.value.find(
         (item) => String(item.value) === String(val)
@@ -392,7 +394,6 @@
     ]
   }
 ])
-
 const handleTabChange = () => {
   searchForm.value.standardNo = ''
   searchForm.value.standardName = ''

--
Gitblit v1.9.3