WXL
3 天以前 dc082351978a1e9f75d7a1471a0ca7ebeac552a5
src/views/business/affirm/affirmInfo.vue
@@ -1,59 +1,30 @@
<template>
  <div class="confirmation-detail">
    <case-basic-info :case-id="caseId" :show-attachment="true" />
    <el-card class="detail-card">
      <!-- 基础信息 -->
      <div slot="header" class="clearfix">
        <span class="detail-title">捐献确认基本信息</span>
        <span class="detail-title">捐献确认信息</span>
        <el-button
          type="success"
          style="float: right;"
          type="primary"
          style="float: right;margin-left: 20px;"
          @click="handleSave"
          :loading="saveLoading"
        >
          保存确认信息
        </el-button>
        <el-button
          type="success"
          style="float: right;margin-left: 20px;"
          @click="accomplish"
          :loading="saveLoading"
        >
          确认完成
        </el-button>
      </div>
      <el-form :model="form" ref="form" label-width="120px">
        <el-row :gutter="20">
          <el-col :span="8">
            <el-form-item label="住院号" prop="caseNo">
              <el-input v-model="form.caseNo" />
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item label="捐献者姓名" prop="name">
              <el-input v-model="form.name" />
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item label="性别" prop="sex">
              <el-select v-model="form.sex" style="width: 100%">
                <el-option label="男" value="1" />
                <el-option label="女" value="2" />
              </el-select>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row :gutter="20">
          <el-col :span="8">
            <el-form-item label="年龄" prop="age">
              <el-input v-model="form.age" />
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item label="疾病诊断" prop="diagnosisname">
              <el-input v-model="form.diagnosisname" />
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item label="所在医疗机构" prop="treatmenthospitalname">
              <el-input v-model="form.treatmenthospitalname" />
            </el-form-item>
          </el-col>
        </el-row>
        <el-row :gutter="20">
          <el-col :span="8">
            <el-form-item label="协调员1" prop="coordinatedusernameo">
@@ -91,7 +62,6 @@
              <el-date-picker
                v-model="form.signdate"
                type="datetime"
                value-format="yyyy-MM-dd"
                style="width: 100%"
              />
            </el-form-item>
@@ -156,7 +126,48 @@
            </el-form-item>
          </el-col>
        </el-row>
        <el-row style="margin-bottom: 10px;">
          <el-button
            type="primary"
            size="mini"
            icon="el-icon-plus"
            @click="openOtherFamilyDialog()"
          >
            添加其他家属
          </el-button>
        </el-row>
        <el-table :data="otherFamilyList" size="small" border>
          <el-table-column label="姓名" prop="name" />
          <el-table-column label="与捐赠者关系" prop="relation">
            <template slot-scope="scope">
              <dict-tag
                :options="dict.type.sys_FamilyRelation"
                :value="scope.row.relation"
              />
            </template>
          </el-table-column>
          <el-table-column label="联系电话" prop="phone" />
          <el-table-column label="操作" width="120" align="center">
            <template slot-scope="scope">
              <el-button
                size="mini"
                type="text"
                @click="editOtherFamily(scope.$index)"
              >
                编辑
              </el-button>
              <el-button
                size="mini"
                type="text"
                style="color:red"
                @click="deleteOtherFamily(scope.$index)"
              >
                删除
              </el-button>
            </template>
          </el-table-column>
        </el-table>
        <el-row>
          <el-form-item label-width="100px" label="捐献决定">
            <el-checkbox-group v-model="organdecision">
@@ -289,7 +300,38 @@
        </el-tab-pane>
      </el-tabs>
    </el-card>
    <!-- 其他家属弹窗 -->
    <el-dialog
      :title="isEditOtherFamily ? '编辑其他家属' : '添加其他家属'"
      :visible.sync="otherFamilyDialogVisible"
      width="400px"
    >
      <el-form :model="currentOtherFamily" label-width="100px">
        <el-form-item label="姓名" prop="name">
          <el-input v-model="currentOtherFamily.name" />
        </el-form-item>
        <el-form-item label="关系" prop="relation">
          <el-select v-model="currentOtherFamily.relation" style="width:100%">
            <el-option
              v-for="dict in dict.type.sys_FamilyRelation"
              :key="dict.value"
              :label="dict.label"
              :value="dict.value"
            />
          </el-select>
        </el-form-item>
        <el-form-item label="电话" prop="phone">
          <el-input v-model="currentOtherFamily.phone" />
        </el-form-item>
      </el-form>
      <span slot="footer">
        <el-button @click="otherFamilyDialogVisible = false">取消</el-button>
        <el-button type="primary" @click="saveOtherFamily">确定</el-button>
      </span>
    </el-dialog>
    <!-- 上传对话框 -->
    <el-dialog
      :title="`上传${getCurrentTypeLabel}附件`"
