From c8e9849cb5f24848df0174c13bfbbff37bb08a5a Mon Sep 17 00:00:00 2001
From: WXL <wl_5969728@163.com>
Date: 星期二, 21 七月 2026 15:45:30 +0800
Subject: [PATCH] 维护

---
 src/views/business/GetWitness/GetWitnessInfo.vue | 1037 ++++++++++++++++++++++++++++++++-------------------------
 1 files changed, 579 insertions(+), 458 deletions(-)

diff --git a/src/views/business/GetWitness/GetWitnessInfo.vue b/src/views/business/GetWitness/GetWitnessInfo.vue
index 69158f8..d42c8bd 100644
--- a/src/views/business/GetWitness/GetWitnessInfo.vue
+++ b/src/views/business/GetWitness/GetWitnessInfo.vue
@@ -6,23 +6,9 @@
     <el-card class="detail-card">
       <div slot="header" class="clearfix">
         <span class="detail-title">鍣ㄥ畼鑾峰彇鍩烘湰淇℃伅</span>
-        <div style="float: right;">
-          <el-button type="primary" @click="handleSave" :loading="saveLoading">
-            淇濆瓨
-          </el-button>
-          <el-button
-            type="success"
-            @click="handleProcure"
-            :disabled="form.recordstate === 'completed'"
-            :loading="confirmLoading"
-          >
-            纭鑾峰彇
-          </el-button>
-        </div>
       </div>
 
       <el-form :model="form" ref="form" :rules="rules" label-width="120px">
-
         <!-- 鎵嬫湳鐩稿叧淇℃伅 -->
         <el-divider content-position="left">鎵嬫湳淇℃伅</el-divider>
 
@@ -39,7 +25,6 @@
                 type="datetime"
                 value-format="yyyy-MM-dd HH:mm:ss"
                 style="width: 100%"
-                :disabled="form.recordstate === 'completed'"
               />
             </el-form-item>
           </el-col>
@@ -50,7 +35,6 @@
                 type="datetime"
                 value-format="yyyy-MM-dd HH:mm:ss"
                 style="width: 100%"
-                :disabled="form.recordstate === 'completed'"
               />
             </el-form-item>
           </el-col>
@@ -67,7 +51,6 @@
                 type="datetime"
                 value-format="yyyy-MM-dd HH:mm:ss"
                 style="width: 100%"
-                :disabled="form.recordstate === 'completed'"
               />
             </el-form-item>
           </el-col>
@@ -81,7 +64,6 @@
                 type="datetime"
                 value-format="yyyy-MM-dd HH:mm:ss"
                 style="width: 100%"
-                :disabled="form.recordstate === 'completed'"
               />
             </el-form-item>
           </el-col>
@@ -89,30 +71,22 @@
 
         <el-row :gutter="20">
           <el-col :span="8">
-            <el-form-item
-              label="闂ㄩ潤鑴夋彃绠℃椂闂�"
-              prop="portalveincannulatime"
-            >
+            <el-form-item label="闂ㄩ潤鑴夋彃绠℃椂闂�" prop="portalveincannulatime">
               <el-date-picker
                 v-model="form.portalveincannulatime"
                 type="datetime"
                 value-format="yyyy-MM-dd HH:mm:ss"
                 style="width: 100%"
-                :disabled="form.recordstate === 'completed'"
               />
             </el-form-item>
           </el-col>
           <el-col :span="8">
-            <el-form-item
-              label="闂ㄩ潤鑴夌亴娉ㄦ椂闂�"
-              prop="portalveinperfusiontime"
-            >
+            <el-form-item label="闂ㄩ潤鑴夌亴娉ㄦ椂闂�" prop="portalveinperfusiontime">
               <el-date-picker
                 v-model="form.portalveinperfusiontime"
                 type="datetime"
                 value-format="yyyy-MM-dd HH:mm:ss"
                 style="width: 100%"
-                :disabled="form.recordstate === 'completed'"
               />
             </el-form-item>
           </el-col>
@@ -122,11 +96,11 @@
         <el-divider content-position="left">鍗忚皟鍛樹俊鎭�</el-divider>
 
         <el-row :gutter="20">
-          <el-col :span="8">
+          <!-- <el-col :span="8">
             <el-form-item label="鍗忚皟鍛樺鍚�" prop="coordinatorName">
               <el-input v-model="form.coordinatorName" />
             </el-form-item>
-          </el-col>
+          </el-col> -->
           <el-col :span="8">
             <el-form-item label="杩涙墜鏈鏃堕棿" prop="coordinatorInOperating">
               <el-date-picker
@@ -134,7 +108,6 @@
                 type="datetime"
                 value-format="yyyy-MM-dd HH:mm:ss"
                 style="width: 100%"
-                :disabled="form.recordstate === 'completed'"
               />
             </el-form-item>
           </el-col>
@@ -145,27 +118,41 @@
                 type="datetime"
                 value-format="yyyy-MM-dd HH:mm:ss"
                 style="width: 100%"
-                :disabled="form.recordstate === 'completed'"
               />
             </el-form-item>
           </el-col>
         </el-row>
 
         <el-row :gutter="20">
-          <el-col :span="8">
+          <!-- <el-col :span="8">
             <el-form-item label="鍗忚皟鍛樼瀛�" prop="coordinatorSign">
               <el-input v-model="form.coordinatorSign" />
             </el-form-item>
-          </el-col>
-          <el-col :span="8">
-            <el-form-item label="绛惧瓧鏃堕棿" prop="coordinatorSignTime">
+          </el-col> -->
+          <!-- <el-col :span="8">
+            <el-form-item label="鑾峰彇鏃堕棿" prop="coordinatorSignTime">
               <el-date-picker
                 v-model="form.coordinatorSignTime"
                 type="datetime"
                 value-format="yyyy-MM-dd HH:mm:ss"
                 style="width: 100%"
-                :disabled="form.recordstate === 'completed'"
               />
+            </el-form-item>
+          </el-col> -->
+          <el-col :span="8">
+            <el-form-item label="鏄惁榛樺搥缂呮��" prop="isspendremember">
+              <el-select v-model="form.isspendremember" 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" style="width: 100%">
+                <el-option label="鏄�" :value="1" />
+                <el-option label="鍚�" :value="0" />
+              </el-select>
             </el-form-item>
           </el-col>
         </el-row>
@@ -180,12 +167,12 @@
             </el-form-item>
           </el-col>
           <el-col :span="8">
-            <el-form-item label="鑱旂粶浜轰竴" prop="coordinatedusernameo">
+            <el-form-item label="鍗忚皟鍛樹竴" prop="coordinatedusernameo">
               <el-input v-model="form.coordinatedusernameo" />
             </el-form-item>
           </el-col>
           <el-col :span="8">
-            <el-form-item label="鑱旂粶浜轰簩" prop="coordinatedusernamet">
+            <el-form-item label="鍗忚皟鍛樹簩" prop="coordinatedusernamet">
               <el-input v-model="form.coordinatedusernamet" />
             </el-form-item>
           </el-col>
@@ -203,41 +190,14 @@
               />
             </el-form-item>
           </el-col>
-          <el-col :span="8">
-            <el-form-item label="鑾峰彇鏈烘瀯缂栫爜" prop="gainhospitalno">
+          <!-- <el-col :span="8">
+            <el-form-item label="鎹愮尞缂栧彿" prop="gainhospitalno">
               <el-input
                 v-model="form.gainhospitalno"
