Przeglądaj źródła

修改上传组件

wangfei 6 lat temu
rodzic
commit
e27e448687

+ 41
- 0
src/components/upload/index.vue Wyświetl plik

@@ -0,0 +1,41 @@
1
+<template>
2
+  <input class="cust-upload" type="file" :accept="allowfile" @change="onchange" />
3
+</template>
4
+
5
+<script>
6
+export default {
7
+  name: 'fileUpload',
8
+  props: [
9
+    'accept',
10
+    'value',
11
+    'upload',
12
+  ],
13
+  data () {
14
+    return {}
15
+  },
16
+  computed: {
17
+    allowfile () {
18
+      return this.accept || 'image/jpeg, image/gif, image/png'
19
+    }
20
+  },
21
+  methods: {
22
+    onchange (e) {
23
+      const files = e.target.files
24
+      if (files && files.length) {
25
+        this.upload(files[0]).then((data) => {
26
+          this.$emit('input', data)
27
+        }).catch((error) => {
28
+          // TODO
29
+          console.log(error)
30
+        })
31
+      }
32
+    },
33
+  },
34
+}
35
+</script>
36
+
37
+<style lang="scss" scoped>
38
+.cust-upload {
39
+
40
+}
41
+</style>

+ 1
- 1
src/pages/system/cardAndCouponManager/bodyBuildingCardManager/edit.vue Wyświetl plik

@@ -24,7 +24,7 @@
24 24
               <a v-if="cardInfo.CardImageUrl && cardInfo.CardImageUrl.indexOf('.mp4') > -1" :href="cardInfo.CardImageUrl" target="blank" style="line-height:40px;">{{cardInfo.CardImageUrl}}</a>
25 25
               <el-upload
26 26
                 class="avatar-uploader"
27
-                :action='$api.file.image.url'
27
+                :action='toolClass.ReplaceOrg($api.file.image.url)'
28 28
                 :show-file-list="false"
29 29
                 :on-success="handleAvatarSuccess">
30 30
                 <img v-if="cardInfo.CardImageUrl && cardInfo.CardImageUrl.indexOf('.mp4') === -1" :src="cardInfo.CardImageUrl" class="avatar">

+ 2
- 2
src/pages/system/cardAndCouponManager/cardManager/edit.vue Wyświetl plik

@@ -23,7 +23,7 @@
23 23
             <div>
24 24
               <el-upload
25 25
                 class="avatar-uploader"
26
-                :action='$api.file.image.url'
26
+                :action='toolClass.ReplaceOrg($api.file.image.url)'
27 27
                 :show-file-list="false"
28 28
                 :on-success="handleAvatarSuccess">
29 29
                 <img v-if="cardInfo.Images" :src="cardInfo.Images[0].CardImageUrl" class="avatar">
@@ -144,7 +144,7 @@
144 144
               <a style="line-height: 40px;" v-if="videoOff" :href="cardInfo.VideoUrl" target="blank">{{cardInfo.VideoUrl}}</a>
145 145
               <el-upload
146 146
                 class="avatar-uploader"
147
-                :action='$api.file.image.url'
147
+                :action='toolClass.ReplaceOrg($api.file.image.url)'
148 148
                 :show-file-list="false"
149 149
                 :on-success="videoSuccess">
150 150
                 <a style="line-height: 40px;padding: 0 10px;">{{videoOff ? '更换' : '添加'}}视频</a>

+ 2
- 2
src/pages/system/cardAndCouponManager/couponManager/edit.vue Wyświetl plik

@@ -24,7 +24,7 @@
24 24
             <div>
25 25
               <el-upload
26 26
                 class="avatar-uploader"
27
-                :action='$api.file.image.url'
27
+                :action='toolClass.ReplaceOrg($api.file.image.url)'
28 28
                 :show-file-list="false"
29 29
                 :on-success="handleAvatarSuccess">
30 30
                 <img v-if="couponInfo.Images[0].CouponImageUrl" :src="couponInfo.Images[0].CouponImageUrl" class="avatar">
