WXL
7 天以前 f806aff5702fc6be9c9348d51964366cbf434bf7
src/views/business/decide/DecideInfo.vue
@@ -502,6 +502,13 @@
        </el-button>
      </div>
    </el-dialog>
    <!-- 附件预览 -->
    <FilePreviewDialog
      :visible="previewVisible"
      :file="currentPreviewFile"
      @close="previewVisible = false"
      @download="handleDownload"
    />
  </div>
</template>
@@ -513,10 +520,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 },
  data() {
    return {
@@ -527,7 +535,9 @@
      // 判定类型标签
      activeJudgmentType: "brain", // 默认显示脑死亡
      // 预览相关
      previewVisible: false,
      currentPreviewFile: null,
      // 表单数据
      form: {
        id: undefined,
@@ -1000,30 +1010,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("文件路径不存在,无法下载");
      }
    },
    // 编辑信息