WXL
17 小时以前 d27451a2c24fcc785d02619d5840378df7cfc939
src/views/business/transfer/TransportEdit.vue
@@ -17,17 +17,27 @@
      />
      <el-card shadow="never" class="case-info-card">
        <el-descriptions :column="2" border>
          <el-descriptions-item label="案例编号">{{ selectedCase.caseNo }}</el-descriptions-item>
          <el-descriptions-item label="患者姓名">{{ selectedCase.name }}</el-descriptions-item>
          <el-descriptions-item label="案例编号">{{
            selectedCase.caseNo
          }}</el-descriptions-item>
          <el-descriptions-item label="患者姓名">{{
            selectedCase.name
          }}</el-descriptions-item>
          <el-descriptions-item label="性别">
            <dict-tag
              :options="dict.type.sys_user_sex"
              :value="selectedCase.sex"
            />
          </el-descriptions-item>
          <el-descriptions-item label="年龄">{{ selectedCase.age }}</el-descriptions-item>
          <el-descriptions-item label="疾病诊断">{{ selectedCase.diagnosisname }}</el-descriptions-item>
          <el-descriptions-item label="治疗医院">{{ selectedCase.treatmenthospitalname }}</el-descriptions-item>
          <el-descriptions-item label="年龄">{{
            selectedCase.age
          }}</el-descriptions-item>
          <el-descriptions-item label="疾病诊断">{{
            selectedCase.diagnosisname
          }}</el-descriptions-item>
          <el-descriptions-item label="治疗医院">{{
            selectedCase.treatmenthospitalname
          }}</el-descriptions-item>
        </el-descriptions>
      </el-card>
    </div>
@@ -41,20 +51,14 @@
      <!-- 基础信息 -->
      <el-card class="form-section" shadow="never">
        <div slot="header" class="section-header">
          <i class="el-icon-document" style="color: #409EFF; margin-right: 8px;"></i>
          <i
            class="el-icon-document"
            style="color: #409EFF; margin-right: 8px;"
          ></i>
          <span>基础信息</span>
        </div>
        <el-row :gutter="20">
          <el-col :span="12">
            <el-form-item label="转运单号" prop="reportId">
              <el-input
                v-model="formData.reportId"
                :disabled="isEdit"
                placeholder="系统自动生成"
              />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="案例编号" prop="caseNo">
              <el-input
@@ -119,7 +123,10 @@
      <!-- 医院信息 -->
      <el-card class="form-section" shadow="never">
        <div slot="header" class="section-header">
          <i class="el-icon-office-building" style="color: #67C23A; margin-right: 8px;"></i>
          <i
            class="el-icon-office-building"
            style="color: #67C23A; margin-right: 8px;"
          ></i>
          <span>医院信息</span>
        </div>
@@ -147,7 +154,10 @@
      <!-- 转运信息 -->
      <el-card class="form-section" shadow="never">
        <div slot="header" class="section-header">
          <i class="el-icon-location-information" style="color: #E6A23C; margin-right: 8px;"></i>
          <i
            class="el-icon-location-information"
            style="color: #E6A23C; margin-right: 8px;"
          ></i>
          <span>转运信息</span>
        </div>
@@ -203,7 +213,10 @@
      <!-- 医护人员信息 -->
      <el-card class="form-section" shadow="never">
        <div slot="header" class="section-header">
          <i class="el-icon-user" style="color: #F56C6C; margin-right: 8px;"></i>
          <i
            class="el-icon-user"
            style="color: #F56C6C; margin-right: 8px;"
          ></i>
          <span>医护人员信息</span>
        </div>
@@ -284,7 +297,10 @@
      <!-- 附件信息 -->
      <el-card class="form-section" shadow="never">
        <div slot="header" class="section-header">
          <i class="el-icon-folder" style="color: #909399; margin-right: 8px;"></i>
          <i
            class="el-icon-folder"
            style="color: #909399; margin-right: 8px;"
          ></i>
          <span>附件信息</span>
        </div>
@@ -292,7 +308,9 @@
          <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 组件 -->