@@ -208,7 +208,7 @@
208 208
               <a style="line-height: 40px;" v-if="videoOff" :href="couponInfo.VideoUrl" target="blank">{{couponInfo.VideoUrl}}</a>
209 209
               <el-upload
210 210
                 class="avatar-uploader"
211
-                :action='$api.file.image.url'
211
+                :action='toolClass.ReplaceOrg($api.file.image.url)'
212 212
                 :show-file-list="false"
213 213
                 :on-success="videoSuccess">
214 214
                 <a style="line-height: 40px;padding: 0 10px;">{{videoOff ? '更换' : '添加'}}视频</a>

+ 2
- 2
src/pages/system/caseManager/caseAreaManager/add.vue Wyświetl plik

@@ -37,7 +37,7 @@
37 37
             <div>
38 38
               <el-upload
39 39
                 class="avatar-uploader"
40
-                :action='$api.file.image.url'
40
+                :action='toolClass.ReplaceOrg($api.file.image.url)'
41 41
                 :show-file-list="false"
42 42
                 :on-success="handleAvatarSuccess">
43 43
                 <img v-if="postData.AreaIcon" :src="postData.AreaIcon" class="avatar">
@@ -52,7 +52,7 @@
52 52
             <div>
53 53
               <el-upload
54 54
                 class="avatar-uploader"
55
-                :action='$api.file.image.url'
55
+                :action='toolClass.ReplaceOrg($api.file.image.url)'
56 56
                 :show-file-list="false"
57 57
                 :on-success="handleAvatarSuccesser">
58 58
                 <img v-if="postData.AreaIconWhite" :src="postData.AreaIconWhite" class="avatar">

+ 2
- 2
src/pages/system/caseManager/caseAreaManager/edit.vue Wyświetl plik

@@ -37,7 +37,7 @@
37 37
             <div>
38 38
               <el-upload
39 39
                 class="avatar-uploader"
40
-                :action='$api.file.image.url'
40
+                :action='toolClass.ReplaceOrg($api.file.image.url)'
41 41
                 :show-file-list="false"
42 42
                 :on-success="handleAvatarSuccess">
43 43
                 <img v-if="postData.AreaIcon" :src="postData.AreaIcon" class="avatar">
@@ -52,7 +52,7 @@
52 52
             <div>
53 53
               <el-upload
54 54
                 class="avatar-uploader"
55
-                :action='$api.file.image.url'
55
+                :action='toolClass.ReplaceOrg($api.file.image.url)'
56 56
                 :show-file-list="false"
57 57
                 :on-success="handleAvatarSuccesser">
58 58
                 <img v-if="postData.AreaIconWhite" :src="postData.AreaIconWhite" class="avatar">

+ 1
- 1
src/pages/system/caseManager/caseInfo/addCase/index.vue Wyświetl plik

@@ -66,7 +66,7 @@
66 66
               </a> -->
67 67
               <el-upload
68 68
                 class="avatar-uploader"
69
-                :action='$api.file.image.url'
69
+                :action='toolClass.ReplaceOrg($api.file.image.url)'
70 70
                 :show-file-list="false"
71 71
                 :on-success="handleAvatarSuccess">
72 72
                 <img v-if="postData.CaseIcon" :src="postData.CaseIcon" class="avatar">

+ 1
- 1
src/pages/system/caseManager/caseInfo/editCase/index.vue Wyświetl plik

@@ -62,7 +62,7 @@
62 62
               </a> -->
63 63
               <el-upload
64 64
                 class="avatar-uploader"
65
-                :action='$api.file.image.url'
65
+                :action='toolClass.ReplaceOrg($api.file.image.url)'
66 66
                 :show-file-list="false"
67 67
                 :on-success="handleAvatarSuccess">
68 68
                 <img v-if="postData.CaseIcon" :src="postData.CaseIcon" class="avatar">

+ 10
- 3
src/pages/system/cmsManager/bannerManager/add.vue Wyświetl plik

