From 39c8b288ec8294e026459dfb1955f0bbc49ebb52 Mon Sep 17 00:00:00 2001
From: WXL (wul) <wl_5969728@163.com>
Date: 星期一, 19 十月 2026 11:10:40 +0800
Subject: [PATCH] 测试完成

---
 src/views/patient/archives/components/EditableTable.vue |   30 +++++++++++++++++++++++++-----
 1 files changed, 25 insertions(+), 5 deletions(-)

diff --git a/src/views/patient/archives/components/EditableTable.vue b/src/views/patient/archives/components/EditableTable.vue
index 3591c6e..970ec14 100644
--- a/src/views/patient/archives/components/EditableTable.vue
+++ b/src/views/patient/archives/components/EditableTable.vue
@@ -66,6 +66,9 @@
     editing: { type: Boolean, default: false },
     columns: { type: Array, default: () => [] },
     tableKey: { type: String, default: "" },
+    // 闇�瑕佽嚜鍔ㄨ繛缁紪鍙风殑鍒� prop锛堝 seq锛夈�傛柊澧炶銆佸垹闄よ鍚庨兘浼氭寜琛屽簭閲嶆帓锛�
+    // 閬垮厤鍑虹幇 1銆�3銆�4 杩欑鏂彿銆備笉浼犲垯涓嶅鐞嗐��
+    autoSeq: { type: String, default: "" },
   },
   data() {
     return {
@@ -80,19 +83,36 @@
   methods: {
     addRow() {
       const row = {};
-      this.columns.forEach(col => {
-        if (col.type === 'number') row[col.prop] = null;
-        else if (col.type === 'date') row[col.prop] = '';
-        else row[col.prop] = '';
+      this.columns.forEach((col) => {
+        // 鍒椾笂閰嶄簡 default 灏变紭鍏堢敤瀹冿紙鍙互鏄�硷紝涔熷彲浠ユ槸 (index, rows) => value锛�
+        if (col.default !== undefined) {
+          row[col.prop] =
+            typeof col.default === "function"
+              ? col.default(this.localData.length, this.localData)
+              : col.default;
+        } else if (col.type === "number") {
+          row[col.prop] = null;
+        } else {
+          row[col.prop] = "";
+        }
       });
       this.localData.push(row);
+      this.renumber();
     },
     deleteRows() {
       // remove by reference
-      this.localData = this.localData.filter(row => !this.selectedRows.includes(row));
+      this.localData = this.localData.filter((row) => !this.selectedRows.includes(row));
       this.selectedRows = [];
+      this.renumber();
       this.$emit("update:data", this.localData);
     },
+    /** 鎸夎搴忛噸鍐� autoSeq 鍒楃殑搴忓彿锛�1銆�2銆�3...锛� */
+    renumber() {
+      if (!this.autoSeq) return;
+      this.localData.forEach((row, i) => {
+        row[this.autoSeq] = String(i + 1);
+      });
+    },
     onSelect(rows) { this.selectedRows = rows; },
     tagType(v) {
       if (!v) return '';

--
Gitblit v1.9.3