WXL
昨天 c8e9849cb5f24848df0174c13bfbbff37bb08a5a
src/views/business/allocation/allocationInfo.vue
@@ -5,47 +5,22 @@
    <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="handleConfirmAllocation"
            :disabled="form.allocationStatus == '1'"
            :loading="confirmLoading"
          >
            确认分配
          </el-button>
        </div>
      </div>
      <el-form :model="form" ref="form" :rules="rules" label-width="120px">
        <el-row :gutter="20">
          <el-col :span="12">
            <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 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 == '1'"
              />
              <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>
@@ -56,16 +31,7 @@
              <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%"
              />
            </el-form-item>
          </el-col>
        </el-row>
      </el-form>
    </el-card>
@@ -75,55 +41,22 @@
      <div slot="header" class="clearfix">
        <span class="detail-title">器官分配记录</span>
        <div style="float: right;">
          <el-tag
            :type="
              form.allocationStatus == '1'
                ? 'success'
                : form.allocationStatus == '2'
                ? 'danger'
                : 'warning'
            "
          >
            {{
              form.allocationStatus == "1"
                ? "已分配"
                : form.allocationStatus == "2"
                ? "作废"
                : "未分配"
            }}
          </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="dict in dict.type.sys_Organ || []"
                  :key="dict.value"
                  :label="dict.value"
                  :disabled="form.allocationStatus == '1'"
                >
              <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-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>
@@ -131,56 +64,26 @@
        <el-row>
          <el-col>
            <el-form-item>
              <el-table
                :data="allocationData.serviceDonateorganList"
                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 :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
                >
                <el-table-column label="分配状态" align="center" width="100" prop="allocationstatus" fixed>
                  <template slot-scope="scope">
                    <el-tag
                      :type="
                        getAllocationStatusTagType(scope.row.allocationstatus)
                      "
                      size="small"
                    >
                    <el-tag :type="getAllocationStatusTagType(scope.row.allocationstatus)
                      " size="small">
                      {{ getAllocationStatusText(scope.row.allocationstatus) }}
                    </el-tag>
                  </template>
                </el-table-column>
                <el-table-column
                  label="器官名称"
                  align="center"
                  width="120"
                  prop="organname"
                >
                <el-table-column label="器官名称" align="center" width="120" prop="organname">
                  <template slot-scope="scope">
                    <el-input
                      v-model="scope.row.organname"
                      placeholder="器官名称"
                      :disabled="true"
                    />
                    <el-input v-model="scope.row.organname" placeholder="器官名称" :disabled="true" />
                  </template>
                </el-table-column>
                <el-table-column
                <!-- <el-table-column
                  label="分配系统编号"
                  align="center"
                  width="150"
@@ -196,143 +99,78 @@
                      "
                    />
                  </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"
                    <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="200" prop="transplanthospitalname">
                  <template slot-scope="scope">
                    <el-autocomplete v-model="scope.row.transplanthospitalname" :fetch-suggestions="queryHospitalSearch"
                      placeholder="请选择或输入移植医院" style="width: 100%" clearable></el-autocomplete>
                  </template>
                  <!-- <template slot-scope="scope">
                    <el-select
                      v-model="scope.row.transplanthospitalname"
                      placeholder="请选择移植医院"
                      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="120"
                  prop="name"
                >
                  <template slot-scope="scope">
                    <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="200"
                  prop="transplanthospitalno"
                >
                  <template slot-scope="scope">
                    <div>
                      <org-selecter
                        ref="tranHosSelect"
                        :org-type="'4'"
                        :dataList="dataList"
                        v-model="scope.row.transplanthospitalno"
                        style="width: 100%"
                        :disabled="
                          form.allocationStatus == '1' ||
                            scope.row.allocationstatus == '3'
                        "
                      />
                    </div>
                  </template>
                    >
                      <el-option
                        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"
                >
                <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'
                        "
                      />
                      <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;"
                      >
                      <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;"
                        >
                      <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>
@@ -340,29 +178,24 @@
                  </template>
                </el-table-column>
                <el-table-column
                  label="操作"
                  align="center"
                  width="120"
                  class-name="small-padding fixed-width"
                  v-if="form.allocationStatus !== '1'"
                  fixed="right"
                >
                <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-button
                      size="mini"
                      type="text"
                      icon="el-icon-copy-document"
                      @click="handleRedistribution(scope.row)"
                      :disabled="
                        scope.row.allocationstatus == '3' || !scope.row.caseno
                      "
                      style="color: #e6a23c;"
                    >
                    <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>
