From 5aa165156994b1b8a601063fa0a1107d1893ea57 Mon Sep 17 00:00:00 2001
From: WXL <wl_5969728@163.com>
Date: 星期四, 19 三月 2026 16:48:13 +0800
Subject: [PATCH] 更新

---
 src/views/business/course/components/DeathJudgmentStage.vue |  418 +++++++++++++++++++++++++++++++++++++++++++----------------
 1 files changed, 304 insertions(+), 114 deletions(-)

diff --git a/src/views/business/course/components/DeathJudgmentStage.vue b/src/views/business/course/components/DeathJudgmentStage.vue
index b72f626..ce25f7f 100644
--- a/src/views/business/course/components/DeathJudgmentStage.vue
+++ b/src/views/business/course/components/DeathJudgmentStage.vue
@@ -4,14 +4,70 @@
       <!-- 鍩虹淇℃伅 -->
       <div slot="header" class="clearfix">
         <span class="detail-title">姝讳骸鍒ゅ畾鍩烘湰淇℃伅</span>
+        <el-button
+          v-if="isEdit"
+          type="success"
+          style="float: right"
+          @click="handleSave"
+          :loading="saveLoading"
+        >
+          淇濆瓨淇℃伅
+        </el-button>
+        <el-button
+          v-else
+          type="primary"
+          style="float: right"
+          @click="handleEdit"
+        >
+          缂栬緫淇℃伅
+        </el-button>
       </div>
 
       <el-form :model="form" ref="form" :rules="rules" label-width="120px">
         <el-row :gutter="20">
           <el-col :span="8">
-            <el-form-item label="姝讳骸鍘熷洜" prop="deathReason">
+            <el-form-item label="鎹愮尞鑰呯紪鍙�" prop="donorno">
+              <el-input
+                v-model="form.donorno"
+                :readonly="!isEdit"
+                placeholder="鑷姩鐢熸垚鎹愮尞鑰呯紪鍙�"
+              />
+            </el-form-item>
+          </el-col>
+          <el-col :span="8">
+            <el-form-item label="鎹愮尞鑰呭鍚�" prop="name">
+              <el-input v-model="form.name" :readonly="!isEdit" />
+            </el-form-item>
+          </el-col>
+          <el-col :span="8">
+            <el-form-item label="鎬у埆" prop="sex">
               <el-select
-                v-model="form.deathReason"
+                v-model="form.sex"
+                :disabled="!isEdit"
+                style="width: 100%"
+              >
+                <el-option label="鐢�" value="1" />
+                <el-option label="濂�" value="2" />
+              </el-select>
+            </el-form-item>
+          </el-col>
+        </el-row>
+
+        <el-row :gutter="20">
+          <el-col :span="8">
+            <el-form-item label="骞撮緞" prop="age">
+              <el-input v-model="form.age" :readonly="!isEdit" />
+            </el-form-item>
+          </el-col>
+          <el-col :span="8">
+            <el-form-item label="鐤剧梾璇婃柇" prop="diagnosisname">
+              <el-input v-model="form.diagnosisname" :readonly="!isEdit" />
+            </el-form-item>
+          </el-col>
+          <el-col :span="8">
+            <el-form-item label="姝讳骸鍘熷洜" prop="deathreason">
+              <el-select
+                v-model="form.deathreason"
                 :disabled="!isEdit"
                 style="width: 100%"
               >
@@ -25,9 +81,9 @@
 
         <el-row :gutter="20">
           <el-col :span="8">
-            <el-form-item label="姝讳骸鏃堕棿" prop="deathTime">
+            <el-form-item label="姝讳骸鏃堕棿" prop="deathtime">
               <el-date-picker
-                v-model="form.deathTime"
+                v-model="form.deathtime"
                 type="datetime"
                 value-format="yyyy-MM-dd HH:mm:ss"
                 style="width: 100%"
@@ -36,20 +92,63 @@
             </el-form-item>
           </el-col>
           <el-col :span="8">
-            <el-form-item label="鍒ゅ畾鍖荤敓涓�" prop="judgmentDoctor">
-              <el-input v-model="form.judgmentDoctorone" :readonly="!isEdit" />
+            <el-form-item label="鍒ゅ畾鍖荤敓涓�" prop="deathjudgedocto">
+              <el-input v-model="form.deathjudgedocto" :readonly="!isEdit" />
             </el-form-item>
           </el-col>
           <el-col :span="8">
