From fb506282831be6014188852c64b907dfd8ad3f6b Mon Sep 17 00:00:00 2001
From: gongchunyi <deslre0381@gmail.com>
Date: 星期五, 07 八月 2026 17:22:08 +0800
Subject: [PATCH] feat: 生产订单新增销售单号搜索

---
 src/components/PIMTable/PIMTable.vue |   24 ++++++++++++++++++------
 1 files changed, 18 insertions(+), 6 deletions(-)

diff --git a/src/components/PIMTable/PIMTable.vue b/src/components/PIMTable/PIMTable.vue
index 631d956..d9cfdda 100644
--- a/src/components/PIMTable/PIMTable.vue
+++ b/src/components/PIMTable/PIMTable.vue
@@ -118,7 +118,7 @@
           <template v-for="(o, key) in item.operation"
                     :key="key">
             <el-button v-show="o.type != 'upload'"
-                       v-if="o.showHide ? o.showHide(scope.row) : true"
+                       v-if="isOperationVisible(o, scope.row)"
                        :disabled="isOperationDisabled(o, scope.row)"
                        :loading="isOperationLoading(o, scope.row)"
                        :plain="o.plain"
@@ -149,7 +149,7 @@
               "
                        v-if="o.type == 'upload'"
                        style="display: inline-block; width: 50px"
-                       v-show="o.showHide ? o.showHide(scope.row) : true"
+                       v-show="isOperationVisible(o, scope.row)"
                        :headers="uploadHeader"
                        :before-upload="(file) => beforeUpload(file, scope.$index)"
                        :on-change="
@@ -224,7 +224,9 @@
   };
 
   const formatters = (val, format) => {
-    return typeof format === "function" ? format(val) : val;
+    if (typeof format === "function") return format(val);
+    if (format && typeof format === "object") return format[val] ?? val;
+    return val;
   };
 
   // Props锛堜娇鐢� defineProps 鐨勯潪 TS 褰㈠紡锛�
@@ -331,6 +333,7 @@
   const uploadRefs = ref([]);
   const currentFiles = ref({});
   const uploadKeys = ref({});
+  const parentMethods = inject("parentMethods", {});
 
   const indexMethod = index => {
     return (props.page.current - 1) * props.page.size + index + 1;
@@ -340,6 +343,10 @@
   const goLink = (row, linkMethod) => {
     if (!linkMethod) {
       return ElMessage.warning("璇烽厤缃� link 浜嬩欢");
+    }
+    if (typeof linkMethod === "function") {
+      linkMethod(row);
+      return;
     }
     const parentMethod = getParentMethod(linkMethod);
     if (typeof parentMethod === "function") {
@@ -351,8 +358,7 @@
 
   // 鑾峰彇鐖剁粍浠舵柟娉曪紙绀轰緥瀹炵幇锛�
   const getParentMethod = methodName => {
-    const parentMethods = inject("parentMethods", {});
-    return parentMethods[methodName];
+    return parentMethods?.[methodName];
   };
 
   const dataTypeFn = (val, format) => {
@@ -372,6 +378,12 @@
     return typeof operation.disabled === "function"
       ? !!operation.disabled(row)
       : !!operation.disabled;
+  };
+
+  const isOperationVisible = (operation, row) => {
+    const visibleHandler = operation?.showHide ?? operation?.show;
+    if (visibleHandler === undefined) return true;
+    return typeof visibleHandler === "function" ? !!visibleHandler(row) : !!visibleHandler;
   };
 
   const isOperationLoading = (operation, row) => {
@@ -455,7 +467,7 @@
   // 鏂囦欢涓婁紶鍓嶆牎楠�
   const beforeUpload = (rawFile, index) => {
     currentFiles.value[index] = {};
-    if (rawfile.size > 1024 * 1024 * 10 * 10) {
+    if (rawFile.size > 1024 * 1024 * 10 * 10) {
       ElMessage.error("涓婁紶鏂囦欢涓嶈秴杩�10M");
       return false;
     }

--
Gitblit v1.9.3