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/ArchiveDialog.vue |   34 ++++++++++++++++++++--------------
 1 files changed, 20 insertions(+), 14 deletions(-)

diff --git a/src/views/patient/archives/components/ArchiveDialog.vue b/src/views/patient/archives/components/ArchiveDialog.vue
index 3b54e85..030464a 100644
--- a/src/views/patient/archives/components/ArchiveDialog.vue
+++ b/src/views/patient/archives/components/ArchiveDialog.vue
@@ -67,7 +67,8 @@
 </template>
 
 <script>
-import { ARCHIVE_TYPES, loadArchives, saveArchives, buildArchiveRecord } from "../types";
+import { ARCHIVE_TYPES } from "../types";
+import { createArchive } from "../apiAdapter";
 
 export default {
   name: "ArchiveDialog",
@@ -117,20 +118,25 @@
 
       const patientList = this.standalone ? [this.standalonePatient] : this.selectedPatients;
       const sourcePage = this.standalone ? "standalone" : this.sourcePage;
-      const records = patientList.map((p) => buildArchiveRecord(p, this.subType, sourcePage));
-      saveArchives([...loadArchives(), ...records]);
-
-      this.submitting = false;
-      this.dialogVisible = false;
-      this.$message.success(`鎴愬姛鍒涘缓 ${records.length} 鏉″缓妗h褰昤);
-      this.$emit("created");
-
-      // 杩涘叆璇︽儏椤碉紙缂栬緫鎬侊級
-      const first = records[0];
       const type = ARCHIVE_TYPES.find((t) => t.key === this.subType);
-      if (first && type) {
-        this.$router.push({ path: type.detailRoute, query: { id: first.id, edit: 1 } });
-      }
+
+      Promise.all(patientList.map((p) => createArchive(p, this.subType, sourcePage)))
+        .then((records) => {
+          this.submitting = false;
+          this.dialogVisible = false;
+          this.$message.success(`鎴愬姛鍒涘缓 ${records.length} 鏉″缓妗h褰昤);
+          this.$emit("created");
+
+          // 杩涘叆璇︽儏椤碉紙缂栬緫鎬侊級
+          const first = records[0];
+          if (first && type && first.id) {
+            this.$router.push({ path: type.detailRoute, query: { id: first.id, type: this.subType, edit: 1 } });
+          }
+        })
+        .catch(() => {
+          this.submitting = false;
+          this.$message.error("寤烘。澶辫触锛岃绋嶅悗閲嶈瘯");
+        });
     },
     handleClose() { this.resetForm(); },
   },

--
Gitblit v1.9.3