-            <el-form-item label="鍒ゅ畾鍖荤敓浜�" prop="judgmentDoctor">
-              <el-input v-model="form.judgmentDoctortwo" :readonly="!isEdit" />
+            <el-form-item label="鍒ゅ畾鍖荤敓浜�" prop="deathjudgedoctt">
+              <el-input v-model="form.deathjudgedoctt" :readonly="!isEdit" />
             </el-form-item>
           </el-col>
         </el-row>
-        <el-row>
+
+        <el-row :gutter="20">
           <el-col :span="8">
-            <el-form-item label="鐧昏浜�" prop="registrant">
-              <el-input v-model="form.registrant" :readonly="!isEdit" />
+            <el-form-item label="鍣ㄥ畼鑾峰彇鏈烘瀯" prop="gainhospitalname">
+              <el-input v-model="form.gainhospitalname" :readonly="!isEdit" />
+            </el-form-item>
+          </el-col>
+          <el-col :span="8">
+            <el-form-item label="鏄惁榛樺搥缂呮��" prop="isspendremember">
+              <el-select
+                v-model="form.isspendremember"
+                :disabled="!isEdit"
+                style="width: 100%"
+              >
+                <el-option label="鏄�" :value="1" />
+                <el-option label="鍚�" :value="0" />
+              </el-select>
+            </el-form-item>
+          </el-col>
+          <el-col :span="8">
+            <el-form-item label="鏄惁鎭㈠閬椾綋浠" prop="isrestoreremains">
+              <el-select
+                v-model="form.isrestoreremains"
+                :disabled="!isEdit"
+                style="width: 100%"
+              >
+                <el-option label="鏄�" :value="1" />
+                <el-option label="鍚�" :value="0" />
+              </el-select>
+            </el-form-item>
+          </el-col>
+        </el-row>
+
+        <el-row :gutter="20">
+          <el-col :span="8">
+            <el-form-item label="璐熻矗浜�" prop="responsibleusername">
+              <el-input
+                v-model="form.responsibleusername"
+                :readonly="!isEdit"
+              />
+            </el-form-item>
+          </el-col>
+          <el-col :span="8">
+            <el-form-item label="璁板綍鐘舵��" prop="recordstate">
+              <el-tag :type="getStatusTag(form.recordstate)">
+                {{ getStatusText(form.recordstate) }}
+              </el-tag>
             </el-form-item>
           </el-col>
         </el-row>
@@ -70,7 +169,7 @@
     <el-card class="attachment-card">
       <div slot="header" class="clearfix">
         <span class="detail-title">姝讳骸鍒ゅ畾璇勪及琛ㄩ檮浠�</span>
-        <el-button
+        <!-- <el-button
           v-if="isEdit"
           type="primary"
           size="mini"
@@ -78,7 +177,7 @@
           :loading="uploadLoading"
         >
           涓婁紶闄勪欢
-        </el-button>
+        </el-button> -->
       </div>
 
       <!-- 闄勪欢绫诲瀷閫夐」鍗� -->
@@ -203,12 +302,14 @@
         ref="uploadRef"
         class="upload-demo"
         drag
-        action="#"
+        :action="uploadAction"
+        :headers="headers"
         multiple
         :file-list="tempFileList"
         :before-upload="beforeUpload"
         :on-change="handleFileChange"
         :on-remove="handleTempRemove"
+        :on-success="handleUploadSuccess"
         :auto-upload="false"
       >
         <i class="el-icon-upload"></i>
@@ -236,13 +337,17 @@
 </template>
 
 <script>
