Browse Source

文件下载,详情展示

李顺 2 years ago
parent
commit
6d3f21908c

+ 13 - 0
src/api/base.ts

@@ -29,6 +29,19 @@ export function getFiles(params) {
     data
   })
 }
+/**
+ * 公共接口,下载文件  mongodb
+ * @param data type {formData}
+ * @returns 
+ */
+ export function downloadFile(params){
+  return request({
+    url: '/tofly-datacheck/fileCommon/downLoad',
+    method: 'get',
+    params,
+    responseType: 'blob'
+  })
+}
 /**
  * 公共接口,批量删除  mongodb
  * @param data type {formData}

+ 1 - 2
src/components/Base/Table/index.vue

@@ -77,8 +77,7 @@
     rerender = false
 
     mounted() {
-      console.log('attrs', this.$attrs)
-      console.log("tf_table:"+this.pagination)
+      
     }
 
     get attrs() {

+ 5 - 1
src/utils/request.ts

@@ -12,7 +12,11 @@ const JSONbigString = require('json-bigint')({
 const transformResponse = [
   (res) => {
     try {
-      return JSON.parse(JSON.stringify(JSONbigString.parse(res)))
+      if(res.type&&res.type==='multipart/form-data'){//下载文件
+        return res;
+      }else{
+        return JSON.parse(JSON.stringify(JSONbigString.parse(res)))
+      }
     } catch (error) {
       console.log(error)
       return JSON.parse(res)

+ 24 - 13
src/views/zhpt/dataImport/jianceData/index.vue

@@ -168,7 +168,7 @@
  */
 import { Vue, Component, Watch } from 'vue-property-decorator'
 import { batchinfoPage, checkDataImport, checkdataPage } from '@/api/dataCheckModule/dataImport'
-import { uploadFile, getAllDepartments } from '@/api/base'
+import { uploadFile, getAllDepartments,downloadFile } from '@/api/base'
 import { projectPage } from '@/api/dataCheckModule/projectList'
 import { getDefaultPagination } from '@/utils/constant'
 import { districts } from '@/views/zhpt/dataImport/common/constant'
