WXL
3 天以前 dc082351978a1e9f75d7a1471a0ca7ebeac552a5
src/views/business/allocation/allocationInfo.vue
@@ -52,7 +52,7 @@
        <el-row :gutter="20">
          <el-col :span="12">
            <el-form-item label="登记人" prop="registrationName">
            <el-form-item label="负责人" prop="registrationName">
              <el-input v-model="form.registrationName" />
            </el-form-item>
          </el-col>
@@ -122,6 +122,7 @@
                v-model="otherOrganInput"
                placeholder="请输入其他器官名称"
                style="margin-top: 10px; width: 300px;"
                :disabled="form.allocationStatus == '1'"
              />
            </el-form-item>
          </el-col>
@@ -137,6 +138,33 @@
                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-tag
                      :type="
                        getAllocationStatusTagType(scope.row.allocationstatus)
                      "
                      size="small"
                    >
                      {{ getAllocationStatusText(scope.row.allocationstatus) }}
                    </el-tag>
                  </template>
                </el-table-column>
                <el-table-column
                  label="器官名称"
                  align="center"
@@ -162,13 +190,16 @@
                    <el-input
                      v-model="scope.row.caseno"
                      placeholder="分配系统编号"
                      :disabled="form.allocationStatus == '1'"
                      :disabled="
                        form.allocationStatus == '1' ||
                          scope.row.allocationstatus == '3'
                      "
                    />
                  </template>
                </el-table-column>
                <el-table-column
                  label="分配接收时间"
                  label="分配开始时间"
                  align="center"
                  width="180"
                  prop="applicanttime"
@@ -181,8 +212,33 @@
                      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'"
                      :disabled="
                        form.allocationStatus == '1' ||
                          scope.row.allocationstatus == '3'
                      "
                    />
                  </template>
                </el-table-column>
@@ -197,7 +253,10 @@
                    <el-input
                      v-model="scope.row.name"
                      placeholder="受体姓氏"
                      :disabled="form.allocationStatus == '1'"
                      :disabled="
                        form.allocationStatus == '1' ||
                          scope.row.allocationstatus == '3'
                      "
                    />
                  </template>
                </el-table-column>
@@ -216,11 +275,16 @@
                        :dataList="dataList"
                        v-model="scope.row.transplanthospitalno"
                        style="width: 100%"
                        :disabled="
                          form.allocationStatus == '1' ||
                            scope.row.allocationstatus == '3'
                        "
                      />
                    </div>
                  </template>
                </el-table-column>
                <!-- 修改template中的说明列 -->
                <el-table-column
                  label="说明"
                  align="center"
@@ -228,13 +292,51 @@
                  min-width="200"
                >
                  <template slot-scope="scope">
                    <el-input
                      type="textarea"
                      clearable
                      v-model="scope.row.reallocationreason"
                      placeholder="请输入说明"
                      :disabled="form.allocationStatus == '1'"
                    />
                    <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>
@@ -244,6 +346,7 @@
                  width="120"
                  class-name="small-padding fixed-width"
                  v-if="form.allocationStatus !== '1'"
                  fixed="right"
                >
                  <template slot-scope="scope">
                    <el-button
@@ -251,9 +354,16 @@
                      type="text"
                      icon="el-icon-copy-document"
                      @click="handleRedistribution(scope.row)"
                      :disabled="!scope.row.caseno"
                      :disabled="
                        scope.row.allocationstatus == '3' || !scope.row.caseno
                      "
                      style="color: #e6a23c;"
                    >
                      重分配
                      {{
                        scope.row.allocationstatus == "3"
                          ? "已重分配"
                          : "重分配"
                      }}
                    </el-button>
                  </template>
                </el-table-column>
@@ -281,8 +391,8 @@
            </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">
@@ -293,26 +403,8 @@
            </el-col>
            <el-col :span="6">
              <div class="stat-item">
                <span class="stat-label">分配状态:</span>
                <span class="stat-value">
                  <el-tag
                    :type="
                      form.allocationStatus == '1'
                        ? 'success'
                        : form.allocationStatus == '2'
                        ? 'danger'
                        : 'warning'
                    "
                  >
                    {{
                      form.allocationStatus == "1"
                        ? "已分配"
                        : form.allocationStatus == "2"
                        ? "作废"
                        : "未分配"
                    }}
                  </el-tag>
                </span>
                <span class="stat-label">重分配:</span>
                <span class="stat-value">{{ redistributedCount }} 个</span>
              </div>
            </el-col>
          </el-row>
@@ -324,28 +416,6 @@
          </el-empty>
        </div>
      </el-form>
      <!-- <div class="dialog-footer" v-if="form.allocationStatus !== '1'">
        <el-button
          type="primary"
          @click="handleSaveAllocation"
          :loading="saveLoading"
          :disabled="
            !allocationData.serviceDonateorganList ||
              allocationData.serviceDonateorganList.length == 0
          "
        >
          保存分配记录
        </el-button>
        <el-button
          type="success"
          @click="handleConfirmAllocation"
          :loading="confirmLoading"
          :disabled="incompleteRecords > 0"
        >
          确认完成分配
        </el-button>
      </div> -->
    </el-card>
    <!-- 附件管理部分优化 -->
