From df1406d0f571972d033dffd6a93fb4b94febeb56 Mon Sep 17 00:00:00 2001
From: gaoluyang <2820782392@qq.com>
Date: 星期二, 24 六月 2025 16:46:44 +0800
Subject: [PATCH] Merge remote-tracking branch 'origin/dev' into dev

---
 src/components/Table/EtableModify.vue |   63 +++++++++++++------------------
 1 files changed, 26 insertions(+), 37 deletions(-)

diff --git a/src/components/Table/EtableModify.vue b/src/components/Table/EtableModify.vue
index 9afb58d..b42e487 100644
--- a/src/components/Table/EtableModify.vue
+++ b/src/components/Table/EtableModify.vue
@@ -28,33 +28,35 @@
       type="index"
       width="60"
       align="center"
-    />
-    <template v-for="col in columns" :key="col.prop">
+    />    <template v-for="col in columns" :key="col.prop">
       <el-table-column
         v-bind="col"
-        :show-overflow-tooltip="false"
         align="center"
       >
         <template #default="scope">
           <template v-if="col.slot">
-            <slot></slot>
-          </template>
-          <template v-else>
+            <slot
+              :name="col.prop"
+              :row="scope.row"
+              :column="scope.column"
+              :index="scope.$index"
+            ></slot>
+          </template>          <template v-else>
             <div
               class="cell-edit"
               @dblclick="handleCellEdit(scope.row, col.prop)"
               :class="{ editable: isColumnEditable(col.prop) }"
             >
+              <!-- 鏄剧ず鐘舵�侊細浣跨敤鏍煎紡鍖栫殑鍊� -->
               <span
                 v-if="!scope.row.editing || !scope.row.editing[col.prop]"
                 class="cell-text"
               >
                 {{
-                  scope.row[col.prop] == null || scope.row[col.prop] === ""
-                    ? "--"
-                    : scope.row[col.prop]
+                  formatCellValue(scope.row, scope.column, scope.row[col.prop], col)
                 }}
               </span>
+              <!-- 缂栬緫鐘舵�侊細浣跨敤鍘熷鍊硷紝涓嶇粡杩囨牸寮忓寲 -->
               <el-input
                 v-else
                 v-model="scope.row[col.prop]"
@@ -69,34 +71,6 @@
         </template>
       </el-table-column>
     </template>
-    <!-- 鎿嶄綔鍒� -->
-    <el-table-column
-      v-if="showOperations"
-      :label="operationsLabel"
-      :width="operationsWidth"
-      fixed="right"
-      align="center"
-    >
-      <template #default="scope">
-        <slot name="operations" :row="scope.row">
-          <el-button
-            v-if="operations.includes('edit')"
-            link
-            type="primary"
-            size="small"
-            @click="handleEdit(scope.row)"
-            >缂栬緫</el-button
-          >
-          <!--            <el-button-->
-          <!--              v-if="operations.includes('delete')"-->
-          <!--              link-->
-          <!--              type="danger"-->
-          <!--              size="small"-->
-          <!--              @click="handleDelete(scope.row)"-->
-          <!--            >鍒犻櫎</el-button>-->
-        </slot>
-      </template>
-    </el-table-column>
   </el-table>
 </template>
 
@@ -217,7 +191,22 @@
   // 妫�鏌ヨ鍒楀湪鎵�鏈夋暟鎹腑鏄惁鏈夐潪绌哄��
   return data.some((row) => row[col.prop] != null && row[col.prop] !== "");
 };
+// 榛樿鐨勬牸寮忓寲鍑芥暟
+const defaultFormatter = (row, column, cellValue) => {
+  return cellValue == null || cellValue === "" || cellValue === 0
+    ? "0"
+    : cellValue;
+};
 
+// 鏍煎紡鍖栧崟鍏冩牸鍊�
+const formatCellValue = (row, column, cellValue, col) => {
+  // 濡傛灉鍒楁湁鑷畾涔夋牸寮忓寲鍣紝浣跨敤鑷畾涔夋牸寮忓寲鍣�
+  if (col.formatter && typeof col.formatter === 'function') {
+    return col.formatter(row, column, cellValue);
+  }
+  // 鍚﹀垯浣跨敤榛樿鏍煎紡鍖栧櫒
+  return defaultFormatter(row, column, cellValue);
+};
 // 澶勭悊鍗曞厓鏍肩紪杈�
 const handleCellEdit = (row, prop) => {
   // 濡傛灉涓嶅厑璁哥紪杈戝崟鍏冩牸锛岀洿鎺ヨ繑鍥�

--
Gitblit v1.9.3