From a9d2b856e0f6be6475319c2dc36bf405c2f908fc Mon Sep 17 00:00:00 2001
From: WXL (wul) <wl_5969728@163.com>
Date: 星期二, 22 九月 2026 14:04:52 +0800
Subject: [PATCH] 测试完成

---
 src/views/patient/archives/components/ArchiveDialog.vue |  276 ++++--------------------------------------------------
 1 files changed, 24 insertions(+), 252 deletions(-)

diff --git a/src/views/patient/archives/components/ArchiveDialog.vue b/src/views/patient/archives/components/ArchiveDialog.vue
index a5a4207..3b54e85 100644
--- a/src/views/patient/archives/components/ArchiveDialog.vue
+++ b/src/views/patient/archives/components/ArchiveDialog.vue
@@ -1,15 +1,14 @@
 <template>
   <el-dialog
-    :title="dialogTitle"
+    :title="standalone ? '鏂板缓寤烘。' : '閫夋嫨寤烘。绫诲瀷'"
     :visible.sync="dialogVisible"
-    width="750px"
+    width="640px"
     :close-on-click-modal="false"
     append-to-body
     @close="handleClose"
-    top="3vh"
   >
     <!-- 宸查�夋偅鑰呴瑙堬紙鍏宠仈寤烘。妯″紡锛� -->
-    <div class="archive-section" v-if="selectedPatients.length > 0">
+    <div class="archive-section" v-if="!standalone && selectedPatients.length > 0">
       <div class="section-title">宸查�夋偅鑰咃紙{{ selectedPatients.length }}浜猴級</div>
       <el-table :data="selectedPatients" border size="small" max-height="180">
         <el-table-column prop="patname" label="濮撳悕" width="80" align="center" />
@@ -52,186 +51,24 @@
       <el-divider />
     </div>
 
-    <!-- 鍎夸繚绉戯細瀹堕暱淇℃伅锛堝繀濉級 -->
-    <div class="archive-section" v-if="mainCategory === 'child'">
-      <div class="section-title">瀹堕暱/鐩戞姢浜轰俊鎭�</div>
-      <el-form :model="parentInfo" label-width="100px" size="small" inline>
-        <el-form-item label="瀹堕暱濮撳悕" required>
-          <el-input v-model="parentInfo.parentName" placeholder="璇疯緭鍏�" style="width:150px" />
-        </el-form-item>
-        <el-form-item label="涓庡効绔ュ叧绯�">
-          <el-select v-model="parentInfo.relation" style="width:120px">
-            <el-option label="鐖朵翰" value="father" />
-            <el-option label="姣嶄翰" value="mother" />
-            <el-option label="绁栫埗" value="grandfather" />
-            <el-option label="绁栨瘝" value="grandmother" />
-            <el-option label="鍏朵粬" value="other" />
-          </el-select>
-        </el-form-item>
-        <el-form-item label="鑱旂郴鐢佃瘽" required>
-          <el-input v-model="parentInfo.parentPhone" placeholder="鑱旂郴鐢佃瘽" style="width:150px" />
-        </el-form-item>
-        <el-form-item label="韬唤璇佸彿">
-          <el-input v-model="parentInfo.parentIdCard" placeholder="韬唤璇佸彿" style="width:200px" />
-        </el-form-item>
-        <el-form-item label="鑱旂郴鍦板潃">
-          <el-input v-model="parentInfo.address" placeholder="鑱旂郴鍦板潃" style="width:300px" />
-        </el-form-item>
-      </el-form>
-      <el-divider />
-    </div>
-
-    <!-- 寤烘。涓诲垎绫� -->
+    <!-- 涓撴绫诲瀷閫夋嫨 -->
     <div class="archive-section">
-      <div class="section-title">閫夋嫨寤烘。绫诲瀷</div>
-      <el-radio-group v-model="mainCategory" size="medium" @change="onMainCategoryChange">
-        <el-radio-button label="child">鍎夸繚绉戝缓妗�</el-radio-button>
-        <el-radio-button label="maternal">濡囦繚绉戝缓妗�</el-radio-button>
-      </el-radio-group>
-    </div>
-
-    <!-- 瀛愮被鍨� -->
-    <div class="archive-section" v-if="mainCategory">
       <div class="section-title">閫夋嫨涓撴绫诲瀷</div>
-      <el-radio-group v-model="subType" size="small" @change="onSubTypeChange">
-        <template v-if="mainCategory === 'child'">
-          <el-radio-button label="highRisk">楂樺嵄鍎夸笓妗堢鐞�</el-radio-button>
-          <el-radio-button label="nutrition">钀ュ吇鎬х柧鐥呬笓妗堢鐞�</el-radio-button>
-          <el-radio-button label="learning">瀛︿範鍥伴毦涓撴绠$悊</el-radio-button>
-        </template>
-        <template v-else>
-          <el-radio-button label="pregnancy">瀛曞闅忚</el-radio-button>
-          <el-radio-button label="menopause">鏇村勾鏈熼殢璁�</el-radio-button>
-        </template>
+      <el-radio-group v-model="subType" size="medium">
+        <el-radio-button v-for="t in typeOptions" :key="t.key" :label="t.key">{{ t.entryLabel }}</el-radio-button>
       </el-radio-group>
