Browse Source

Merge remote-tracking branch 'origin/develop' into develop

ZZH-wl 3 years ago
parent
commit
e87a8a1131
1 changed files with 58 additions and 7 deletions
  1. 58 7
      src/views/plat/task/detail.vue

+ 58 - 7
src/views/plat/task/detail.vue

@@ -88,7 +88,23 @@
               </el-table-column>
               <el-table-column align="center" label="附件" prop="progFile">
                 <template #default="{ row }">
-                  <el-link v-show="row.progFile" @click="showFile(row.progFile)">查看附件</el-link>
+                  <el-upload action="#" :http-request="uploadrequest" :show-file-list="false">
+                    <el-button
+                      size="mini"
+                      style="margin-left: 10px"
+                      slot="trigger"
+                      type="primary"
+                      @click="showUploadFileDialog(row)">
+                      上传/更新
+                    </el-button>
+                    <el-button
+                      v-show="row.progFile"
+                      size="mini"
+                      style="margin-left: 10px"
+                      @click="showFile(row.progFile)">
+                      查看附件
+                    </el-button>
+                  </el-upload>
                 </template>
               </el-table-column>
               <el-table-column align="center" label="备注" prop="remark">
@@ -172,7 +188,9 @@
   import to from 'await-to-js'
   import taskApi from '@/api/plat/task'
   import userApi from '@/api/system/user'
+  import asyncUploadFile from '@/utils/uploadajax'
   import dictApi from '@/api/system/dict'
+  import axios from 'axios'
   export default {
     name: 'TaskDetail',
     data() {
@@ -190,6 +208,8 @@
           comment: '',
         },
         type: '',
+        // 选中进展
+        theProp: {},
       }
     },
     async mounted() {
@@ -286,19 +306,50 @@
       },
       // 查看附件
       showFile(path) {
-        const a = document.createElement('a')
-        a.href = path // 文件链接
-        a.download = path // 文件名,跨域资源download无效
-        a.click()
-        a.remove()
+        window.open(path, '_system')
       },
       // 添加进展
       addProgress() {
-        this.progressList.push({})
+        this.progressList.push({
+          progDesc: '',
+          progDate: '',
+          progFile: '',
+          remark: '',
+        })
       },
       handleDel(index) {
         this.progressList.splice(index, 1)
       },
+      // 开始上传附件
+      showUploadFileDialog(row) {
+        this.theProp = row
+      },
+      // 上传
+      uploadrequest(option) {
+        let _this = this
+        let url = process.env.VUE_APP_UPLOAD_WEED
+        axios
+          .post(url)
+          .then(function (res) {
+            if (res.data && res.data.fid && res.data.fid !== '') {
+              option.action = `${process.env.VUE_APP_PROTOCOL}${res.data.publicUrl}/${res.data.fid}`
+              asyncUploadFile(option).then(() => {
+                _this.theProp.progFile = `${process.env.VUE_APP_PROTOCOL}${res.data.publicUrl}/${res.data.fid}`
+              })
+            } else {
+              _this.$message({
+                type: 'warning',
+                message: '未上传成功!请重新上传!',
+              })
+            }
+          })
+          .catch(function () {
+            _this.$message({
+              type: 'warning',
+              message: '未上传成功!请重新上传!',
+            })
+          })
+      },
     },
   }
 </script>