@@ -436,12 +506,18 @@
      title="器官重分配"
      :visible.sync="redistributionDialogVisible"
      width="500px"
      @close="handleRedistributionDialogClose"
    >
      <el-form :model="redistributionForm" label-width="100px">
      <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">
        <el-form-item label="重分配原因" prop="reason" required>
          <el-input
            type="textarea"
            :rows="4"
@@ -449,15 +525,170 @@
            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>
    <!-- 在template中添加重分配详情弹窗 -->
    <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="200">
                  <template slot-scope="scope">
                    <i
                      class="el-icon-document"
                      :style="{ color: getFileIconColor(scope.row.fileName) }"
                    ></i>
                    <span class="file-name">{{ scope.row.fileName }}</span>
                  </template>
                </el-table-column>
                <el-table-column label="文件类型" width="100">
                  <template slot-scope="scope">
                    <el-tag
                      :type="getFileTagType(scope.row.fileName)"
                      size="small"
                    >
                      {{ getFileTypeText(scope.row.fileName) }}
                    </el-tag>
                  </template>
                </el-table-column>
                <el-table-column label="上传时间" width="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"
@@ -499,7 +730,10 @@
  data() {
    return {
      caseId: null,
      // 重分配详情相关
      redistributionDetailDialogVisible: false,
      redistributionDetailLoading: false,
      currentRedistributionDetail: null,
      // 表单数据
      form: {
        id: undefined,
@@ -538,9 +772,19 @@
      },
      // 分配记录验证规则
      allocationRules: {},
      // 重分配验证规则
      redistributionRules: {
        reason: [
          { required: true, message: "重分配原因不能为空", trigger: "blur" }
        ],
        redistributionTime: [
          { required: true, message: "重分配时间不能为空", trigger: "blur" }
        ]
      },
      // 保存加载状态
      saveLoading: false,
      confirmLoading: false,
      redistributionLoading: false,
      // 加载状态
      loading: false,
      // 选中的器官(存储字典value)
@@ -564,8 +808,11 @@
      redistributionDialogVisible: false,
      redistributionForm: {
        organname: "",
        reason: ""
        reason: "",
        redistributionTime: ""
      },
      redistributionAttachmentList: [],
      redistributionFormRef: null,
      currentRedistributeRecord: null,
      // 文件预览相关
      filePreviewVisible: false,
@@ -585,8 +832,23 @@
        record =>
          !record.caseno ||
          !record.applicanttime ||
          !record.organgettime ||
          !record.name ||
          !record.transplanthospitalno
      ).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;
    },
    // 唯一医院数量
@@ -604,6 +866,15 @@
    // 判断是否需要显示其他输入框
    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: {
@@ -639,6 +910,100 @@
    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 : "未知状态";
    },
    // 查看重分配详情
    handleViewRedistributionDetail(row) {
      this.redistributionDetailLoading = true;
      this.redistributionDetailDialogVisible = true;
      try {
        if (row.redistributionInfo) {
          // 解析重分配信息
          const redistributionInfo = JSON.parse(row.redistributionInfo);
          this.currentRedistributionDetail = {
            organname: row.organname || "-",
            ...redistributionInfo
          };
        } else {
          this.currentRedistributionDetail = {
            organname: row.organname || "-",
            reason: "无重分配原因",
            attachments: []
          };
        }
      } catch (error) {
        console.error("解析重分配信息失败:", 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);
@@ -671,6 +1036,7 @@
      this.getHospitalData();
    },
    // 生成捐献者编号
    generateDonorNo() {
      const timestamp = Date.now().toString();
@@ -692,10 +1058,10 @@
        this.form.attachments = [];
      }
    },
    // 获取详情
    async getDetail(infoid, id) {
      this.loading = true;
      donateorganBaseinfoInfo(id);
      try {
        const response = await allocationList({ infoid });
        if (response.code == 200 && response.data && response.data.length > 0) {
@@ -719,7 +1085,30 @@
            this.allocationData.serviceDonateorganList = Array.isArray(
              data.serviceDonateorganList
            )
              ? data.serviceDonateorganList
              ? data.serviceDonateorganList.map(item => {
                  // 确保每条记录都有分配状态字段,默认值为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;
                    }
                  }
                  return {
                    ...item,
                    allocationstatus,
                    redistributionInfo: redistributionInfo
                      ? JSON.stringify(redistributionInfo)
                      : null
                  };
                })
              : [];
            // 更新选中的器官
@@ -767,6 +1156,7 @@
        this.loading = false;
      }
    },
    // 获取医院数据
    async getHospitalData() {
      try {
@@ -784,6 +1174,7 @@
        this.$message.error("获取医院数据失败");
      }
    },
    // 器官选择状态变化
    handleOrganSelectionChange(selectedValues) {
      if (!this.allocationData.serviceDonateorganList) {
@@ -884,10 +1275,13 @@
        organno: organValue,
        caseno: "",
        applicanttime: "",
        organgettime: "",
        name: "",
        transplanthospitalno: "",
        transplantHospitalName: "",
        reallocationreason: "",
        allocationstatus: "0", // 默认提交分配状态
        redistributionInfo: null,
        organState: 1
      });
    },
