Browse Source

修复人员信息图片回显问题

凉纪 2 years ago
parent
commit
6f2a6d53ca
4 changed files with 14 additions and 6 deletions
  1. 3 5
      src/components/ImageUpload/index.vue
  2. 2 1
      src/main.js
  3. 6 0
      src/utils/ruoyi.js
  4. 3 0
      src/views/system/user/extend.vue

+ 3 - 5
src/components/ImageUpload/index.vue

@@ -116,6 +116,7 @@
 <script>
 import { getToken } from "@/utils/auth";
 import { upload } from "@/api/system/public";
+import {imageUrl} from "@/utils/ruoyi";
 
 export default {
   props: {
@@ -210,10 +211,7 @@ export default {
         .then((res) => {
           /*上传成功*/
           this.$modal.closeLoading();
-          let imgUrl =
-            process.env.NODE_ENV === "development"
-              ? process.env.VUE_APP_BASE_API + res.data.url
-              : window.origin + res.data.url;
+          let imgUrl = this.imageUrl(res.data.url); //拼接完整图片URL路径
           let arr = [];
           arr.push({ name: res.data.name, url: imgUrl });
           if(this.type=='more'){
@@ -338,7 +336,7 @@ export default {
     clearFiles(){
         this.$refs["imageUpload"].clearFiles();
         // this.fileList = [];
-        // this.fileValueList = [];        
+        // this.fileValueList = [];
       },
   },
 };

+ 2 - 1
src/main.js

@@ -22,7 +22,7 @@ import {
   selectDictLabel,
   selectDictLabels,
   handleTree,
-  formatTime
+  formatTime, imageUrl
 } from "@/utils/ruoyi";
 // 分页组件
 import Pagination from "@/components/Pagination";
@@ -69,6 +69,7 @@ Vue.prototype.selectDictLabel = selectDictLabel
 Vue.prototype.selectDictLabels = selectDictLabels
 Vue.prototype.download = download
 Vue.prototype.handleTree = handleTree
+Vue.prototype.imageUrl = imageUrl
 
 // 全局组件挂载
 Vue.component('DictTag', DictTag)

+ 6 - 0
src/utils/ruoyi.js

@@ -5,6 +5,12 @@ import dayjs from "dayjs";
  * Copyright (c) 2019 ruoyi
  */
 
+/*图片拼接url*/
+export function imageUrl(url){
+  return  process.env.NODE_ENV === "development"
+    ? process.env.VUE_APP_BASE_API + url
+    : window.origin + url;
+}
 
 // 时间比较
 export function timeCheck(arr) {

+ 3 - 0
src/views/system/user/extend.vue

@@ -382,7 +382,10 @@ export default {
         this.roleName = data.roleName;
         this.sex = data.sex;
         this.status = data.status;
+        console.log( data.information.qualificationCertificateUrl,'5555')
+        let img = data.information.qualificationCertificateUrl.split(',');
         this.formData = data.information;
+        this.formData.qualificationCertificateUrl = img.map((v, i) => {return this.imageUrl(v)});
       });
     },