-    </div>
-
-    <!-- 寤烘。涓撳睘瀛楁 -->
-    <div class="archive-section" v-if="subType">
-      <div class="section-title">寤烘。淇℃伅</div>
-      <el-form :model="archiveForm" label-width="120px" size="small">
-        <!-- 鍎夸繚绉� - 楂樺嵄鍎� -->
-        <template v-if="mainCategory === 'child' && subType === 'highRisk'">
-          <el-form-item label="楂樺嵄鍥犵礌">
-            <el-select v-model="archiveForm.riskFactor" multiple placeholder="鍙閫�" style="width:100%">
-              <el-option label="鏃╀骇/浣庝綋閲�" value="preterm" />
-              <el-option label="绐掓伅鍙�" value="asphyxia" />
-              <el-option label="棰呭唴鍑鸿" value="ich" />
-              <el-option label="楂樿儐绾㈢礌琛�鐥�" value="hyperbilirubinemia" />
-              <el-option label="瀹唴鎰熸煋" value="intrauterine" />
-              <el-option label="鍏堝ぉ鐣稿舰" value="malformation" />
-              <el-option label="鍏朵粬" value="other" />
-            </el-select>
-          </el-form-item>
-          <el-form-item label="鍑虹敓浣撻噸(g)">
-            <el-input-number v-model="archiveForm.birthWeight" :min="500" :max="6000" />
-          </el-form-item>
-          <el-form-item label="鍑虹敓瀛曞懆">
-            <el-input-number v-model="archiveForm.gestationalWeek" :min="22" :max="42" :precision="1" /> 鍛�
-          </el-form-item>
-          <el-form-item label="寤烘。鍖荤敓">
-            <el-input v-model="archiveForm.doctorName" placeholder="璇疯緭鍏ュ缓妗e尰鐢�" />
-          </el-form-item>
-          <el-form-item label="澶囨敞">
-            <el-input v-model="archiveForm.remark" type="textarea" :rows="2" />
-          </el-form-item>
-        </template>
-
-        <!-- 鍎夸繚绉� - 钀ュ吇鎬х柧鐥� -->
-        <template v-if="mainCategory === 'child' && subType === 'nutrition'">
-          <el-form-item label="钀ュ吇璇婃柇" required>
-            <el-select v-model="archiveForm.nutritionDiagnosis" placeholder="璇烽�夋嫨" style="width:100%">
-              <el-option label="钀ュ吇涓嶈壇" value="malnutrition" />
-              <el-option label="瓒呴噸" value="overweight" />
-              <el-option label="鑲ヨ儢" value="obesity" />
-              <el-option label="寰噺鍏冪礌缂轰箯" value="micronutrient" />
-              <el-option label="鍠傚吇鍥伴毦" value="feeding" />
-            </el-select>
-          </el-form-item>
-          <el-form-item label="寤烘。鍖荤敓">
-            <el-input v-model="archiveForm.doctorName" placeholder="璇疯緭鍏ュ缓妗e尰鐢�" />
-          </el-form-item>
-          <el-form-item label="澶囨敞">
-            <el-input v-model="archiveForm.remark" type="textarea" :rows="2" />
-          </el-form-item>
-        </template>
-
-        <!-- 鍎夸繚绉� - 瀛︿範鍥伴毦 -->
-        <template v-if="mainCategory === 'child' && subType === 'learning'">
-          <el-form-item label="瀛︿範闂" required>
-            <el-select v-model="archiveForm.learningIssue" placeholder="璇烽�夋嫨" style="width:100%">
-              <el-option label="闃呰闅滅" value="dyslexia" />
-              <el-option label="涔﹀啓闅滅" value="dysgraphia" />
-              <el-option label="璁$畻闅滅" value="dyscalculia" />
-              <el-option label="娉ㄦ剰鍔涚己闄�" value="adhd" />
-              <el-option label="娣峰悎鍨�" value="mixed" />
-            </el-select>
-          </el-form-item>
-          <el-form-item label="寤烘。鍖荤敓">
-            <el-input v-model="archiveForm.doctorName" placeholder="璇疯緭鍏ュ缓妗e尰鐢�" />
-          </el-form-item>
-          <el-form-item label="澶囨敞">
-            <el-input v-model="archiveForm.remark" type="textarea" :rows="2" />
-          </el-form-item>
-        </template>
-
-        <!-- 濡囦繚绉� - 瀛曞闅忚 -->
-        <template v-if="mainCategory === 'maternal' && subType === 'pregnancy'">
-          <el-form-item label="鏈鏈堢粡">
-            <el-date-picker v-model="archiveForm.lmp" type="date" value-format="yyyy-MM-dd" placeholder="閫夋嫨鏃ユ湡" style="width:100%" />
-          </el-form-item>
-          <el-row :gutter="12">
-            <el-col :span="8"><el-form-item label="瀛曞懆"><el-input-number v-model="archiveForm.gestationalWeek" :min="1" :max="42" :precision="1" /> 鍛�</el-form-item></el-col>
-            <el-col :span="8"><el-form-item label="瀛曟"><el-input-number v-model="archiveForm.gravidity" :min="1" :max="20" /></el-form-item></el-col>
-            <el-col :span="8"><el-form-item label="浜ф"><el-input-number v-model="archiveForm.parity" :min="0" :max="20" /></el-form-item></el-col>
-          </el-row>
-          <el-form-item label="棰勪骇鏈�">
-            <el-date-picker v-model="archiveForm.edd" type="date" value-format="yyyy-MM-dd" placeholder="閫夋嫨棰勪骇鏈�" style="width:100%" />
-          </el-form-item>
-          <el-form-item label="楂樺嵄濡婂">
-            <el-switch v-model="archiveForm.highRiskPregnancy" active-text="鏄�" inactive-text="鍚�" />
-          </el-form-item>
-          <el-form-item label="寤烘。鍖荤敓">
-            <el-input v-model="archiveForm.doctorName" placeholder="璇疯緭鍏ュ缓妗e尰鐢�" />
-          </el-form-item>
-          <el-form-item label="澶囨敞">
-            <el-input v-model="archiveForm.remark" type="textarea" :rows="2" />
-          </el-form-item>
-        </template>
-
-        <!-- 濡囦繚绉� - 鏇村勾鏈熼殢璁� -->
-        <template v-if="mainCategory === 'maternal' && subType === 'menopause'">
-          <el-form-item label="鏈堢粡鐘舵��">
-            <el-select v-model="archiveForm.menstrualStatus" placeholder="璇烽�夋嫨" style="width:100%">
-              <el-option label="鏈堢粡绱婁贡" value="irregular" />
-              <el-option label="闂粡锛�<12涓湀锛�" value="amenorrhea_short" />
-              <el-option label="缁濈粡锛堚墺12涓湀锛�" value="menopause" />
-              <el-option label="浜哄伐缁濈粡" value="surgical" />
-            </el-select>
-          </el-form-item>
-          <el-form-item label="鏈鏈堢粡">
-            <el-date-picker v-model="archiveForm.lmp" type="date" value-format="yyyy-MM-dd" placeholder="閫夋嫨鏃ユ湡" style="width:100%" />
-          </el-form-item>
-          <el-form-item label="寤烘。鍖荤敓">
-            <el-input v-model="archiveForm.doctorName" placeholder="璇疯緭鍏ュ缓妗e尰鐢�" />
-          </el-form-item>
-          <el-form-item label="澶囨敞">
-            <el-input v-model="archiveForm.remark" type="textarea" :rows="2" />
-          </el-form-item>
-        </template>
-      </el-form>
     </div>
 
     <div slot="footer" class="dialog-footer">
       <el-button @click="dialogVisible = false">鍙� 娑�</el-button>