@@ -373,7 +206,7 @@
        </el-row>
        <!-- 分配统计信息 -->
        <div
        <!-- <div
          class="allocation-stats"
          v-if="
            allocationData.serviceDonateorganList &&
@@ -408,9 +241,12 @@
              </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>
@@ -423,34 +259,21 @@
      <div class="attachment-header">
        <i class="el-icon-paperclip"></i>
        <span class="attachment-title">相关附件</span>
        <span class="attachment-tip"
          >支持上传器官分配相关文件 (最多{{ attachmentLimit }}个)</span
        >
        <span class="attachment-tip">支持上传器官分配相关文件 (最多{{ attachmentLimit }}个)</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"
      />
      <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="200">
          <el-table-column label="文件名" min-width="150">
            <template slot-scope="scope">
              <i
                class="el-icon-document"
                :style="{ color: getFileIconColor(scope.row.fileName) }"
              ></i>
              <i class="el-icon-document" :style="{ color: getFileIconColor(scope.row.fileName) }"></i>
              <span class="file-name">{{ scope.row.fileName }}</span>
            </template>
          </el-table-column>
@@ -471,28 +294,16 @@
              <span>{{ formatFileSize(scope.row.fileSize) }}</span>
            </template>
          </el-table-column>
          <el-table-column label="操作" width="200" fixed="right">
          <el-table-column label="操作" width="280" fixed="right">
            <template slot-scope="scope">
              <el-button
                size="mini"
                type="primary"
                @click="handlePreview(scope.row)"
                :disabled="!isPreviewable(scope.row.fileName)"
              >
              <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 size="mini" type="success" @click="handleDownloadAttachment(scope.row)">
                下载
              </el-button>
              <el-button
                size="mini"
                type="danger"
                @click="handleRemoveAttachment(scope.$index)"
              >
              <el-button size="mini" type="danger" @click="handleRemoveAttachment(scope.$index)">
                删除
              </el-button>
            </template>
@@ -500,52 +311,34 @@
        </el-table>
      </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="handleConfirmAllocation" :disabled="form.allocationStatus == '1'"
        :loading="confirmLoading">
        确认分配
      </el-button>
    </div>
    <!-- 重分配对话框 -->
    <el-dialog
      title="器官重分配"
      :visible.sync="redistributionDialogVisible"
      width="500px"
      @close="handleRedistributionDialogClose"
    >
      <el-form
        :model="redistributionForm"
        :rules="redistributionRules"
        ref="redistributionFormRef"
        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-form-item>
        <el-form-item label="重分配原因" prop="reason" required>
          <el-input
            type="textarea"
            :rows="4"
            v-model="redistributionForm.reason"
            placeholder="请输入重分配原因"
          />
          <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-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"
          />
          <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>
@@ -553,21 +346,13 @@
      </el-form>
      <div slot="footer">
        <el-button @click="redistributionDialogVisible = false">取消</el-button>
        <el-button
          type="primary"
          @click="handleRedistributionConfirm"
          :loading="redistributionLoading"
        >
        <el-button type="primary" @click="handleRedistributionConfirm" :loading="redistributionLoading">
          确认重分配
        </el-button>
      </div>
    </el-dialog>
    <!-- 在template中添加重分配详情弹窗 -->
    <el-dialog
      title="重分配详情"
      :visible.sync="redistributionDetailDialogVisible"
      width="600px"
    >
    <el-dialog title="重分配详情" :visible.sync="redistributionDetailDialogVisible" width="600px">
      <div v-loading="redistributionDetailLoading">
        <div v-if="currentRedistributionDetail" style="padding: 20px;">
          <!-- 基本信息 -->
@@ -589,8 +374,8 @@
              {{
                currentRedistributionDetail.redistributionTime
                  ? formatDateTime(
                      currentRedistributionDetail.redistributionTime
                    )
                    currentRedistributionDetail.redistributionTime
                  )
                  : "-"
              }}
            </el-descriptions-item>
@@ -599,46 +384,30 @@
          <!-- 重分配原因 -->
          <div style="margin-top: 20px;">
            <div class="section-title">重分配原因</div>
            <div
              class="section-content"
              style="padding: 10px; background: #f5f7fa; border-radius: 4px;"
            >
            <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 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="200">
              <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>
                    <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"
                    >
                    <el-tag :type="getFileTagType(scope.row.fileName)" size="small">
                      {{ getFileTypeText(scope.row.fileName) }}
                    </el-tag>
                  </template>
@@ -654,19 +423,11 @@
                </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 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 size="mini" type="success" @click="handleRedistributionAttachmentDownload(scope.row)">
                      下载
                    </el-button>
                  </template>