@@ -78,7 +78,7 @@
78 78
           <span>图片:</span>
79 79
           <div class="flex-item">
80 80
             <!-- <el-upload
81
-              :action="$api.file.image.url"
81
+              :action="toolClass.ReplaceOrg($api.file.image.url)"
82 82
               :limit='limit'
83 83
               list-type="picture-card"
84 84
               :file-list='imgsArr'
@@ -92,12 +92,15 @@
92 92
             </el-dialog> -->
93 93
             <el-upload
94 94
               class="avatar-uploader"
95
-              :action='$api.file.image.url'
95
+              :action='toolClass.ReplaceOrg($api.file.image.url)'
96 96
               :show-file-list="false"
97 97
               :on-success="handleAvatarSuccess">
98 98
               <img v-if="postData.ImageUrl" :src="postData.ImageUrl" class="avatar">
99 99
               <i v-else class="el-icon-plus avatar-uploader-icon"></i>
100 100
             </el-upload>
101
+            <!-- <div>
102
+              <image-uploader :upload="uploader" v-model="postData.ImageUrl" />
103
+            </div> -->
101 104
           </div>
102 105
         </li>
103 106
         <!-- <li class="flex-h">
@@ -126,6 +129,7 @@
126 129
 
127 130
 <script>
128 131
 import { mapState, createNamespacedHelpers, mapActions } from 'vuex'
132
+// import upload from '@/util/upload'
129 133
 
130 134
 const { mapActions: mapCmsActions } = createNamespacedHelpers('cms')
131 135
 const { mapState: mapCourseState, mapActions: mapCourseActions } = createNamespacedHelpers('course')