@@ -286,7 +286,19 @@ export default class JianCeDataImport extends Vue {
     this.fileList = fileList
   }
   handlePreview(file) {
-    console.log('点击文件列表中已上传的文件时的钩子', file)
+    if(this.formType==="edit"){
+      downloadFile({fileMark:file.fileId}).then(result=>{
+        const buffer = new Blob([result], {
+          type: 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet;charset=utf-8'
+        })
+        const link = document.createElement('a')
+        link.href = window.URL.createObjectURL(buffer)
+        link.download =file.name
+        link.click()
+        //释放内存
+        window.URL.revokeObjectURL(link.href)
+      })
+    }
   }
   handleExceed(files, fileList) {
     this.$message.warning(
@@ -390,14 +402,15 @@ export default class JianCeDataImport extends Vue {
               return
             }
             const fileID = result.result[0].fileId
-
-            const data = {
-              prjId: this.addForm.project,
-              district: this.addForm.district,
-              departmentId: this.addForm.tcUnit,
-              remark: this.addForm.remark,
-              fileId: fileID
-            }
+            const fileName = result.result[0].fileName
+          const data = {
+            prjId: this.addForm.project,
+            district: this.addForm.district,
+            departmentId: this.addForm.tcUnit,
+            remark: this.addForm.remark,
+            fileId: fileID,
+            fileName:fileName
+          }
             checkDataImport(data)
               .then((addResult) => {
                 if (addResult.code === 1) {
@@ -432,9 +445,7 @@ export default class JianCeDataImport extends Vue {
       type: 'tc',
       remark: row.remark
     }
-    // this.fileList = row.toflyFiles.map((item) => {
-    //   return item.fileName
-    // })
+    //this.fileList=[{name: row.fileName, fileId: row.fileId }]
   }
   /**数据导入列表 */
   batchinfoPage() {

+ 18 - 7
src/views/zhpt/dataImport/jiancejiesuanData/index.vue

@@ -163,7 +163,7 @@
  */
 import { Vue, Component,Watch } from 'vue-property-decorator'
 import { batchinfoPage, monitorSettleImport,monitorsettlePage } from '@/api/dataCheckModule/dataImport'
-import { uploadFile, getAllDepartments } from '@/api/base'
+import { uploadFile, getAllDepartments,downloadFile  } from '@/api/base'
 import { projectPage } from '@/api/dataCheckModule/projectList'
 import { getDefaultPagination } from '@/utils/constant'
 import { districts } from '@/views/zhpt/dataImport/common/constant'
@@ -274,7 +274,19 @@ export default class JianCeJiesuanDataImport extends Vue {
     this.fileList = fileList
   }
   handlePreview(file) {
-    console.log('点击文件列表中已上传的文件时的钩子', file)
+    if(this.formType==="edit"){
+      downloadFile({fileMark:file.fileId}).then(result=>{
+        const buffer = new Blob([result], {
+          type: 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet;charset=utf-8'
+        })
+        const link = document.createElement('a')
+        link.href = window.URL.createObjectURL(buffer)
+        link.download =file.name
+        link.click()
+        //释放内存
+        window.URL.revokeObjectURL(link.href)
+      })
+    }
   }
   handleExceed(files, fileList) {
     this.$message.warning(
@@ -378,13 +390,14 @@ export default class JianCeJiesuanDataImport extends Vue {
             return
           }
           const fileID = result.result[0].fileId
-
+            const fileName = result.result[0].fileName
           const data = {
             prjId: this.addForm.project,
             district: this.addForm.district,
             departmentId: this.addForm.tcUnit,
             remark: this.addForm.remark,
-            fileId: fileID
+            fileId: fileID,
+            fileName:fileName
           }
           monitorSettleImport(data)
             .then((addResult) => {
@@ -420,9 +433,7 @@ export default class JianCeJiesuanDataImport extends Vue {
       type: 'tc',
       remark: row.remark
     }
-    // this.fileList = row.toflyFiles.map((item) => {
-    //   return item.fileName
-    // })
+    //this.fileList=[{name: row.fileName, fileId: row.fileId }]
   }
   /**数据导入列表 */
   batchinfoPage() {

+ 18 - 7
src/views/zhpt/dataImport/renwuData/index.vue

@@ -168,7 +168,7 @@
  */
 import { Vue, Component, Watch } from 'vue-property-decorator'
 import { batchinfoPage, taskDataImport,taskDataPage } from '@/api/dataCheckModule/dataImport'
-import { uploadFile, getAllDepartments } from '@/api/base'
+import { uploadFile, getAllDepartments,downloadFile } from '@/api/base'
 import { projectPage } from '@/api/dataCheckModule/projectList'
 import { getDefaultPagination } from '@/utils/constant'
 import { districts } from '@/views/zhpt/dataImport/common/constant'
@@ -279,7 +279,19 @@ export default class RenWuImport extends Vue {
     this.fileList = fileList
   }
   handlePreview(file) {
-    console.log('点击文件列表中已上传的文件时的钩子', file)
+    if(this.formType==="edit"){
+      downloadFile({fileMark:file.fileId}).then(result=>{
+        const buffer = new Blob([result], {
+          type: 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet;charset=utf-8'
+        })
+        const link = document.createElement('a')
+        link.href = window.URL.createObjectURL(buffer)
+        link.download =file.name
+        link.click()
+        //释放内存
+        window.URL.revokeObjectURL(link.href)
+      })
+    }
   }
   handleExceed(files, fileList) {
     this.$message.warning(
@@ -383,13 +395,14 @@ export default class RenWuImport extends Vue {
             return
           }
           const fileID = result.result[0].fileId
-
+            const fileName = result.result[0].fileName
           const data = {
             prjId: this.addForm.project,
             district: this.addForm.district,
             departmentId: this.addForm.tcUnit,
             remark: this.addForm.remark,
-            fileId: fileID
+            fileId: fileID,
+            fileName:fileName
           }
           taskDataImport(data)
             .then((addResult) => {
@@ -425,9 +438,7 @@ export default class RenWuImport extends Vue {
       type: 'tc',
       remark: row.remark
     }
-    // this.fileList = row.toflyFiles.map((item) => {
-    //   return item.fileName
-    // })
+    //this.fileList=[{name: row.fileName, fileId: row.fileId }]
   }
   /**数据导入列表 */
   batchinfoPage() {

+ 24 - 13
src/views/zhpt/dataImport/tanceData/index.vue

@@ -169,7 +169,7 @@
 import { Vue, Component, Watch } from 'vue-property-decorator'
 import { batchinfoPage, detectDataImport, detectDataPage } from '@/api/dataCheckModule/dataImport'
 import { projectPage } from '@/api/dataCheckModule/projectList'
-import { uploadFile, getAllDepartments } from '@/api/base'
+import { uploadFile, getAllDepartments,downloadFile } from '@/api/base'
 import { getDefaultPagination } from '@/utils/constant'
 import { districts } from '@/views/zhpt/dataImport/common/constant'
 import { ElForm } from 'element-ui/types/form'
@@ -290,7 +290,19 @@ export default class TanceDataImport extends Vue {
     this.fileList = fileList
   }
   handlePreview(file) {
-    console.log('点击文件列表中已上传的文件时的钩子', file)
+    if(this.formType==="edit"){
+      downloadFile({fileMark:file.fileId}).then(result=>{
+        const buffer = new Blob([result], {
+          type: 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet;charset=utf-8'
+        })
+        const link = document.createElement('a')
+        link.href = window.URL.createObjectURL(buffer)
+        link.download =file.name
+        link.click()
+        //释放内存
+        window.URL.revokeObjectURL(link.href)
+      })
+    }
   }
   handleExceed(files, fileList) {
     this.$message.warning(
@@ -393,14 +405,15 @@ export default class TanceDataImport extends Vue {
               return
             }
             const fileID = result.result[0].fileId
-
-            const data = {
-              prjId: this.addForm.project,
-              district: this.addForm.district,
-              departmentId: this.addForm.tcUnit,
-              remark: this.addForm.remark,
-              fileId: fileID
-            }
+            const fileName = result.result[0].fileName
+          const data = {
+            prjId: this.addForm.project,
+            district: this.addForm.district,
+            departmentId: this.addForm.tcUnit,
+            remark: this.addForm.remark,
+            fileId: fileID,
+            fileName:fileName
+          }
             detectDataImport(data)
               .then((addResult) => {
                 if (addResult.code === 1) {
@@ -435,9 +448,7 @@ export default class TanceDataImport extends Vue {
       type: 'tc',
       remark: row.remark
     }
-    // this.fileList = row.toflyFiles.map((item) => {
-    //   return item.fileName
-    // })
+    //this.fileList=[{name: row.fileName, fileId: row.fileId }]
   }
   /**数据导入列表 */
   batchinfoPage() {

+ 18 - 7
src/views/zhpt/dataImport/yuchuliData/index.vue

@@ -168,7 +168,7 @@
  */
 import { Vue, Component,Watch } from 'vue-property-decorator'
 import { batchinfoPage, handleDataImport,handledataPage } from '@/api/dataCheckModule/dataImport'
-import { uploadFile, getAllDepartments } from '@/api/base'
+import { uploadFile, getAllDepartments,downloadFile } from '@/api/base'
 import { projectPage } from '@/api/dataCheckModule/projectList'
 import { getDefaultPagination } from '@/utils/constant'
 import { districts } from '@/views/zhpt/dataImport/common/constant'
@@ -292,7 +292,19 @@ export default class YuChuLiDataImport extends Vue {
     this.fileList = fileList
   }
   handlePreview(file) {
-    console.log('点击文件列表中已上传的文件时的钩子', file)
+   if(this.formType==="edit"){
+      downloadFile({fileMark:file.fileId}).then(result=>{
+        const buffer = new Blob([result], {
+          type: 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet;charset=utf-8'
+        })
+        const link = document.createElement('a')
+        link.href = window.URL.createObjectURL(buffer)
+        link.download =file.name
+        link.click()
+        //释放内存
+        window.URL.revokeObjectURL(link.href)
+      })
+    }
   }
   handleExceed(files, fileList) {
     this.$message.warning(
@@ -396,13 +408,14 @@ export default class YuChuLiDataImport extends Vue {
             return
           }
           const fileID = result.result[0].fileId
-
+            const fileName = result.result[0].fileName
           const data = {
             prjId: this.addForm.project,
             district: this.addForm.district,
             departmentId: this.addForm.tcUnit,
             remark: this.addForm.remark,
-            fileId: fileID
+            fileId: fileID,
+            fileName:fileName
           }
           handleDataImport(data)
             .then((addResult) => {
@@ -438,9 +451,7 @@ export default class YuChuLiDataImport extends Vue {
       type: 'tc',
       remark: row.remark
     }
-    // this.fileList = row.toflyFiles.map((item) => {
-    //   return item.fileName
-    // })
+    //this.fileList=[{name: row.fileName, fileId: row.fileId }]
   }
   /**数据导入列表 */
   batchinfoPage() {

+ 18 - 7
src/views/zhpt/dataImport/yuchulijiesuanData/index.vue

@@ -183,7 +183,7 @@
  */
 import { Vue, Component,Watch } from 'vue-property-decorator'
 import { batchinfoPage, preSettleImport,presettlePage } from '@/api/dataCheckModule/dataImport'
-import { uploadFile, getAllDepartments } from '@/api/base'
+import { uploadFile, getAllDepartments,downloadFile } from '@/api/base'
 import { projectPage } from '@/api/dataCheckModule/projectList'
 import { getDefaultPagination } from '@/utils/constant'
 import { districts,DiameterLevel } from '@/views/zhpt/dataImport/common/constant'
@@ -297,7 +297,19 @@ export default class YuChuLiJiesuanDataImport extends Vue {
     this.fileList = fileList
   }
   handlePreview(file) {
-    console.log('点击文件列表中已上传的文件时的钩子', file)
+    if(this.formType==="edit"){
+      downloadFile({fileMark:file.fileId}).then(result=>{
+        const buffer = new Blob([result], {
+          type: 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet;charset=utf-8'
+        })
+        const link = document.createElement('a')
+        link.href = window.URL.createObjectURL(buffer)
+        link.download =file.name
+        link.click()
+        //释放内存
+        window.URL.revokeObjectURL(link.href)
+      })
+    }
   }
   handleExceed(files, fileList) {
     this.$message.warning(
@@ -426,13 +438,14 @@ export default class YuChuLiJiesuanDataImport extends Vue {
             return
           }
           const fileID = result.result[0].fileId
-
+          const fileName = result.result[0].fileName
           const data = {
             prjId: this.addForm.project,
             district: this.addForm.district,
             departmentId: this.addForm.tcUnit,
             remark: this.addForm.remark,
-            fileId: fileID
+            fileId: fileID,
+            fileName:fileName
           }
           preSettleImport(data)
             .then((addResult) => {
@@ -468,9 +481,7 @@ export default class YuChuLiJiesuanDataImport extends Vue {
       type: 'tc',
       remark: row.remark
     }
-    // this.fileList = row.toflyFiles.map((item) => {
-    //   return item.fileName
-    // })
+   //this.fileList=[{name: row.fileName, fileId: row.fileId }]
   }
   /**数据导入列表 */
   batchinfoPage() {

+ 14 - 2
src/views/zhpt/filesManage/contract/index.vue

@@ -103,7 +103,7 @@
 import { Vue, Component, Prop, Watch } from 'vue-property-decorator'
 import { projectPage, uploadFile } from '@/api/dataCheckModule/projectList'
 import { contractmanagerPage, addContract, editContract, delContract } from '@/api/dataCheckModule/fileManage'
-import { getAllDepartments } from '@/api/base'
+import { getAllDepartments,downloadFile } from '@/api/base'
 import { parseTime } from '@/utils/index'
 import { ContractType } from '@/views/zhpt/dataImport/common/constant'
 import { getDefaultPagination } from '@/utils/constant'
@@ -191,7 +191,19 @@ export default class ContractManage extends Vue {
     this.fileList = fileList
   }
   handlePreview(file) {
-    console.log('点击文件列表中已上传的文件时的钩子', file)
+    if(this.formType==="edit"){
+      downloadFile({fileMark:file.fileId}).then(result=>{
+        const buffer = new Blob([result], {
+          type: 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet;charset=utf-8'
+        })
+        const link = document.createElement('a')
+        link.href = window.URL.createObjectURL(buffer)
+        link.download =file.name
+        link.click()
+        //释放内存
+        window.URL.revokeObjectURL(link.href)
+      })
+    }
   }
   handleExceed(files, fileList) {
     this.$message.warning(

+ 14 - 2
src/views/zhpt/filesManage/fileImport/index.vue

@@ -105,7 +105,7 @@
 import { Vue, Component, Prop, Watch } from 'vue-property-decorator'
 import { projectPage, uploadFile } from '@/api/dataCheckModule/projectList'
 import { fileImportPage, fileManagerUpload } from '@/api/dataCheckModule/fileManage'
-import { getAllDepartments } from '@/api/base'
+import { getAllDepartments,downloadFile } from '@/api/base'
 import { parseTime } from '@/utils/index'
 import { FileTypes } from '@/views/zhpt/dataImport/common/constant'
 import { getDefaultPagination } from '@/utils/constant'
@@ -191,7 +191,19 @@ export default class ProjectFileImport extends Vue {
     this.fileList = fileList
   }
   handlePreview(file) {
-    console.log('点击文件列表中已上传的文件时的钩子', file)
+    if(this.formType==="edit"){
+      downloadFile({fileMark:file.fileId}).then(result=>{
+        const buffer = new Blob([result], {
+          type: 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet;charset=utf-8'
+        })
+        const link = document.createElement('a')
+        link.href = window.URL.createObjectURL(buffer)
+        link.download =file.name
+        link.click()
+        //释放内存
+        window.URL.revokeObjectURL(link.href)
+      })
+    }
   }
   handleExceed(files, fileList) {
     this.$message.warning(

+ 14 - 2
src/views/zhpt/filesManage/fileManage/index.vue

@@ -127,7 +127,7 @@
 import { Vue, Component, Prop, Watch } from 'vue-property-decorator'
 import { projectPage, uploadFile } from '@/api/dataCheckModule/projectList'
 import { fileImportPage, fileManagerUpload,delFile,recordmanagerUpload,getRecordLinkData,fileManagerPage } from '@/api/dataCheckModule/fileManage'
-import { getAllDepartments,deleteFileByIds,getFileById } from '@/api/base'
+import { getAllDepartments,deleteFileByIds,getFileById,downloadFile } from '@/api/base'
 import { parseTime } from '@/utils/index'
 import { FileTypes,districts } from '@/views/zhpt/dataImport/common/constant'
 import { getDefaultPagination } from '@/utils/constant'
@@ -262,7 +262,19 @@ export default class ProjectFileImport extends Vue {
     this.fileList = fileList
   }
   handlePreview(file) {
-    console.log('点击文件列表中已上传的文件时的钩子', file)
+   if(this.formType==="edit"){
+      downloadFile({fileMark:file.fileId}).then(result=>{
+        const buffer = new Blob([result], {
+          type: 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet;charset=utf-8'
+        })
+        const link = document.createElement('a')
+        link.href = window.URL.createObjectURL(buffer)
+        link.download =file.name
+        link.click()
+        //释放内存
+        window.URL.revokeObjectURL(link.href)
+      })
+    }
   }
   handleExceed(files, fileList) {
     this.$message.warning(

+ 15 - 2
src/views/zhpt/projectManage/index.vue

@@ -115,7 +115,7 @@ import {
   uploadFile,
   delStandingBook
 } from '@/api/dataCheckModule/projectList'
-import { getAllDepartments } from '@/api/base'
+import { getAllDepartments,downloadFile } from '@/api/base'
 import { parseTime } from '@/utils/index'
 import { ElForm } from 'element-ui/types/form'
 @Component({
@@ -194,7 +194,19 @@ export default class ProjectManage extends Vue {
     this.fileList = fileList
   }
   handlePreview(file) {
-    console.log('点击文件列表中已上传的文件时的钩子', file)
+    if(this.formType==="edit"){
+      downloadFile({fileMark:file.fileId}).then(result=>{
+        const buffer = new Blob([result], {
+          type: 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet;charset=utf-8'
+        })
+        const link = document.createElement('a')
+        link.href = window.URL.createObjectURL(buffer)
+        link.download =file.name
+        link.click()
+        //释放内存
+        window.URL.revokeObjectURL(link.href)
+      })
+    }
   }
   handleExceed(files, fileList) {
     this.$message.warning(
@@ -330,6 +342,7 @@ export default class ProjectManage extends Vue {
     }
 
     this.$nextTick(() => {
+      (this.$refs['addForm'] as ElForm).clearValidate()
       this.addForm.creator = this.$store.state.user.realName
       this.addForm.createTime = parseTime(new Date(), '{y}-{m}-{d} {h}:{i}:{s}')
     })