@@ -901,38 +1295,184 @@
        row.transplantHospitalName = hospital.hospitalName;
      }
    },
    // 重分配操作
    handleRedistribution(row) {
      this.currentRedistributeRecord = row;
      this.redistributionForm.organname = row.organname;
      this.redistributionForm.reason = row.reallocationreason || "";
      this.redistributionForm.reason = "";
      this.redistributionForm.redistributionTime = new Date()
        .toISOString()
        .replace("T", " ")
        .substring(0, 19);
      this.redistributionAttachmentList = [];
      this.redistributionDialogVisible = true;
    },
    // 确认重分配
    handleRedistributionConfirm() {
      if (!this.redistributionForm.reason) {
        this.$message.warning("请输入重分配原因");
        return;
      }
      if (this.currentRedistributeRecord) {
        this.currentRedistributeRecord.reallocationreason = this.redistributionForm.reason;
        this.$message.success("重分配原因已更新");
        this.redistributionDialogVisible = false;
    // 重分配对话框关闭
    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);
        }
      }
    },
    // 确认重分配
    async handleRedistributionConfirm() {
      this.$refs.redistributionFormRef.validate(async valid => {
        if (!valid) {
          this.$message.warning("请完善重分配信息");
          return;
        }
        console.log(1, this.redistributionAttachmentList);
        this.redistributionLoading = true;
        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, // 新记录ID为空
              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;
        }
      });
    },
    // 器官行样式
    getOrganRowClassName({ row }) {
      if (
      if (row.allocationstatus == "3") {
        return "redistributed-row"; // 重分配记录样式
      } else if (
        !row.caseno ||
        !row.applicanttime ||
        !row.organgettime ||
        !row.name ||
        !row.transplanthospitalno
      ) {
        return "warning-row";
        return "warning-row"; // 信息不完整样式
      } else if (row.allocationstatus == "0") {
        return "pending-row"; // 待审核样式
      }
      return "";
    },
    // 构建 filePatch 字段
    buildFilePatch() {
      if (!this.attachments || this.attachments.length == 0) {
@@ -940,6 +1480,7 @@
      }
      return JSON.stringify(this.attachments);
    },
    // 保存基本信息
    async handleSave() {
      this.$refs.form.validate(async valid => {
@@ -955,17 +1496,26 @@
            serviceDonateorganList:
              this.allocationData.serviceDonateorganList || []
          };
          if (
            submitData.allocationStatus == 1 ||
            !submitData.allocationStatus
          ) {
            submitData.allocationStatus = 2;
          }
          saveData.fileName = this.buildFilePatch();
          // 确保每条记录都有分配状态
          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);
@@ -973,9 +1523,6 @@
            this.$message.success("保存成功");
            if (!this.form.id && response.data) {
              this.form.id = response.data;
              // this.$router.replace({
              //   query: { ...this.$route.query, id: this.form.id }
              // });
            }
          } else {
            this.$message.error("保存失败:" + (response.msg || "未知错误"));
@@ -988,38 +1535,7 @@
        }
      });
    },
    // 保存分配记录
    async handleSaveAllocation() {
      if (!this.form.id) {
        this.$message.warning("请先保存基本信息");
        return;
      }
      this.saveLoading = true;
      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 || "未知错误")
          );
        }
      } catch (error) {
        console.error("保存分配记录失败:", error);
        this.$message.error("保存分配记录失败");
      } finally {
        this.saveLoading = false;
      }
    },
    // 确认完成分配
    async handleConfirmAllocation() {
      if (this.incompleteRecords > 0) {
@@ -1075,6 +1591,9 @@
    /** 附件变化处理 */
    handleAttachmentChange(fileList) {
      this.attachmentFileList = fileList;
    },
    handleRedistributionChange(fileList) {
      this.redistributionAttachmentList = fileList;
    },
    /** 附件移除处理 */
@@ -1132,9 +1651,9 @@
        fileUrl: file.path || file.fileUrl,
        fileType: this.getFileType(file.fileName)
      };
      // this.filePreviewTitle = file.fileName;
      this.filePreviewVisible = true;
    },
    handleDownloadAttachment(file) {
      const fileUrl = file.path || file.fileUrl;
      const fileName = file.fileName;
@@ -1213,6 +1732,8 @@
    /** 获取文件扩展名 */
    getFileExtension(filename) {
      console.log(filename, "filename");
      return filename
        .split(".")
        .pop()
@@ -1342,7 +1863,46 @@
  font-size: 20px;
  font-weight: bold;
}
/* 在style部分添加 */
.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;
  }
}
/* 空状态样式 */
.empty-allocation {
  text-align: center;
@@ -1350,15 +1910,23 @@
  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;
}
@@ -1367,6 +1935,42 @@
  background-color: #ffecc2;
}
:deep(.pending-row) {
  background-color: #f0f9ff;
}
:deep(.pending-row:hover) {
  background-color: #e0f2ff;
}
/* 禁用状态的输入框样式 */
: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;
}
/* 重分配按钮样式 */
: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 {