Переглянути джерело

Merge branch 'http_mock' of git.xiaojukeji.com:jacklijiajia/thoth-frontend into http_mock

qinzhipeng_v 5 роки тому
батько
коміт
25671817f8

+ 1 - 0
src/views/projectManage/bugList/bugindex.vue

@@ -462,6 +462,7 @@
           :id="bugQuery.id+''"
           ref="bugDetails"
           :type="'drawer'"
+          :drawer-show="drawerShow"
           @close="drawerShow = false"
           @delete="drawerShow = false;type === 'page'?getBugList():getBugSelfList()"
           @update="type === 'page'?getBugList():getBugSelfList()"

+ 12 - 1
src/views/projectManage/bugList/details/index.vue

@@ -636,6 +636,10 @@ export default {
     type: {
       type: String,
       default: 'page'
+    },
+    drawerShow: {
+      type: Boolean,
+      default: false
     }
   },
   data() {
@@ -713,7 +717,8 @@ export default {
         reasonOrDesc: [
           { required: true, message: '请输入Reopen原因', trigger: 'blur' }
         ]
-      }
+      },
+      uploadButton: this.drawerShow
     }
   },
   watch: {
@@ -729,6 +734,9 @@ export default {
       this.bugNameForm = { bugName: '' }
       this.loading.drawer = false
       this.init()
+    },
+    drawerShow(newV) {
+      this.uploadButton = newV
     }
   },
   created() {
@@ -1164,6 +1172,9 @@ export default {
       })
     },
     async pasteUpload() {
+      if (!this.uploadButton) {
+        return false
+      }
       const res = await this.update(window.uploadFiles[0])
       console.log(res)
       const data = res.data

+ 56 - 0
src/views/projectManage/bugList/file/createdBug.vue

@@ -169,6 +169,7 @@
           <el-button :disabled="dis" type="primary" size="small" @click="bug_created(formInline)">创 建</el-button>
         </el-form-item>
       </el-form>
+      <el-button id="pasteUpload" type="primary" style="display: none" @click="pasteUpload">upload</el-button>
     </el-dialog>
     <el-dialog title="附件预览" :modal-append-to-body="false" :visible.sync="dialogVisible">
       <img width="100%" :src="dialogImageUrl" alt="图片加载失败">
@@ -181,6 +182,23 @@ import E from 'wangeditor'
 import { bugGetEnum, settingGetBizList, taskListCreate, releaseList, bugCreate, settingQueryBizModuleList } from '@/api/defectManage'
 import { memberQueryMemberInfoByIDAPorName } from '@/api/projectIndex'
 import '@/views/projectManage/bugList/css/index.css'
+import axios from 'axios'
+
+document.body.onpaste = function(event) {
+  const data = (event.clipboardData || window.clipboardData)
+  const items = data.items
+  const fileList = [] // 存储文件数据
+  if (items && items.length) {
+    // 检索剪切板items
+    for (let i = 0; i < items.length; i++) {
+      // console.log(items[i].getAsFile()) // <--- 这里打印出来就就是你想要的文件
+      fileList.push(items[i].getAsFile())
+      window.uploadFiles = fileList
+    }
+    document.getElementById('pasteUpload').click()
+  }
+}
+
 export default {
   name: 'Createdbug',
   props: {
@@ -405,6 +423,44 @@ export default {
           }))
         }))
       })
+    },
+    async pasteUpload() {
+      if (!this.modalShow) {
+        return false
+      }
+      const res = await this.update(window.uploadFiles[0])
+      console.log(res)
+      const data = res.data
+      const item = {
+        name: data.originResult.md5 + '.png' || '',
+        url: 'http:' + data.url
+      }
+      this.fileList.push(item)
+      this.fileDbList.push(item)
+      this.$message({
+        showClose: true,
+        message: '文件上传成功',
+        type: 'success'
+      })
+      window.uploadFiles = null
+    },
+    update(file) {
+      const param = new FormData() // 创建form对象
+      param.append('file', file)// 通过append向form对象添加数据
+      const config = {
+        headers: {
+          'Content-Type': 'multipart/form-data'
+        },
+        withCredentials: false
+      } // 添加请求头
+      return new Promise((resolve, reject) => {
+        axios.post('http://star.xiaojukeji.com/upload/img.node', param, config)
+          .then(response => {
+            resolve(response)
+          }).catch(err => {
+            reject(err)
+          })
+      })
     }
   }
 }