Эх сурвалжийг харах

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

qinzhipeng_v 5 жил өмнө
parent
commit
d60b1f44b2

+ 13 - 1
src/components/dialog/normalDialog.vue

@@ -1,6 +1,13 @@
 <template>
   <div class="dialog-main">
-    <el-dialog :title="title" :visible.sync="visible" @close="cancel()">
+    <el-dialog
+      :title="title"
+      :visible.sync="visible"
+      :width="width"
+      :modal-append-to-body="false"
+      :close-on-click-modal="false"
+      @close="cancel()"
+    >
       <slot />
       <span slot="footer" class="dialog-footer">
         <el-button @click="cancel()">取 消</el-button>
@@ -17,6 +24,11 @@ export default {
       default: '',
       required: false
     },
+    width: {
+      type: String,
+      default: '',
+      required: false
+    },
     showDialog: {
       type: Boolean,
       default: false,

+ 47 - 6
src/views/projectManage/bugList/details/index.vue

@@ -584,6 +584,22 @@
           <el-button type="primary" @click="statusDialogConfirm">确 定</el-button>
         </template>
       </el-dialog>
+      <normal-dialog
+        :show-dialog="showCopyFile"
+        :title="'复制信息'"
+        :width="'35%'"
+        @confirm="confirmUpload()"
+        @cancel="showCopyFile=false"
+      >
+        <div class="file-dialog">
+          <el-form ref="form" label-width="80px">
+            <el-form-item label="图片名称">
+              <el-input v-model="imageName" />
+            </el-form-item>
+          </el-form>
+          <img :src="imageUrl" class="image-url">
+        </div>
+      </normal-dialog>
     </el-container>
     <el-button id="pasteUpload" type="primary" style="display: none" @click="pasteUpload">upload</el-button>
   </div>
@@ -605,6 +621,7 @@ import {
   settingQueryBizModuleList
 } from '@/api/defectManage.js'
 import Dropdown from './dropdown.vue'
+import normalDialog from '@/components/dialog/normalDialog'
 import axios from 'axios'
 
 document.body.onpaste = function(event) {
@@ -625,7 +642,8 @@ document.body.onpaste = function(event) {
 export default {
   name: 'BugDetails',
   components: {
-    Dropdown
+    Dropdown,
+    normalDialog
   },
   mixins: [fackClickOutSide],
   props: {
@@ -718,6 +736,9 @@ export default {
           { required: true, message: '请输入Reopen原因', trigger: 'blur' }
         ]
       },
+      showCopyFile: false, // 复制文件对话框
+      imageName: null,
+      imageUrl: null,
       uploadButton: this.drawerShow
     }
   },
@@ -747,6 +768,9 @@ export default {
       height -= 130
       this.height = height + 'px'
     }
+    if (this.type === 'page') {
+      this.uploadButton = true
+    }
   },
   mounted() {
     this.bugGetEnum()
@@ -1171,15 +1195,24 @@ export default {
         return res
       })
     },
