Browse Source

文件上传

lizhenhao 2 năm trước cách đây
mục cha
commit
d86ae0ab6b
1 tập tin đã thay đổi với 15 bổ sung0 xóa
  1. 15 0
      src/views/modules/sys/project/AssessForm.vue

+ 15 - 0
src/views/modules/sys/project/AssessForm.vue

@@ -338,6 +338,7 @@
             <vxe-column title="操作" width="200px" fixed="right" align="center">
               <template  slot-scope="scope">
                 <el-button type="text"  icon="el-icon-delete" size="small" @click="del(scope.row.id)">删除</el-button>
+                <el-button type="text"  icon="el-icon-edit" size="small" @click="toHref(scope.row)">下载</el-button>
               </template>
             </vxe-column>
           </vxe-table>
@@ -432,6 +433,19 @@
       this.projectService = new ProjectService()
     },
     methods: {
+      async toHref (row) {
+        console.log('rr', row)
+        const link = document.createElement('a')
+        link.setAttribute('download', row.name)
+        if (row.id === null || row.id === undefined || row.id === '') {
+          await this.ossService.getTemporaryUrl(row.raw.url).then((data) => {
+            link.setAttribute('href', data.data)
+          })
+        } else {
+          link.setAttribute('href', row.url)
+          link.click()
+        }
+      },
       onPreview (url) {
         this.url = url
         this.showViewer = true
@@ -534,6 +548,7 @@
             console.log(this.dataListNew)
             this.inputForm.workAttachments = []
             this.dataListNew.forEach((item) => {
+              item.url = item.raw.url
               item.attachmentFlag = 'projectRecords'
               item.fileSize = item.size
               item.attachmentName = item.name