-                placeholder="璇疯緭鍏ヨ幏鍙栨満鏋勭紪鐮�"
+                placeholder="璇疯緭鍏ユ崘鐚紪鍙�"
               />
             </el-form-item>
-          </el-col>
-        </el-row>
-
-        <!-- 璁板綍淇℃伅 -->
-        <el-divider content-position="left">璁板綍淇℃伅</el-divider>
-
-        <el-row :gutter="20">
-          <el-col :span="8">
-            <el-form-item label="浣忛櫌鍙�" prop="donorno">
-              <el-input v-model="form.donorno" readonly />
-            </el-form-item>
-          </el-col>
-          <el-col :span="8">
-            <el-form-item label="鎵�鍦ㄥ尰鐤楁満鏋�" prop="treatmenthospitalname">
-              <el-input
-                v-model="form.treatmenthospitalname"
-                placeholder="璇疯緭鍏ュ尰鐤楁満鏋勫悕绉�"
-              />
-            </el-form-item>
-          </el-col>
-          <el-col :span="8">
-            <el-form-item label="鍖荤枟鏈烘瀯缂栫爜" prop="treatmenthospitalno">
-              <el-input
-                v-model="form.treatmenthospitalno"
-                placeholder="璇疯緭鍏ュ尰鐤楁満鏋勭紪鐮�"
-              />
-            </el-form-item>
-          </el-col>
+          </el-col> -->
         </el-row>
       </el-form>
     </el-card>
@@ -247,13 +207,10 @@
       <div slot="header" class="clearfix">
         <span class="detail-title">鍣ㄥ畼鑾峰彇璁板綍</span>
         <div style="float: right;">
-          <el-tag
-            :type="
-              form.recordstate === 'completed' ? 'success' : 'warning'
-            "
-          >
-            {{ form.recordstate === "completed" ? "宸插畬鎴�" : "杩涜涓�" }}
-          </el-tag>
+          <dict-tag
+            :options="dict.type.Obtain_status"
+            :value="form.witnessState"
+          />
         </div>
       </div>
 
@@ -274,7 +231,6 @@
                   v-for="dict in dict.type.sys_Organ || []"
                   :key="dict.value"
                   :label="dict.value"
-                  :disabled="form.recordstate === 'completed'"
                 >
                   {{ dict.label }}
                 </el-checkbox>
@@ -287,7 +243,7 @@
           <el-col>
             <el-form-item>
               <el-table
-                :data="procurementData.serviceDonationwitnessorgans"
+                :data="displayOrgans"
                 v-loading="loading"
                 border
                 style="width: 100%"
@@ -311,7 +267,7 @@
                 <el-table-column
                   label="鑾峰彇寮�濮嬫椂闂�"
                   align="center"
-                  width="180"
+                  width="260"
                   prop="organStartTime"
                 >
                   <template slot-scope="scope">
@@ -323,7 +279,6 @@
                       type="datetime"
                       value-format="yyyy-MM-dd HH:mm:ss"
                       placeholder="閫夋嫨鑾峰彇寮�濮嬫椂闂�"
-                      :disabled="form.recordstate === 'completed'"
                     />
                   </template>
                 </el-table-column>
@@ -331,19 +286,18 @@
                 <el-table-column
                   label="鍣ㄥ畼绂讳綋鏃堕棿"
                   align="center"
-                  width="180"
-                  prop="organGetTime"
+                  width="260"
+                  prop="organgettime"
                 >
                   <template slot-scope="scope">
                     <el-date-picker
                       clearable
                       size="small"
                       style="width: 100%"
-                      v-model="scope.row.organGetTime"
+                      v-model="scope.row.organgettime"
                       type="datetime"
                       value-format="yyyy-MM-dd HH:mm:ss"
                       placeholder="閫夋嫨鍣ㄥ畼绂讳綋鏃堕棿"
-                      :disabled="form.recordstate === 'completed'"
                     />
                   </template>
                 </el-table-column>
@@ -351,138 +305,83 @@
                 <el-table-column
                   label="鑾峰彇鍖婚櫌"
                   align="center"
-                  width="200"
-                  prop="gainHospitalNo"
+                  width="300"
+                  prop="gainhospitalname"
                 >
-                  <template slot-scope="scope">
+                  <!-- <template slot-scope="scope">
                     <el-select
-                      v-model="scope.row.gainHospitalNo"
+                      v-model="scope.row.gainhospitalname"
                       placeholder="璇烽�夋嫨鑾峰彇鍖婚櫌"
                       style="width: 100%"
-                      :disabled="form.recordstate === 'completed'"
-                      @change="handleHospitalChange(scope.row, $event)"
                     >
                       <el-option
-                        v-for="hospital in hospitalList"
-                        :key="hospital.hospitalNo"
-                        :label="hospital.hospitalName"
-                        :value="hospital.hospitalNo"
-                      />
+                        v-for="dict in dict.type.Geta_hospital"
+                        :key="dict.value"
+                        :label="dict.label"
+                        :value="dict.value"
+                      ></el-option>
+
                     </el-select>
+                  </template> -->
+                  <template slot-scope="scope">
+                    <el-autocomplete
+                      v-model="scope.row.gainhospitalname"
+                      :fetch-suggestions="queryHospitalSearch"
+                      placeholder="璇烽�夋嫨鎴栬緭鍏ヨ幏鍙栧尰闄�"
+                      style="width: 100%"
+                      clearable
+                    ></el-autocomplete>
                   </template>
                 </el-table-column>
 
                 <el-table-column
                   label="鑾峰彇鍖诲笀"
                   align="center"
-                  width="120"
-                  prop="organGetDoctor"
+                  width="150"
+                  prop="organgetdoct"
                 >
                   <template slot-scope="scope">
                     <el-input
-                      v-model="scope.row.organGetDoctor"
+                      v-model="scope.row.organgetdoct"
                       placeholder="鑾峰彇鍖诲笀"
-                      :disabled="form.recordstate === 'completed'"
                     />
                   </template>
                 </el-table-column>
 
-                <el-table-column
-                  label="鍔╂墜"
-                  align="center"
-                  width="120"
-                  prop="assistant"
-                >
-                  <template slot-scope="scope">
-                    <el-input
-                      v-model="scope.row.assistant"
-                      placeholder="鍔╂墜"
-                      :disabled="form.recordstate === 'completed'"
-                    />
-                  </template>
-                </el-table-column>
-
-                <el-table-column
-                  label="鑾峰彇鎶ゅ+"
-                  align="center"
-                  width="120"
-                  prop="procurementNurse"
-                >
-                  <template slot-scope="scope">
-                    <el-input
-                      v-model="scope.row.procurementNurse"
-                      placeholder="鑾峰彇鎶ゅ+"
-                      :disabled="form.recordstate === 'completed'"
-                    />
-                  </template>
-                </el-table-column>
-
-                <el-table-column
-                  label="鎵嬫湳瀹ゆ姢澹�"
-                  align="center"
-                  width="120"
-                  prop="operatingRoomNurse"
-                >
-                  <template slot-scope="scope">
-                    <el-input
-                      v-model="scope.row.operatingRoomNurse"
-                      placeholder="鎵嬫湳瀹ゆ姢澹�"
-                      :disabled="form.recordstate === 'completed'"
-                    />
-                  </template>
-                </el-table-column>
-
-                <el-table-column
-                  label="楹婚唹鍖荤敓"
-                  align="center"
-                  width="120"
-                  prop="anesthesiologist"
-                >
-                  <template slot-scope="scope">
-                    <el-input
-                      v-model="scope.row.anesthesiologist"
-                      placeholder="楹婚唹鍖荤敓"
-                      :disabled="form.recordstate === 'completed'"
-                    />
-                  </template>
-                </el-table-column>
-
-                <el-table-column
+                <!-- <el-table-column
                   label="鑾峰彇鐘舵��"
                   align="center"
                   width="120"