-import {
-  getDeathJudgmentDetail,
-  updateDeathJudgment
-} from "./api/mockDeathJudgmentApi";
+import { deathinfoedit, queryDathInfoBaseInfo } from "@/api/businessApi";
+import { getToken } from "@/utils/auth";
 
 export default {
   name: "DeathJudgmentDetail",
+  props: {
+    infoid: {
+      type: String,
+      default: true
+    }
+  },
   data() {
     return {
       // 鏄惁缂栬緫妯″紡
@@ -252,31 +357,39 @@
       // 琛ㄥ崟鏁版嵁
       form: {
         id: undefined,
-        hospitalNo: "",
-        donorName: "",
-        gender: "",
+        infoid: undefined,
+        donorno: "",
+        name: "",
+        sex: "",
         age: "",
-        diagnosis: "",
-        deathReason: "",
-        deathTime: "",
-        judgmentDoctor: "",
-        judgmentDescription: "",
-        registrant: "",
-        registrationTime: ""
+        diagnosisname: "",
+        deathreason: "",
+        deathtime: "",
+        deathjudgedocto: "",
+        deathjudgedoctt: "",
+        gainhospitalno: "",
+        gainhospitalname: "",
+        isspendremember: 0,
+        isrestoreremains: 0,
+        rememberannex: "",
+        responsibleuserid: "",
+        responsibleusername: "",
+        recordstate: "0",
+        judgmentDescription: ""
       },
       // 琛ㄥ崟楠岃瘉瑙勫垯
       rules: {
-        donorName: [
+        name: [
           { required: true, message: "鎹愮尞鑰呭鍚嶄笉鑳戒负绌�", trigger: "blur" }
         ],
-        deathReason: [
+        deathreason: [
           { required: true, message: "姝讳骸鍘熷洜涓嶈兘涓虹┖", trigger: "change" }
         ],
-        deathTime: [
+        deathtime: [
           { required: true, message: "姝讳骸鏃堕棿涓嶈兘涓虹┖", trigger: "change" }
         ],
-        judgmentDoctor: [
-          { required: true, message: "鍒ゅ畾鍖荤敓涓嶈兘涓虹┖", trigger: "blur" }
+        deathjudgedocto: [
+          { required: true, message: "鍒ゅ畾鍖荤敓涓�涓嶈兘涓虹┖", trigger: "blur" }
         ]
       },
       // 闄勪欢鐩稿叧鏁版嵁
@@ -286,7 +399,10 @@
       uploadLoading: false,
       tempFileList: [],
       currentUploadType: "",
-
+      uploadAction: process.env.VUE_APP_BASE_API + "/common/upload",
+      headers: {
+        Authorization: "Bearer " + getToken()
+      },
       // 璇勪及琛ㄧ被鍨嬪畾涔�
       attachmentTypes: [
         { value: "1", label: "鑴戞浜″垽瀹氳〃" },
@@ -311,58 +427,89 @@
     }
   },
   created() {
-    const id = this.$route.query.id;
-    this.isEdit =
-      this.$route.path.includes("/edit") || this.$route.path.includes("/add");
-    if (id && !this.$route.path.includes("/add")) {
-      this.getDetail(id);
-    } else if (this.$route.path.includes("/add")) {
-      this.generateHospitalNo();
-    }
+    this.getDetail(this.infoid);
     this.getAttachmentList();
   },
   methods: {
-    // 鐢熸垚浣忛櫌鍙�
-    generateHospitalNo() {
-      // 妯℃嫙鐢熸垚浣忛櫌鍙凤細D + 鏃堕棿鎴冲悗6浣�
+    // 鐢熸垚鎹愮尞鑰呯紪鍙�
+    generateDonorNo() {
       const timestamp = Date.now().toString();
-      this.form.hospitalNo = "D" + timestamp.slice(-6);
+      this.form.donorno = "DONOR" + timestamp.slice(-8);
     },
     // 鑾峰彇璇︽儏
-    getDetail(id) {
-      getDeathJudgmentDetail(id).then(response => {
-        if (response.code === 200) {
-          this.form = response.data;
+    async getDetail(id) {
+      try {
+        const response = await queryDathInfoBaseInfo({ infoid: id });
+        let realData = {};
+
+        if (response && response.data) {
+          realData = response.data[0];
+        } else if (response) {
+          realData = response;
         }
-      });
+
+        // 鏄犲皠瀛楁鍒拌〃鍗�
+        this.form = {
+          ...this.form,
+          ...realData,
+          // 纭繚鏁板�肩被鍨嬪瓧娈垫纭浆鎹�
+          isspendremember: realData.isspendremember
+            ? parseInt(realData.isspendremember)
+            : 0,
+          isrestoreremains: realData.isrestoreremains
+            ? parseInt(realData.isrestoreremains)
+            : 0
+        };
+
+        // 瑙f瀽闄勪欢淇℃伅
+        if (realData.rememberannex) {
+          this.parseAttachmentData(realData.rememberannex);
+        }
+      } catch (error) {
+        console.error("鑾峰彇姝讳骸鍒ゅ畾璇︽儏澶辫触:", error);
+        this.$message.error("鏁版嵁鍔犺浇澶辫触");
+      }
+    },
+    // 瑙f瀽闄勪欢鏁版嵁
+    parseAttachmentData(attachmentJson) {
+      try {
+        if (attachmentJson) {
+          const attachments = JSON.parse(attachmentJson);
+          if (Array.isArray(attachments)) {
+            this.attachmentList = attachments;
+          }
+        }
+      } catch (error) {
+        console.error("瑙f瀽闄勪欢鏁版嵁澶辫触:", error);
+      }
+    },
+    // 鏋勫缓闄勪欢JSON鏁版嵁
+    buildAttachmentJson() {
+      return JSON.stringify(this.attachmentList);
+    },
+    // 鑾峰彇鐘舵�佹爣绛炬牱寮�
+    getStatusTag(status) {
+      const statusMap = {
+        "0": "warning", // 缁存姢涓�
+        "1": "success", // 宸插畬鎴�
+        "99": "danger" // 宸茬粓姝�
+      };
+      return statusMap[status] || "info";
+    },
+    // 鑾峰彇鐘舵�佹枃鏈�
+    getStatusText(status) {
+      const textMap = {
+        "0": "缁存姢涓�",
+        "1": "宸插畬鎴�",
+        "99": "宸茬粓姝�"
+      };
+      return textMap[status] || "鏈煡鐘舵��";
     },
     // 鑾峰彇闄勪欢鍒楄〃
     getAttachmentList() {
       this.attachmentLoading = true;
-      // 妯℃嫙闄勪欢鏁版嵁 - 瀹為檯椤圭洰涓粠鎺ュ彛鑾峰彇
+      // 瀹為檯椤圭洰涓粠鎺ュ彛鑾峰彇闄勪欢鏁版嵁
       setTimeout(() => {
-        this.attachmentList = [
-          {
-            id: 1,
-            type: "1",
-            typeName: "鑴戞浜″垽瀹氳〃",
-            fileName: "鑴戞浜″垽瀹氳〃_202512001.pdf",
-            fileSize: 2548321,
-            uploadTime: "2025-12-01 10:30:00",
-            uploader: "寮犲尰鐢�",
-            fileUrl: "/attachments/brain_death_1.pdf"
-          },
-          {
-            id: 2,
-            type: "2",
-            typeName: "鑴戠數鍥捐瘎浼拌〃",
-            fileName: "鑴戠數鍥捐瘎浼拌〃_202512001.docx",
-            fileSize: 512345,
-            uploadTime: "2025-12-01 14:20:00",
-            uploader: "鏉庡尰鐢�",
-            fileUrl: "/attachments/eeg_1.docx"
-          }
-        ];
         this.attachmentLoading = false;
       }, 500);
     },
@@ -413,7 +560,6 @@
 
       const maxSize = 10 * 1024 * 1024; // 10MB
 
-      // 鏍¢獙鏂囦欢绫诲瀷
       const isTypeOk =
         allowedTypes.includes(file.type) ||
         file.name.endsWith(".pdf") ||
@@ -432,7 +578,6 @@
         return false;
       }
 
-      // 鏍¢獙鏂囦欢澶у皬
       if (file.size > maxSize) {
         this.$message.error("鏂囦欢澶у皬涓嶈兘瓒呰繃10MB");
         return false;
@@ -448,17 +593,11 @@
     handleTempRemove(file, fileList) {
       this.tempFileList = fileList;
     },
-    // 鎻愪氦涓婁紶
-    async submitUpload() {
-      if (this.tempFileList.length === 0) {
-        this.$message.warning("璇峰厛閫夋嫨瑕佷笂浼犵殑鏂囦欢");
-        return;
-      }
-
-      this.uploadLoading = true;
-
-      try {
-        // 妯℃嫙涓婁紶杩囩▼ - 瀹為檯椤圭洰涓皟鐢ㄤ笂浼犳帴鍙�
+    /** 涓婁紶鎴愬姛澶勭悊 */
+    handleUploadSuccess(response, file, fileList) {
+      if (response.code === 200) {
+        file.url = response.data || response.url;
+        this.$message.success("鏂囦欢涓婁紶鎴愬姛");
         for (const file of this.tempFileList) {
           const newAttachment = {
             id: Date.now() + Math.random(),
@@ -468,21 +607,60 @@
             fileSize: file.size,
             uploadTime: new Date().toISOString(),
             uploader: "褰撳墠鐢ㄦ埛",
-            fileUrl: URL.createObjectURL(file.raw)
+            fileUrl: file.url
           };
 
           this.attachmentList.push(newAttachment);
         }
 
+        // 鏇存柊闄勪欢JSON鏁版嵁鍒拌〃鍗�
+        this.form.rememberannex = this.buildAttachmentJson();
+
         this.$message.success("鏂囦欢涓婁紶鎴愬姛");
         this.uploadDialogVisible = false;
-        this.tempFileList = [];
-      } catch (error) {
-        this.$message.error("鏂囦欢涓婁紶澶辫触");
-        console.error("涓婁紶澶辫触:", error);
-      } finally {
         this.uploadLoading = false;
+        this.tempFileList = [];
+      } else {
+        this.$message.error(response.msg || "鏂囦欢涓婁紶澶辫触");
       }
+    },
+    // 鎻愪氦涓婁紶
+    async submitUpload() {
+      if (this.tempFileList.length === 0) {
+        this.$message.warning("璇峰厛閫夋嫨瑕佷笂浼犵殑鏂囦欢");
+        return;
+      }
+      this.$refs.uploadRef.submit();
+      this.uploadLoading = true;
+
+      // try {
+      //   for (const file of this.tempFileList) {
+      //     const newAttachment = {
+      //       id: Date.now() + Math.random(),
+      //       type: this.currentUploadType,
+      //       typeName: this.getCurrentTypeLabel,
+      //       fileName: file.name,
+      //       fileSize: file.size,
+      //       uploadTime: new Date().toISOString(),
+      //       uploader: "褰撳墠鐢ㄦ埛",
+      //       fileUrl: URL.createObjectURL(file.raw)
+      //     };
+
+      //     this.attachmentList.push(newAttachment);
+      //   }
+
+      //   // 鏇存柊闄勪欢JSON鏁版嵁鍒拌〃鍗�
+      //   this.form.rememberannex = this.buildAttachmentJson();
+
+      //   this.$message.success("鏂囦欢涓婁紶鎴愬姛");
+      //   this.uploadDialogVisible = false;
+      //   this.tempFileList = [];
+      // } catch (error) {
+      //   this.$message.error("鏂囦欢涓婁紶澶辫触");
+      //   console.error("涓婁紶澶辫触:", error);
+      // } finally {
+      //   this.uploadLoading = false;
+      // }
     },
     // 鍒犻櫎闄勪欢
     handleRemoveAttachment(attachment) {
@@ -497,6 +675,8 @@
           );
           if (index !== -1) {
             this.attachmentList.splice(index, 1);
+            // 鏇存柊闄勪欢JSON鏁版嵁鍒拌〃鍗�
+            this.form.rememberannex = this.buildAttachmentJson();
             this.$message.success("璇勪及琛ㄥ垹闄ゆ垚鍔�");
           }
         })
@@ -521,38 +701,48 @@
     },
     // 涓嬭浇闄勪欢
     handleDownload(attachment) {
-      // 瀹為檯椤圭洰涓皟鐢ㄤ笅杞芥帴鍙�
       const link = document.createElement("a");
       link.href = attachment.fileUrl;
       link.download = attachment.fileName;
       link.click();
       this.$message.success(`寮�濮嬩笅杞�: ${attachment.fileName}`);
     },
+    // 缂栬緫淇℃伅
+    handleEdit() {
+      this.isEdit = true;
+    },
     // 淇濆瓨淇℃伅
-    handleSave() {
-      this.$refs.form.validate(valid => {
+    async handleSave() {
+      this.$refs.form.validate(async valid => {
         if (valid) {
           this.saveLoading = true;
 
-          // 妯℃嫙淇濆瓨杩囩▼
-          updateDeathJudgment(this.form)
-            .then(response => {
-              if (response.code === 200) {
-                this.$message.success("淇濆瓨鎴愬姛");
-                if (this.$route.path.includes("/add")) {
-                  this.$router.push("/case/deathJudgment");
-                } else {
-                  this.isEdit = false;
-                }
+          try {
+            // 鏋勫缓鎻愪氦鏁版嵁
+            const submitData = {
+              ...this.form,
+              // 纭繚闄勪欢鏁版嵁鏈�鏂�
+              rememberannex: this.buildAttachmentJson()
+            };
+
+            const response = await deathinfoedit(submitData);
+
+            if (response.code === 200) {
+              this.$message.success("淇濆瓨鎴愬姛");
+              this.isEdit = false;
+
+              if (this.$route.path.includes("/add")) {
+                this.$router.push("/case/deathJudgment");
               }
-            })
-            .catch(error => {
-              console.error("淇濆瓨澶辫触:", error);
-              this.$message.error("淇濆瓨澶辫触");
-            })
-            .finally(() => {
-              this.saveLoading = false;
-            });
+            } else {
+              this.$message.error(response.message || "淇濆瓨澶辫触");
+            }
+          } catch (error) {
+            console.error("淇濆瓨澶辫触:", error);
+            this.$message.error("淇濆瓨澶辫触");
+          } finally {
+            this.saveLoading = false;
+          }
         }
       });
     },

--
Gitblit v1.9.3