@@ -309,18 +327,32 @@
        </div>
        <!-- 附件列表 -->
        <div class="attachment-list" v-if="formData.annexfilesList && formData.annexfilesList.length > 0">
          <div class="list-title">已上传附件 ({{ formData.annexfilesList.length }})</div>
          <el-table :data="formData.annexfilesList" style="width: 100%" size="small">
        <div
          class="attachment-list"
          v-if="formData.annexfilesList && formData.annexfilesList.length > 0"
        >
          <div class="list-title">
            已上传附件 ({{ formData.annexfilesList.length }})
          </div>
          <el-table
            :data="formData.annexfilesList"
            style="width: 100%"
            size="small"
          >
            <el-table-column label="文件名" min-width="200">
              <template slot-scope="scope">
                <i class="el-icon-document" style="margin-right: 8px; color: #409EFF;"></i>
                <i
                  class="el-icon-document"
                  style="margin-right: 8px; color: #409EFF;"
                ></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 size="small">{{ getFileType(scope.row.fileName) }}</el-tag>
                <el-tag size="small">{{
                  getFileType(scope.row.fileName)
                }}</el-tag>
              </template>
            </el-table-column>
            <el-table-column label="创建时间" width="160">
@@ -360,7 +392,10 @@
      <!-- 备注信息 -->
      <el-card class="form-section" shadow="never">
        <div slot="header" class="section-header">
          <i class="el-icon-edit" style="color: #409EFF; margin-right: 8px;"></i>
          <i
            class="el-icon-edit"
            style="color: #409EFF; margin-right: 8px;"
          ></i>
          <span>备注信息</span>
        </div>
        <el-form-item prop="remark">
@@ -378,7 +413,9 @@
    <div slot="footer" class="dialog-footer">
      <el-button @click="handleClose">取消</el-button>
      <el-button type="primary" :loading="saveLoading" @click="handleSave">保存</el-button>
      <el-button type="primary" :loading="saveLoading" @click="handleSave"
        >保存</el-button
      >
    </div>
    <!-- 文件预览弹窗 -->