@@ -675,27 +436,18 @@
            </div>
          </div>
          <div
            v-else
            style="margin-top: 20px; text-align: center; color: #909399;"
          >
          <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
        >
        <el-button @click="redistributionDetailDialogVisible = false">关闭</el-button>
      </div>
    </el-dialog>
    <!-- 附件预览对话框 -->
    <FilePreviewDialog
      :visible="filePreviewVisible"
      :file="currentPreviewFile"
      @close="filePreviewVisible = false"
      @download="handleDownloadAttachment"
    />
    <FilePreviewDialog :visible="filePreviewVisible" :file="currentPreviewFile" @close="filePreviewVisible = false"
      @download="handleDownloadAttachment" />
  </div>
</template>
@@ -725,6 +477,8 @@
    "sys_DonationCategory",
    "sys_RecordState",
    "sys_Organ",
    "Geta_hospital",
    "organ_allocation_status"
  ],
  data() {
@@ -825,16 +579,19 @@
    currentUser() {
      return JSON.parse(sessionStorage.getItem("user") || "{}");
    },
     displayOrgans() {
    return (this.allocationData.serviceDonateorganList || [])
      .filter(item => item.delFlag !== 1);
  },
    // 不完整的记录数量
    incompleteRecords() {
      if (!this.allocationData.serviceDonateorganList) return 0;
      return this.allocationData.serviceDonateorganList.filter(
        record =>
          !record.caseno ||
          !record.applicanttime ||
          !record.organgettime ||
          !record.name ||
          !record.transplanthospitalno
          !record.transplanthospitalname
      ).length;
    },
    // 待审核记录数量
@@ -851,11 +608,10 @@
        record => record.allocationstatus == "3"
      ).length;
    },
    // 唯一医院数量
    uniqueHospitals() {
      if (!this.allocationData.serviceDonateorganList) return 0;
      const hospitals = this.allocationData.serviceDonateorganList
        .map(record => record.transplanthospitalno)
        .map(record => record.transplanthospitalname)
        .filter(Boolean);
      return new Set(hospitals).size;
    },
@@ -872,7 +628,7 @@
      return {
        "0": { label: "提交分配", type: "info" },
        "1": { label: "审核通过", type: "success" },
        "2": { label: "审核拒绝", type: "danger" },
        "2": { label: "已作废", type: "danger" },
        "3": { label: "重分配", type: "warning" }
      };
    }
@@ -921,7 +677,17 @@
      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;
@@ -1067,7 +833,6 @@
        if (response.code == 200 && response.data && response.data.length > 0) {
          const data = response.data[0];
          data.allocationStatus = JSON.stringify(data.allocationStatus);
          // 填充表单数据
          Object.assign(this.form, data);
          // 转换附件为集合
@@ -1086,29 +851,29 @@
              data.serviceDonateorganList
            )
              ? data.serviceDonateorganList.map(item => {
                  // 确保每条记录都有分配状态字段,默认值为0
                  const allocationstatus = item.allocationstatus || "0";
                  let redistributionInfo = null;
                // 确保每条记录都有分配状态字段,默认值为0
                const allocationstatus = item.allocationstatus || "0";
                let redistributionInfo = null;
                  // 解析重分配信息
                  if (allocationstatus == "3" && item.reallocationreason) {
                    try {
                      redistributionInfo = JSON.parse(item.reallocationreason);
                      console.log(redistributionInfo);
                    } catch (error) {
                      console.warn("解析重分配信息失败:", error);
                      redistributionInfo = item.reallocationreason;
                    }
                // 解析重分配信息
                if (allocationstatus == "3" && item.reallocationreason) {
                  try {
                    redistributionInfo = JSON.parse(item.reallocationreason);
                    console.log(redistributionInfo);
                  } catch (error) {
                    console.warn("解析重分配信息失败:", error);
                    redistributionInfo = item.reallocationreason;
                  }
                }
                  return {
                    ...item,
                    allocationstatus,
                    redistributionInfo: redistributionInfo
                      ? JSON.stringify(redistributionInfo)
                      : null
                  };
                })
                return {
                  ...item,
                  allocationstatus,
                  redistributionInfo: redistributionInfo
                    ? JSON.stringify(redistributionInfo)
                    : null
                };
              })
              : [];
            // 更新选中的器官