-      <el-button type="primary" :loading="submitting" @click="handleSubmit" :disabled="!canSubmit">
-        纭寤烘。
-      </el-button>
+      <el-button type="primary" :loading="submitting" @click="handleSubmit" :disabled="!canSubmit">纭寤烘。</el-button>
     </div>
   </el-dialog>
 </template>
 
 <script>
+import { ARCHIVE_TYPES, loadArchives, saveArchives, buildArchiveRecord } from "../types";
+
 export default {
   name: "ArchiveDialog",
   props: {
@@ -243,33 +80,20 @@
   data() {
     return {
       dialogVisible: false,
-      mainCategory: "",
       subType: "",
       submitting: false,
       standalonePatient: { patname: "", sex: 2, age: "", telcode: "", deptname: "", diagname: "" },
-      parentInfo: { parentName: "", relation: "", parentPhone: "", parentIdCard: "", address: "" },
-      archiveForm: {
-        riskFactor: [], birthWeight: null, gestationalWeek: null,
-        nutritionDiagnosis: "", learningIssue: "",
-        gravidity: 1, parity: 0, edd: "", lmp: "",
-        highRiskPregnancy: false, menstrualStatus: "",
-        doctorName: "", remark: "",
-      },
     };
   },
   computed: {
-    dialogTitle() {
-      return this.standalone ? "鏂板缓寤烘。" : "鎮h�呭缓妗�";
-    },
+    typeOptions() { return ARCHIVE_TYPES; },
     canSubmit() {
       if (!this.subType) return false;
-      if (this.mainCategory === 'child' && !this.parentInfo.parentName) return false;
       if (this.standalone && !this.standalonePatient.patname) return false;
+      if (!this.standalone && this.selectedPatients.length === 0) return false;
       return true;
     },
-    selectedPatients() {
-      return this.patients || [];
-    },
+    selectedPatients() { return this.patients || []; },
   },
   watch: {
     visible(val) {
@@ -282,83 +106,31 @@
   },
   methods: {
     resetForm() {
-      this.mainCategory = "";
       this.subType = "";
       this.standalonePatient = { patname: "", sex: 2, age: "", telcode: "", deptname: "", diagname: "" };
-      this.parentInfo = { parentName: "", relation: "", parentPhone: "", parentIdCard: "", address: "" };
-      this.archiveForm = {
-        riskFactor: [], birthWeight: null, gestationalWeek: null,
-        nutritionDiagnosis: "", learningIssue: "",
-        gravidity: 1, parity: 0, edd: "", lmp: "",
-        highRiskPregnancy: false, menstrualStatus: "",
-        doctorName: "", remark: "",
-      };
     },
-    onMainCategoryChange() { this.subType = ""; },
-    onSubTypeChange() {},
-
-    getSubTypeLabel() {
-      const map = { highRisk: "楂樺嵄鍎夸笓妗堢鐞�", nutrition: "钀ュ吇鎬х柧鐥呬笓妗堢鐞�", learning: "瀛︿範鍥伴毦涓撴绠$悊", pregnancy: "瀛曞闅忚", menopause: "鏇村勾鏈熼殢璁�" };
-      return map[this.subType] || "";
-    },
-    getMainCategoryLabel() {
-      return this.mainCategory === "child" ? "鍎夸繚绉戝缓妗�" : "濡囦繚绉戝缓妗�";
-    },
-
     handleSubmit() {
       if (!this.subType) { this.$message.warning("璇烽�夋嫨涓撴绫诲瀷"); return; }
+      if (this.standalone && !this.standalonePatient.patname) { this.$message.warning("璇疯緭鍏ュ鍚�"); return; }
       if (!this.standalone && this.selectedPatients.length === 0) { this.$message.warning("璇烽�夋嫨鎮h��"); return; }
       this.submitting = true;
 
-      const archives = JSON.parse(localStorage.getItem("patientArchives") || "[]");
-      const now = new Date().toISOString().replace("T", " ").substring(0, 19);
-
-      // 纭畾鎮h�呭垪琛�
-      const patientList = this.standalone
-        ? [{ ...this.standalonePatient, patid: "sa_" + Date.now() }]
-        : this.selectedPatients;
-
-      patientList.forEach((patient) => {
-        archives.push({
-          id: "arc_" + Date.now() + "_" + Math.random().toString(36).substr(2, 6),
-          patientId: patient.patid || patient.id,
-          patname: patient.patname,
-          sex: patient.sex,
-          age: patient.age,
-          telcode: patient.telcode || patient.phone || "",
-          deptname: patient.deptname || "",
-          diagname: patient.diagname || "",
-          inhospno: patient.inhospno || "",
-          outhospno: patient.outhospno || "",
-          bedNo: patient.bedNo || "",
-          drname: patient.drname || "",
-          nurseName: patient.nurseName || "",
-          starttime: patient.starttime || patient.admitdate || "",
-          mainCategory: this.mainCategory,
-          mainCategoryLabel: this.getMainCategoryLabel(),
-          subType: this.subType,
-          subTypeLabel: this.getSubTypeLabel(),
-          archiveForm: JSON.parse(JSON.stringify(this.archiveForm)),
-          parentInfo: this.mainCategory === 'child' ? JSON.parse(JSON.stringify(this.parentInfo)) : {},
-          sourcePage: this.standalone ? "standalone" : this.sourcePage,
-          status: "active",
-          createTime: now,
-          updateTime: now,
-        });
-      });
-
-      localStorage.setItem("patientArchives", JSON.stringify(archives));
+      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(`鎴愬姛鍒涘缓 ${patientList.length} 鏉″缓妗h褰昤);
+      this.$message.success(`鎴愬姛鍒涘缓 ${records.length} 鏉″缓妗h褰昤);
       this.$emit("created");
 
-      // 璺宠浆
-      const routePath = this.mainCategory === "child"
-        ? "/filing/childHealth"
-        : "/filing/maternalHealth";
-      this.$router.push({ path: routePath });
+      // 杩涘叆璇︽儏椤碉紙缂栬緫鎬侊級
+      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 } });
+      }
     },
     handleClose() { this.resetForm(); },
   },

--
Gitblit v1.9.3