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/allocation/allocationInfo.vue | 2160 ++++++++++++++++++++++++++++++++++++++++++-----------------
 1 files changed, 1,518 insertions(+), 642 deletions(-)

diff --git a/src/views/business/allocation/allocationInfo.vue b/src/views/business/allocation/allocationInfo.vue
index fcda788..1ab3aab 100644
--- a/src/views/business/allocation/allocationInfo.vue
+++ b/src/views/business/allocation/allocationInfo.vue
@@ -1,109 +1,37 @@
 <template>
   <div class="organ-allocation-detail">
+    <case-basic-info :case-id="caseId" :show-attachment="true" />
     <!-- 鍩烘湰淇℃伅閮ㄥ垎 -->
     <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="handleAllocate"
-            :disabled="form.allocationStatus === 'allocated'"
-          >
-            纭鍒嗛厤
-          </el-button>
-        </div>
       </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="hospitalNo">
-              <el-input v-model="form.hospitalNo" readonly />
-            </el-form-item>
-          </el-col>
-          <el-col :span="8">
-            <el-form-item label="妗堜緥缂栧彿" prop="caseNo">
-              <el-input v-model="form.caseNo" readonly />
-            </el-form-item>
-          </el-col>
-          <el-col :span="8">
-            <el-form-item label="鎹愮尞鑰呭鍚�" prop="donorName">
-              <el-input v-model="form.donorName" />
-            </el-form-item>
-          </el-col>
-        </el-row>
-
-        <el-row :gutter="20">
-          <el-col :span="8">
-            <el-form-item label="鎬у埆" prop="gender">
-              <el-select v-model="form.gender" style="width: 100%">
-                <el-option label="鐢�" value="0" />
-                <el-option label="濂�" value="1" />
-              </el-select>
-            </el-form-item>
-          </el-col>
-          <el-col :span="8">
-            <el-form-item label="骞撮緞" prop="age">
-              <el-input v-model="form.age" />
-            </el-form-item>
-          </el-col>
-          <el-col :span="8">
-            <el-form-item label="鍑虹敓鏃ユ湡" prop="birthDate">
-              <el-date-picker
-                v-model="form.birthDate"
-                type="date"
-                value-format="yyyy-MM-dd"
-                style="width: 100%"
-              />
-            </el-form-item>
-          </el-col>
-        </el-row>
-
-        <el-row :gutter="20">
           <el-col :span="12">
-            <el-form-item label="鐤剧梾璇婃柇" prop="diagnosis">
-              <el-input
-                type="textarea"
-                :rows="2"
-                v-model="form.diagnosis"
-                placeholder="璇疯緭鍏ョ柧鐥呰瘖鏂俊鎭�"
-              />
+            <el-form-item label="鍒嗛厤鐘舵��" prop="allocationStatus">
+              <el-select v-model="form.allocationStatus" placeholder="璇烽�夋嫨鍒嗛厤鐘舵��">
+                <el-option v-for="dict in dict.type.organ_allocation_status || []" :key="dict.value" :label="dict.label"
+                  :value="dict.value"></el-option>
+              </el-select>
             </el-form-item>
           </el-col>
           <el-col :span="12">
             <el-form-item label="鍒嗛厤鏃堕棿" prop="allocationTime">
-              <el-date-picker
-                v-model="form.allocationTime"
-                type="datetime"
-                value-format="yyyy-MM-dd HH:mm:ss"
-                style="width: 100%"
-                :disabled="form.allocationStatus !== 'allocated'"
-              />
+              <el-date-picker v-model="form.allocationTime" type="datetime" value-format="yyyy-MM-dd HH:mm:ss"
+                style="width: 100%" :disabled="form.allocationStatus == '1'" />
             </el-form-item>
           </el-col>
         </el-row>
 
         <el-row :gutter="20">
           <el-col :span="12">
-            <el-form-item label="鐧昏浜�" prop="registrant">
-              <el-input v-model="form.registrant" />
+            <el-form-item label="璐熻矗浜�" prop="registrationName">
+              <el-input v-model="form.registrationName" />
             </el-form-item>
           </el-col>
-          <el-col :span="12">
-            <el-form-item label="鐧昏鏃堕棿" prop="registrationTime">
-              <el-date-picker
-                v-model="form.registrationTime"
-                type="datetime"
-                value-format="yyyy-MM-dd HH:mm:ss"
-                style="width: 100%"
-                readonly
-              />
-            </el-form-item>
-          </el-col>
+
         </el-row>
       </el-form>
     </el-card>
@@ -113,38 +41,22 @@
       <div slot="header" class="clearfix">
         <span class="detail-title">鍣ㄥ畼鍒嗛厤璁板綍</span>
         <div style="float: right;">
-          <el-tag
-            :type="
-              form.allocationStatus === 'allocated' ? 'success' : 'warning'
-            "
-          >
-            {{ form.allocationStatus === "allocated" ? "宸插垎閰�" : "寰呭垎閰�" }}
-          </el-tag>
+          <dict-tag :options="dict.type.organ_allocation_status" :value="form.allocationStatus" />
         </div>
       </div>
 
-      <el-form
-        ref="allocationForm"
-        :rules="allocationRules"
-        :model="allocationData"
-        label-position="right"
-      >
+      <el-form ref="allocationForm" :rules="allocationRules" :model="allocationData" label-position="right">
         <el-row>
           <el-col>
             <el-form-item label-width="100px" label="鍒嗛厤鍣ㄥ畼">
-              <el-checkbox-group
-                v-model="selectedOrgans"
-                @change="handleOrganSelectionChange"
-              >
-                <el-checkbox
-                  v-for="organ in organDict"
-                  :key="organ.value"
-                  :label="organ.value"
-                  :disabled="form.allocationStatus === 'allocated'"
-                >
-                  {{ organ.label }}
+              <el-checkbox-group v-model="selectedOrgans" @change="handleOrganSelectionChange">
+                <el-checkbox v-for="dict in dict.type.sys_Organ || []" :key="dict.value" :label="dict.value"
+                  :disabled="form.allocationStatus == '1'">
+                  {{ dict.label }}
                 </el-checkbox>
               </el-checkbox-group>
+              <el-input v-if="showOtherInput" v-model="otherOrganInput" placeholder="璇疯緭鍏ュ叾浠栧櫒瀹樺悕绉�"
+                style="margin-top: 10px; width: 300px;" :disabled="form.allocationStatus == '1'" />
             </el-form-item>
           </el-col>
         </el-row>
@@ -152,135 +64,139 @@
         <el-row>
           <el-col>
             <el-form-item>
-              <el-table
-                :data="allocationData.records"
-                v-loading="loading"
-                border
-                style="width: 100%"
-                :row-class-name="getOrganRowClassName"
-              >
-                <el-table-column
-                  label="鍣ㄥ畼鍚嶇О"
-                  align="center"
-                  width="120"
-                  prop="organName"
-                >
+              <el-table :data="displayOrgans" v-loading="loading" border style="width: 100%"
+                :row-class-name="getOrganRowClassName">
+                <el-table-column label="搴忓彿" type="index" width="60" align="center" fixed></el-table-column>
+
+                <el-table-column label="鍒嗛厤鐘舵��" align="center" width="100" prop="allocationstatus" fixed>
                   <template slot-scope="scope">
-                    <el-input
-                      v-model="scope.row.organName"
-                      placeholder="鍣ㄥ畼鍚嶇О"
-                      :disabled="true"
-                    />
+                    <el-tag :type="getAllocationStatusTagType(scope.row.allocationstatus)
+                      " size="small">
+                      {{ getAllocationStatusText(scope.row.allocationstatus) }}
+                    </el-tag>
                   </template>
                 </el-table-column>
 
-                <el-table-column
+                <el-table-column label="鍣ㄥ畼鍚嶇О" align="center" width="120" prop="organname">
+                  <template slot-scope="scope">
+                    <el-input v-model="scope.row.organname" placeholder="鍣ㄥ畼鍚嶇О" :disabled="true" />
+                  </template>
+                </el-table-column>
+
+                <!-- <el-table-column
                   label="鍒嗛厤绯荤粺缂栧彿"
                   align="center"
                   width="150"
-                  prop="systemNo"
+                  prop="caseno"
                 >
                   <template slot-scope="scope">
                     <el-input
-                      v-model="scope.row.systemNo"
+                      v-model="scope.row.caseno"
                       placeholder="鍒嗛厤绯荤粺缂栧彿"
-                      :disabled="form.allocationStatus === 'allocated'"
+                      :disabled="
+                        form.allocationStatus == '1' ||
+                          scope.row.allocationstatus == '3'
+                      "
                     />
+                  </template>
+                </el-table-column> -->
+
+                <el-table-column label="鍒嗛厤寮�濮嬫椂闂�" align="center" width="180" prop="applicanttime">
+                  <template slot-scope="scope">
+                    <el-date-picker clearable size="small" style="width: 100%" v-model="scope.row.applicanttime"
+                      type="datetime" value-format="yyyy-MM-dd HH:mm:ss" placeholder="閫夋嫨寮�濮嬫帴鏀舵椂闂�" :disabled="form.allocationStatus == '1' ||
+                        scope.row.allocationstatus == '3'
+                        " />
+                  </template>
+                </el-table-column>
+                <el-table-column label="鍒嗛厤鎺ユ敹鏃堕棿" align="center" width="180" prop="organgettime">
+                  <template slot-scope="scope">
+                    <el-date-picker clearable size="small" style="width: 100%" v-model="scope.row.organgettime"
+                      type="datetime" value-format="yyyy-MM-dd HH:mm:ss" placeholder="閫夋嫨鍒嗛厤鎺ユ敹鏃堕棿" :disabled="form.allocationStatus == '1' ||
+                        scope.row.allocationstatus == '3'
+                        " />
                   </template>
                 </el-table-column>
 
-                <el-table-column
-                  label="鍒嗛厤鎺ユ敹鏃堕棿"
-                  align="center"
-                  width="180"
-                  prop="applicantTime"
-                >
+                <el-table-column label="鍙椾綋濮撴皬" align="center" width="120" prop="name">
                   <template slot-scope="scope">
-                    <el-date-picker
-                      clearable
-                      size="small"
-                      style="width: 100%"
-                      v-model="scope.row.applicantTime"
-                      type="datetime"
-                      value-format="yyyy-MM-dd HH:mm:ss"
-                      placeholder="閫夋嫨鍒嗛厤鎺ユ敹鏃堕棿"
-                      :disabled="form.allocationStatus === 'allocated'"
-                    />
+                    <el-input v-model="scope.row.name" placeholder="鍙椾綋濮撴皬" :disabled="form.allocationStatus == '1' ||
+                      scope.row.allocationstatus == '3'
+                      " />
                   </template>
                 </el-table-column>
 
-                <el-table-column
-                  label="鍙椾綋濮撴皬"
-                  align="center"
-                  width="120"
-                  prop="recipientName"
-                >
+                <el-table-column label="绉绘鍖婚櫌" align="center" width="200" prop="transplanthospitalname">
                   <template slot-scope="scope">