@@ -134,6 +138,7 @@ export default {
134 138
   name: '',
135 139
   data () {
136 140
     return {
141
+      // uploader: upload,
137 142
       postData: {
138 143
         ForwardType: '1',
139 144
         ForwardUrl: '',
@@ -151,7 +156,9 @@ export default {
151 156
       limit: 1
152 157
     }
153 158
   },
154
-  components: {},
159
+  components: {
160
+    // imageUploader: () => import('@/components/upload')
161
+  },
155 162
   created () {
156 163
     this.GetCourseList({page: 1, pagesize: 100})
157 164
     this.updateLocationInfo()

+ 2
- 2
src/pages/system/cmsManager/bannerManager/edit.vue Wyświetl plik

@@ -78,7 +78,7 @@
78 78
           <span>图片:</span>
79 79
           <div class="flex-item">
80 80
             <!-- <el-upload
81
-              :action="$api.file.image.url"
81
+              :action="toolClass.ReplaceOrg($api.file.image.url)"
82 82
               :limit='limit'
83 83
               list-type="picture-card"
84 84
               :file-list='imgsArr'
@@ -92,7 +92,7 @@
92 92
             </el-dialog> -->
93 93
             <el-upload
94 94
               class="avatar-uploader"
95
-              :action='$api.file.image.url'
95
+              :action='toolClass.ReplaceOrg($api.file.image.url)'
96 96
               :show-file-list="false"
97 97
               :on-success="handleAvatarSuccess">
98 98
               <img v-if="postData.ImageUrl" :src="postData.ImageUrl" class="avatar">

+ 4
- 4
src/pages/system/cmsManager/majorProjects/edit.vue Wyświetl plik

@@ -45,7 +45,7 @@
45 45
           <span>图片:</span>
46 46
           <div class="flex-item">
47 47
             <!-- <el-upload
48
-              :action="$api.file.image.url"
48
+              :action="toolClass.ReplaceOrg($api.file.image.url)"
49 49
               list-type="picture-card"
50 50
               :limit='limit'
51 51
               :file-list='imgsArr'
@@ -57,7 +57,7 @@
57 57
             <!-- 单选 -->
58 58
             <el-upload
59 59
               class="avatar-uploader"
60
-              :action='$api.file.image.url'
60
+              :action='toolClass.ReplaceOrg($api.file.image.url)'
61 61
               :show-file-list="false"
62 62
               :on-success="handleImgSuccess">
63 63
               <img v-if="imgShow" :src="imgShow" class="avatar">
@@ -69,7 +69,7 @@
69 69
           <span>详细图片:</span>
70 70
           <div class="flex-item">
71 71
             <!-- <el-upload
72
-              :action='$api.file.image.url'
72
+              :action='toolClass.ReplaceOrg($api.file.image.url)'
73 73
               list-type="picture-card"
74 74
               :limit='limit'
75 75
               :file-list='detailimgsArr'
@@ -81,7 +81,7 @@
81 81
             <!-- 单选 -->
82 82
             <el-upload
83 83
               class="avatar-uploader"
84
-              :action='$api.file.image.url'
84
+              :action='toolClass.ReplaceOrg($api.file.image.url)'
85 85
               :show-file-list="false"
86 86
               :on-success="handleDetailImgSuccess">
87 87
               <img v-if="detailImgShow" :src="detailImgShow" class="avatar">

+ 2
- 2
src/pages/system/cmsManager/newsManager/add.vue Wyświetl plik

@@ -63,7 +63,7 @@
63 63
           <span>图片:</span>
64 64
           <div class="flex-item">
65 65
             <!-- <el-upload
66
-              :action="$api.file.image.url"
66
+              :action="toolClass.ReplaceOrg($api.file.image.url)"
67 67
               :limit='limit'
68 68
               list-type="picture-card"
69 69
               :file-list='imgsArr'
@@ -78,7 +78,7 @@
78 78
             <!-- 单选 -->
79 79
             <el-upload
80 80
               class="avatar-uploader"
81
-              :action='$api.file.image.url'
81
+              :action='toolClass.ReplaceOrg($api.file.image.url)'
82 82
               :show-file-list="false"
83 83
               :on-success="handleAvatarSuccess">
84 84
               <img v-if="postData.ImageUrl" :src="postData.ImageUrl" class="avatar">

+ 2
- 2
src/pages/system/cmsManager/newsManager/edit.vue Wyświetl plik

@@ -63,7 +63,7 @@
63 63
           <span>图片:</span>
64 64
           <div class="flex-item">
65 65
             <!-- <el-upload
66
-              :action="$api.file.image.url"
66
+              :action="toolClass.ReplaceOrg($api.file.image.url)"
67 67
               :limit='limit'
68 68
               list-type="picture-card"
69 69
               :file-list='imgsArr'
@@ -77,7 +77,7 @@
77 77
             </el-dialog> -->
78 78
             <el-upload
79 79
               class="avatar-uploader"
80
-              :action='$api.file.image.url'
80
+              :action='toolClass.ReplaceOrg($api.file.image.url)'
81 81
               :show-file-list="false"
82 82
               :on-success="handleAvatarSuccess">
83 83
               <img v-if="postData.ImageUrl" :src="postData.ImageUrl" class="avatar">

+ 1
- 1
src/pages/system/courseManager/courseList/add.vue Wyświetl plik

@@ -8,7 +8,7 @@
8 8
             <div>
9 9
               <el-upload
10 10
                 class="avatar-uploader"
11
-                :action='$api.file.image.url'
11
+                :action='toolClass.ReplaceOrg($api.file.image.url)'
12 12
                 :show-file-list="false"
13 13
                 :on-success="handleAvatarSuccess">
14 14
                 <img v-if="detail.CourseImg" :src="detail.CourseImg" class="avatar">

+ 1
- 1
src/pages/system/courseManager/courseList/index.vue Wyświetl plik

@@ -170,7 +170,7 @@
170 170
             <div>
171 171
               <el-upload
172 172
                 class="avatar-uploader"
173
-                :action='$api.file.image.url'
173
+                :action='toolClass.ReplaceOrg($api.file.image.url)'
174 174
                 :show-file-list="false"
175 175
                 :on-success="handleAvatarSuccess">
176 176
                 <img v-if="newImg" :src="newImg" class="avatar">

+ 1
- 1
src/pages/system/courseManager/fiveA/add.vue Wyświetl plik

@@ -42,7 +42,7 @@
42 42
           <span>图片:</span>
43 43
           <div class="flex-item">
44 44
             <el-upload
45
-              :action="$api.file.image.url"
45
+              :action="toolClass.ReplaceOrg($api.file.image.url)"
46 46
               :limit='limit'
47 47
               list-type="picture-card"
48 48
               :file-list='imgsArr'

+ 1
- 1
src/pages/system/courseManager/fiveA/edit.vue Wyświetl plik

@@ -54,7 +54,7 @@
54 54
           <span>图片:</span>
55 55
           <div class="flex-item">
56 56
             <el-upload
57
-              :action="$api.file.image.url"
57
+              :action="toolClass.ReplaceOrg($api.file.image.url)"
58 58
               :limit='limit'
59 59
               list-type="picture-card"
60 60
               :file-list='imgsArr'

+ 2
- 2
src/pages/system/goodsManager/goodManager/edit.vue Wyświetl plik

@@ -35,7 +35,7 @@
35 35
             <div style="width:50%">
36 36
               <!-- 多选 -->
37 37
               <!-- <el-upload
38
-                :action="$api.file.image.url"
38
+                :action="toolClass.ReplaceOrg($api.file.image.url)"
39 39
                 :limit='limit'
40 40
                 list-type="picture-card"
41 41
                 :file-list='imgsArr'
@@ -47,7 +47,7 @@
47 47
               <!-- 单选 -->
48 48
               <el-upload
49 49
                 class="avatar-uploader"
50
-                :action='$api.file.image.url'
50
+                :action='toolClass.ReplaceOrg($api.file.image.url)'
51 51
                 :show-file-list="false"
52 52
                 :on-success="handleAvatarSuccess">
53 53
                 <img v-if="Image" :src="Image" class="avatar">

+ 1
- 1
src/pages/system/systemSet/userManager/add.vue Wyświetl plik

@@ -28,7 +28,7 @@
28 28
             <div>
29 29
               <el-upload
30 30
                 class="avatar-uploader"
31
-                :action='$api.file.image.url'
31
+                :action='toolClass.ReplaceOrg($api.file.image.url)'
32 32
                 :show-file-list="false"
33 33
                 :on-success="handleAvatarSuccess">
34 34
                 <img v-if="postData.Headimgurl" :src="postData.Headimgurl" class="avatar">

+ 1
- 1
src/pages/system/systemSet/userManager/edit.vue Wyświetl plik

@@ -28,7 +28,7 @@
28 28
             <div>
29 29
               <el-upload
30 30
                 class="avatar-uploader"
31
-                :action='$api.file.image.url'
31
+                :action='toolClass.ReplaceOrg($api.file.image.url)'
32 32
                 :show-file-list="false"
33 33
                 :on-success="handleAvatarSuccess">
34 34
                 <img v-if="postData.Headimgurl" :src="postData.Headimgurl" class="avatar">

+ 13
- 0
src/util/upload.js Wyświetl plik

@@ -0,0 +1,13 @@
1
+import api from './api'
2
+import ajax from './ajax'
3
+
4
+export default function upload (file) {
5
+  return new Promise((resolve, reject) => {
6
+    ajax({
7
+      ...api.file.image,
8
+      data: { file: file },
9
+    }).then(({ url }) => {
10
+      resolve(url)
11
+    }).catch(reject)
12
+  })
13
+}

+ 3
- 1
src/util/util.js Wyświetl plik

@@ -24,7 +24,9 @@ const toolClass = {
24 24
     }
25 25
     return fmt
26 26
   },
27
-
27
+  ReplaceOrg (url) {
28
+    return url.replace(':org', 'MQ')
29
+  }
28 30
 }
29 31
 
30 32
 export function formatTimeBySeconds (ms) {