WXL
2 天以前 c8e9849cb5f24848df0174c13bfbbff37bb08a5a
src/views/business/course/components/DeathJudgmentStage.vue
@@ -1,5 +1,6 @@
<template>
  <div class="death-judgment-detail">
    <!-- <case-basic-info :case-id="caseId" :show-attachment="true" /> -->
    <!-- 公共信息模块(独立显示) -->
    <!-- 判定类型标签页 -->
@@ -45,30 +46,7 @@
              <el-input v-model="form.gainhospitalname" :readonly="!isEdit" />
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item label="是否默哀缅怀" prop="isspendremember">
              <el-select
                v-model="form.isspendremember"
                :disabled="!isEdit"
                style="width: 100%"
              >
                <el-option label="是" :value="1" />
                <el-option label="否" :value="0" />
              </el-select>
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item label="恢复遗体仪容" prop="isrestoreremains">
              <el-select
                v-model="form.isrestoreremains"
                :disabled="!isEdit"
                style="width: 100%"
              >
                <el-option label="是" :value="1" />
                <el-option label="否" :value="0" />
              </el-select>
            </el-form-item>
          </el-col>
        </el-row>
      </el-form>
    </el-card> -->
@@ -76,32 +54,6 @@
    <el-card v-if="activeJudgmentType === 'brain'" class="detail-card">
      <div slot="header" class="clearfix">
        <span class="detail-title">脑死亡判定信息</span>
        <el-button
          v-if="isEdit"
          style="float: right; margin-left: 10px;"
          type="success"
          @click="handleSave"
          :loading="saveLoading"
        >
          保存信息
        </el-button>
        <el-button
          v-if="isEdit"
          style="float: right; margin-left: 10px;"
          type="success"
          @click="accomplish"
          :loading="saveLoading"
        >
          完成判定
        </el-button>
        <el-button
          v-else
          style="float: right; margin-left: 10px;"
          type="primary"
          @click="handleEdit"
        >
          编辑信息
        </el-button>
      </div>
      <el-form :model="form" ref="brainForm" :rules="rules" label-width="120px">
@@ -133,6 +85,32 @@
          <el-col :span="8">
            <el-form-item label="判定医生二" prop="deathjudgedoctt">
              <el-input v-model="form.deathjudgedoctt" :readonly="!isEdit" />
            </el-form-item>
          </el-col>
        </el-row>
        <el-row :gutter="20">
          <el-col :span="24">
            <el-form-item label="其他判定医生">
              <div
                v-for="(doctor, index) in brainExtraDoctors"
                :key="index"
                style="display: flex; align-items: center; margin-bottom: 8px;"
              >
                <el-input
                  v-model="brainExtraDoctors[index]"
                  placeholder="请输入医生姓名"
                  style="flex: 1; margin-right: 10px;"
                  :readonly="!isEdit"
                />
                <el-button
                  v-if="isEdit"
                  type="danger"
                  icon="el-icon-minus"
                  circle
                  size="mini"
                  @click="removeBrainDoctor(index)"
                />
              </div>
            </el-form-item>
          </el-col>
        </el-row>
@@ -290,7 +268,7 @@
        <el-row :gutter="20">
          <el-col :span="8">
            <el-form-item label="心死亡时间" prop="heartdeathtime">
            <el-form-item label="心死亡判定完成时间" prop="heartdeathtime">
              <el-date-picker
                v-model="form.heartdeathtime"
                type="datetime"
@@ -314,6 +292,41 @@
                v-model="form.heartdeathjudgedoctt"
                :readonly="!isEdit"
              />
            </el-form-item>
          </el-col>
        </el-row>
        <el-row :gutter="20">
          <el-col :span="24">
            <el-form-item label="其他判定医生">
              <div
                v-for="(doctor, index) in heartExtraDoctors"
                :key="index"
                style="display: flex; align-items: center; margin-bottom: 8px;"
              >
                <el-input
                  v-model="heartExtraDoctors[index]"
                  placeholder="请输入医生姓名"
                  style="flex: 1; margin-right: 10px;"
                  :readonly="!isEdit"
                />
                <el-button
                  v-if="isEdit"
                  type="danger"
                  icon="el-icon-minus"
                  circle
                  size="mini"
                  @click="removeHeartDoctor(index)"
                />
              </div>
              <el-button
                v-if="isEdit"
                type="primary"
                icon="el-icon-plus"
                size="small"
                @click="addHeartDoctor"
              >
                添加医生
              </el-button>
            </el-form-item>
          </el-col>
        </el-row>