-                    <el-input
-                      v-model="scope.row.recipientName"
-                      placeholder="鍙椾綋濮撴皬"
-                      :disabled="form.allocationStatus === 'allocated'"
-                    />
+                    <el-autocomplete v-model="scope.row.transplanthospitalname" :fetch-suggestions="queryHospitalSearch"
+                      placeholder="璇烽�夋嫨鎴栬緭鍏ョЩ妞嶅尰闄�" style="width: 100%" clearable></el-autocomplete>
                   </template>
-                </el-table-column>
-
-                <el-table-column
-                  label="绉绘鍖婚櫌"
-                  align="center"
-                  width="200"
-                  prop="transplantHospitalNo"
-                >
-                  <template slot-scope="scope">
+                  <!-- <template slot-scope="scope">
                     <el-select
-                      v-model="scope.row.transplantHospitalNo"
+                      v-model="scope.row.transplanthospitalname"
                       placeholder="璇烽�夋嫨绉绘鍖婚櫌"
                       style="width: 100%"
-                      :disabled="form.allocationStatus === 'allocated'"
-                      @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> -->
+                </el-table-column>
+
+                <!-- 淇敼template涓殑璇存槑鍒� -->
+                <el-table-column label="璇存槑" align="center" prop="reallocationreason" min-width="200">
+                  <template slot-scope="scope">
+                    <div v-if="scope.row.allocationstatus != '3'">
+                      <el-input type="textarea" clearable v-model="scope.row.reallocationreason" placeholder="璇疯緭鍏ヨ鏄�"
+                        :disabled="form.allocationStatus == '1' ||
+                          scope.row.allocationstatus == '3'
+                          " />
+                    </div>
+                    <div v-else>
+                      <!-- 閲嶅垎閰嶈褰曪細鏄剧ず璇︾粏鏌ョ湅鎸夐挳 -->
+                      <el-button v-if="scope.row.reallocationreason" type="text" size="small"
+                        @click="handleViewRedistributionDetail(scope.row)" style="color: #e6a23c;">
+                        <i class="el-icon-document"></i>
+                        鏌ョ湅閲嶅垎閰嶈鎯�
+                      </el-button>
+                      <span v-else class="no-data">-</span>
+
+                      <!-- 淇濈暀鍘熸湁鐨勫伐鍏锋彁绀猴紙鍙Щ闄ゆ垨淇濈暀锛� -->
+                      <el-tooltip v-if="scope.row.redistributionInfo" :content="formatRedistributionTooltip(
+                        scope.row.redistributionInfo
+                      )
+                        " placement="top">
+                        <el-button type="text" size="small" style="margin-left: 5px;">
+                          <i class="el-icon-info"></i>
+                        </el-button>
+                      </el-tooltip>
+                    </div>
                   </template>
                 </el-table-column>
 
-                <el-table-column
-                  label="璇存槑"
-                  align="center"
-                  prop="reallocationReason"
-                  min-width="200"
-                >
+                <el-table-column label="鎿嶄綔" align="center" width="120" class-name="small-padding fixed-width"
+                  v-if="form.allocationStatus !== '1'" fixed="right">
                   <template slot-scope="scope">
-                    <el-input
-                      type="textarea"
-                      clearable
-                      v-model="scope.row.reallocationReason"
-                      placeholder="璇疯緭鍏ヨ鏄�"
-                      :disabled="form.allocationStatus === 'allocated'"
-                    />
-                  </template>
-                </el-table-column>
-
-                <el-table-column
-                  label="鎿嶄綔"
-                  align="center"
-                  width="120"
-                  class-name="small-padding fixed-width"
-                  v-if="form.allocationStatus !== 'allocated'"
-                >
-                  <template slot-scope="scope">
-                    <el-button
-                      size="mini"
-                      type="text"
-                      icon="el-icon-copy-document"
-                      @click="handleRedistribution(scope.row)"
-                      :disabled="!scope.row.systemNo"
-                    >
-                      閲嶅垎閰�
+                    <el-button size="mini" type="text" icon="el-icon-copy-document"
+                      @click="handleRedistribution(scope.row)" :disabled="scope.row.allocationstatus == '3'"
+                      style="color: #e6a23c;">
+                      {{
+                        scope.row.allocationstatus == "3"
+                          ? "宸查噸鍒嗛厤"
+                          : "閲嶅垎閰�"
+                      }}
+                    </el-button>
+                    <el-button v-if="scope.row.allocationstatus != '3'" size="mini" type="text" icon="el-icon-delete"
+                      @click="handleInvalidate(scope.row)" :disabled="scope.row.allocationstatus == '3' ||
+                        scope.row.allocationstatus == '2'
+                        " style="color: #f56c6c;">
+                      {{
+                        scope.row.allocationstatus == "2" ? "宸蹭綔搴�" : "浣滃簾"
+                      }}
                     </el-button>
                   </template>
                 </el-table-column>
@@ -290,20 +206,26 @@
         </el-row>
 
         <!-- 鍒嗛厤缁熻淇℃伅 -->
-        <div class="allocation-stats" v-if="allocationData.records.length > 0">
+        <!-- <div
+          class="allocation-stats"
+          v-if="
+            allocationData.serviceDonateorganList &&
+              allocationData.serviceDonateorganList.length > 0
+          "
+        >
           <el-row :gutter="20">
             <el-col :span="6">
               <div class="stat-item">
                 <span class="stat-label">宸插垎閰嶅櫒瀹�:</span>
                 <span class="stat-value"
-                  >{{ allocationData.records.length }} 涓�</span
+                  >{{ allocationData.serviceDonateorganList.length }} 涓�</span
                 >
               </div>
             </el-col>
             <el-col :span="6">
               <div class="stat-item">
-                <span class="stat-label">寰呭畬鍠勪俊鎭�:</span>
-                <span class="stat-value">{{ incompleteRecords }} 涓�</span>
+                <span class="stat-label">寰呭鏍�:</span>
+                <span class="stat-value">{{ pendingReviewCount }} 涓�</span>
               </div>
             </el-col>
             <el-col :span="6">
@@ -314,233 +236,342 @@
             </el-col>
             <el-col :span="6">
               <div class="stat-item">
-                <span class="stat-label">鍒嗛厤鐘舵��:</span>
-                <span class="stat-value">
-                  <el-tag
-                    :type="
-                      form.allocationStatus === 'allocated'
-                        ? 'success'
-                        : 'warning'
-                    "
-                  >
-                    {{
-                      form.allocationStatus === "allocated"
-                        ? "宸插畬鎴�"
-                        : "杩涜涓�"
-                    }}
-                  </el-tag>
-                </span>
+                <span class="stat-label">閲嶅垎閰�:</span>
+                <span class="stat-value">{{ redistributedCount }} 涓�</span>
               </div>
             </el-col>
           </el-row>
-        </div>
+        </div> -->
 
-        <div v-else class="empty-allocation">
+        <div v-if="
+          !allocationData.serviceDonateorganList ||
+          allocationData.serviceDonateorganList.length == 0
+        " class="empty-allocation">
           <el-empty description="鏆傛棤鍒嗛厤璁板綍" :image-size="80">
             <span>璇峰厛閫夋嫨瑕佸垎閰嶇殑鍣ㄥ畼</span>
           </el-empty>
         </div>
       </el-form>
-
-      <div class="dialog-footer" v-if="form.allocationStatus !== 'allocated'">
-        <el-button
-          type="primary"
-          @click="handleSaveAllocation"
-          :loading="saveLoading"
-          :disabled="allocationData.records.length === 0"
-        >
-          淇濆瓨鍒嗛厤璁板綍
-        </el-button>
-        <el-button
-          type="success"
-          @click="handleConfirmAllocation"
-          :loading="confirmLoading"
-          :disabled="incompleteRecords > 0"
-        >
-          纭瀹屾垚鍒嗛厤
-        </el-button>
-      </div>
     </el-card>
 
-    <!-- 闄勪欢绠$悊閮ㄥ垎 -->
+    <!-- 闄勪欢绠$悊閮ㄥ垎浼樺寲 -->
     <el-card class="attachment-card">
-      <div slot="header" class="clearfix">
-        <span class="detail-title">鐩稿叧闄勪欢</span>
-        <upload-attachment
-          :file-list="attachments"
-          @change="handleAttachmentChange"
-          :limit="10"
-          :accept="'.pdf,.jpg,.jpeg,.png,.doc,.docx'"
-        />
+      <div class="attachment-header">
+        <i class="el-icon-paperclip"></i>
+        <span class="attachment-title">鐩稿叧闄勪欢</span>
+        <span class="attachment-tip">鏀寔涓婁紶鍣ㄥ畼鍒嗛厤鐩稿叧鏂囦欢 (鏈�澶歿{ attachmentLimit }}涓�)</span>
       </div>
 
-      <div class="attachment-list">
-        <el-table :data="attachments" style="width: 100%">
-          <el-table-column label="鏂囦欢鍚嶇О" min-width="200">
+      <!-- 浣跨敤 UploadAttachment 缁勪欢 -->
+      <UploadAttachment ref="uploadAttachment" :file-list="attachmentFileList" :limit="attachmentLimit"
+        :accept="attachmentAccept" :multiple="true" @change="handleAttachmentChange"
+        @upload-success="handleUploadSuccess" @upload-error="handleUploadError" @remove="handleAttachmentRemove" />
+
+      <!-- 闄勪欢鍒楄〃灞曠ず -->
+      <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="150">
             <template slot-scope="scope">
-              <div class="file-info">
-                <i
-                  :class="getFileIcon(scope.row.fileName)"
-                  style="margin-right: 8px; color: #409EFF;"
-                ></i>
-                <span>{{ scope.row.fileName }}</span>
-              </div>
+              <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" align="center">
+          <el-table-column label="鏂囦欢绫诲瀷" width="100">
             <template slot-scope="scope">
-              <el-tag size="small">{{
-                getFileType(scope.row.fileName)
-              }}</el-tag>
+              <el-tag :type="getFileTagType(scope.row.fileName)" size="small">
+                {{ getFileTypeText(scope.row.fileName) }}
+              </el-tag>
             </template>
           </el-table-column>
-
-          <el-table-column label="鏂囦欢澶у皬" width="100" align="center">
+          <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="160" align="center">
+          <el-table-column label="鎿嶄綔" width="280" fixed="right">
             <template slot-scope="scope">
-              <span>{{ parseTime(scope.row.uploadTime) }}</span>
-            </template>
-          </el-table-column>
-
-          <el-table-column label="鎿嶄綔" width="150" align="center">
-            <template slot-scope="scope">
-              <el-button
-                size="mini"
-                type="text"
-                icon="el-icon-view"
-                @click="handlePreviewAttachment(scope.row)"
-                >棰勮</el-button
-              >
-              <el-button
-                size="mini"
-                type="text"
-                icon="el-icon-download"
-                @click="handleDownloadAttachment(scope.row)"
-                >涓嬭浇</el-button
-              >
-              <el-button
-                size="mini"
-                type="text"
-                icon="el-icon-delete"
-                style="color: #F56C6C;"
-                @click="handleRemoveAttachment(scope.row)"
-                >鍒犻櫎</el-button
-              >
+              <el-button size="mini" type="primary" @click="handlePreview(scope.row)"
+                :disabled="!isPreviewable(scope.row.fileName)">
+                棰勮
+              </el-button>
+              <el-button size="mini" type="success" @click="handleDownloadAttachment(scope.row)">
+                涓嬭浇
+              </el-button>
+              <el-button size="mini" type="danger" @click="handleRemoveAttachment(scope.$index)">
+                鍒犻櫎
+              </el-button>
             </template>
           </el-table-column>
         </el-table>
       </div>
     </el-card>
