马宇豪
2024-01-08 4ef6c36c631c3aa3916e0861fd211dec9b03231b
src/views/notCoalMine/nCertificateList/components/certificateDialog.vue
@@ -92,11 +92,14 @@
        <el-row>
          <el-col :span="20">
            <el-form-item label="图片查看" prop="imgPath">
              <el-image
                style="width: 100px; height: 100px"
                :src="imgPath"
                fit="fill"></el-image>
<!--            <el-form-item label="图片查看" prop="imgPath">-->
<!--              <el-image-->
<!--                style="width: 100px; height: 100px"-->
<!--                src="http://inspurtestcx.saws.org.cn/zwfile/zwdownload?filePath=QRCODE/2020/12/01/QRCODE362421197712217718_A12000036320030846.jpg"-->
<!--                fit="fill"></el-image>-->
<!--            </el-form-item>-->
            <el-form-item label="图片查看">
              <el-link type="primary" style="margin-right: 20px" @click="downloadFile(form.imgPath)" target="_blank">点击查看</el-link>
            </el-form-item>
          </el-col>
        </el-row>
@@ -115,6 +118,7 @@
<script>
// import {getExpertTypes,addExpertInfo,uploadFile} from '@/api/system/form'
// import { verifySimplePhone, verifyIdCard } from "@/utils/validate";
import axios from "axios";
export default {
  name: "nCertificateDialog",
  dicts: ['sys_nation_code'],
@@ -314,7 +318,26 @@
    },
    changeSource(num){
      this.form.source = num
    }
    },
    downloadFile(file){
      const t = this
      axios.get(file,{headers:{'Content-Type': 'application/json','Authorization': "Bearer " + getToken()},responseType: 'blob'}).then(res=>{
        if (res) {
          const link = document.createElement('a')
          let blob = new Blob([res.data],{type: res.data.type})
          link.style.display = "none";
          link.href = URL.createObjectURL(blob); // 创建URL
          window.open(link.href)
          // link.setAttribute("download", file.name);
          // document.body.appendChild(link);
          // link.click();
          // document.body.removeChild(link);
        } else {
          this.$message.error('获取文件失败')
        }
      })
    },
  }
};
</script>