-    async pasteUpload() {
+    pasteUpload() {
       if (!this.uploadButton) {
         return false
       }
-      const res = await this.update(window.uploadFiles[0])
-      console.log(res)
+      if (window.uploadFiles[0]) {
+        const reader = new FileReader()
+        reader.readAsDataURL(window.uploadFiles[0])
+        reader.onload = () => {
+          this.imageUrl = reader.result
+        }
+        this.showCopyFile = true
+      }
+    },
+    async confirmUpload() {
+      const res = await this.updateFile(window.uploadFiles[0])
       const data = res.data
       const item = {
-        name: data.originResult.md5 + '.png' || '',
+        name: this.imageName || '',
         url: 'http:' + data.url
       }
       this.fileList.push(item)
@@ -1193,7 +1226,7 @@ export default {
       this.bugUpdate(this.bug, 'accessory')
       window.uploadFiles = null
     },
-    update(file) {
+    updateFile(file) {
       const param = new FormData() // 创建form对象
       param.append('file', file)// 通过append向form对象添加数据
       const config = {
@@ -1402,4 +1435,12 @@ export default {
   color:#F56C6C;
   position: absolute;
 }
+.file-dialog {
+  display: flex;
+  flex-direction: column;
+  align-items: center;
+}
+.image-url {
+  width: 50%;
+}
 </style>

+ 48 - 6
src/views/projectManage/bugList/file/createdBug.vue

@@ -171,6 +171,22 @@
       </el-form>
       <el-button id="pasteUpload" type="primary" style="display: none" @click="pasteUpload">upload</el-button>
     </el-dialog>
+    <normal-dialog
+      :show-dialog="showCopyFile"
+      :title="'复制信息'"
+      :width="'35%'"
+      @confirm="confirmUpload()"
+      @cancel="showCopyFile=false"
+    >
+      <div class="file-dialog">
+        <el-form ref="form" label-width="80px">
+          <el-form-item label="图片名称">
+            <el-input v-model="imageName" />
+          </el-form-item>
+        </el-form>
+        <img :src="imageUrl" class="image-url">
+      </div>
+    </normal-dialog>
     <el-dialog title="附件预览" :modal-append-to-body="false" :visible.sync="dialogVisible">
       <img width="100%" :src="dialogImageUrl" alt="图片加载失败">
     </el-dialog>
@@ -181,6 +197,7 @@
 import E from 'wangeditor'
 import { bugGetEnum, settingGetBizList, taskListCreate, releaseList, bugCreate, settingQueryBizModuleList } from '@/api/defectManage'
 import { memberQueryMemberInfoByIDAPorName } from '@/api/projectIndex'
+import normalDialog from '@/components/dialog/normalDialog'
 import '@/views/projectManage/bugList/css/index.css'
 import axios from 'axios'
 
@@ -201,6 +218,9 @@ document.body.onpaste = function(event) {
 
 export default {
   name: 'Createdbug',
+  components: {
+    normalDialog
+  },
   props: {
     getBugList: {
       type: Function,
@@ -261,7 +281,10 @@ export default {
       discoveryMethEnumList: [], // 发现方式
       bugStageEnumList: [], // 发现阶段
       networkTypeEnumList: [], // 网络
-      sysTypeEnumList: [] // 端类型
+      sysTypeEnumList: [], // 端类型
+      showCopyFile: false, // 复制文件对话框
+      imageName: null,
+      imageUrl: null
     }
   },
   created() {
@@ -424,15 +447,24 @@ export default {
         }))
       })
     },
-    async pasteUpload() {
+    pasteUpload() {
       if (!this.modalShow) {
         return false
       }
-      const res = await this.update(window.uploadFiles[0])
-      console.log(res)
+      if (window.uploadFiles[0]) {
+        const reader = new FileReader()
+        reader.readAsDataURL(window.uploadFiles[0])
+        reader.onload = () => {
+          this.imageUrl = reader.result
+        }
+        this.showCopyFile = true
+      }
+    },
+    async confirmUpload() {
+      const res = await this.updateFile(window.uploadFiles[0])
       const data = res.data
       const item = {
-        name: data.originResult.md5 + '.png' || '',
+        name: this.imageName || '',
         url: 'http:' + data.url
       }
       this.fileList.push(item)
@@ -444,7 +476,7 @@ export default {
       })
       window.uploadFiles = null
     },
-    update(file) {
+    updateFile(file) {
       const param = new FormData() // 创建form对象
       param.append('file', file)// 通过append向form对象添加数据
       const config = {
@@ -465,3 +497,13 @@ export default {
   }
 }
 </script>
+<style lang="scss" scoped>
+.file-dialog {
+  display: flex;
+  flex-direction: column;
+  align-items: center;
+}
+.image-url {
+  width: 50%;
+}
+</style>