@@ -1176,58 +941,78 @@
    },
    // 器官选择状态变化
    handleOrganSelectionChange(selectedValues) {
      if (!this.allocationData.serviceDonateorganList) {
        this.allocationData.serviceDonateorganList = [];
   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);
    }
  });
      const currentOrganValues = this.allocationData.serviceDonateorganList.map(
        item => item.organno
  // 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'
        }
      );
      // 处理互斥逻辑(参考捐献决定页面)
      this.handleExclusiveSelections(selectedValues);
      // 新增选择的器官
      selectedValues.forEach(organValue => {
        if (!currentOrganValues.includes(organValue)) {
          this.createOrganRecord(organValue);
      // 用户确认:标记 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; // 退出方法,避免继续执行
    }
  }
      // 移除取消选择的器官
      this.allocationData.serviceDonateorganList = this.allocationData.serviceDonateorganList.filter(
        record => {
          if (selectedValues.includes(record.organno)) {
            return true;
          } else {
            if (record.id) {
              this.$confirm(
                "删除器官分配数据后将无法恢复,您确认删除该条记录吗?",
                "提示",
                {
                  confirmButtonText: "确定",
                  cancelButtonText: "取消",
                  type: "warning"
                }
              )
                .then(() => {
                  this.allocationData.serviceDonateorganList = this.allocationData.serviceDonateorganList.filter(
                    r => r.organno !== record.organno
                  );
                  this.$message.success("删除成功");
                })
                .catch(() => {
                  this.selectedOrgans.push(record.organno);
                });
              return true; // 等待用户确认
            } else {
              return false; // 直接删除新记录
            }
          }
        }
      );
    },
  // 5. 注意:对于已标记删除的记录,我们不从 selectedOrgans 中移除(已在确认时移除)
  // 但还要考虑:某些记录可能因为互斥逻辑被移除,已包含在 finalSelected 中处理,无额外操作
  // 更新表单字段(如果需要保存选中的器官列表,可以在这里设置 this.form.donateorgan,但本项目未用)
  // 如果需要,可以添加 this.form.donateorgan = this.selectedOrgans.join(',');
},
    // 处理互斥选择(参考捐献决定页面)
    handleExclusiveSelections(selectedValues) {
@@ -1282,7 +1067,8 @@
        reallocationreason: "",
        allocationstatus: "0", // 默认提交分配状态
        redistributionInfo: null,
        organState: 1
        organState: 1,
          delFlag: 0   // 新增
      });
    },
@@ -1308,7 +1094,41 @@
      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 = {
@@ -1459,12 +1279,13 @@
    getOrganRowClassName({ row }) {
      if (row.allocationstatus == "3") {
        return "redistributed-row"; // 重分配记录样式
      } else if (row.allocationstatus == "2") {
        return "invalidated-row"; // 作废记录样式
      } else if (
        !row.caseno ||
        !row.applicanttime ||
        !row.organgettime ||
        !row.name ||
        !row.transplanthospitalno
        !row.transplanthospitalname
      ) {
        return "warning-row"; // 信息不完整样式
      } else if (row.allocationstatus == "0") {
@@ -1584,7 +1405,7 @@
            this.confirmLoading = false;
          }
        })
        .catch(() => {});
        .catch(() => { });
    },
    // 附件相关方法
@@ -1863,6 +1684,7 @@
  font-size: 20px;
  font-weight: bold;
}
/* 在style部分添加 */
.section-title {
  font-weight: 600;
@@ -1903,6 +1725,7 @@
    overflow-x: auto;
  }
}
/* 空状态样式 */
.empty-allocation {
  text-align: center;
@@ -1916,7 +1739,9 @@
  font-style: italic;
}
/* 表格行样式 */
/* ===== 表格行样式 ===== */
/* 重分配行样式 */
:deep(.redistributed-row) {
  background-color: #fdf6ec;
  opacity: 0.8;
@@ -1927,6 +1752,7 @@
  opacity: 0.9;
}
/* 信息不完整警告行样式 */
:deep(.warning-row) {
  background-color: #fff7e6;
}
@@ -1935,12 +1761,99 @@
  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;
}
/* 禁用状态的输入框样式 */
@@ -1958,19 +1871,6 @@
  cursor: not-allowed;
}
/* 重分配按钮样式 */
:deep(.el-button--text.is-disabled) {
  color: #c0c4cc !important;
  cursor: not-allowed;
}
/* 重分配信息提示框样式 */
:deep(.el-tooltip__popper) {
  max-width: 300px;
  white-space: pre-line;
  line-height: 1.6;
}
/* 响应式设计 */
@media (max-width: 768px) {
  .organ-allocation-detail {
@@ -1980,5 +1880,11 @@
  .allocation-stats .el-col {
    margin-bottom: 10px;
  }
  /* 移动端操作按钮样式调整 */
  :deep(.el-table .el-button--text) {
    padding: 2px 4px;
    font-size: 11px;
  }
}
</style>