shijiplus-web-plugin 0.1.36 → 0.1.38
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json
CHANGED
|
@@ -17,7 +17,7 @@
|
|
|
17
17
|
</upload-file>
|
|
18
18
|
</template>
|
|
19
19
|
<script>
|
|
20
|
-
import UploadFile from '
|
|
20
|
+
import UploadFile from './upload-file'
|
|
21
21
|
export default {
|
|
22
22
|
name: 'upload-file-single',
|
|
23
23
|
components: { UploadFile },
|
|
@@ -47,7 +47,7 @@ export default {
|
|
|
47
47
|
default: ''
|
|
48
48
|
},
|
|
49
49
|
maxSize: {
|
|
50
|
-
default:
|
|
50
|
+
default: 1024 * 5
|
|
51
51
|
},
|
|
52
52
|
sizeUnit: {
|
|
53
53
|
default: 1024
|
|
@@ -55,7 +55,14 @@ export default {
|
|
|
55
55
|
sizeUnitStr: {
|
|
56
56
|
default: 'MB'
|
|
57
57
|
},
|
|
58
|
-
|
|
58
|
+
maxMb: {
|
|
59
|
+
type: Number,
|
|
60
|
+
default: 0
|
|
61
|
+
},
|
|
62
|
+
action: {
|
|
63
|
+
type: String,
|
|
64
|
+
default: ''
|
|
65
|
+
}
|
|
59
66
|
// imgType: {
|
|
60
67
|
// type: Number,
|
|
61
68
|
// default: () => {
|
|
@@ -66,7 +73,7 @@ export default {
|
|
|
66
73
|
data() {
|
|
67
74
|
return {
|
|
68
75
|
fileList: [],
|
|
69
|
-
fileMaxSize: this.maxSize
|
|
76
|
+
fileMaxSize: this.maxMb * 1024 || this.maxSize
|
|
70
77
|
}
|
|
71
78
|
},
|
|
72
79
|
watch: {
|
|
@@ -33,7 +33,7 @@
|
|
|
33
33
|
:on-success="handleSuccess"
|
|
34
34
|
:format="['jpg', 'jpeg', 'png', 'gif']"
|
|
35
35
|
accept="image/*"
|
|
36
|
-
:headers="
|
|
36
|
+
:headers="uploadHeaders"
|
|
37
37
|
:max-size="fileMaxSize"
|
|
38
38
|
:on-format-error="handleFormatError"
|
|
39
39
|
:on-exceeded-size="handleMaxSize"
|
|
@@ -72,14 +72,7 @@
|
|
|
72
72
|
</div>
|
|
73
73
|
</template>
|
|
74
74
|
<script>
|
|
75
|
-
import config from '@/config'
|
|
76
|
-
import store from '@/store'
|
|
77
75
|
import Emitter from 'iview/src/mixins/emitter'
|
|
78
|
-
const baseUrl = config.plusApiV5Domain()
|
|
79
|
-
let authHeader = {}
|
|
80
|
-
authHeader[config.tokenHeaderName] = store.state.user.token
|
|
81
|
-
authHeader['token'] = store.state.user.token
|
|
82
|
-
authHeader['app_name'] = 'op'
|
|
83
76
|
export default {
|
|
84
77
|
name: 'upload-file',
|
|
85
78
|
mixins: [Emitter],
|
|
@@ -125,12 +118,15 @@ export default {
|
|
|
125
118
|
},
|
|
126
119
|
action: {
|
|
127
120
|
default: ''
|
|
121
|
+
},
|
|
122
|
+
headers: {
|
|
123
|
+
default() {
|
|
124
|
+
return {}
|
|
125
|
+
}
|
|
128
126
|
}
|
|
129
127
|
},
|
|
130
128
|
data() {
|
|
131
129
|
return {
|
|
132
|
-
headers: authHeader,
|
|
133
|
-
baseUrl,
|
|
134
130
|
imgName: '',
|
|
135
131
|
visible: false,
|
|
136
132
|
remainderCount: this.maxUploadFiles,
|
|
@@ -139,8 +135,21 @@ export default {
|
|
|
139
135
|
}
|
|
140
136
|
},
|
|
141
137
|
computed: {
|
|
138
|
+
baseUrl() {
|
|
139
|
+
return this.$config.uploadDomain()
|
|
140
|
+
},
|
|
142
141
|
fileMaxSize() {
|
|
143
142
|
return this.maxSize * this.sizeUnit
|
|
143
|
+
},
|
|
144
|
+
uploadHeaders() {
|
|
145
|
+
let authHeader = {}
|
|
146
|
+
authHeader[this.$config.tokenHeaderName] = this.$store.state.user.token
|
|
147
|
+
authHeader['token'] = this.$store.state.user.token
|
|
148
|
+
authHeader['app_name'] = this.$config.appName
|
|
149
|
+
return {
|
|
150
|
+
...authHeader,
|
|
151
|
+
...this.headers
|
|
152
|
+
}
|
|
144
153
|
}
|
|
145
154
|
},
|
|
146
155
|
watch: {
|
|
@@ -223,27 +232,12 @@ export default {
|
|
|
223
232
|
// 对新露的上传接口做兼容, 他用的是其他字段
|
|
224
233
|
res.data.path = res.data.accessURL
|
|
225
234
|
}
|
|
226
|
-
if (!res.data) {
|
|
235
|
+
if (!res.data || !res.data.path) {
|
|
227
236
|
console.log(res)
|
|
228
237
|
file.status = 'fail'
|
|
229
238
|
this.$Notice.error({
|
|
230
239
|
title: `上传失败`,
|
|
231
|
-
desc: res.codex + ':' + res.message
|
|
232
|
-
})
|
|
233
|
-
this.uploadList.forEach((item, index) => {
|
|
234
|
-
if (item.status == 'fail') {
|
|
235
|
-
this.uploadList.splice(index, 1)
|
|
236
|
-
}
|
|
237
|
-
})
|
|
238
|
-
this.remainderCount++
|
|
239
|
-
return
|
|
240
|
-
}
|
|
241
|
-
if (!res.data.path) {
|
|
242
|
-
console.log(res)
|
|
243
|
-
file.status = 'fail'
|
|
244
|
-
this.$Notice.error({
|
|
245
|
-
title: `上传失败`,
|
|
246
|
-
desc: res.message
|
|
240
|
+
desc: (res.codex || '') + ':' + res.message
|
|
247
241
|
})
|
|
248
242
|
this.uploadList.forEach((item, index) => {
|
|
249
243
|
if (item.status == 'fail') {
|
|
@@ -326,7 +320,18 @@ export default {
|
|
|
326
320
|
}
|
|
327
321
|
}
|
|
328
322
|
},
|
|
329
|
-
mounted() {}
|
|
323
|
+
mounted() {},
|
|
324
|
+
updated() {
|
|
325
|
+
this.$nextTick(() => {
|
|
326
|
+
if (!this.$slots.tips) {
|
|
327
|
+
this.$refs.tipsRef.style.display = 'none'
|
|
328
|
+
} else if (!this.$slots.tips[0]) {
|
|
329
|
+
this.$refs.tipsRef.style.display = 'none'
|
|
330
|
+
} else {
|
|
331
|
+
this.$refs.tipsRef.style.display = 'block'
|
|
332
|
+
}
|
|
333
|
+
})
|
|
334
|
+
}
|
|
330
335
|
}
|
|
331
336
|
</script>
|
|
332
337
|
<style lang="less" scoped>
|
package/src/index.js
CHANGED
|
@@ -7,7 +7,7 @@ import PlusComp from './components/plus-comp'
|
|
|
7
7
|
import BeginEndDatePicker from './components/begin-end-date-picker'
|
|
8
8
|
import UploadFileSingle from './components/upload-file/upload-file-single'
|
|
9
9
|
import UploadFile from './components/upload-file/upload-file'
|
|
10
|
-
import UploadFileInput from './components/upload-file/upload-file-input'
|
|
10
|
+
// import UploadFileInput from './components/upload-file/upload-file-input'
|
|
11
11
|
|
|
12
12
|
console.log('--------web-tool---index.js----------')
|
|
13
13
|
|
|
@@ -24,7 +24,7 @@ export default {
|
|
|
24
24
|
vue.component('BeginEndDatePicker', BeginEndDatePicker)
|
|
25
25
|
vue.component('UploadFileSingle', UploadFileSingle)
|
|
26
26
|
vue.component('UploadFile', UploadFile)
|
|
27
|
-
vue.component('UploadFileInput', UploadFileInput)
|
|
27
|
+
// vue.component('UploadFileInput', UploadFileInput)
|
|
28
28
|
/**
|
|
29
29
|
* 注册指令
|
|
30
30
|
*/
|