马宇豪
2024-11-26 bd19a941293d124d7c58c6d351e7e86c1fa15559
src/views/dataUpload/saftyBaseInfo/judgeReport/index.vue
@@ -12,11 +12,24 @@
                <el-table-column prop="id" label="id" show-overflow-tooltip></el-table-column>
                <el-table-column prop="createTime" label="上报时间" show-overflow-tooltip></el-table-column>
                <el-table-column prop="name" label="报告名称" show-overflow-tooltip></el-table-column>
                <el-table-column prop="type" label="报告类型" show-overflow-tooltip>
                  <template #default="scope">
                    {{scope.row.type == 1 ? '安全评价报告':scope.row.type == 2 ? '安全三同时':'--'}}
                  </template>
                </el-table-column>
                <el-table-column prop="remarks" label="备注" show-overflow-tooltip></el-table-column>
                <el-table-column prop="evaluateTime" label="评价时间" show-overflow-tooltip></el-table-column>
                <el-table-column prop="files" label="附件" show-overflow-tooltip>
                  <template #default="scope">
                    <el-button v-if="scope.row.files !== ''" size="small" text type="primary" @click="openFile(scope.row.files)">查看</el-button>
                  </template>
                </el-table-column>
                <el-table-column prop="threeMeanwhileType" label="安全三同时文件类型" show-overflow-tooltip>
                  <template #default="scope">
                    <span v-if="scope.row.type == 2">
                      {{getTypeName(scope.row.threeMeanwhileType)}}
                    </span>
                    <span v-else>/</span>
                  </template>
                </el-table-column>
                <el-table-column label="操作" width="140">
@@ -62,6 +75,7 @@
    pageSize: number
  }
  total: null | number
  typeList: Array<object>
}
export default defineComponent({
@@ -76,7 +90,29 @@
          pageIndex: 1,
          pageSize: 10
        },
        total: null
        total: null,
        typeList: [
          {
            value: 'TMT1',
            label: '立项文件'
          },
          {
            value: 'TMT2',
            label: '安全预评价报告',
          },
          {
            value: 'TMT3',
            label: '设计专篇'
          },
          {
            value: 'TMT4',
            label: '安全验收报告'
          },
          {
            value: 'TMT5',
            label: '安全现状报告'
          }
        ]
      });
      // 页面加载时
@@ -98,24 +134,29 @@
      }
      const openDialog=(type:string,data:object)=>{
        reportRef.value.open(type,data)
        reportRef.value.open(type,data,state.typeList)
      }
      const getTypeName = (type: string)=>{
        return state.typeList.find(i=>i.value == type)?.label
      }
      const openFile=(file: string)=>{
        axios.get(import.meta.env.VITE_API_URL + file,{headers:{'Content-Type': 'application/json','Authorization': `${Cookies.get('token')}`,'uid':`${Cookies.get('uid')}`},responseType: 'blob'}).then(res=>{
          if (res) {
            const link = document.createElement('a')
            let blob = new Blob([res.data],{type: 'application/pdf'})
            link.style.display = "none";
            link.href = URL.createObjectURL(blob); // 创建URL
            window.open(link.href)
          } else {
            ElMessage({
              type: 'warning',
              message: '文件读取失败'
            });
          }
        })
        // axios.get(file,{headers:{'Content-Type': 'application/json','Authorization': `${Cookies.get('token')}`,'uid':`${Cookies.get('uid')}`},responseType: 'blob'}).then(res=>{
        //   if (res) {
        //     const link = document.createElement('a')
        //     let blob = new Blob([res.data],{type: 'application/pdf'})
        //     link.style.display = "none";
        //     link.href = URL.createObjectURL(blob); // 创建URL
        //     window.open(link.href)
        //   } else {
        //     ElMessage({
        //       type: 'warning',
        //       message: '文件读取失败'
        //     });
        //   }
        // })
        window.open(file)
      }
      // 删除用户
@@ -156,6 +197,7 @@
      return {
        reportRef,
        openFile,
        getTypeName,
        openDialog,
        getData,
        onRowDel,