@@ -436,7 +449,25 @@
        </el-tabs>
      </div>
    </el-card>
    <!-- 底部操作按钮 -->
    <div style="text-align: center; margin: 30px 0;">
      <el-button
        v-if="isEdit"
        type="primary"
        @click="handleSave"
        :loading="saveLoading"
      >
        保存信息
      </el-button>
      <el-button
        v-if="isEdit"
        type="success"
        @click="accomplish"
        :loading="saveLoading"
      >
        完成判定
      </el-button>
    </div>
    <!-- 上传对话框(脑死亡) -->
    <el-dialog
      :title="`上传${getCurrentBrainDeathTypeLabel}评估表`"
@@ -524,6 +555,13 @@
        </el-button>
      </div>
    </el-dialog>
    <!-- 附件预览 -->
    <FilePreviewDialog
      :visible="previewVisible"
      :file="currentPreviewFile"
      @close="previewVisible = false"
      @download="handleDownload"
    />
  </div>
</template>
@@ -535,10 +573,11 @@
} from "@/api/businessApi";
import { getToken } from "@/utils/auth";
import CaseBasicInfo from "@/components/CaseBasicInfo";
import FilePreviewDialog from "@/components/FilePreviewDialog";
export default {
  name: "DeathJudgmentDetail",
  components: { CaseBasicInfo },
  components: { CaseBasicInfo, FilePreviewDialog },
  props: {
    infoid: {
      type: String,
@@ -548,12 +587,15 @@
  data() {
    return {
      caseId: null,
      isEdit: false,
      isEdit: true,
      saveLoading: false,
      brainExtraDoctors: [], // 脑死亡其他判定医生
      heartExtraDoctors: [], // 心死亡其他判定医生
      // 判定类型标签
      activeJudgmentType: "brain", // 默认显示脑死亡
      // 预览相关
      previewVisible: false,
      currentPreviewFile: null,
      // 表单数据
      form: {
        id: undefined,
@@ -604,7 +646,11 @@
          { required: false, message: "心死亡原因不能为空", trigger: "blur" }
        ],
        heartdeathtime: [
          { required: false, message: "心死亡时间不能为空", trigger: "change" }
          {
            required: false,
            message: "心死亡判定完成时间不能为空",
            trigger: "change"
          }
        ],
        heartdeathjudgedocto: [
          {
@@ -637,12 +683,14 @@
        { value: "3", label: "短潜伏期体感诱发电位评估表" },
        { value: "4", label: "经颅多普勒超声评估记录" },
        { value: "5", label: "卫健委脑损伤质控中心 - 临床综合评估表" },
        { value: "6", label: "UW评分表" }
        { value: "7", label: "AT前" },
        { value: "8", label: "AT后" },
        { value: "6", label: "UW评分表(脑死亡)" }
      ],
      // 心死亡评估表类型定义
      heartDeathAttachmentTypes: [
        { value: "heart_1", label: "心死亡判定表" },
        { value: "heart_2", label: "心电图评估表" }
        { value: "heart_2", label: "UW评分表(心死亡)" }
      ],
      // 附件列表数据
@@ -665,10 +713,13 @@
    }
  },
  created() {
    this.infoid = this.infoid;
    this.caseId = this.infoid;
    this.activeJudgmentType = this.$route.query.type;
    // 从路由参数获取默认显示类型
    if (this.$route.query.judgmentType) {
      this.activeJudgmentType = this.$route.query.type;
      this.activeJudgmentType = this.$route.query.judgmentType;
    }
    this.getDetail(this.infoid);
@@ -680,7 +731,32 @@
      this.activeJudgmentType = tab.name;
      // 可以在这里添加其他切换逻辑
    },
    addBrainDoctor() {
      this.brainExtraDoctors.push("");
    },
    removeBrainDoctor(index) {
      this.brainExtraDoctors.splice(index, 1);
    },
    addHeartDoctor() {
      this.heartExtraDoctors.push("");
    },
    removeHeartDoctor(index) {
      this.heartExtraDoctors.splice(index, 1);
    },
    // 序列化额外医生列表为字符串(用中文逗号分隔)
    serializeExtraDoctors(list) {
      return list.filter(name => name && name.trim()).join(",");
    },
    // 从字符串解析出医生列表(按中文逗号拆分)
    parseExtraDoctors(str) {
      if (!str) return [];
      return str
        .split(",")
        .map(s => s.trim())
        .filter(s => s);
    },
    // 生成捐献者编号
    generateDonorNo() {
      const timestamp = Date.now().toString();
@@ -691,13 +767,8 @@
    async getDetail(infoid) {
      try {
        const response = await queryDathInfoBaseInfo({ infoid });
        let realData = {};
        if (response && response.data) {
          realData = response.data[0];
        } else if (response) {
          realData = response;
        }
        let realData = response?.data?.[0] || response || {};
        // 映射字段到表单
        this.form = {
@@ -716,7 +787,18 @@
        if (realData.rememberAnnex) {
          this.parseAttachmentData(realData.rememberAnnex, "brain");
        }
        if (realData.remark) {
          const parts = realData.remark.split(" | ");
          parts.forEach(part => {
            if (part.includes("脑死亡其他医生:")) {
              const doctorsStr = part.replace("脑死亡其他医生:", "");
              this.brainExtraDoctors = this.parseExtraDoctors(doctorsStr);
            } else if (part.includes("心死亡其他医生:")) {
              const doctorsStr = part.replace("心死亡其他医生:", "");
              this.heartExtraDoctors = this.parseExtraDoctors(doctorsStr);
            }
          });
        }
        // 解析心死亡附件信息
        if (realData.heartdeathjudgeannex) {
          this.parseAttachmentData(realData.heartdeathjudgeannex, "heart");
@@ -1023,30 +1105,63 @@
    },
    // 预览附件
    handlePreview(attachment) {
      if (attachment.fileName.endsWith(".pdf")) {
        window.open(attachment.fileUrl, "_blank");
      } else if (attachment.fileName.match(/\.(jpg|jpeg|png)$/i)) {
        this.$alert(
          `<img src="${attachment.fileUrl}" style="max-width: 100%;" alt="${attachment.fileName}">`,
          "图片预览",
          {
            dangerouslyUseHTMLString: true,
            customClass: "image-preview-dialog"
          }
        );
      } else {
        this.$message.info("该文件类型暂不支持在线预览,请下载后查看");
      }
    },
    handlePreview(file) {
      console.log(file, "file");
      this.currentPreviewFile = {
        fileName: file.fileName,
        fileUrl: file.path || file.fileUrl,
        fileType: this.getFileType(file.fileName)
      };
      this.previewVisible = true;
      // if (attachment.fileName.endsWith(".pdf")) {
      //   window.open(attachment.fileUrl, "_blank");
      // } else if (attachment.fileName.match(/\.(jpg|jpeg|png)$/i)) {
      //   this.$alert(
      //     `<img src="${attachment.fileUrl}" style="max-width: 100%;" alt="${attachment.fileName}">`,
      //     "图片预览",
      //     {
      //       dangerouslyUseHTMLString: true,
      //       customClass: "image-preview-dialog"
      //     }
      //   );
      // } else {
      //   this.$message.info("该文件类型暂不支持在线预览,请下载后查看");
      // }
    },
    getFileType(fileName) {
      if (!fileName) return "other";
      const extension = fileName
        .split(".")
        .pop()
        .toLowerCase();
      const imageTypes = ["jpg", "jpeg", "png", "gif", "bmp", "webp"];
      const pdfTypes = ["pdf"];
      const officeTypes = ["doc", "docx", "xls", "xlsx", "ppt", "pptx"];
      if (imageTypes.includes(extension)) return "image";
      if (pdfTypes.includes(extension)) return "pdf";
      if (officeTypes.includes(extension)) return "office";
      return "other";
    },
    // 下载附件
    handleDownload(attachment) {
    handleDownload(file) {
      const fileUrl = file.path || file.fileUrl;
      const fileName = file.fileName;
      if (fileUrl) {
      const link = document.createElement("a");
      link.href = attachment.fileUrl;
      link.download = attachment.fileName;
        link.href = fileUrl;
        link.download = fileName;
        link.style.display = "none";
        document.body.appendChild(link);
      link.click();
      this.$message.success(`开始下载: ${attachment.fileName}`);
        document.body.removeChild(link);
        this.$message.success("开始下载文件");
      } else {
        this.$message.warning("文件路径不存在,无法下载");
      }
    },
    // 编辑信息
@@ -1077,13 +1192,32 @@
          this.saveLoading = true;
          try {
            // 构建额外医生字符串
            const brainExtraStr = this.serializeExtraDoctors(
              this.brainExtraDoctors
            );
            const heartExtraStr = this.serializeExtraDoctors(
              this.heartExtraDoctors
            );
            let remark = this.form.remark || "";
            // 如果已有备注,用 ' | ' 分隔;否则直接赋值
            if (brainExtraStr) {
              remark +=
                (remark ? " | " : "") + "脑死亡其他医生:" + brainExtraStr;
            }
            if (heartExtraStr) {
              remark +=
                (remark ? " | " : "") + "心死亡其他医生:" + heartExtraStr;
            }
            // 构建提交数据
            const submitData = {
              ...this.form,
              infoid: this.infoid,
              // 确保附件数据最新
              rememberAnnex: this.buildBrainDeathAttachmentJson(),
              heartdeathjudgeannex: this.buildHeartDeathAttachmentJson()
              rememberannex: this.buildBrainDeathAttachmentJson(),
              heartdeathjudgeannex: this.buildHeartDeathAttachmentJson(),
              remark: remark // 使用合并后的 remark
            };
            if (submitData.state == 1 || !submitData.state) {
              submitData.state = 2;