-    <!-- 闄勪欢棰勮瀵硅瘽妗� -->
-    <attachment-preview
-      :visible="attachmentPreviewVisible"
-      :file-list="currentAttachmentList"
-      :title="attachmentPreviewTitle"
-      @close="attachmentPreviewVisible = false"
-    />
+    <div style="text-align: center; margin: 30px 0;">
+      <el-button type="primary" @click="handleSave" :loading="saveLoading">
+        淇濆瓨
+      </el-button>
+      <el-button type="success" @click="handleConfirmAllocation" :disabled="form.allocationStatus == '1'"
+        :loading="confirmLoading">
+        纭鍒嗛厤
+      </el-button>
+    </div>
     <!-- 閲嶅垎閰嶅璇濇 -->
-    <el-dialog
-      title="鍣ㄥ畼閲嶅垎閰�"
-      :visible.sync="redistributionDialogVisible"
-      width="500px"
-    >
-      <el-form :model="redistributionForm" label-width="100px">
+    <el-dialog title="鍣ㄥ畼閲嶅垎閰�" :visible.sync="redistributionDialogVisible" width="500px"
+      @close="handleRedistributionDialogClose">
+      <el-form :model="redistributionForm" :rules="redistributionRules" ref="redistributionFormRef" label-width="100px">
         <el-form-item label="鍘熷櫒瀹樹俊鎭�">
-          <el-input v-model="redistributionForm.organName" readonly />
+          <el-input v-model="redistributionForm.organname" readonly />
         </el-form-item>
-        <el-form-item label="閲嶅垎閰嶅師鍥�" prop="reason">
-          <el-input
-            type="textarea"
-            :rows="4"
-            v-model="redistributionForm.reason"
-            placeholder="璇疯緭鍏ラ噸鍒嗛厤鍘熷洜"
-          />
+        <el-form-item label="閲嶅垎閰嶅師鍥�" prop="reason" required>
+          <el-input type="textarea" :rows="4" v-model="redistributionForm.reason" placeholder="璇疯緭鍏ラ噸鍒嗛厤鍘熷洜" />
+        </el-form-item>
+        <el-form-item label="閲嶅垎閰嶆椂闂�" prop="redistributionTime" required>
+          <el-date-picker v-model="redistributionForm.redistributionTime" type="datetime" placeholder="璇烽�夋嫨閲嶅垎閰嶆椂闂�"
+            value-format="yyyy-MM-dd HH:mm:ss" style="width: 100%" />
+        </el-form-item>
+        <el-form-item label="閲嶅垎閰嶉檮浠�">
+          <UploadAttachment ref="redistributionAttachmentUpload" :file-list="redistributionAttachmentList" :limit="5"
+            :accept="attachmentAccept" :multiple="true" @change="handleRedistributionChange"
+            @upload-success="handleRedistributionUploadSuccess" @upload-error="handleRedistributionUploadError"
+            @remove="handleRedistributionAttachmentRemove" />
+          <div style="margin-top: 5px; font-size: 12px; color: #999;">
+            鏀寔涓婁紶閲嶅垎閰嶇浉鍏虫枃浠� (鏈�澶�5涓�)
+          </div>
         </el-form-item>
       </el-form>
       <div slot="footer">
         <el-button @click="redistributionDialogVisible = false">鍙栨秷</el-button>
-        <el-button type="primary" @click="handleRedistributionConfirm"
-          >纭閲嶅垎閰�</el-button
-        >
+        <el-button type="primary" @click="handleRedistributionConfirm" :loading="redistributionLoading">
+          纭閲嶅垎閰�
+        </el-button>
       </div>
     </el-dialog>
+    <!-- 鍦╰emplate涓坊鍔犻噸鍒嗛厤璇︽儏寮圭獥 -->
+    <el-dialog title="閲嶅垎閰嶈鎯�" :visible.sync="redistributionDetailDialogVisible" width="600px">
+      <div v-loading="redistributionDetailLoading">
+        <div v-if="currentRedistributionDetail" style="padding: 20px;">
+          <!-- 鍩烘湰淇℃伅 -->
+          <el-descriptions title="閲嶅垎閰嶄俊鎭�" :column="2" border>
+            <el-descriptions-item label="鍣ㄥ畼鍚嶇О">
+              {{ currentRedistributionDetail.organname || "-" }}
+            </el-descriptions-item>
+            <el-descriptions-item label="鎿嶄綔浜�">
+              {{ currentRedistributionDetail.operator || "-" }}
+            </el-descriptions-item>
+            <el-descriptions-item label="鎿嶄綔鏃堕棿">
+              {{
+                currentRedistributionDetail.operatorTime
+                  ? formatDateTime(currentRedistributionDetail.operatorTime)
+                  : "-"
+              }}
+            </el-descriptions-item>
+            <el-descriptions-item label="閲嶅垎閰嶆椂闂�">
+              {{
+                currentRedistributionDetail.redistributionTime
+                  ? formatDateTime(
+                    currentRedistributionDetail.redistributionTime
+                  )
+                  : "-"
+              }}
+            </el-descriptions-item>
+          </el-descriptions>
+
+          <!-- 閲嶅垎閰嶅師鍥� -->
+          <div style="margin-top: 20px;">
+            <div class="section-title">閲嶅垎閰嶅師鍥�</div>
+            <div class="section-content" style="padding: 10px; background: #f5f7fa; border-radius: 4px;">
+              {{ currentRedistributionDetail.reason || "鏃�" }}
+            </div>
+          </div>
+
+          <!-- 閲嶅垎閰嶉檮浠� -->
+          <div style="margin-top: 20px;" v-if="
+            currentRedistributionDetail.attachments &&
+            currentRedistributionDetail.attachments.length > 0
+          ">
+            <div class="section-title">
+              閲嶅垎閰嶉檮浠� ({{ currentRedistributionDetail.attachments.length }})
+            </div>
+            <div class="redistribution-attachments">
+              <el-table :data="currentRedistributionDetail.attachments" size="small" style="width: 100%">
+                <el-table-column label="鏂囦欢鍚�" min-width="150">
+                  <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="150">
+                  <template slot-scope="scope">
+                    <span>{{
+                      scope.row.uploadTime
+                        ? formatDateTime(scope.row.uploadTime)
+                        : "-"
+                    }}</span>
+                  </template>
+                </el-table-column>
+                <el-table-column label="鎿嶄綔" width="150" fixed="right">
+                  <template slot-scope="scope">
+                    <el-button size="mini" type="primary" @click="handleRedistributionAttachmentPreview(scope.row)"
+                      :disabled="!isPreviewable(scope.row.fileName)">
+                      棰勮
+                    </el-button>
+                    <el-button size="mini" type="success" @click="handleRedistributionAttachmentDownload(scope.row)">
+                      涓嬭浇
+                    </el-button>
+                  </template>
+                </el-table-column>
+              </el-table>
+            </div>
+          </div>
+
+          <div v-else style="margin-top: 20px; text-align: center; color: #909399;">
+            鏃犻噸鍒嗛厤闄勪欢
+          </div>
+        </div>
+      </div>
+      <div slot="footer">
+        <el-button @click="redistributionDetailDialogVisible = false">鍏抽棴</el-button>
+      </div>
+    </el-dialog>
+    <!-- 闄勪欢棰勮瀵硅瘽妗� -->
+    <FilePreviewDialog :visible="filePreviewVisible" :file="currentPreviewFile" @close="filePreviewVisible = false"
+      @download="handleDownloadAttachment" />
   </div>
 </template>
 
 <script>
 import {
-  getOrganAllocationDetail,
-  updateOrganAllocation,
-  saveAllocationRecords,
-  getHospitalList,
-  getOrganDict
-} from "./organAllocation";
+  allocationList,
+  allocationadd,
+  allocationedit,
+  donateorganBaseinfoInfo
+} from "@/api/businessApi";
 import UploadAttachment from "@/components/UploadAttachment";