-                  prop="organState"
+                  prop="organstate"
                 >
                   <template slot-scope="scope">
                     <el-select
-                      v-model="scope.row.organState"
+                      v-model="scope.row.organstate"
                       placeholder="璇烽�夋嫨鑾峰彇鐘舵��"
                       style="width: 100%"
-                      :disabled="form.recordstate === 'completed'"
                     >
                       <el-option
-                        v-for="dict in organStateList"
+                        v-for="dict in dict.type.Obtain_status"
                         :key="dict.value"
                         :label="dict.label"
                         :value="dict.value"
                       />
                     </el-select>
                   </template>
-                </el-table-column>
+                </el-table-column> -->
 
                 <el-table-column
                   label="璇存槑"
                   align="center"
-                  prop="notGetReason"
+                  prop="notgetreason"
                   min-width="200"
                 >
                   <template slot-scope="scope">
                     <el-input
                       type="textarea"
                       clearable
-                      v-model="scope.row.notGetReason"
+                      v-model="scope.row.notgetreason"
                       placeholder="璇疯緭鍏ユ湭鑾峰彇璇存槑"
-                      :disabled="form.recordstate === 'completed'"
                     />
                   </template>
                 </el-table-column>
@@ -492,7 +391,6 @@
                   align="center"
                   width="120"
                   class-name="small-padding fixed-width"
-                  v-if="form.recordstate !== 'completed'"
                 >
                   <template slot-scope="scope">
                     <el-button
@@ -510,168 +408,141 @@
           </el-col>
         </el-row>
 
-        <!-- 鑾峰彇缁熻淇℃伅 -->
         <div
-          class="procurement-stats"
-          v-if="procurementData.serviceDonationwitnessorgans && procurementData.serviceDonationwitnessorgans.length > 0"
+          v-if="!procurementData.serviceDonationwitnessorgans"
+          class="empty-procurement"
         >
-          <el-row :gutter="20">
-            <el-col :span="6">
-              <div class="stat-item">
-                <span class="stat-label">宸茶幏鍙栧櫒瀹�:</span>
-                <span class="stat-value"
-                  >{{ procurementData.serviceDonationwitnessorgans.length }} 涓�</span
-                >
-              </div>
-            </el-col>
-            <el-col :span="6">
-              <div class="stat-item">
-                <span class="stat-label">寰呭畬鍠勪俊鎭�:</span>
-                <span class="stat-value">{{ incompleteRecords }} 涓�</span>
-              </div>
-            </el-col>
-            <el-col :span="6">
-              <div class="stat-item">
-                <span class="stat-label">娑夊強鍖婚櫌:</span>
-                <span class="stat-value">{{ uniqueHospitals }} 瀹�</span>
-              </div>
-            </el-col>
-            <el-col :span="6">
-              <div class="stat-item">
-                <span class="stat-label">鑾峰彇鐘舵��:</span>
-                <span class="stat-value">
-                  <el-tag
-                    :type="
-                      form.recordstate === 'completed'
-                        ? 'success'
-                        : 'warning'
-                    "
-                  >
-                    {{
-                      form.recordstate === "completed"
-                        ? "宸插畬鎴�"
-                        : "杩涜涓�"
-                    }}
-                  </el-tag>
-                </span>
-              </div>
-            </el-col>
-          </el-row>
-        </div>
-
-        <div v-else class="empty-procurement">
           <el-empty description="鏆傛棤鑾峰彇璁板綍" :image-size="80">
             <span>璇峰厛閫夋嫨瑕佽幏鍙栫殑鍣ㄥ畼</span>
           </el-empty>
         </div>
       </el-form>
-
-      <div class="dialog-footer" v-if="form.recordstate !== 'completed'">
-        <el-button
-          type="primary"
-          @click="handleSaveProcurement"
-          :loading="saveLoading"
-          :disabled="!procurementData.serviceDonationwitnessorgans || procurementData.serviceDonationwitnessorgans.length === 0"
-        >
-          淇濆瓨鑾峰彇璁板綍
-        </el-button>
-        <el-button
-          type="success"
-          @click="handleConfirmProcurement"
-          :loading="confirmLoading"
-          :disabled="incompleteRecords > 0"
-        >
-          纭瀹屾垚鑾峰彇
-        </el-button>
-      </div>
     </el-card>
 
-    <!-- 闄勪欢绠$悊閮ㄥ垎浼樺寲 -->
+    <!-- 闄勪欢绠$悊閮ㄥ垎 - 鍒嗙被Tab灞曠ず -->
     <el-card class="attachment-card">
-      <div class="attachment-header">
-        <i class="el-icon-paperclip"></i>
-        <span class="attachment-title">鐩稿叧闄勪欢</span>
-        <span class="attachment-tip"
-          >鏀寔涓婁紶鍣ㄥ畼鑾峰彇鐩稿叧鏂囦欢 (鏈�澶歿{ attachmentLimit }}涓�)</span
-        >
+      <div slot="header" class="clearfix">
+        <span class="detail-title">鐩稿叧闄勪欢</span>
       </div>
 
-      <!-- 浣跨敤 UploadAttachment 缁勪欢 -->
-      <UploadAttachment
-        ref="uploadAttachment"
-        :file-list="attachmentFileList"
-        :limit="attachmentLimit"
-        :accept="attachmentAccept"
-        :multiple="true"
-        @change="handleAttachmentChange"
-        @upload-success="handleUploadSuccess"
-        @upload-error="handleUploadError"
-        @remove="handleAttachmentRemove"
-      />
+      <!-- 涓婁紶鍖哄煙锛堟棤鍒嗙被閫夋嫨锛岀敱Tab鎺у埗锛� -->
+      <div class="upload-wrapper">
+        <UploadAttachment
+          ref="uploadAttachment"
+          :file-list="attachmentFileList"
+          :limit="attachmentLimit"
+          :accept="attachmentAccept"
+          :multiple="true"
+          @change="handleAttachmentChange"
+          @upload-success="handleUploadSuccess"
+          @upload-error="handleUploadError"
+          @remove="handleAttachmentRemove"
+        />
+        <div style="font-size:12px; color:#909399; margin-top:4px;">
+          褰撳墠涓婁紶鍒嗙被锛�<el-tag size="small" type="info">{{
+            activeTab === "鏈垎绫�" ? "鏈垎绫�" : activeTab
+          }}</el-tag>
+          锛堝垏鎹� Tab 鍙敼鍙樹笂浼犲垎绫伙級
+        </div>
+      </div>
 
