马宇豪
2024-03-05 2bc59d909462d305e9c71db0c8d54b70a26c43a4
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,8 @@
<script>
// import {getExpertTypes,addExpertInfo,uploadFile} from '@/api/system/form'
// import { verifySimplePhone, verifyIdCard } from "@/utils/validate";
import { getToken } from "@/utils/auth";
import axios from "axios";
export default {
  name: "nCertificateDialog",
  dicts: ['sys_nation_code'],
@@ -211,17 +216,17 @@
      return key in obj
    },
    async getExpertsType(){
      const res = await getExpertTypes()
      if(res.code == 200){
        this.expertsType = res.data
      }else{
        this.$message({
          type: 'warning',
          message: res.msg
        });
      }
    },
    // async getExpertsType(){
    //   const res = await getExpertTypes()
    //   if(res.code == 200){
    //     this.expertsType = res.data
    //   }else{
    //     this.$message({
    //       type: 'warning',
    //       message: res.msg
    //     });
    //   }
    // },
    avatorChange(file, fileList) {
      this.fileList = fileList;
    },
@@ -279,13 +284,6 @@
      console.log(file, fileList);
    },
    async submit(){
      if(this.form.supportDirectionSafety.length == 0 && this.form.supportDirectionPrevention.length == 0 && this.form.supportDirectionEmergency.length == 0){
        this.$message({
          type:'warning',
          message: '请至少选择一种支撑方向'
        })
        return
      }
      this.$refs["ruleForm"].validate(async(valid) =>{
        if(valid) {
          await this.submitUpload()
@@ -321,7 +319,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>