-import AttachmentPreview from "@/components/AttachmentPreview";
+import FilePreviewDialog from "@/components/FilePreviewDialog";
+import OrgSelecter from "@/views/project/components/orgselect";
+import CaseBasicInfo from "@/components/CaseBasicInfo";
+import dayjs from "dayjs";
+
 export default {
   name: "OrganAllocationDetail",
   components: {
     UploadAttachment,
-    AttachmentPreview,
+    OrgSelecter,
+    FilePreviewDialog,
+    CaseBasicInfo
   },
+  dicts: [
+    "sys_BloodType",
+    "sys_DonationCategory",
+    "sys_RecordState",
+    "sys_Organ",
+    "Geta_hospital",
+
+    "organ_allocation_status"
+  ],
   data() {
     return {
+      caseId: null,
+      // 閲嶅垎閰嶈鎯呯浉鍏�
+      redistributionDetailDialogVisible: false,
+      redistributionDetailLoading: false,
+      currentRedistributionDetail: null,
       // 琛ㄥ崟鏁版嵁
       form: {
         id: undefined,
-        hospitalNo: "",
+        infoid: undefined,
+        donationcategory: "",
         caseNo: "",
-        donorName: "",
-        gender: "",
+        donorno: "",
+        treatmenthospitalname: "",
+        treatmenthospitalno: "",
+        sex: "",
+        name: "",
         age: "",
-        birthDate: "",
-        diagnosis: "",
-        allocationStatus: "pending",
+        bloodtype: "",
+        idcardno: "",
+        diagnosisname: "",
+        allocationStatus: "0", // 0:鏈垎閰嶏紱1锛氬凡鍒嗛厤锛�2浣滃簾
         allocationTime: "",
-        registrant: "",
-        registrationTime: ""
+        registrationCode: "",
+        registrationName: "",
+        registrationTime: "",
+        attachments: [] // 娣诲姞闄勪欢瀛楁
       },
+      // 闄勪欢棰勮鐩稿叧
+      attachmentPreviewVisible: false,
+      currentAttachmentList: [],
+      attachmentPreviewTitle: "",
+      dataList: [],
       // 琛ㄥ崟楠岃瘉瑙勫垯
       rules: {
-        donorName: [
+        name: [
           { required: true, message: "鎹愮尞鑰呭鍚嶄笉鑳戒负绌�", trigger: "blur" }
         ],
-        diagnosis: [
+        diagnosisname: [
           { required: true, message: "鐤剧梾璇婃柇涓嶈兘涓虹┖", trigger: "blur" }
         ]
       },
       // 鍒嗛厤璁板綍楠岃瘉瑙勫垯
       allocationRules: {},
+      // 閲嶅垎閰嶉獙璇佽鍒�
+      redistributionRules: {
+        reason: [
+          { required: true, message: "閲嶅垎閰嶅師鍥犱笉鑳戒负绌�", trigger: "blur" }
+        ],
+        redistributionTime: [
+          { required: true, message: "閲嶅垎閰嶆椂闂翠笉鑳戒负绌�", trigger: "blur" }
+        ]
+      },
       // 淇濆瓨鍔犺浇鐘舵��
       saveLoading: false,
       confirmLoading: false,
+      redistributionLoading: false,
       // 鍔犺浇鐘舵��
       loading: false,
-      // 閫変腑鐨勫櫒瀹�
+      // 閫変腑鐨勫櫒瀹橈紙瀛樺偍瀛楀吀value锛�
       selectedOrgans: [],
-      // 鍣ㄥ畼瀛楀吀
-      organDict: [],
+      // 鍏朵粬鍣ㄥ畼杈撳叆
+      otherOrganInput: "",
       // 鍖婚櫌鍒楄〃
       hospitalList: [],
       // 鍒嗛厤璁板綍鏁版嵁
       allocationData: {
-        records: []
+        serviceDonateorganList: []
       },
       // 闄勪欢鏁版嵁
       attachments: [],
+      attachmentFileList: [],
+      // 闄勪欢鐩稿叧閰嶇疆
+      attachmentLimit: 10,
+      attachmentAccept:
+        ".pdf,.jpg,.jpeg,.png,.doc,.docx,.xls,.xlsx,.ppt,.pptx,.txt",
       // 閲嶅垎閰嶅璇濇
       redistributionDialogVisible: false,
       redistributionForm: {
-        organName: "",
-        reason: ""
+        organname: "",
+        reason: "",
+        redistributionTime: ""
       },
-      currentRedistributeRecord: null
+      redistributionAttachmentList: [],
+      redistributionFormRef: null,
+      currentRedistributeRecord: null,
+      // 鏂囦欢棰勮鐩稿叧
+      filePreviewVisible: false,
+      currentPreviewFile: null,
+      filePreviewTitle: ""
     };
   },
   computed: {
@@ -548,248 +579,786 @@
     currentUser() {
       return JSON.parse(sessionStorage.getItem("user") || "{}");
     },
+     displayOrgans() {
+    return (this.allocationData.serviceDonateorganList || [])
+      .filter(item => item.delFlag !== 1);
+  },
     // 涓嶅畬鏁寸殑璁板綍鏁伴噺
     incompleteRecords() {
-      return this.allocationData.records.filter(
+      if (!this.allocationData.serviceDonateorganList) return 0;
+      return this.allocationData.serviceDonateorganList.filter(
         record =>
-          !record.systemNo ||
-          !record.applicantTime ||
-          !record.recipientName ||
-          !record.transplantHospitalNo
+          !record.applicanttime ||
+          !record.organgettime ||
+          !record.name ||
+          !record.transplanthospitalname
       ).length;
     },
-    // 鍞竴鍖婚櫌鏁伴噺
+    // 寰呭鏍歌褰曟暟閲�
+    pendingReviewCount() {
+      if (!this.allocationData.serviceDonateorganList) return 0;
+      return this.allocationData.serviceDonateorganList.filter(
+        record => record.allocationstatus == "0"
+      ).length;
+    },
+    // 閲嶅垎閰嶈褰曟暟閲�
+    redistributedCount() {
+      if (!this.allocationData.serviceDonateorganList) return 0;
+      return this.allocationData.serviceDonateorganList.filter(
+        record => record.allocationstatus == "3"
+      ).length;
+    },
     uniqueHospitals() {
-      const hospitals = this.allocationData.records
-        .map(record => record.transplantHospitalNo)
+      if (!this.allocationData.serviceDonateorganList) return 0;
+      const hospitals = this.allocationData.serviceDonateorganList
+        .map(record => record.transplanthospitalname)
         .filter(Boolean);
       return new Set(hospitals).size;
+    },
+    // 鑾峰彇鍣ㄥ畼瀛楀吀
+    organDict() {
+      return this.dict.type.sys_Organ || [];
+    },
+    // 鍒ゆ柇鏄惁闇�瑕佹樉绀哄叾浠栬緭鍏ユ
+    showOtherInput() {
+      return this.selectedOrgans.includes("C01"); // 鍋囪"鍏朵粬"鐨勫瓧鍏稿�兼槸C01
+    },
+    // 鍒嗛厤鐘舵�佸瓧鍏告槧灏�
+    allocationStatusDict() {
+      return {
+        "0": { label: "鎻愪氦鍒嗛厤", type: "info" },
+        "1": { label: "瀹℃牳閫氳繃", type: "success" },
+        "2": { label: "宸蹭綔搴�", type: "danger" },
+        "3": { label: "閲嶅垎閰�", type: "warning" }
+      };
+    }
+  },
+  watch: {
+    // 鐩戝惉闄勪欢鏁版嵁鍙樺寲
+    attachments: {
+      handler(newAttachments) {
+        this.attachmentFileList = newAttachments.map(item => ({
+          uid: item.id || Math.random(),
+          name: item.fileName,
+          fileSize: item.fileSize,
+          url: item.path || item.fileUrl,
+          uploadTime: item.uploadTime,
+          status: "success"
+        }));
+      },
+      deep: true
+    },
+    // 鐩戝惉鍏朵粬鍣ㄥ畼杈撳叆鍙樺寲
+    otherOrganInput(newValue) {
+      if (newValue && this.selectedOrgans.includes("C01")) {
+        // 鏇存柊鍣ㄥ畼瀛楀吀涓殑"鍏朵粬"鏍囩鏄剧ず
+        const otherRecord = this.allocationData.serviceDonateorganList.find(
+          item => item.organname && item.organname.includes("鍏朵粬")
+        );
+        if (otherRecord) {
+          otherRecord.organname = `鍏朵粬(${newValue})`;
+        }
+      }
     }
   },
   created() {
-    const id = this.$route.query.id;
-    if (id) {
-      this.getDetail(id);
-    } else {
-      this.generateCaseNo();
-      this.form.registrant = this.currentUser.username || "褰撳墠鐢ㄦ埛";
+    this.caseId = this.$route.query.infoid;
+    this.initData();
+  },
+  methods: {
+    // 鑾峰彇鍒嗛厤鐘舵�佹爣绛剧被鍨�
+    getAllocationStatusTagType(status) {
+      const statusMap = this.allocationStatusDict;
+      return statusMap[status] ? statusMap[status].type : "info";
+    },
+
+    // 鑾峰彇鍒嗛厤鐘舵�佹枃鏈�
+    getAllocationStatusText(status) {
+      const statusMap = this.allocationStatusDict;
+      return statusMap[status] ? statusMap[status].label : "鏈煡鐘舵��";
+    },
+    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 })));
+    },
+    // 鏌ョ湅閲嶅垎閰嶈鎯�
+    handleViewRedistributionDetail(row) {
+      this.redistributionDetailLoading = true;
+      this.redistributionDetailDialogVisible = true;
+
+      try {
+        if (row.redistributionInfo) {
+          // 瑙f瀽閲嶅垎閰嶄俊鎭�
+          const redistributionInfo = JSON.parse(row.redistributionInfo);
+          this.currentRedistributionDetail = {
+            organname: row.organname || "-",
+            ...redistributionInfo
+          };
+        } else {
+          this.currentRedistributionDetail = {
+            organname: row.organname || "-",
+            reason: "鏃犻噸鍒嗛厤鍘熷洜",
+            attachments: []
+          };
+        }
+      } catch (error) {
+        console.error("瑙f瀽閲嶅垎閰嶄俊鎭け璐�:", error);
+        this.$message.error("閲嶅垎閰嶄俊鎭В鏋愬け璐�");
+        this.currentRedistributionDetail = {
+          organname: row.organname || "-",
+          reason: "閲嶅垎閰嶄俊鎭牸寮忛敊璇�",
+          attachments: []
+        };
+      } finally {
+        this.redistributionDetailLoading = false;
+      }
+    },
+
+    // 棰勮閲嶅垎閰嶉檮浠�
+    handleRedistributionAttachmentPreview(file) {
+      this.currentPreviewFile = {
+        fileName: file.fileName,
+        fileUrl: file.path || file.fileUrl,
+        fileType: this.getFileType(file.fileName)
+      };
+      this.filePreviewVisible = true;
+    },
+
+    // 涓嬭浇閲嶅垎閰嶉檮浠�
+    handleRedistributionAttachmentDownload(file) {
+      const fileUrl = file.path || file.fileUrl;
+      const fileName = file.fileName;
+
+      if (fileUrl) {
+        const link = document.createElement("a");
+        link.href = fileUrl;
+        link.download = fileName;
+        link.style.display = "none";
+        document.body.appendChild(link);
+        link.click();
+        document.body.removeChild(link);
+        this.$message.success("寮�濮嬩笅杞芥枃浠�");
+      } else {
+        this.$message.warning("鏂囦欢璺緞涓嶅瓨鍦紝鏃犳硶涓嬭浇");
+      }
+    },
+
+    // 澧炲己鏍煎紡鍖栧伐鍏锋彁绀烘柟娉�
+    formatRedistributionTooltip(redistributionInfo) {
+      if (!redistributionInfo) return "";
+      try {
+        const info = JSON.parse(redistributionInfo);
+        let tooltip = `閲嶅垎閰嶅師鍥�: ${info.reason}\n閲嶅垎閰嶆椂闂�: ${info.redistributionTime}`;
+
+        // 娣诲姞闄勪欢淇℃伅
+        if (info.attachments && info.attachments.length > 0) {
+          tooltip += `\n\n闄勪欢(${info.attachments.length}涓�):`;
+          info.attachments.forEach((att, index) => {
+            tooltip += `\n${index + 1}. ${att.fileName}`;
+          });
+        }
+
+        return tooltip;
+      } catch (error) {
+        return redistributionInfo;
+      }
+    },
+    // 鏍规嵁瀛楀吀value鑾峰彇label
+    getOrganLabel(organValue) {
+      const dictItem = this.organDict.find(item => item.value == organValue);
+      return dictItem ? dictItem.label : organValue;
+    },
+
+    // 鍒濆鍖栨暟鎹�
+    initData() {
+      const { id, infoid } = this.$route.query;
+
+      if (!infoid) {
+        this.$message.error("缂哄皯蹇呰鐨勮矾鐢卞弬鏁� infoid");
+        this.$router.back();
+        return;
+      }
+
+      this.form.infoid = infoid;
+      this.form.registrationName =
+        this.currentUser.nickName || this.currentUser.username || "褰撳墠鐢ㄦ埛";
       this.form.registrationTime = new Date()
         .toISOString()
         .replace("T", " ")
         .substring(0, 19);
-    }
-    this.getOrganDictionary();
-    this.getHospitalData();
-  },
-  methods: {
-    // 鐢熸垚妗堜緥缂栧彿
-    generateCaseNo() {
+
+      if (infoid) {
+        this.getDetail(infoid, id);
+      } else {
+        this.generateDonorNo();
+      }
+
+      this.getHospitalData();
+    },
+
+    // 鐢熸垚鎹愮尞鑰呯紪鍙�
+    generateDonorNo() {
       const timestamp = Date.now().toString();
-      this.form.hospitalNo = "D" + timestamp.slice(-6);
-      this.form.caseNo = "C" + timestamp.slice(-6);
+      this.form.donorno = "D" + timestamp.slice(-8);
+      this.form.caseNo = "CASE" + timestamp.slice(-6);
     },
+
+    // 瑙f瀽 filePatch 瀛楁
+    parseFilePatch(filePatch) {
+      if (!filePatch) {
+        this.form.attachments = [];
+        return;
+      }
+
+      try {
+        this.form.attachments = JSON.parse(filePatch);
+      } catch (error) {
+        console.error("瑙f瀽 filePatch 瀛楁澶辫触:", error);
+        this.form.attachments = [];
+      }
+    },
+
     // 鑾峰彇璇︽儏
-    getDetail(id) {
+    async getDetail(infoid, id) {
       this.loading = true;
-      getOrganAllocationDetail(id)
-        .then(response => {
-          if (response.code === 200) {
-            this.form = response.data;
-            if (response.data.allocationRecords) {
-              this.allocationData.records = response.data.allocationRecords;
-              this.selectedOrgans = response.data.allocationRecords.map(
-                item => item.organNo
-              );
-            }
+      try {
+        const response = await allocationList({ infoid });
+        if (response.code == 200 && response.data && response.data.length > 0) {
+          const data = response.data[0];
+
+          // 濉厖琛ㄥ崟鏁版嵁
+          Object.assign(this.form, data);
+          // 杞崲闄勪欢涓洪泦鍚�
+          this.parseFilePatch(this.form.fileName);
+
+          // 鍒濆鍖栭檮浠�
+          if (this.form.attachments) {
+            this.attachments = Array.isArray(this.form.attachments)
+              ? [...this.form.attachments]
+              : [];
           }
-          this.loading = false;
-        })
-        .catch(error => {
-          console.error("鑾峰彇鍣ㄥ畼鍒嗛厤璇︽儏澶辫触:", error);
-          this.loading = false;
-          this.$message.error("鑾峰彇璇︽儏澶辫触");
-        });
-    },
-    // 鑾峰彇鍣ㄥ畼瀛楀吀
-    getOrganDictionary() {
-      getOrganDict().then(response => {
-        if (response.code === 200) {
-          this.organDict = response.data;
-        }
-      });
-    },
-    // 鑾峰彇鍖婚櫌鏁版嵁
-    getHospitalData() {
-      getHospitalList().then(response => {
-        if (response.code === 200) {
-          this.hospitalList = response.data;
-        }
-      });
-    },
-      handleAttachmentChange(fileList) {
-console.log(fileList,'娴嬭瘯');
 
-    },
-    // 鍣ㄥ畼閫夋嫨鐘舵�佸彉鍖�
-    handleOrganSelectionChange(selectedValues) {
-      const currentOrganNos = this.allocationData.records.map(
-        item => item.organNo
-      );
+          // 澶勭悊鍒嗛厤璁板綍
+          if (data.serviceDonateorganList) {
+            this.allocationData.serviceDonateorganList = Array.isArray(
+              data.serviceDonateorganList
+            )
+              ? data.serviceDonateorganList.map(item => {
+                // 纭繚姣忔潯璁板綍閮芥湁鍒嗛厤鐘舵�佸瓧娈碉紝榛樿鍊间负0
+                const allocationstatus = item.allocationstatus || "0";
+                let redistributionInfo = null;
 
-      // 鏂板閫夋嫨鐨勫櫒瀹�
-      selectedValues.forEach(organValue => {
-        if (!currentOrganNos.includes(organValue)) {
-          const organInfo = this.organDict.find(
-            item => item.value === organValue
-          );
-          if (organInfo) {
-            this.allocationData.records.push({
-              organName: organInfo.label,
-              organNo: organValue,
-              id: null,
-              allocationId: this.form.id,
-              systemNo: "",
-              applicantTime: "",
-              recipientName: "",
-              transplantHospitalNo: "",
-              transplantHospitalName: "",
-              reallocationReason: "",
-              organState: 1
-            });
-          }
-        }
-      });
-
-      // 绉婚櫎鍙栨秷閫夋嫨鐨勫櫒瀹�
-      this.allocationData.records = this.allocationData.records.filter(
-        record => {
-          if (selectedValues.includes(record.organNo)) {
-            return true;
-          } else {
-            if (record.id) {
-              this.$confirm(
-                "鍒犻櫎鍣ㄥ畼鍒嗛厤鏁版嵁鍚庡皢鏃犳硶鎭㈠锛屾偍纭鍒犻櫎璇ユ潯璁板綍鍚楋紵",
-                "鎻愮ず",
-                {
-                  confirmButtonText: "纭畾",
-                  cancelButtonText: "鍙栨秷",
-                  type: "warning"
+                // 瑙f瀽閲嶅垎閰嶄俊鎭�
+                if (allocationstatus == "3" && item.reallocationreason) {
+                  try {
+                    redistributionInfo = JSON.parse(item.reallocationreason);
+                    console.log(redistributionInfo);
+                  } catch (error) {
+                    console.warn("瑙f瀽閲嶅垎閰嶄俊鎭け璐�:", error);
+                    redistributionInfo = item.reallocationreason;
+                  }
                 }
-              )
-                .then(() => {
-                  // 瀹為檯椤圭洰涓繖閲屽簲璇ヨ皟鐢ㄥ垹闄PI
-                  this.allocationData.records = this.allocationData.records.filter(
-                    r => r.organNo !== record.organNo
+
+                return {
+                  ...item,
+                  allocationstatus,
+                  redistributionInfo: redistributionInfo
+                    ? JSON.stringify(redistributionInfo)
+                    : null
+                };
+              })
+              : [];
+
+            // 鏇存柊閫変腑鐨勫櫒瀹�
+            this.selectedOrgans = this.allocationData.serviceDonateorganList
+              .map(item => {
+                // 浠庡悗绔暟鎹腑鑾峰彇鍣ㄥ畼鐨剉alue
+                if (item.organno) {
+                  return item.organno;
+                }
+
+                // 濡傛灉鍚庣鍙湁鍣ㄥ畼鍚嶇О锛屽皾璇曚粠瀛楀吀涓尮閰�
+                if (item.organname) {
+                  const dictItem = this.organDict.find(
+                    org =>
+                      org.label == item.organname ||
+                      (item.organname && item.organname.includes(org.label))
                   );
-                  this.$message.success("鍒犻櫎鎴愬姛");
-                })
-                .catch(() => {
-                  this.selectedOrgans.push(record.organNo);
-                });
-              return true; // 绛夊緟鐢ㄦ埛纭
-            } else {
-              return false; // 鐩存帴鍒犻櫎鏂拌褰�
+                  return dictItem ? dictItem.value : null;
+                }
+
+                return null;
+              })
+              .filter(Boolean);
+
+            // 澶勭悊"鍏朵粬"鍣ㄥ畼
+            const otherRecord = this.allocationData.serviceDonateorganList.find(
+              item => item.organname && item.organname.includes("鍏朵粬(")
+            );
+            if (otherRecord) {
+              const match = otherRecord.organname.match(/鍏朵粬\((.*?)\)/);
+              if (match) {
+                this.otherOrganInput = match[1];
+              }
             }
           }
+
+          this.$message.success("鏁版嵁鍔犺浇鎴愬姛");
+        } else {
+          this.$message.warning("鏈壘鍒板搴旂殑鍣ㄥ畼鍒嗛厤鏁版嵁");
+        }
+      } catch (error) {
+        console.error("鑾峰彇鍣ㄥ畼鍒嗛厤璇︽儏澶辫触:", error);
+        this.$message.error("鑾峰彇璇︽儏澶辫触");
+      } finally {
+        this.loading = false;
+      }
+    },
+
+    // 鑾峰彇鍖婚櫌鏁版嵁
+    async getHospitalData() {
+      try {
+        // TODO: 鏇挎崲涓哄疄闄呯殑鍖婚櫌鍒楄〃鎺ュ彛
+        // 鏆傛椂浣跨敤妯℃嫙鏁版嵁
+        this.hospitalList = [
+          { hospitalNo: "H001", hospitalName: "鍖椾含鍗忓拰鍖婚櫌" },
+          { hospitalNo: "H002", hospitalName: "涓婃捣鍗庡北鍖婚櫌" },
+          { hospitalNo: "H003", hospitalName: "骞垮窞涓北鍖婚櫌" },
+          { hospitalNo: "H004", hospitalName: "姝︽眽鍚屾祹鍖婚櫌" },
+          { hospitalNo: "H005", hospitalName: "鎴愰兘鍗庤タ鍖婚櫌" }
+        ];
+      } catch (error) {
+        console.error("鑾峰彇鍖婚櫌鏁版嵁澶辫触:", error);
+        this.$message.error("鑾峰彇鍖婚櫌鏁版嵁澶辫触");
+      }
+    },
+
+    // 鍣ㄥ畼閫夋嫨鐘舵�佸彉鍖�
+   async handleOrganSelectionChange(selectedValues) {
+  // 1. 澶勭悊浜掓枼閫昏緫锛堜慨鏀� this.selectedOrgans锛�
+  this.handleExclusiveSelections(selectedValues);
+
+  const finalSelected = this.selectedOrgans;
+  const records = this.allocationData.serviceDonateorganList || [];
+
+  // 2. 鏋勫缓鐩爣鍣ㄥ畼缂栧彿鍒楄〃锛堢洿鎺ヤ娇鐢ㄩ�変腑鐨勫�硷紝涓嶅睍寮�锛�
+  const targetOrganNos = finalSelected; // 杩欓噷涓嶅睍寮�锛屽氨鏄�変腑鐨勫櫒瀹樼紪鍙�
+
+  // 3. 鏂板鎴栨仮澶嶈褰�
+  targetOrganNos.forEach(no => {
+    const existing = records.find(r => r.organno === no);
+    if (existing) {
+      if (existing.delFlag === 1) {
+        existing.delFlag = 0; // 鎭㈠鏄剧ず
+      }
+    } else {
+      this.createOrganRecord(no);
+    }
+  });
+
+  // 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;
+        // 浠� selectedOrgans 涓Щ闄ゅ搴旂殑鍣ㄥ畼缂栧彿
+        const idx = this.selectedOrgans.indexOf(r.organno);
+        if (idx !== -1) this.selectedOrgans.splice(idx, 1);
+      });
+    } catch (error) {
+      // 鐢ㄦ埛鍙栨秷锛氭仮澶嶉�変腑鐘舵�侊紙灏嗗彇娑堢殑鍣ㄥ畼閲嶆柊鍔犲叆 selectedOrgans锛�
+      const parentToRestore = new Set();
+      toRemoveSaved.forEach(r => {
+        // 鐩存帴鎭㈠鍣ㄥ畼缂栧彿锛堝洜涓轰笉灞曞紑锛屾墍浠ュ氨鏄� r.organno锛�
+        if (!this.selectedOrgans.includes(r.organno)) {
+          this.selectedOrgans.push(r.organno);
+        }
+      });
+      this.$message.info('宸插彇娑堝垹闄ゆ搷浣�');
+      return; // 閫�鍑烘柟娉曪紝閬垮厤缁х画鎵ц
+    }
+  }
+
+  // 5. 娉ㄦ剰锛氬浜庡凡鏍囪鍒犻櫎鐨勮褰曪紝鎴戜滑涓嶄粠 selectedOrgans 涓Щ闄わ紙宸插湪纭鏃剁Щ闄わ級
+  // 浣嗚繕瑕佽�冭檻锛氭煇浜涜褰曞彲鑳藉洜涓轰簰鏂ラ�昏緫琚Щ闄わ紝宸插寘鍚湪 finalSelected 涓鐞嗭紝鏃犻澶栨搷浣�
+  // 鏇存柊琛ㄥ崟瀛楁锛堝鏋滈渶瑕佷繚瀛橀�変腑鐨勫櫒瀹樺垪琛紝鍙互鍦ㄨ繖閲岃缃� this.form.donateorgan锛屼絾鏈」鐩湭鐢級
+  // 濡傛灉闇�瑕侊紝鍙互娣诲姞 this.form.donateorgan = 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")
+      ) {
+        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")
+      ) {
+        this.selectedOrgans = selectedValues.filter(item => item !== "C34");
+      }
     },
+
+    // 鍒涘缓鍣ㄥ畼璁板綍
+    createOrganRecord(organValue) {
+      let organName = this.getOrganLabel(organValue);
+
+      // 濡傛灉鏄�"鍏朵粬"鍣ㄥ畼涓旀湁杈撳叆鍊�
+      if (organValue == "C01" && this.otherOrganInput) {
+        organName = `鍏朵粬(${this.otherOrganInput})`;
+      }
+
+      this.allocationData.serviceDonateorganList.push({
+        id: null,
+        organname: organName,
+        organno: organValue,
+        caseno: "",
+        applicanttime: "",
+        organgettime: "",
+        name: "",
+        transplanthospitalno: "",
+        transplantHospitalName: "",
+        reallocationreason: "",
+        allocationstatus: "0", // 榛樿鎻愪氦鍒嗛厤鐘舵��
+        redistributionInfo: null,
+        organState: 1,
+          delFlag: 0   // 鏂板
+      });
+    },
+
     // 鍖婚櫌閫夋嫨鍙樺寲
     handleHospitalChange(row, hospitalNo) {
       const hospital = this.hospitalList.find(
-        item => item.hospitalNo === hospitalNo
+        item => item.hospitalNo == hospitalNo
       );
       if (hospital) {
         row.transplantHospitalName = hospital.hospitalName;
       }
     },
+
     // 閲嶅垎閰嶆搷浣�
     handleRedistribution(row) {
       this.currentRedistributeRecord = row;
-      this.redistributionForm.organName = row.organName;
-      this.redistributionForm.reason = row.reallocationReason || "";
+      this.redistributionForm.organname = row.organname;
+      this.redistributionForm.reason = "";
+      this.redistributionForm.redistributionTime = new Date()
+        .toISOString()
+        .replace("T", " ")
+        .substring(0, 19);
+      this.redistributionAttachmentList = [];
       this.redistributionDialogVisible = true;
     },
+    // 浣滃簾鎿嶄綔
+    handleInvalidate(row) {
+      this.$confirm(`纭畾瑕佸皢 "${row.organname}" 鐨勫垎閰嶈褰曚綔搴熷悧锛焋, "鎻愮ず", {
+        confirmButtonText: "纭畾",
+        cancelButtonText: "鍙栨秷",
+        type: "warning"
+      })
+        .then(() => {
+          // 鎵惧埌褰撳墠璁板綍鐨勭储寮�
+          const index = this.allocationData.serviceDonateorganList.findIndex(
+            item => item === row
+          );
+
+          if (index !== -1) {
+            // 鏇存柊璁板綍鐘舵�佷负浣滃簾
+            this.allocationData.serviceDonateorganList[index].allocationstatus =
+              "2";
+
+            // 鏇存柊閫変腑鐨勫櫒瀹樺垪琛紙濡傛灉璇ュ櫒瀹樹笉鍐嶆湁鍏朵粬鏈夋晥璁板綍锛�
+            const organNo = row.organno;
+            const hasOtherValidRecord = this.allocationData.serviceDonateorganList.some(
+              item => item.organno === organNo && item.allocationstatus !== "2"
+            );
+
+            if (!hasOtherValidRecord) {
+              this.selectedOrgans = this.selectedOrgans.filter(
+                item => item !== organNo
+              );
+            }
+
+            this.$message.success("璁板綍宸蹭綔搴�");
+          }
+        })
+        .catch(() => { });
+    },
+    // 閲嶅垎閰嶅璇濇鍏抽棴
+    handleRedistributionDialogClose() {
+      this.redistributionForm = {
+        organname: "",
+        reason: "",
+        redistributionTime: ""
+      };
+      this.redistributionAttachmentList = [];
+      this.currentRedistributeRecord = null;
+    },
+
+    // 閲嶅垎閰嶉檮浠朵笂浼犳垚鍔�
+    handleRedistributionUploadSuccess({ 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")
+        };
+        console.log(11);
+
+        this.redistributionAttachmentList = fileList;
+        this.$message.success("閲嶅垎閰嶉檮浠朵笂浼犳垚鍔�");
+      }
+    },
+
+    // 閲嶅垎閰嶉檮浠朵笂浼犻敊璇�
+    handleRedistributionUploadError({ file, fileList, error }) {
+      console.error("閲嶅垎閰嶉檮浠朵笂浼犲け璐�:", error);
+      this.$message.error("閲嶅垎閰嶉檮浠朵笂浼犲け璐ワ紝璇烽噸璇�");
+    },
+
+    // 閲嶅垎閰嶉檮浠剁Щ闄�
+    handleRedistributionAttachmentRemove(file) {
+      if (file.url) {
+        const index = this.redistributionAttachmentList.findIndex(
+          item => item.path == file.url || item.fileUrl == file.url
+        );
+        if (index > -1) {
+          this.redistributionAttachmentList.splice(index, 1);
+        }
+      }
+    },
+
     // 纭閲嶅垎閰�
-    handleRedistributionConfirm() {
-      if (!this.redistributionForm.reason) {
-        this.$message.warning("璇疯緭鍏ラ噸鍒嗛厤鍘熷洜");
-        return;
-      }
+    async handleRedistributionConfirm() {
+      this.$refs.redistributionFormRef.validate(async valid => {
+        if (!valid) {
+          this.$message.warning("璇峰畬鍠勯噸鍒嗛厤淇℃伅");
+          return;
+        }
+        console.log(1, this.redistributionAttachmentList);
 
-      if (this.currentRedistributeRecord) {
-        this.currentRedistributeRecord.reallocationReason = this.redistributionForm.reason;
-        this.$message.success("閲嶅垎閰嶅師鍥犲凡鏇存柊");
-        this.redistributionDialogVisible = false;
-      }
-    },
-    // 鍣ㄥ畼琛屾牱寮�
-    getOrganRowClassName({ row }) {
-      if (
-        !row.systemNo ||
-        !row.applicantTime ||
-        !row.recipientName ||
-        !row.transplantHospitalNo
-      ) {
-        return "warning-row";
-      }
-      return "";
-    },
-    // 淇濆瓨鍩烘湰淇℃伅
-    handleSave() {
-      this.$refs.form.validate(valid => {
-        if (valid) {
-          this.saveLoading = true;
-          const apiMethod = this.form.id
-            ? updateOrganAllocation
-            : addOrganAllocation;
+        this.redistributionLoading = true;
 
-          apiMethod(this.form)
-            .then(response => {
-              if (response.code === 200) {
-                this.$message.success("淇濆瓨鎴愬姛");
-                if (!this.form.id) {
-                  this.form.id = response.data.id;
-                  this.$router.replace({
-                    query: { ...this.$route.query, id: this.form.id }
-                  });
-                }
-              }
-            })
-            .catch(error => {
-              console.error("淇濆瓨澶辫触:", error);
-              this.$message.error("淇濆瓨澶辫触");
-            })
-            .finally(() => {
-              this.saveLoading = false;
-            });
+        try {
+          // 鏋勫缓閲嶅垎閰嶄俊鎭璞�
+          const redistributionInfo = {
+            reason: this.redistributionForm.reason,
+            redistributionTime: this.redistributionForm.redistributionTime,
+            attachments: this.redistributionAttachmentList.map(att => ({
+              // fileName: att.fileName,
+              // path: att.path || att.fileUrl,
+              // fileUrl: att.path || att.fileUrl,
+              // fileType: this.getFileExtension(att.name),
+              // fileSize: att.fileSize,
+              // uploadTime: att.uploadTime
+              fileName: att.name,
+              path: att.url,
+              fileUrl: att.url,
+              fileType: this.getFileExtension(att.name),
+              fileSize: att.size,
+              uploadTime: dayjs().format("YYYY-MM-DD HH:mm:ss")
+            })),
+
+            operator: this.currentUser.username || this.currentUser.nickName,
+            operatorTime: new Date()
+              .toISOString()
+              .replace("T", " ")
+              .substring(0, 19)
+          };
+          console.log(2, this.redistributionAttachmentList);
+
+          // 鎵惧埌褰撳墠璁板綍鐨勭储寮�
+          const currentIndex = this.allocationData.serviceDonateorganList.findIndex(
+            item => item == this.currentRedistributeRecord
+          );
+
+          if (currentIndex !== -1) {
+            // 1. 鏇存柊鍘熻褰曠殑鐘舵�佷负3锛堥噸鍒嗛厤锛夊苟淇濆瓨閲嶅垎閰嶄俊鎭�
+            const originalRecord = { ...this.currentRedistributeRecord };
+            originalRecord.allocationstatus = "3";
+            originalRecord.reallocationreason = JSON.stringify(
+              redistributionInfo
+            );
+            originalRecord.redistributionInfo = JSON.stringify(
+              redistributionInfo
+            );
+
+            // 2. 鍒涘缓鏂扮殑璁板綍
+            const newRecord = {
+              ...this.currentRedistributeRecord,
+              id: null, // 鏂拌褰旾D涓虹┖
+              allocationstatus: "0", // 鏂拌褰曠姸鎬佷负鎻愪氦鍒嗛厤
+              reallocationreason: "", // 娓呯┖閲嶅垎閰嶅師鍥�
+              redistributionInfo: null,
+              // 閲嶇疆鐩稿叧瀛楁锛屼絾淇濈暀鍣ㄥ畼淇℃伅
+              caseno: "",
+              applicanttime: "",
+              organgettime: "",
+              name: "",
+              transplanthospitalno: "",
+              transplantHospitalName: ""
+            };
+
+            // 3. 鍦ㄦ暟缁勪腑鎻掑叆鏂拌褰曪紙鍦ㄦ棫璁板綍涔嬪悗锛�
+            this.allocationData.serviceDonateorganList.splice(
+              currentIndex + 1,
+              0,
+              newRecord
+            );
+            // 4. 鏇存柊鍘熻褰�
+            this.allocationData.serviceDonateorganList[
+              currentIndex
+            ] = originalRecord;
+
+            // 5. 鏇存柊閫変腑鐨勫櫒瀹樺垪琛�
+            this.selectedOrgans.push(this.currentRedistributeRecord.organno);
+
+            this.$message.success("閲嶅垎閰嶆搷浣滄垚鍔熷畬鎴�");
+            this.redistributionDialogVisible = false;
+          } else {
+            this.$message.error("鏈壘鍒板搴旂殑璁板綍");
+          }
+        } catch (error) {
+          console.error("閲嶅垎閰嶆搷浣滃け璐�:", error);
+          this.$message.error("閲嶅垎閰嶆搷浣滃け璐�");
+        } finally {
+          this.redistributionLoading = false;
         }
       });
     },
-    // 淇濆瓨鍒嗛厤璁板綍
-    handleSaveAllocation() {
-      if (!this.form.id) {
-        this.$message.warning("璇峰厛淇濆瓨鍩烘湰淇℃伅");
-        return;
-      }
 
-      this.saveLoading = true;
-      saveAllocationRecords(this.form.id, this.allocationData.records)
-        .then(response => {
-          if (response.code === 200) {
-            this.$message.success("鍒嗛厤璁板綍淇濆瓨鎴愬姛");
-          }
-        })
-        .catch(error => {
-          console.error("淇濆瓨鍒嗛厤璁板綍澶辫触:", error);
-          this.$message.error("淇濆瓨鍒嗛厤璁板綍澶辫触");
-        })
-        .finally(() => {
-          this.saveLoading = false;
-        });
+    // 鍣ㄥ畼琛屾牱寮�
+    getOrganRowClassName({ row }) {
+      if (row.allocationstatus == "3") {
+        return "redistributed-row"; // 閲嶅垎閰嶈褰曟牱寮�
+      } else if (row.allocationstatus == "2") {
+        return "invalidated-row"; // 浣滃簾璁板綍鏍峰紡
+      } else if (
+        !row.applicanttime ||
+        !row.organgettime ||
+        !row.name ||
+        !row.transplanthospitalname
+      ) {
+        return "warning-row"; // 淇℃伅涓嶅畬鏁存牱寮�
+      } else if (row.allocationstatus == "0") {
+        return "pending-row"; // 寰呭鏍告牱寮�
+      }
+      return "";
     },
+
+    // 鏋勫缓 filePatch 瀛楁
+    buildFilePatch() {
+      if (!this.attachments || this.attachments.length == 0) {
+        return "";
+      }
+      return JSON.stringify(this.attachments);
+    },
+
+    // 淇濆瓨鍩烘湰淇℃伅
+    async handleSave() {
+      this.$refs.form.validate(async valid => {
+        if (!valid) {
+          this.$message.warning("璇峰畬鍠勮〃鍗曚俊鎭�");
+          return;
+        }
+
+        this.saveLoading = true;
+        try {
+          const saveData = {
+            ...this.form,
+            serviceDonateorganList:
+              this.allocationData.serviceDonateorganList || []
+          };
+
+          // 纭繚姣忔潯璁板綍閮芥湁鍒嗛厤鐘舵��
+          saveData.serviceDonateorganList.forEach(item => {
+            item.baseid = this.form.id;
+            item.infoid = this.form.infoid;
+            // 纭繚鏈夊垎閰嶇姸鎬佸瓧娈�
+            if (!item.allocationstatus) {
+              item.allocationstatus = "0";
+            }
+            // 濡傛灉鏄噸鍒嗛厤璁板綍锛岀‘淇濇湁閲嶅垎閰嶄俊鎭�
+            if (item.allocationstatus == "3" && !item.reallocationreason) {
+              item.reallocationreason = item.redistributionInfo || "";
+            }
+          });
+
+          if (saveData.allocationStatus == 1 || !saveData.allocationStatus) {
+            saveData.allocationStatus = 2;
+          }
+          saveData.fileName = this.buildFilePatch();
+
+          const apiMethod = this.form.id ? allocationedit : allocationadd;
+          const response = await apiMethod(saveData);
+
+          if (response.code == 200) {
+            this.$message.success("淇濆瓨鎴愬姛");
+            if (!this.form.id && response.data) {
+              this.form.id = response.data;
+            }
+          } else {
+            this.$message.error("淇濆瓨澶辫触锛�" + (response.msg || "鏈煡閿欒"));
+          }
+        } catch (error) {
+          console.error("淇濆瓨澶辫触:", error);
+          this.$message.error("淇濆瓨澶辫触");
+        } finally {
+          this.saveLoading = false;
+        }
+      });
+    },
+
     // 纭瀹屾垚鍒嗛厤
-    handleConfirmAllocation() {
+    async handleConfirmAllocation() {
       if (this.incompleteRecords > 0) {
         this.$message.warning("璇峰厛瀹屽杽鎵�鏈夊垎閰嶈褰曠殑淇℃伅");
         return;
@@ -800,117 +1369,222 @@
         cancelButtonText: "鍙栨秷",
         type: "warning"
       })
-        .then(() => {
+        .then(async () => {
           this.confirmLoading = true;
-          this.form.allocationStatus = "allocated";
+          this.form.allocationStatus = "3";
           this.form.allocationTime = new Date()
             .toISOString()
             .replace("T", " ")
             .substring(0, 19);
 
-          updateOrganAllocation(this.form)
-            .then(response => {
-              if (response.code === 200) {
-                this.$message.success("鍣ㄥ畼鍒嗛厤宸插畬鎴�");
-              }
-            })
-            .catch(error => {
-              console.error("纭鍒嗛厤澶辫触:", error);
-              this.$message.error("纭鍒嗛厤澶辫触");
-            })
-            .finally(() => {
-              this.confirmLoading = false;
-            });
+          try {
+            const saveData = {
+              ...this.form,
+              attachments: this.attachments,
+              serviceDonateorganList:
+                this.allocationData.serviceDonateorganList || []
+            };
+
+            const response = await allocationedit(saveData);
+
+            if (response.code == 200) {
+              this.$message.success("鍣ㄥ畼鍒嗛厤宸插畬鎴�");
+            } else {
+              this.$message.error(
+                "纭鍒嗛厤澶辫触锛�" + (response.msg || "鏈煡閿欒")
+              );
+              this.form.allocationStatus = "0";
+              this.form.allocationTime = "";
+            }
+          } catch (error) {
+            console.error("纭鍒嗛厤澶辫触:", error);
+            this.$message.error("纭鍒嗛厤澶辫触");
+            this.form.allocationStatus = "0";
+            this.form.allocationTime = "";
+          } finally {
+            this.confirmLoading = false;
+          }
         })
-        .catch(() => {});
+        .catch(() => { });
     },
-    // 涓婁紶闄勪欢
-    handleUploadAttachment() {
-      // 闄勪欢涓婁紶閫昏緫
-      this.$message.info("闄勪欢涓婁紶鍔熻兘");
+
+    // 闄勪欢鐩稿叧鏂规硶
+    /** 闄勪欢鍙樺寲澶勭悊 */
+    handleAttachmentChange(fileList) {
+      this.attachmentFileList = fileList;
     },
-    // 棰勮闄勪欢
-    handlePreviewAttachment(attachment) {
-      // 闄勪欢棰勮閫昏緫
-      this.$message.info("闄勪欢棰勮鍔熻兘");
+    handleRedistributionChange(fileList) {
+      this.redistributionAttachmentList = fileList;
     },
-    // 涓嬭浇闄勪欢
-    handleDownloadAttachment(attachment) {
-      // 闄勪欢涓嬭浇閫昏緫
-      this.$message.info("闄勪欢涓嬭浇鍔熻兘");
-    },
-    // 鍒犻櫎闄勪欢
-    handleRemoveAttachment(attachment) {
-      this.$confirm("纭畾瑕佸垹闄よ繖涓檮浠跺悧锛�", "鎻愮ず", {
-        confirmButtonText: "纭畾",
-        cancelButtonText: "鍙栨秷",
-        type: "warning"
-      })
-        .then(() => {
+
+    /** 闄勪欢绉婚櫎澶勭悊 */
+    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("闄勪欢鍒犻櫎鎴愬姛");
-        })
-        .catch(() => {});
+        }
+      }
     },
-    // 鑾峰彇鏂囦欢鍥炬爣
-    getFileIcon(fileName) {
-      const ext = fileName
-        .split(".")
-        .pop()
-        .toLowerCase();
-      const iconMap = {
-        pdf: "el-icon-document",
-        doc: "el-icon-document",
-        docx: "el-icon-document",
-        xls: "el-icon-document",
-        xlsx: "el-icon-document",
-        jpg: "el-icon-picture",
-        jpeg: "el-icon-picture",
-        png: "el-icon-picture"
+
+    /** 涓婁紶鎴愬姛澶勭悊 */
+    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 (!Array.isArray(this.attachments)) {
+          this.attachments = [];
+        }
+
+        this.attachments.push(attachmentObj);
+        this.attachmentFileList = fileList;
+        this.$message.success("鏂囦欢涓婁紶鎴愬姛");
+      }
+    },
+
+    /** 涓婁紶閿欒澶勭悊 */
+    handleUploadError({ file, fileList, error }) {
+      console.error("闄勪欢涓婁紶澶辫触:", error);
+      this.$message.error("鏂囦欢涓婁紶澶辫触锛岃閲嶈瘯");
+    },
+
+    /** 鎵嬪姩鍒犻櫎闄勪欢 */
+    handleRemoveAttachment(index) {
+      this.attachments.splice(index, 1);
+      this.attachmentFileList.splice(index, 1);
+      this.$message.success("闄勪欢鍒犻櫎鎴愬姛");
+    },
+
+    /** 鏂囦欢棰勮 */
+    handlePreview(file) {
+      this.currentPreviewFile = {
+        fileName: file.fileName,
+        fileUrl: file.path || file.fileUrl,
+        fileType: this.getFileType(file.fileName)
       };
-      return iconMap[ext] || "el-icon-document";
+      this.filePreviewVisible = true;
     },
-    // 鑾峰彇鏂囦欢绫诲瀷
+
+    handleDownloadAttachment(file) {
+      const fileUrl = file.path || file.fileUrl;
+      const fileName = file.fileName;
+
+      if (fileUrl) {
+        const link = document.createElement("a");
+        link.href = fileUrl;
+        link.download = fileName;
+        link.style.display = "none";
+        document.body.appendChild(link);
+        link.click();
+        document.body.removeChild(link);
+        this.$message.success("寮�濮嬩笅杞芥枃浠�");
+      } else {
+        this.$message.warning("鏂囦欢璺緞涓嶅瓨鍦紝鏃犳硶涓嬭浇");
+      }
+    },
+
+    /** 鑾峰彇鏂囦欢绫诲瀷 */
     getFileType(fileName) {
-      const ext = fileName
+      if (!fileName) return "other";
+      const extension = fileName
         .split(".")
         .pop()
         .toLowerCase();
-      const typeMap = {
-        pdf: "PDF",
-        doc: "DOC",
-        docx: "DOCX",
-        xls: "XLS",
-        xlsx: "XLSX",
-        jpg: "JPG",
-        jpeg: "JPEG",
-        png: "PNG"
-      };
-      return typeMap[ext] || ext.toUpperCase();
+      const imageTypes = ["jpg", "jpeg", "png", "gif", "bmp", "webp"];
+      const pdfTypes = ["pdf"];
+      const officeTypes = ["doc", "docx", "xls", "xlsx", "ppt", "pptx"];
+      if (imageTypes.includes(extension)) return "image";
+      if (pdfTypes.includes(extension)) return "pdf";
+      if (officeTypes.includes(extension)) return "office";
+      return "other";
     },
-    // 鏂囦欢澶у皬鏍煎紡鍖�
-    formatFileSize(size) {
-      if (size === 0) return "0 B";
+
+    /** 鑾峰彇鏂囦欢鍥炬爣棰滆壊 */
+    getFileIconColor(fileName) {
+      const type = this.getFileType(fileName);
+      const colorMap = {
+        image: "#67C23A",
+        pdf: "#F56C6C",
+        office: "#409EFF",
+        other: "#909399"
+      };
+      return colorMap[type] || "#909399";
+    },
+
+    /** 鑾峰彇鏂囦欢鏍囩绫诲瀷 */
+    getFileTagType(fileName) {
+      const type = this.getFileType(fileName);
+      const typeMap = {
+        image: "success",
+        pdf: "danger",
+        office: "primary",
+        other: "info"
+      };
+      return typeMap[type] || "info";
+    },
+
+    /** 鑾峰彇鏂囦欢绫诲瀷鏂囨湰 */
+    getFileTypeText(fileName) {
+      const type = this.getFileType(fileName);
+      const textMap = {
+        image: "鍥剧墖",
+        pdf: "PDF",
+        office: "鏂囨。",
+        other: "鍏朵粬"
+      };
+      return textMap[type] || "鏈煡";
+    },
+
+    /** 妫�鏌ユ槸鍚﹀彲棰勮 */
+    isPreviewable(fileName) {
+      const type = this.getFileType(fileName);
+      return ["image", "pdf"].includes(type);
+    },
+
+    /** 鑾峰彇鏂囦欢鎵╁睍鍚� */
+    getFileExtension(filename) {
+      console.log(filename, "filename");
+
+      return filename
+        .split(".")
+        .pop()
+        .toLowerCase();
+    },
+
+    /** 鏍煎紡鍖栨枃浠跺ぇ灏� */
+    formatFileSize(bytes) {
+      if (!bytes || bytes == 0) return "0 B";
       const k = 1024;
       const sizes = ["B", "KB", "MB", "GB"];
-      const i = Math.floor(Math.log(size) / Math.log(k));
-      return parseFloat((size / Math.pow(k, i)).toFixed(2)) + " " + sizes[i];
+      const i = Math.floor(Math.log(bytes) / Math.log(k));
+      return parseFloat((bytes / Math.pow(k, i)).toFixed(2)) + " " + sizes[i];
     },
-    // 鏃堕棿鏍煎紡鍖�
-    parseTime(time) {
-      if (!time) return "";
-      const date = new Date(time);
-      return `${date.getFullYear()}-${(date.getMonth() + 1)
-        .toString()
-        .padStart(2, "0")}-${date
-        .getDate()
-        .toString()
-        .padStart(2, "0")} ${date
-        .getHours()
-        .toString()
-        .padStart(2, "0")}:${date
-        .getMinutes()
-        .toString()
-        .padStart(2, "0")}`;
+
+    /** 鏃ユ湡鏃堕棿鏍煎紡鍖� */
+    formatDateTime(dateTime) {
+      if (!dateTime) return "";
+      try {
+        const date = new Date(dateTime);
+        if (isNaN(date.getTime())) return dateTime;
+        const year = date.getFullYear();
+        const month = String(date.getMonth() + 1).padStart(2, "0");
+        const day = String(date.getDate()).padStart(2, "0");
+        const hours = String(date.getHours()).padStart(2, "0");
+        const minutes = String(date.getMinutes()).padStart(2, "0");
+        return `${year}-${month}-${day} ${hours}:${minutes}`;
+      } catch (error) {
+        return dateTime;
+      }
     }
   }
 };
@@ -938,6 +1612,44 @@
   margin-bottom: 20px;
   border-radius: 8px;
   box-shadow: 0 2px 12px 0 rgba(0, 0, 0, 0.1);
+  padding: 20px;
+  background: #fafafa;
+}
+
+.attachment-header {
+  display: flex;
+  align-items: center;
+  gap: 8px;
+  margin-bottom: 16px;
+  padding-bottom: 8px;
+  border-bottom: 1px solid #ebeef5;
+}
+
+.attachment-title {
+  font-weight: 600;
+  color: #303133;
+}
+
+.attachment-tip {
+  font-size: 12px;
+  color: #909399;
+  margin-left: auto;
+}
+
+.attachment-list {
+  margin-top: 16px;
+}
+
+.list-title {
+  font-weight: bold;
+  margin-bottom: 12px;
+  color: #303133;
+  font-size: 14px;
+}
+
+.file-name {
+  font-size: 13px;
+  margin-left: 8px;
 }
 
 .detail-title {
@@ -964,17 +1676,54 @@
 }
 
 .stat-label {
-  /* font-size: 12px; */
   opacity: 0.9;
-
-  /* color: #606266; */
   margin-bottom: 5px;
 }
 
 .stat-value {
   font-size: 20px;
   font-weight: bold;
-  /* color: #303133; */
+}
+
+/* 鍦╯tyle閮ㄥ垎娣诲姞 */
+.section-title {
+  font-weight: 600;
+  color: #303133;
+  margin-bottom: 8px;
+  font-size: 14px;
+}
+
+.section-content {
+  background: #f5f7fa;
+  padding: 12px;
+  border-radius: 4px;
+  border-left: 3px solid #e6a23c;
+  line-height: 1.6;
+}
+
+.redistribution-attachments {
+  margin-top: 10px;
+  border: 1px solid #ebeef5;
+  border-radius: 4px;
+  overflow: hidden;
+}
+
+/* 閲嶅垎閰嶈鎯呰〃鏍兼牱寮� */
+:deep(.redistribution-attachments .el-table) {
+  border: none;
+}
+
+:deep(.redistribution-attachments .el-table th) {
+  background-color: #f5f7fa;
+  color: #606266;
+  font-weight: 600;
+}
+
+/* 鍝嶅簲寮忚皟鏁� */
+@media (max-width: 768px) {
+  .redistribution-attachments {
+    overflow-x: auto;
+  }
 }
 
 /* 绌虹姸鎬佹牱寮� */
@@ -984,21 +1733,142 @@
   color: #909399;
 }
 
-/* 瀵硅瘽妗嗗簳閮ㄦ寜閽� */
-.dialog-footer {
-  margin-top: 20px;
-  text-align: center;
-  padding-top: 20px;
-  border-top: 1px solid #e4e7ed;
+/* 鏃犳暟鎹牱寮� */
+.no-data {
+  color: #909399;
+  font-style: italic;
 }
 
-/* 琛ㄦ牸琛屾牱寮� */
+/* ===== 琛ㄦ牸琛屾牱寮� ===== */
+
+/* 閲嶅垎閰嶈鏍峰紡 */
+:deep(.redistributed-row) {
+  background-color: #fdf6ec;
+  opacity: 0.8;
+}
+
+:deep(.redistributed-row:hover) {
+  background-color: #faecd8;
+  opacity: 0.9;
+}
+
+/* 淇℃伅涓嶅畬鏁磋鍛婅鏍峰紡 */
 :deep(.warning-row) {
   background-color: #fff7e6;
 }
 
 :deep(.warning-row:hover) {
   background-color: #ffecc2;
+}
+
+/* 寰呭鏍歌鏍峰紡 */
+:deep(.pending-row) {
+  background-color: #f0f9ff;
+}
+
+:deep(.pending-row:hover) {
+  background-color: #e0f2ff;
+}
+
+/* ===== 鏂板锛氫綔搴熻鏍峰紡 ===== */
+:deep(.invalidated-row) {
+  background-color: #fef0f0;
+  position: relative;
+}
+
+:deep(.invalidated-row td) {
+  opacity: 0.6;
+  text-decoration: line-through;
+  color: #c0c4cc !important;
+}
+
+:deep(.invalidated-row:hover td) {
+  background-color: #fde2e2 !important;
+  opacity: 0.75;
+}
+
+/* 浣滃簾琛屽唴鐨勮緭鍏ユ鍜岄�夋嫨鍣ㄦ牱寮� */
+:deep(.invalidated-row .el-input__inner),
+:deep(.invalidated-row .el-textarea__inner),
+:deep(.invalidated-row .el-date-editor .el-input__inner) {
+  background-color: #fef0f0 !important;
+  border-color: #fbc4c4 !important;
+  color: #c0c4cc !important;
+  cursor: not-allowed !important;
+}
+
+/* 浣滃簾琛屽唴鐨勬爣绛炬牱寮� */
+:deep(.invalidated-row .el-tag) {
+  opacity: 0.5;
+}
+
+/* 浣滃簾琛屽唴鐨勬寜閽牱寮� */
+:deep(.invalidated-row .el-button--text) {
+  color: #c0c4cc !important;
+  cursor: not-allowed !important;
+}
+
+/* ===== 鎿嶄綔鎸夐挳鏍峰紡 ===== */
+
+/* 鎿嶄綔鎸夐挳瀹瑰櫒 */
+.operation-buttons {
+  display: flex;
+  gap: 4px;
+  justify-content: center;
+  align-items: center;
+}
+
+/* 鎿嶄綔鎸夐挳閫氱敤鏍峰紡 */
+:deep(.el-table .el-button--text) {
+  padding: 4px 6px;
+  font-size: 12px;
+}
+
+/* 閲嶅垎閰嶆寜閽牱寮� */
+:deep(.el-button--text.redistribute-btn) {
+  color: #e6a23c;
+}
+
+:deep(.el-button--text.redistribute-btn:hover:not(:disabled)) {
+  color: #cf9236;
+}
+
+/* 浣滃簾鎸夐挳鏍峰紡 */
+:deep(.el-button--text.invalidate-btn) {
+  color: #f56c6c;
+}
+
+:deep(.el-button--text.invalidate-btn:hover:not(:disabled)) {
+  color: #d9534f;
+}
+
+/* 绂佺敤鐘舵�佺殑鎸夐挳鏍峰紡 */
+:deep(.el-button--text.is-disabled) {
+  color: #c0c4cc !important;
+  cursor: not-allowed !important;
+  opacity: 0.5;
+}
+
+/* 閲嶅垎閰嶄俊鎭彁绀烘鏍峰紡 */
+:deep(.el-tooltip__popper) {
+  max-width: 300px;
+  white-space: pre-line;
+  line-height: 1.6;
+}
+
+/* 绂佺敤鐘舵�佺殑杈撳叆妗嗘牱寮� */
+:deep(.el-input.is-disabled .el-input__inner) {
+  background-color: #f5f7fa;
+  border-color: #e4e7ed;
+  color: #c0c4cc;
+  cursor: not-allowed;
+}
+
+:deep(.el-textarea.is-disabled .el-textarea__inner) {
+  background-color: #f5f7fa;
+  border-color: #e4e7ed;
+  color: #c0c4cc;
+  cursor: not-allowed;
 }
 
 /* 鍝嶅簲寮忚璁� */
@@ -1010,5 +1880,11 @@
   .allocation-stats .el-col {
     margin-bottom: 10px;
   }
+
+  /* 绉诲姩绔搷浣滄寜閽牱寮忚皟鏁� */
+  :deep(.el-table .el-button--text) {
+    padding: 2px 4px;
+    font-size: 11px;
+  }
 }
 </style>

--
Gitblit v1.9.3