@@ -464,9 +501,14 @@
  watch: {
    editOpen(val) {
      if (val) {
        if (this.isEdit) {
          // 编辑模式,使用传入的转运单数据
          this.formData = { ...this.getDefaultFormData(), ...this.transportData };
          this.formData = {
            ...this.getDefaultFormData(),
            ...this.transportData
          };
        } else {
          // 新增模式
          this.formData = this.getDefaultFormData();
@@ -499,7 +541,6 @@
    getDefaultFormData() {
      return {
        id: undefined,
        reportId: undefined,
        caseNo: undefined,
        patName: undefined,
        sex: undefined,
@@ -531,18 +572,20 @@
    /** 用案例数据填充表单 */
    fillFormWithCaseData(caseData) {
      this.formData = {
        ...this.formData,
        caseNo: caseData.caseNo || '',
        patName: caseData.name || '',
        sex: caseData.sex || '',
        age: caseData.age || '',
        diagnosisname: caseData.diagnosisname || '',
        treatmentHospitalName: caseData.treatmenthospitalname || '',
        treatmentDeptName: caseData.treatmentdeptname || '',
        caseNo: caseData.caseNo || "",
        patName: caseData.name || "",
        sex: caseData.sex || "",
        age: caseData.age || "",
        reportId: caseData.id || null,
        diagnosisname: caseData.diagnosisname || "",
        treatmentHospitalName: caseData.treatmenthospitalname || "",
        treatmentDeptName: caseData.treatmentdeptname || "",
        // 可以设置一些默认值
        transportStartPlace: caseData.treatmenthospitalname || '',
        contactPerson: caseData.coordinatorName || ''
        transportStartPlace: caseData.treatmenthospitalname || "",
        contactPerson: caseData.coordinatorName || ""
      };
    },
@@ -550,12 +593,14 @@
    initAttachmentList() {
      if (this.isEdit && this.transportData.annexfilesList) {
        this.formData.annexfilesList = [...this.transportData.annexfilesList];
        this.attachmentFileList = this.transportData.annexfilesList.map(item => ({
          uid: item.id || Math.random(),
          name: item.fileName,
          url: item.path || item.fileUrl,
          status: 'success'
        }));
        this.attachmentFileList = this.transportData.annexfilesList.map(
          item => ({
            uid: item.id || Math.random(),
            name: item.fileName,
            url: item.path || item.fileUrl,
            status: "success"
          })
        );
      } else {
        this.formData.annexfilesList = [];
        this.attachmentFileList = [];
@@ -570,8 +615,8 @@
    /** 附件移除处理 */
    handleAttachmentRemove(file) {
      if (file.url) {
        const index = this.formData.annexfilesList.findIndex(item =>
          item.path === file.url || item.fileUrl === file.url
        const index = this.formData.annexfilesList.findIndex(
          item => item.path === file.url || item.fileUrl === file.url
        );
        if (index > -1) {
          this.formData.annexfilesList.splice(index, 1);
@@ -583,7 +628,7 @@
    handleRemoveAttachment(index) {
      this.formData.annexfilesList.splice(index, 1);
      this.attachmentFileList.splice(index, 1);
      this.$message.success('附件删除成功');
      this.$message.success("附件删除成功");
    },
    /** 上传成功处理 */
@@ -594,21 +639,21 @@
          path: response.data || file.url,
          fileUrl: response.data || file.url,
          type: this.getFileExtension(file.name),
          createTime: dayjs().format('YYYY-MM-DD HH:mm:ss'),
          createTime: dayjs().format("YYYY-MM-DD HH:mm:ss"),
          transportId: this.formData.id,
          delFlag: 0,
          caseNo: this.formData.caseNo
        };
        this.formData.annexfilesList.push(attachmentObj);
        this.$message.success('文件上传成功');
        this.$message.success("文件上传成功");
      }
    },
    /** 上传错误处理 */
    handleUploadError({ file, fileList, error }) {
      console.error('附件上传失败:', error);
      this.$message.error('文件上传失败,请重试');
      console.error("附件上传失败:", error);
      this.$message.error("文件上传失败,请重试");
    },
    /** 文件预览 */
@@ -627,53 +672,59 @@
      const fileName = file.fileName;
      if (fileUrl) {
        const link = document.createElement('a');
        const link = document.createElement("a");
        link.href = fileUrl;
        link.download = fileName;
        link.style.display = 'none';
        link.style.display = "none";
        document.body.appendChild(link);
        link.click();
        document.body.removeChild(link);
        this.$message.success('开始下载文件');
        this.$message.success("开始下载文件");
      } else {
        this.$message.warning('文件路径不存在,无法下载');
        this.$message.warning("文件路径不存在,无法下载");
      }
    },
    /** 获取文件类型 */
    getFileType(fileName) {
      if (!fileName) return 'other';
      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'];
      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';
      if (imageTypes.includes(extension)) return "image";
      if (pdfTypes.includes(extension)) return "pdf";
      if (officeTypes.includes(extension)) return "office";
      return "other";
    },
    /** 获取文件扩展名 */
    getFileExtension(filename) {
      return filename.split('.').pop().toLowerCase();
      return filename
        .split(".")
        .pop()
        .toLowerCase();
    },
    /** 日期时间格式化 */
    formatDateTime(dateTime) {
      if (!dateTime) return '';
      if (!dateTime) return "";
      try {
        const date = new Date(dateTime);
        if (isNaN(date.getTime())) return dateTime;
        const year = date.getFullYear();
        const month = String(date.getMonth() + 1).padStart(2, '0');
        const day = String(date.getDate()).padStart(2, '0');
        const hours = String(date.getHours()).padStart(2, '0');
        const minutes = String(date.getMinutes()).padStart(2, '0');
        const seconds = String(date.getSeconds()).padStart(2, '0');
        const month = String(date.getMonth() + 1).padStart(2, "0");
        const day = String(date.getDate()).padStart(2, "0");
        const hours = String(date.getHours()).padStart(2, "0");
        const minutes = String(date.getMinutes()).padStart(2, "0");
        const seconds = String(date.getSeconds()).padStart(2, "0");
        return `${year}-${month}-${day} ${hours}:${minutes}:${seconds}`;
      } catch (error) {
@@ -692,9 +743,13 @@
        const valid = await this.$refs.editForm.validate();
        if (!valid) return;
        const pendingFiles = this.attachmentFileList.filter(item => item.status !== 'success');
        const pendingFiles = this.attachmentFileList.filter(
          item => item.status !== "success"
        );
        if (pendingFiles.length > 0) {
          this.$message.warning('还有文件未上传完成,请先上传所有文件或移除未上传的文件');
          this.$message.warning(
            "还有文件未上传完成,请先上传所有文件或移除未上传的文件"
          );
          return;
        }
@@ -702,7 +757,6 @@
        const requestData = { ...this.formData };
        let response;
        if (this.isEdit) {
          response = await transportEdit(requestData);
        } else {