-      <!-- 闄勪欢鍒楄〃灞曠ず -->
-      <div
-        class="attachment-list"
-        v-if="attachments && attachments.length > 0"
-      >
-        <div class="list-title">宸蹭笂浼犻檮浠� ({{ attachments.length }})</div>
-        <el-table :data="attachments" style="width: 100%" size="small">
-          <el-table-column label="鏂囦欢鍚�" min-width="200">
-            <template slot-scope="scope">
-              <i
-                class="el-icon-document"
-                :style="{ color: getFileIconColor(scope.row.fileName) }"
-              ></i>
-              <span class="file-name">{{ scope.row.fileName }}</span>
-            </template>
-          </el-table-column>
-          <el-table-column label="鏂囦欢绫诲瀷" width="100">
-            <template slot-scope="scope">
-              <el-tag :type="getFileTagType(scope.row.fileName)" size="small">
-                {{ getFileTypeText(scope.row.fileName) }}
-              </el-tag>
-            </template>
-          </el-table-column>
-          <el-table-column label="涓婁紶鏃堕棿" width="160">
-            <template slot-scope="scope">
-              <span>{{ formatDateTime(scope.row.uploadTime) }}</span>
-            </template>
-          </el-table-column>
-          <el-table-column label="鏂囦欢澶у皬" width="100">
-            <template slot-scope="scope">
-              <span>{{ formatFileSize(scope.row.fileSize) }}</span>
-            </template>
-          </el-table-column>
-          <el-table-column label="鎿嶄綔" width="200" fixed="right">
-            <template slot-scope="scope">
-              <el-button
-                size="mini"
-                type="primary"
-                @click="handlePreview(scope.row)"
-                :disabled="!isPreviewable(scope.row.fileName)"
-              >
-                棰勮
-              </el-button>
-              <el-button
-                size="mini"
-                type="success"
-                @click="handleDownload(scope.row)"
-              >
-                涓嬭浇
-              </el-button>
-              <el-button
-                size="mini"
-                type="danger"
-                @click="handleRemoveAttachment(scope.$index)"
-              >
-                鍒犻櫎
-              </el-button>
-            </template>
-          </el-table-column>
-        </el-table>
+      <!-- 闄勪欢鍒楄〃 - 鍒嗙被Tab灞曠ず锛屾敮鎸佷慨鏀瑰垎绫� -->
+      <div class="attachment-list" v-if="attachments && attachments.length > 0">
+        <el-tabs v-model="activeTab" type="border-card">
+          <el-tab-pane
+            v-for="category in categories"
+            :key="category"
+            :label="category + '(' + getCategoryCount(category) + ')'"
+            :name="category"
+          >
+            <el-table
+              :data="getCategoryFiles(category)"
+              style="width: 100%"
+              size="small"
+              border
+            >
+              <el-table-column label="鏂囦欢鍚�" min-width="180">
+                <template #default="scope">
+                  <i
+                    class="el-icon-document"
+                    style="margin-right: 8px; color: #409EFF;"
+                  ></i>
+                  <span class="file-name">{{ scope.row.fileName }}</span>
+                </template>
+              </el-table-column>
+              <!-- 鍙紪杈戝垎绫讳笅鎷� -->
+              <el-table-column label="鍒嗙被" width="150">
+                <template #default="scope">
+                  <el-select
+                    v-model="scope.row.fileType"
+                    size="small"
+                    @change="updateAttachmentCategory(scope.row, $event)"
+                    placeholder="閫夋嫨鍒嗙被"
+                  >
+                    <el-option label="鍘熻〃鎷嶇収" value="鍘熻〃鎷嶇収" />
+                    <el-option label="浼︾悊瀹℃煡鏉愭枡" value="浼︾悊瀹℃煡鏉愭枡" />
+                    <el-option label="姝讳骸鍒ゅ畾鏉愭枡" value="姝讳骸鍒ゅ畾鏉愭枡" />
+                    <el-option label="榛樺搥浠紡鐓х墖" value="榛樺搥浠紡鐓х墖" />
+                    <el-option label="鎹愮尞瑙佽瘉瑙嗛" value="鎹愮尞瑙佽瘉瑙嗛" />
+                    <el-option label="鏈垎绫�" value="" />
+                  </el-select>
+                </template>
+              </el-table-column>
+              <el-table-column label="鏂囦欢绫诲瀷" width="100">
+                <template #default="scope">
+                  <el-tag size="small">{{
+                    getFileTypeText(scope.row.fileName)
+                  }}</el-tag>
+                </template>
+              </el-table-column>
+              <el-table-column label="涓婁紶鏃堕棿" width="160">
+                <template #default="scope">
+                  <span>{{ formatDateTime(scope.row.uploadTime) }}</span>
+                </template>
+              </el-table-column>
+              <el-table-column label="鏂囦欢澶у皬" width="100">
+                <template #default="scope">
+                  <span>{{ formatFileSize(scope.row.fileSize) }}</span>
+                </template>
+              </el-table-column>
+              <el-table-column label="鎿嶄綔" width="180" fixed="right">
+                <template #default="scope">
+                  <el-button
+                    size="mini"
+                    type="primary"
+                    @click="handlePreview(scope.row)"
+                    >棰勮</el-button
+                  >
+                  <el-button
+                    size="mini"
+                    type="danger"
+                    @click="handleRemoveAttachmentByFile(scope.row)"
+                    >鍒犻櫎</el-button
+                  >
+                </template>
+              </el-table-column>
+            </el-table>
+          </el-tab-pane>
+        </el-tabs>
+      </div>
+
+      <!-- 鏃犻檮浠舵椂鏄剧ず -->
+      <div v-else style="text-align:center; padding:20px; color:#909399;">
+        鏆傛棤闄勪欢锛岃涓婁紶
       </div>
     </el-card>
-
+    <div style="text-align: center; margin: 30px 0;">
+      <el-button type="primary" @click="handleSave" :loading="saveLoading">
+        淇濆瓨
+      </el-button>
+      <el-button
+        type="success"
+        @click="handleProcure"
+        :loading="confirmLoading"
+      >
+        纭鑾峰彇
+      </el-button>
+    </div>
     <!-- 缂栬緫鑾峰彇璁板綍瀵硅瘽妗� -->
     <el-dialog
       title="缂栬緫鍣ㄥ畼鑾峰彇璁板綍"
@@ -685,25 +556,25 @@
               <el-input v-model="currentRecord.organname" readonly />
             </el-form-item>
           </el-col>
-          <el-col :span="12">
+          <!-- <el-col :span="12">
             <el-form-item label="鑾峰彇鐘舵��">
-              <el-select v-model="currentRecord.organState" style="width: 100%">
+              <el-select v-model="currentRecord.organstate" style="width: 100%">
                 <el-option
-                  v-for="dict in organStateList"
+                  v-for="dict in dict.type.Obtain_status"
                   :key="dict.value"
                   :label="dict.label"
                   :value="dict.value"
                 />
               </el-select>
             </el-form-item>
-          </el-col>
+          </el-col> -->
         </el-row>
 
         <el-row :gutter="20">
           <el-col :span="12">
             <el-form-item label="鑾峰彇鍖诲笀">
               <el-input
-                v-model="currentRecord.organGetDoctor"
+                v-model="currentRecord.organgetdoct"
                 placeholder="璇疯緭鍏ヨ幏鍙栧尰甯�"
               />
             </el-form-item>
@@ -744,14 +615,11 @@
           />
         </el-form-item>
 
-        <el-form-item
-          label="鏈幏鍙栬鏄�"
-          v-if="currentRecord.organState === '0'"
-        >
+        <el-form-item label="鏈幏鍙栬鏄�">
           <el-input
             type="textarea"
             :rows="3"
-            v-model="currentRecord.notGetReason"
+            v-model="currentRecord.notgetreason"
             placeholder="璇疯緭鍏ユ湭鑾峰彇鐨勫師鍥犺鏄�"
           />
         </el-form-item>
@@ -772,10 +640,17 @@
     >
       <div v-if="currentPreviewFile">
         <div v-if="currentPreviewFile.fileType === 'image'">
-          <img :src="currentPreviewFile.fileUrl" style="max-width: 100%; max-height: 500px;" />
+          <img
+            :src="currentPreviewFile.fileUrl"
+            style="max-width: 100%; max-height: 500px;"
+          />
         </div>
         <div v-else-if="currentPreviewFile.fileType === 'pdf'">