@@ -301,14 +343,15 @@
        ref="uploadRef"
        class="upload-demo"
        drag
        action="#"
        :action="uploadAction"
        :headers="headers"
        multiple
        :file-list="tempFileList"
        :before-upload="beforeUpload"
        :on-change="handleFileChange"
        :on-remove="handleTempRemove"
        :on-success="handleUploadSuccess"
        :auto-upload="false"
        :http-request="handleHttpRequest"
      >
        <i class="el-icon-upload"></i>
        <div class="el-upload__text">将文件拖到此处,或<em>点击上传</em></div>
@@ -343,15 +386,20 @@
<script>
import { relativesList, relativesEdit, relativesAdd } from "@/api/businessApi";
import FilePreviewDialog from "@/components/FilePreviewDialog";
import CaseBasicInfo from "@/components/CaseBasicInfo";
import { getToken } from "@/utils/auth";
export default {
  name: "ConfirmationDetail",
  components: {
    FilePreviewDialog
    FilePreviewDialog,
    CaseBasicInfo
  },
  dicts: ["sys_FamilyRelation"],
  data() {
    return {
      caseId: null,
      // 是否编辑模式
      isEdit: false,
      // 表单数据
@@ -374,26 +422,45 @@
        relativeidcardno: "",
        relativephone: "",
        relativeRemark: "",
        assessannex: "" // JSON字符串存储所有附件
        assessannex: "", // JSON字符串存储所有附件
        otherFamilyMembers: "" // ✅ 新增
      },
      uploadAction: process.env.VUE_APP_BASE_API + "/common/upload",
      headers: {
        Authorization: "Bearer " + getToken()
      },
      // 其他家属表格数据
      otherFamilyList: [],
      // 当前编辑的其他家属(弹窗用)
      currentOtherFamily: {
        name: "",
        relation: "",
        phone: ""
      },
      // 是否编辑模式(其他家属)
      isEditOtherFamily: false,
      editOtherFamilyIndex: -1,
      // 其他家属弹窗
      otherFamilyDialogVisible: false,
      organdecision: [],
      organdecisionOther: "",
      organselection: [
        "肝脏",
        "双肾",
        "左肾",
        "右肾",
        "肾脏",
        "心脏",
        "肺脏",
        "胰腺",
        "小肠",
        "双眼组织",
        "遗体",
        "眼角膜",
        "其他"
      ],
      // 加载状态
      loading: false,
      saveLoading: false,
      infoid: null,
      // 附件相关数据
      activeAttachmentType: "1",
      attachmentLoading: false,
@@ -435,10 +502,11 @@
    }
  },
  created() {
    const infoid = this.$route.query.infoid;
    this.infoid = this.$route.query.infoid;
    this.caseId = this.$route.query.infoid;
    this.isEdit = this.$route.query.confirm === "true";
    if (infoid) {
      this.getDetail(infoid);
    if (this.infoid) {
      this.getDetail(this.infoid);
    }
  },
  methods: {
@@ -479,7 +547,17 @@
      } else {
        detailData = response;
      }
      // 处理其他家属数据
      if (detailData.otherFamilyMembers) {
        try {
          this.otherFamilyList =
            typeof detailData.otherFamilyMembers === "string"
              ? JSON.parse(detailData.otherFamilyMembers)
              : detailData.otherFamilyMembers || [];
        } catch (e) {
          this.otherFamilyList = [];
        }
      }
      // 映射字段到表单
      this.form = {
        ...this.form,
@@ -611,55 +689,40 @@
      this.tempFileList = fileList;
    },
    // 自定义上传请求
    handleHttpRequest(options) {
      return new Promise((resolve, reject) => {
        this.uploadLoading = true;
    handleUploadSuccess(response, file) {
      if (response.code !== 200) {
        this.$message.error(response.msg || "上传失败");
        return;
      }
        // 模拟上传过程
        setTimeout(() => {
          const newAttachment = {
            id: Date.now(),
            fileName: options.file.name,
            fileUrl: URL.createObjectURL(options.file),
            fileSize: options.file.size,
            fileType: this.getFileExtension(options.file.name),
            type: this.currentUploadType, // 记录附件类型
            uploadTime: new Date().toISOString(),
            uploader: "当前用户"
          };
      const newAttachment = {
        id: Date.now(),
        fileName: file.name,
        fileUrl: response.url,
        fileSize: file.size,
        fileType: this.getFileExtension(file.name),
        type: this.currentUploadType,
        uploadTime: this.getCurrentTime(),
        uploader: "当前用户"
      };
          // 添加到对应类型的附件列表
          if (this.attachmentData[this.currentUploadType]) {
            this.attachmentData[this.currentUploadType].push(newAttachment);
          }
      this.attachmentData[this.currentUploadType].push(newAttachment);
      this.updateAssessannexField();
          this.uploadLoading = false;
          this.updateAssessannexField(); // 更新存储字段
          resolve({ code: 200, data: newAttachment });
        }, 1500);
      });
      this.$message.success("上传成功");
      this.uploadLoading = false;
      this.uploadDialogVisible = false;
      this.tempFileList = [];
    },
    // 提交上传
    async submitUpload() {
    submitUpload() {
      if (this.tempFileList.length === 0) {
        this.$message.warning("请先选择要上传的文件");
        return;
      }
      try {
        for (const file of this.tempFileList) {
          await this.$refs.uploadRef.submit();
        }
        this.$message.success("文件上传成功");
        this.uploadDialogVisible = false;
        this.tempFileList = [];
      } catch (error) {
        this.$message.error("文件上传失败");
        console.error("上传失败:", error);
      }
      this.uploadLoading = true;
      this.$refs.uploadRef.submit(); // ✅ 只调用一次
    },
    // 删除附件
@@ -678,7 +741,51 @@
        })
        .catch(() => {});
    },
    openOtherFamilyDialog(index) {
      this.isEditOtherFamily = typeof index === "number";
      this.editOtherFamilyIndex = index || -1;
      this.currentOtherFamily = this.isEditOtherFamily
        ? { ...this.otherFamilyList[index] }
        : { name: "", relation: "", phone: "" };
      this.otherFamilyDialogVisible = true;
    },
    editOtherFamily(index) {
      this.openOtherFamilyDialog(index);
    },
    deleteOtherFamily(index) {
      this.$confirm("确认删除该家属?", "提示", { type: "warning" }).then(
        () => {
          this.otherFamilyList.splice(index, 1);
          this.updateOtherFamilyField();
        }
      );
    },
    saveOtherFamily() {
      if (
        !this.currentOtherFamily.name ||
        !this.currentOtherFamily.relation ||
        !this.currentOtherFamily.phone
      ) {
        this.$message.warning("请填写完整信息");
        return;
      }
      if (this.isEditOtherFamily) {
        this.otherFamilyList.splice(this.editOtherFamilyIndex, 1, {
          ...this.currentOtherFamily
        });
      } else {
        this.otherFamilyList.push({ ...this.currentOtherFamily });
      }
      this.updateOtherFamilyField();
      this.otherFamilyDialogVisible = false;
    },
    updateOtherFamilyField() {
      this.form.otherFamilyMembers = JSON.stringify(this.otherFamilyList);
    },
    // 更新assessannex存储字段
    updateAssessannexField() {
      // 将所有类型的附件合并为一个数组
@@ -789,6 +896,19 @@
        .toString()
        .padStart(2, "0")}`;
    },
    accomplish() {
      this.$confirm("是否完成该案例捐献确认步骤?", "提醒", {
        confirmButtonText: "确定",
        cancelButtonText: "取消",
        type: "warning"
      })
        .then(() => {
          this.form.state = 3;
          this.handleSave();
        })
        .catch(() => {});
    },
    // 保存确认信息
    async handleSave() {
@@ -796,15 +916,18 @@
        await this.$refs.form.validate();
        this.saveLoading = true;
        // 确保附件数据是最新的
        this.updateOtherFamilyField();
        this.updateAssessannexField();
        const saveData = {
          ...this.form,
          infoid: this.infoid,
          organdecision: this.organdecision.join(","),
          organdecisionOther: this.organdecisionOther
          // assessannex字段已在updateAssessannexField中更新
        };
        if (saveData.state == 1 || !saveData.state) {
          saveData.state = 2;
        }
        let response = null;
        if (saveData.id) {
          response = await relativesEdit(saveData);