-          <iframe :src="currentPreviewFile.fileUrl" width="100%" height="500px"></iframe>
+          <iframe
+            :src="currentPreviewFile.fileUrl"
+            width="100%"
+            height="500px"
+          ></iframe>
         </div>
         <div v-else>
           <p>涓嶆敮鎸侀瑙堟鏂囦欢绫诲瀷锛岃涓嬭浇鏌ョ湅</p>
@@ -786,7 +661,7 @@
 </template>
 
 <script>
-import { witnessList, witnessadd, witnessedit, } from "@/api/businessApi";
+import { witnessList, witnessadd, witnessedit } from "@/api/businessApi";
 import UploadAttachment from "@/components/UploadAttachment";
 import CaseBasicInfo from "@/components/CaseBasicInfo";
 import dayjs from "dayjs";
@@ -794,9 +669,16 @@
 export default {
   name: "OrganProcurementDetail",
   components: {
-    UploadAttachment,CaseBasicInfo
+    UploadAttachment,
+    CaseBasicInfo
   },
-  dicts: ["sys_BloodType", "sys_DonationCategory", "sys_Organ"],
+  dicts: [
+    "sys_BloodType",
+    "Geta_hospital",
+    "sys_DonationCategory",
+    "sys_Organ",
+    "Obtain_status"
+  ],
   data() {
     return {
       caseId: null,
@@ -806,7 +688,7 @@
         infoid: undefined,
         name: "",
         inpatientno: "",
-        recordstate: "pending",
+        witnessState: "2",
         caseNo: "",
         donorno: "",
         treatmenthospitalname: "",
@@ -853,6 +735,18 @@
         coordinatorSignTime: "",
         attachments: []
       },
+      activeTab: "鍘熻〃鎷嶇収", // 褰撳墠婵�娲荤殑闄勪欢鍒嗙被Tab
+      presetCategories: [
+        "鍘熻〃鎷嶇収",
+        "浼︾悊瀹℃煡鏉愭枡",
+        "姝讳骸鍒ゅ畾鏉愭枡",
+        "榛樺搥浠紡鐓х墖",
+        "鎹愮尞瑙佽瘉瑙嗛"
+      ], // 棰勮鍒嗙被
+      organExpansionMap: {
+        C64: { subItems: ["C64L", "C64R"], subNames: ["宸﹁偩", "鍙宠偩"] },
+        C34: { subItems: ["C34L", "C34R"], subNames: ["宸﹁偤", "鍙宠偤"] }
+      },
       // 琛ㄥ崟楠岃瘉瑙勫垯
       rules: {
         name: [
@@ -879,12 +773,6 @@
       selectedOrgans: [],
       // 鍖婚櫌鍒楄〃
       hospitalList: [],
-      // 鍣ㄥ畼鐘舵�佸垪琛�
-      organStateList: [
-        { value: "1", label: "宸茶幏鍙�" },
-        { value: "0", label: "鏈幏鍙�" },
-        { value: "2", label: "閮ㄥ垎鑾峰彇" }
-      ],
       // 鑾峰彇璁板綍鏁版嵁
       procurementData: {
         serviceDonationwitnessorgans: []
@@ -894,7 +782,8 @@
       attachmentFileList: [],
       // 闄勪欢鐩稿叧閰嶇疆
       attachmentLimit: 10,
-      attachmentAccept: ".pdf,.jpg,.jpeg,.png,.doc,.docx,.xls,.xlsx,.ppt,.pptx,.txt",
+      attachmentAccept:
+        ".pdf,.jpg,.jpeg,.png,.doc,.docx,.xls,.xlsx,.ppt,.pptx,.txt",
       // 缂栬緫瀵硅瘽妗�
       editDialogVisible: false,
       currentRecord: {},
@@ -910,22 +799,48 @@
     currentUser() {
       return JSON.parse(sessionStorage.getItem("user") || "{}");
     },
+    displayOrgans() {
+      return (this.procurementData.serviceDonationwitnessorgans || []).filter(
+        item => item.delFlag !== 1
+      );
+    },
+    categories() {
+      // 濮嬬粓杩斿洖鎵�鏈夐璁惧垎绫� + 鏈垎绫伙紝鏃犺鏄惁鏈夋暟鎹�
+      return [
+        "鍘熻〃鎷嶇収",
+        "浼︾悊瀹℃煡鏉愭枡",
+        "姝讳骸鍒ゅ畾鏉愭枡",
+        "榛樺搥浠紡鐓х墖",
+        "鎹愮尞瑙佽瘉瑙嗛",
+        "鏈垎绫�"
+      ];
+    },
+    organReverseMap() {
+      const map = {};
+      for (const key in this.organExpansionMap) {
+        const { subItems } = this.organExpansionMap[key];
+        subItems.forEach(item => {
+          map[item] = key;
+        });
+      }
+      return map;
+    },
     // 涓嶅畬鏁寸殑璁板綍鏁伴噺
     incompleteRecords() {
       if (!this.procurementData.serviceDonationwitnessorgans) return 0;
       return this.procurementData.serviceDonationwitnessorgans.filter(
         record =>
           !record.organStartTime ||
-          !record.organGetTime ||
-          !record.gainHospitalNo ||
-          !record.organGetDoctor
+          !record.organgettime ||
+          !record.gainhospitalno ||
+          !record.organgetdoct
       ).length;
     },
     // 鍞竴鍖婚櫌鏁伴噺
     uniqueHospitals() {
       if (!this.procurementData.serviceDonationwitnessorgans) return 0;
       const hospitals = this.procurementData.serviceDonationwitnessorgans
-        .map(record => record.gainHospitalNo)
+        .map(record => record.gainhospitalno)
         .filter(Boolean);
       return new Set(hospitals).size;
     },
@@ -973,7 +888,7 @@
       }
 
       this.form.infoid = infoid;
-      this.generateDonorNo();
+      // this.generateDonorNo();
 
       if (infoid) {
         this.getDetail(infoid);
@@ -981,12 +896,17 @@
 
       this.getHospitalData();
     },
-    // 鐢熸垚鎹愮尞鑰呯紪鍙�
-    generateDonorNo() {
-      const timestamp = Date.now().toString();
-      this.form.donorno = "D" + timestamp.slice(-8);
-      this.form.caseNo = "CASE" + timestamp.slice(-6);
-      this.form.inpatientno = "IP" + timestamp.slice(-6);
+    getOrganNameByNo(organno) {
+      // 妫�鏌ユ槸鍚﹀湪鏄犲皠鐨勫瓙椤逛腑
+      for (const key in this.organExpansionMap) {
+        const { subItems, subNames } = this.organExpansionMap[key];
+        const idx = subItems.indexOf(organno);
+        if (idx !== -1) {
+          return subNames[idx];
+        }
+      }
+      // 鍚﹀垯浠庡瓧鍏镐腑鑾峰彇
+      return this.getOrganLabel(organno);
     },
     // 鑾峰彇璇︽儏
     async getDetail(infoid) {
@@ -999,15 +919,34 @@
           response.data.length > 0
         ) {
           const data = response.data[0];
+          if (!data.witnessState || data.witnessState == 1) {
+            data.witnessState = "2";
+          }
 
           // 濉厖琛ㄥ崟鏁版嵁
           Object.assign(this.form, data);
 
           // 鍒濆鍖栭檮浠�
-          if (this.form.attachments) {
-            this.attachments = Array.isArray(this.form.attachments)
-              ? [...this.form.attachments]
-              : [];
+          if (this.form.deathjudgeannex) {
+            const parsed = JSON.parse(this.form.deathjudgeannex);
+            this.attachments = parsed.map(item => ({
+              ...item,
+              fileType: item.fileType || "" // 榛樿绌哄瓧绗︿覆琛ㄧず鏈垎绫�
+            }));
+            this.form.attachments = this.attachments;
+            // 鍚屾 attachmentFileList
+            this.attachmentFileList = this.attachments.map(item => ({
+              uid: item.id || Math.random(),
+              name: item.fileName,
+              url: item.path || item.fileUrl,
+              fileSize: item.fileSize,
+              uploadTime: item.uploadTime,
+              status: "success",
+              raw: item
+            }));
+          } else {
+            this.attachments = [];
+            this.attachmentFileList = [];
           }
 
           // 澶勭悊鎹愮尞鍣ㄥ畼瀛楁
@@ -1029,6 +968,7 @@
           }
 
           this.$message.success("鏁版嵁鍔犺浇鎴愬姛");
+          this.syncOrgansFromSelection();
         } else {
           this.$message.warning("鏈壘鍒板搴旂殑鍣ㄥ畼鑾峰彇鏁版嵁");
         }
@@ -1038,6 +978,52 @@
       } finally {
         this.loading = false;
       }
+    },
+    syncOrgansFromSelection() {
+      const records = this.procurementData.serviceDonationwitnessorgans || [];
+      const targetNos = [];
+      this.selectedOrgans.forEach(val => {
+        if (this.organExpansionMap[val]) {
+          targetNos.push(...this.organExpansionMap[val].subItems);
+        } else {
+          targetNos.push(val);
+        }
+      });
+
+      // 鏂板鎴栨仮澶�
+      targetNos.forEach(no => {
+        const existing = records.find(r => r.organno === no);
+        if (existing) {
+          if (existing.delFlag === 1) {
+            existing.delFlag = 0; // 鎭㈠鏄剧ず
+          }
+        } else {
+          records.push({
+            id: null,
+            organname: this.getOrganNameByNo(no),
+            organno: no,
+            organStartTime: "",
+            organgettime: "",
+            gainhospitalno: "",
+            gainhospitalname: "",
+            organgetdoct: "",
+            assistant: "",
+            procurementNurse: "",
+            operatingRoomNurse: "",
+            anesthesiologist: "",
+            organstate: "1",
+            notgetreason: "",
+            delFlag: 0
+          });
+        }
+      });
+
+      // 锛堝彲閫夛級濡傛灉鍔犺浇鏃跺悗绔繑鍥炰簡 delFlag=1 鐨勮褰曪紝浣嗗疄闄呭簲璇ユ樉绀猴紝寮哄埗閲嶇疆
+      records.forEach(r => {
+        if (r.delFlag === 1) r.delFlag = 0;
+      });
+
+      this.form.organdonation = this.selectedOrgans.join(",");
     },
     // 鑾峰彇鍖婚櫌鏁版嵁
     async getHospitalData() {
@@ -1056,84 +1042,142 @@
         this.$message.error("鑾峰彇鍖婚櫌鏁版嵁澶辫触");
       }
     },
+    // 绉绘鍖婚櫌妯$硦鎼滅储
+    queryHospitalSearch(queryString, cb) {
+      const hospitals = this.dict.type.Geta_hospital || [];
+      const results = queryString
+        ? hospitals.filter(item =>
+            item.label.toLowerCase().includes(queryString.toLowerCase())
+          )
+        : hospitals;
+
+      // el-autocomplete 闇�瑕� value 瀛楁
+      cb(results.map(item => ({ value: item.label })));
+    },
     // 鍣ㄥ畼閫夋嫨鐘舵�佸彉鍖�
-    handleOrganSelectionChange(selectedValues) {
-      if (!this.procurementData.serviceDonationwitnessorgans) {
-        this.procurementData.serviceDonationwitnessorgans = [];
-      }
-
-      const currentOrganValues = this.procurementData.serviceDonationwitnessorgans.map(
-        item => item.organno
-      );
-
-      // 澶勭悊浜掓枼閫昏緫
+    async handleOrganSelectionChange(selectedValues) {
+      // 1. 澶勭悊浜掓枼閫昏緫锛堜慨鏀� this.selectedOrgans锛�
       this.handleExclusiveSelections(selectedValues);
 
-      // 鏇存柊鎹愮尞鍣ㄥ畼瀛楁
-      this.form.organdonation = selectedValues.join(",");
+      const finalSelected = this.selectedOrgans;
+      const records = this.procurementData.serviceDonationwitnessorgans || [];
 
-      // 鏂板閫夋嫨鐨勫櫒瀹�
-      selectedValues.forEach(organValue => {
-        if (!currentOrganValues.includes(organValue)) {
-          this.createOrganRecord(organValue);
+      // 2. 鏋勫缓鐩爣鍣ㄥ畼缂栧彿鍒楄〃锛堝睍寮�缁勫悎鍣ㄥ畼锛�
+      const targetOrganNos = [];
+      finalSelected.forEach(val => {
+        if (this.organExpansionMap[val]) {
+          targetOrganNos.push(...this.organExpansionMap[val].subItems);
+        } else {
+          targetOrganNos.push(val);
         }
       });
 
-      // 绉婚櫎鍙栨秷閫夋嫨鐨勫櫒瀹�
-      this.procurementData.serviceDonationwitnessorgans = this.procurementData.serviceDonationwitnessorgans.filter(
-        record => {
-          if (selectedValues.includes(record.organno)) {
-            return true;
-          } else {
-            if (record.id) {
-              this.$confirm(
-                "鍒犻櫎鍣ㄥ畼鑾峰彇鏁版嵁鍚庡皢鏃犳硶鎭㈠锛屾偍纭鍒犻櫎璇ユ潯璁板綍鍚楋紵",
-                "鎻愮ず",
-                {
-                  confirmButtonText: "纭畾",
-                  cancelButtonText: "鍙栨秷",
-                  type: "warning"
-                }
-              )
-                .then(() => {
-                  this.procurementData.serviceDonationwitnessorgans = this.procurementData.serviceDonationwitnessorgans.filter(
-                    r => r.organno !== record.organno
-                  );
-                  this.$message.success("鍒犻櫎鎴愬姛");
-                })
-                .catch(() => {
-                  this.selectedOrgans.push(record.organno);
-                });
-              return true;
-            } else {
-              return false;
-            }
+      // 3. 鏂板鎴栨仮澶嶇洰鏍囧櫒瀹樿褰曪紙鏃犲脊绐楋級
+      targetOrganNos.forEach(no => {
+        const existing = records.find(r => r.organno === no);
+        if (existing) {
+          if (existing.delFlag === 1) {
+            existing.delFlag = 0; // 鎭㈠鏄剧ず
           }
+        } else {
+          records.push({
+            id: null,
+            organname: this.getOrganNameByNo(no),
+            organno: no,
+            organStartTime: "",
+            organgettime: "",
+            gainhospitalno: "",
+            gainhospitalname: "",
+            organgetdoct: "",
+            assistant: "",
+            procurementNurse: "",
+            operatingRoomNurse: "",
+            anesthesiologist: "",
+            organstate: "1",
+            notgetreason: "",
+            delFlag: 0
+          });
         }
-      );
+      });
+
+      // 4. 鎵惧嚭闇�瑕佸彇娑堢殑璁板綍锛堜笉鍦ㄧ洰鏍囬泦鍚堜腑锛�
+      const toRemove = records.filter(r => !targetOrganNos.includes(r.organno));
+      const toRemoveSaved = toRemove.filter(r => r.id); // 宸蹭繚瀛橈紝闇�纭
+      const toRemoveUnsaved = toRemove.filter(r => !r.id); // 鏈繚瀛橈紝鐩存帴绉婚櫎
+
+      // 4.1 鐩存帴绉婚櫎鏈繚瀛樼殑璁板綍
+      toRemoveUnsaved.forEach(r => {
+        const idx = records.indexOf(r);
+        if (idx !== -1) records.splice(idx, 1);
+      });
+
+      // 4.2 澶勭悊宸蹭繚瀛樼殑璁板綍锛氬脊绐楃‘璁�
+      if (toRemoveSaved.length > 0) {
+        const organNames = toRemoveSaved.map(r => r.organname).join("銆�");
+        try {
+          await this.$confirm(
+            `鎮ㄧ‘瀹氳鍙栨秷浠ヤ笅宸蹭繚瀛樼殑鍣ㄥ畼鑾峰彇璁板綍鍚楋紵\n${organNames}\n鍙栨秷鍚庯紝杩欎簺璁板綍灏嗕粠鍒楄〃涓Щ闄わ紙鏁版嵁浠嶄繚鐣欙紝鍙仮澶嶏級銆俙,
+            "鎻愮ず",
+            {
+              confirmButtonText: "纭畾绉婚櫎",
+              cancelButtonText: "鍙栨秷",
+              type: "warning"
+            }
+          );
+          // 鐢ㄦ埛纭锛氭爣璁� delFlag=1
+          toRemoveSaved.forEach(r => {
+            r.delFlag = 1;
+          });
+        } catch (error) {
+          // 鐢ㄦ埛鍙栨秷锛氭仮澶嶉�変腑鐘舵��
+          const parentToRestore = new Set();
+          toRemoveSaved.forEach(r => {
+            const parent = this.organReverseMap[r.organno];
+            if (parent) {
+              parentToRestore.add(parent);
+            } else {
+              parentToRestore.add(r.organno);
+            }
+          });
+          parentToRestore.forEach(val => {
+            if (!this.selectedOrgans.includes(val)) {
+              this.selectedOrgans.push(val);
+            }
+          });
+          this.$message.info("宸插彇娑堝垹闄ゆ搷浣�");
+          // 鏇存柊琛ㄥ崟瀛楁锛堜繚鎸佷竴鑷存�э級
+          this.form.organdonation = this.selectedOrgans.join(",");
+          return; // 閫�鍑烘柟娉曪紝閬垮厤缁х画鎵ц
+        }
+      }
+
+      // 5. 鏇存柊琛ㄥ崟瀛楁
+      this.form.organdonation = this.selectedOrgans.join(",");
     },
 
     // 澶勭悊浜掓枼閫夋嫨
     handleExclusiveSelections(selectedValues) {
-      // 濡傛灉閫夋嫨浜�"鍙岃偩"(鍋囪瀛楀吀鍊间负C64)锛岃嚜鍔ㄥ彇娑堝崟鐙殑"宸﹁偩"(C64L)鍜�"鍙宠偩"(C64R)閫夋嫨
+      // 鍙岃偩涓庡乏鍙宠偩浜掓枼
       if (selectedValues.includes("C64")) {
         this.selectedOrgans = selectedValues.filter(
           item => item !== "C64L" && item !== "C64R"
         );
-      }
-      // 濡傛灉閫夋嫨浜�"宸﹁偩"鎴�"鍙宠偩"锛屽彇娑�"鍙岃偩"閫夋嫨
-      else if (selectedValues.includes("C64L") || selectedValues.includes("C64R")) {
+      } else if (
+        selectedValues.includes("C64L") ||
+        selectedValues.includes("C64R")
+      ) {
         this.selectedOrgans = selectedValues.filter(item => item !== "C64");
       }
 
-      // 濡傛灉閫夋嫨浜�"鍏ㄨ偤"(鍋囪瀛楀吀鍊间负C34)锛岃嚜鍔ㄥ彇娑堝崟鐙殑"宸﹁偤"(C34L)鍜�"鍙宠偤"(C34R)閫夋嫨
+      // 鍏ㄨ偤涓庡乏鍙宠偤浜掓枼
       if (selectedValues.includes("C34")) {
         this.selectedOrgans = selectedValues.filter(
           item => item !== "C34L" && item !== "C34R"
         );
-      }
-      // 濡傛灉閫夋嫨浜�"宸﹁偤"鎴�"鍙宠偤"锛屽彇娑�"鍏ㄨ偤"閫夋嫨
-      else if (selectedValues.includes("C34L") || selectedValues.includes("C34R")) {
+      } else if (
+        selectedValues.includes("C34L") ||
+        selectedValues.includes("C34R")
+      ) {
         this.selectedOrgans = selectedValues.filter(item => item !== "C34");
       }
     },
@@ -1147,16 +1191,16 @@
         organname: organName,
         organno: organValue,
         organStartTime: "",
-        organGetTime: "",
-        gainHospitalNo: "",
-        gainHospitalName: "",
-        organGetDoctor: "",
+        organgettime: "",
+        gainhospitalno: "",
+        gainhospitalname: "",
+        organgetdoct: "",
         assistant: "",
         procurementNurse: "",
         operatingRoomNurse: "",
         anesthesiologist: "",
-        organState: "1",
-        notGetReason: ""
+        organstate: "1",
+        notgetreason: ""
       });
     },
 
@@ -1166,7 +1210,7 @@
         item => item.hospitalNo === hospitalNo
       );
       if (hospital) {
-        row.gainHospitalName = hospital.hospitalName;
+        row.gainhospitalname = hospital.hospitalName;
       }
     },
     // 缂栬緫鑾峰彇璁板綍
@@ -1183,7 +1227,9 @@
     // 纭缂栬緫
     handleEditConfirm() {
       if (this.currentEditIndex !== -1) {
-        this.procurementData.serviceDonationwitnessorgans[this.currentEditIndex] = {
+        this.procurementData.serviceDonationwitnessorgans[
+          this.currentEditIndex
+        ] = {
           ...this.currentRecord
         };
         this.$message.success("鑾峰彇璁板綍鏇存柊鎴愬姛");
@@ -1194,9 +1240,9 @@
     getOrganRowClassName({ row }) {
       if (
         !row.organStartTime ||
-        !row.organGetTime ||
-        !row.gainHospitalNo ||
-        !row.organGetDoctor
+        !row.organgettime ||
+        !row.gainhospitalno ||
+        !row.organgetdoct
       ) {
         return "warning-row";
       }
@@ -1208,13 +1254,19 @@
         if (valid) {
           this.saveLoading = true;
           try {
+            console.log(this.procurementData.serviceDonationwitnessorgans);
+
             const saveData = {
               ...this.form,
-              attachments: this.attachments,
+              deathjudgeannex: JSON.stringify(this.attachments),
               organdonation: this.selectedOrgans.join(","),
+              serviceDonationwitnessorganList:
+                this.procurementData.serviceDonationwitnessorgans || [],
               serviceDonationwitnessorgans:
                 this.procurementData.serviceDonationwitnessorgans || []
             };
+            console.log(saveData.serviceDonationwitnessorganList);
+            console.log(saveData.serviceDonationwitnessorgans);
 
             const apiMethod = this.form.id ? witnessedit : witnessadd;
             const response = await apiMethod(saveData);
@@ -1286,11 +1338,13 @@
       })
         .then(async () => {
           this.confirmLoading = true;
-          this.form.recordstate = "completed";
-          this.form.operationendtime = this.form.operationendtime || new Date()
-            .toISOString()
-            .replace("T", " ")
-            .substring(0, 19);
+          this.form.witnessState = "3";
+          this.form.operationendtime =
+            this.form.operationendtime ||
+            new Date()
+              .toISOString()
+              .replace("T", " ")
+              .substring(0, 19);
 
           try {
             const saveData = {
@@ -1309,13 +1363,13 @@
               this.$message.error(
                 "纭鑾峰彇澶辫触锛�" + (response.msg || "鏈煡閿欒")
               );
-              this.form.recordstate = "pending";
+              this.form.witnessState = "2";
               this.form.operationendtime = "";
             }
           } catch (error) {
             console.error("纭鑾峰彇澶辫触:", error);
             this.$message.error("纭鑾峰彇澶辫触");
-            this.form.recordstate = "pending";
+            this.form.witnessState = "2";
             this.form.operationendtime = "";
           } finally {
             this.confirmLoading = false;
@@ -1335,40 +1389,101 @@
     },
 
     /** 闄勪欢绉婚櫎澶勭悊 */
-    handleAttachmentRemove(file) {
-      if (file.url) {
-        const index = this.attachments.findIndex(
-          item => item.path === file.url || item.fileUrl === file.url
-        );
-        if (index > -1) {
-          this.attachments.splice(index, 1);
-          this.$message.success("闄勪欢鍒犻櫎鎴愬姛");
-        }
-      }
-    },
+   handleAttachmentRemove(file) {
+  // 鐩存帴璋冪敤鏂扮殑鍒犻櫎鏂规硶
+  if (file.raw) {
+    this.handleRemoveAttachmentByFile(file.raw);
+  } else if (file.url) {
+    const target = this.attachments.find(
+      item => item.path === file.url || item.fileUrl === file.url
+    );
+    if (target) {
+      this.handleRemoveAttachmentByFile(target);
+    }
+  }
+},
 
     /** 涓婁紶鎴愬姛澶勭悊 */
     handleUploadSuccess({ file, fileList, response }) {
-      if (response.code === 200) {
-        const attachmentObj = {
-          fileName: file.name,
-          path: response.fileUrl || file.url,
-          fileUrl: response.fileUrl || file.url,
-          fileType: this.getFileExtension(file.name),
-          fileSize: file.size,
-          uploadTime: dayjs().format("YYYY-MM-DD HH:mm:ss")
-        };
+  if (response.code === 200) {
+    // 鏍规嵁褰撳墠婵�娲荤殑 Tab 鍐冲畾鍒嗙被锛堟湭鍒嗙被 Tab 瀵瑰簲绌哄瓧绗︿覆锛�
+    const category = this.activeTab === '鏈垎绫�' ? '' : this.activeTab;
+    const attachmentObj = {
+      fileName: file.name,
+      path: response.fileUrl || file.url,
+      fileUrl: response.fileUrl || file.url,
+      fileType: category,                    // 鍏抽敭锛氳褰曞垎绫�
+      fileSize: file.size,
+      uploadTime: dayjs().format('YYYY-MM-DD HH:mm:ss')
+    };
 
-        if (!Array.isArray(this.attachments)) {
-          this.attachments = [];
-        }
+    if (!Array.isArray(this.attachments)) {
+      this.attachments = [];
+    }
+    this.attachments.push(attachmentObj);
+    this.attachmentFileList = fileList;
+    this.$message.success('鏂囦欢涓婁紶鎴愬姛');
+  }
+},
+// 鑾峰彇鏌愬垎绫荤殑鏂囦欢鏁伴噺
+getCategoryCount(category) {
+  return this.attachments.filter(item => {
+    const type = item.fileType || '';
+    if (category === '鏈垎绫�') {
+      return !this.presetCategories.includes(type);
+    }
+    return type === category;
+  }).length;
+},
 
-        this.attachments.push(attachmentObj);
-        this.attachmentFileList = fileList;
-        this.$message.success("鏂囦欢涓婁紶鎴愬姛");
-      }
-    },
+// 鑾峰彇鏌愬垎绫荤殑鏂囦欢鍒楄〃
+getCategoryFiles(category) {
+  return this.attachments.filter(item => {
+    const type = item.fileType || '';
+    if (category === '鏈垎绫�') {
+      return !this.presetCategories.includes(type);
+    }
+    return type === category;
+  });
+},
 
+// 鏇存柊闄勪欢鍒嗙被锛堜笅鎷変慨鏀规椂瑙﹀彂锛�
+updateAttachmentCategory(row, newVal) {
+  const target = this.attachments.find(item => item === row);
+  if (target) {
+    target.fileType = newVal; // 鍙兘涓虹┖瀛楃涓�
+    // 鍚屾鏇存柊 attachmentFileList
+    const fileItem = this.attachmentFileList.find(
+      f => f.raw === row || f.url === row.fileUrl
+    );
+    if (fileItem) {
+      fileItem.raw.fileType = newVal;
+      fileItem.fileType = newVal || '鏈垎绫�';
+    }
+    // 濡傛灉褰撳墠婵�娲荤殑tab娌℃湁鏂囦欢浜嗭紝鑷姩鍒囨崲鍒扮涓�涓湁鏂囦欢鐨則ab
+    const currentTabHasFiles = this.getCategoryFiles(this.activeTab).length > 0;
+    if (!currentTabHasFiles) {
+      const firstCategory = this.categories[0];
+      if (firstCategory) this.activeTab = firstCategory;
+    }
+  }
+},
+
+// 鎸夋枃浠跺璞″垹闄わ紙鐢ㄤ簬琛ㄦ牸涓殑鍒犻櫎鎸夐挳锛�
+handleRemoveAttachmentByFile(file) {
+  const index = this.attachments.findIndex(item => item === file);
+  if (index > -1) {
+    this.attachments.splice(index, 1);
+    // 鍚屾鍒犻櫎 attachmentFileList
+    const fileIndex = this.attachmentFileList.findIndex(
+      f => f.raw === file || f.url === file.fileUrl
+    );
+    if (fileIndex > -1) {
+      this.attachmentFileList.splice(fileIndex, 1);
+    }
+    this.$message.success('闄勪欢鍒犻櫎鎴愬姛');
+  }
+},
     /** 涓婁紶閿欒澶勭悊 */
     handleUploadError({ file, fileList, error }) {
       console.error("闄勪欢涓婁紶澶辫触:", error);
@@ -1415,7 +1530,10 @@
     /** 鑾峰彇鏂囦欢绫诲瀷 */
     getFileType(fileName) {
       if (!fileName) return "other";
-      const extension = fileName.split(".").pop().toLowerCase();
+      const extension = fileName
+        .split(".")
+        .pop()
+        .toLowerCase();
       const imageTypes = ["jpg", "jpeg", "png", "gif", "bmp", "webp"];
       const pdfTypes = ["pdf"];
       const officeTypes = ["doc", "docx", "xls", "xlsx", "ppt", "pptx"];
@@ -1469,7 +1587,10 @@
 
     /** 鑾峰彇鏂囦欢鎵╁睍鍚� */
     getFileExtension(filename) {
-      return filename.split(".").pop().toLowerCase();
+      return filename
+        .split(".")
+        .pop()
+        .toLowerCase();
     },
 
     /** 鏍煎紡鍖栨枃浠跺ぇ灏� */

--
Gitblit v1.9.3