meixioacomponent 0.3.89 → 0.3.92
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/lib/meixioacomponent.common.js +251 -188
- package/lib/meixioacomponent.umd.js +251 -188
- package/lib/meixioacomponent.umd.min.js +14 -14
- package/package.json +1 -1
- package/packages/components/base/baseUpload/baseUploadItem.vue +38 -5
- package/packages/components/base/baseUpload/mixins.js +6 -1
- package/packages/components/base/baseUploadTemplate/index.vue +236 -0
- package/packages/components/base/upload/upload.vue +55 -54
- package/packages/components/proPageTable/oa_pro_table.vue +7 -1
- package/packages/config/componentConfig.js +5 -1
- package/packages/config/uploadRequest.js +31 -31
- package/packages/config/use/UseUpload.js +25 -20
- package/src/App.vue +15 -4
|
@@ -1,68 +1,68 @@
|
|
|
1
|
-
import axios from
|
|
2
|
-
import { GetToken } from
|
|
3
|
-
import componentConfig from
|
|
1
|
+
import axios from 'axios'
|
|
2
|
+
import { GetToken } from '../utils/utils.js'
|
|
3
|
+
import componentConfig from './componentConfig.js'
|
|
4
4
|
|
|
5
5
|
const ossInstance = (params, uploadProgressFn) => {
|
|
6
6
|
// 创建 axios 实例
|
|
7
7
|
const instance = axios.create({
|
|
8
8
|
// API 请求的默认前缀
|
|
9
|
-
baseURL: `${componentConfig.
|
|
10
|
-
})
|
|
9
|
+
baseURL: `${componentConfig.uploadUrl}`,
|
|
10
|
+
})
|
|
11
11
|
|
|
12
12
|
// 异常拦截处理器
|
|
13
13
|
const errorHandler = (error) => {
|
|
14
|
-
return Promise.reject(error)
|
|
15
|
-
}
|
|
14
|
+
return Promise.reject(error)
|
|
15
|
+
}
|
|
16
16
|
|
|
17
17
|
// 响应异常拦截处理器
|
|
18
18
|
const resErrorHandler = (error) => {
|
|
19
19
|
// Message.error(`网络超时,请稍后重试`);
|
|
20
20
|
// return errorHandler(error);
|
|
21
|
-
}
|
|
21
|
+
}
|
|
22
22
|
|
|
23
23
|
// request 拦截器
|
|
24
24
|
instance.interceptors.request.use((config) => {
|
|
25
|
-
config.headers[
|
|
26
|
-
config.headers[
|
|
25
|
+
config.headers['Content-Type'] = 'multipart/form-data'
|
|
26
|
+
config.headers['authorization'] = `Bearer ${GetToken('token')}`
|
|
27
27
|
config.onUploadProgress = (progressEvent) => {
|
|
28
28
|
if (uploadProgressFn) {
|
|
29
|
-
const percent = (progressEvent.loaded / progressEvent.total) * 100 || 0
|
|
30
|
-
uploadProgressFn(percent)
|
|
29
|
+
const percent = (progressEvent.loaded / progressEvent.total) * 100 || 0
|
|
30
|
+
uploadProgressFn(percent)
|
|
31
31
|
}
|
|
32
|
-
}
|
|
33
|
-
return config
|
|
34
|
-
}, errorHandler)
|
|
32
|
+
}
|
|
33
|
+
return config
|
|
34
|
+
}, errorHandler)
|
|
35
35
|
|
|
36
36
|
// response 拦截器
|
|
37
37
|
instance.interceptors.response.use(async (response) => {
|
|
38
|
-
return response
|
|
39
|
-
}, resErrorHandler)
|
|
38
|
+
return response
|
|
39
|
+
}, resErrorHandler)
|
|
40
40
|
|
|
41
|
-
return instance(params)
|
|
42
|
-
}
|
|
41
|
+
return instance(params)
|
|
42
|
+
}
|
|
43
43
|
|
|
44
44
|
export default (file, uploadProgressFn, sourceToken) => {
|
|
45
45
|
return new Promise((resolve, reject) => {
|
|
46
|
-
const params = new FormData()
|
|
47
|
-
params.append(
|
|
46
|
+
const params = new FormData()
|
|
47
|
+
params.append('file', file)
|
|
48
48
|
ossInstance(
|
|
49
49
|
{
|
|
50
|
-
url:
|
|
50
|
+
url: '/',
|
|
51
51
|
data: params,
|
|
52
|
-
method:
|
|
52
|
+
method: 'post',
|
|
53
53
|
cancelToken: sourceToken.token,
|
|
54
54
|
},
|
|
55
|
-
uploadProgressFn
|
|
55
|
+
uploadProgressFn,
|
|
56
56
|
)
|
|
57
57
|
.then((res) => {
|
|
58
|
-
const { status } = res
|
|
58
|
+
const { status } = res
|
|
59
59
|
if (status == 200) {
|
|
60
|
-
const { data } = res
|
|
61
|
-
resolve(data.data.original)
|
|
60
|
+
const { data } = res
|
|
61
|
+
resolve(data.data.original)
|
|
62
62
|
}
|
|
63
63
|
})
|
|
64
64
|
.catch((error) => {
|
|
65
|
-
reject()
|
|
66
|
-
})
|
|
67
|
-
})
|
|
68
|
-
}
|
|
65
|
+
reject()
|
|
66
|
+
})
|
|
67
|
+
})
|
|
68
|
+
}
|
|
@@ -1,47 +1,52 @@
|
|
|
1
|
-
import uploadVue from
|
|
2
|
-
import DynamicMount from
|
|
1
|
+
import uploadVue from '../../components/base/upload/upload.vue'
|
|
2
|
+
import DynamicMount from '../../components/dynamicmount/DynamicMount'
|
|
3
3
|
|
|
4
4
|
class UseUpload {
|
|
5
5
|
constructor() {
|
|
6
|
-
this.
|
|
6
|
+
this.cbList = []
|
|
7
|
+
this.dynamicMount = null
|
|
7
8
|
}
|
|
8
9
|
|
|
9
10
|
toUpload(uploadList, cb) {
|
|
11
|
+
if (cb) {
|
|
12
|
+
this.cbList.push({ cb, uploadList })
|
|
13
|
+
}
|
|
10
14
|
if (this.dynamicMount) {
|
|
11
|
-
this.appendUploadItem(uploadList)
|
|
15
|
+
this.appendUploadItem(uploadList)
|
|
12
16
|
} else {
|
|
13
17
|
this.dynamicMount = new DynamicMount({
|
|
14
18
|
componentProps: {
|
|
15
19
|
uploadEdEvent: (list) => {
|
|
16
|
-
this.uploadEd(
|
|
17
|
-
if (cb) {
|
|
18
|
-
cb(list);
|
|
19
|
-
}
|
|
20
|
+
this.uploadEd()
|
|
20
21
|
},
|
|
21
|
-
|
|
22
|
+
toUploadList: uploadList,
|
|
22
23
|
},
|
|
23
24
|
vueComponent: uploadVue,
|
|
24
|
-
})
|
|
25
|
-
this.dynamicMount.init()
|
|
25
|
+
})
|
|
26
|
+
this.dynamicMount.init()
|
|
26
27
|
}
|
|
27
28
|
}
|
|
28
29
|
|
|
29
|
-
uploadEd(
|
|
30
|
+
uploadEd() {
|
|
31
|
+
this.cbList.forEach((item) => {
|
|
32
|
+
item.cb(item.uploadList)
|
|
33
|
+
})
|
|
30
34
|
setTimeout(() => {
|
|
31
|
-
let component = this.dynamicMount.getComponent()
|
|
32
|
-
component.$destroy()
|
|
33
|
-
this.dynamicMount = null
|
|
34
|
-
|
|
35
|
+
let component = this.dynamicMount.getComponent()
|
|
36
|
+
component.$destroy()
|
|
37
|
+
this.dynamicMount = null
|
|
38
|
+
this.cbList = []
|
|
39
|
+
}, 3000)
|
|
35
40
|
}
|
|
36
41
|
|
|
37
42
|
appendUploadItem(list) {
|
|
38
|
-
let refComponent = this.dynamicMount.getComponent()
|
|
43
|
+
let refComponent = this.dynamicMount.getComponent()
|
|
39
44
|
if (refComponent) {
|
|
40
|
-
refComponent.appendUploadItem(list)
|
|
45
|
+
refComponent.appendUploadItem(list)
|
|
41
46
|
}
|
|
42
47
|
}
|
|
43
48
|
}
|
|
44
49
|
|
|
45
|
-
let useUpload = new UseUpload()
|
|
50
|
+
let useUpload = new UseUpload()
|
|
46
51
|
|
|
47
|
-
export default useUpload
|
|
52
|
+
export default useUpload
|
package/src/App.vue
CHANGED
|
@@ -1,8 +1,11 @@
|
|
|
1
1
|
<template>
|
|
2
2
|
<div id="app">
|
|
3
3
|
<div style="height: 100vh;">
|
|
4
|
-
<
|
|
5
|
-
<
|
|
4
|
+
<baseUploadTemplate></baseUploadTemplate>
|
|
5
|
+
<!-- <el-button @click="click">click</el-button>
|
|
6
|
+
<base-upload :max="1" v-model="test"></base-upload>
|
|
7
|
+
<base-upload :max="1" v-model="test2"></base-upload> -->
|
|
8
|
+
<!-- <test></test> -->
|
|
6
9
|
<!-- <base-upload-item
|
|
7
10
|
:fileType="`img`"
|
|
8
11
|
:cropper="true"
|
|
@@ -16,16 +19,24 @@
|
|
|
16
19
|
|
|
17
20
|
<script>
|
|
18
21
|
import test from './component/test.vue'
|
|
19
|
-
|
|
22
|
+
import baseUploadTemplate from '../packages/components/base/baseUploadTemplate/index.vue'
|
|
20
23
|
import BaseArea from '../packages/components/base/baseArea/baseArea.vue'
|
|
21
24
|
import BaseTimeLine from '../packages/components/base/baseTimeLine/baseTimeLine.vue'
|
|
22
25
|
import BaseUpload from '../packages/components/base/baseUpload/baseUpload.vue'
|
|
23
26
|
import BaseUploadItem from '../packages/components/base/baseUpload/baseUploadItem.vue'
|
|
24
27
|
export default {
|
|
25
|
-
components: {
|
|
28
|
+
components: {
|
|
29
|
+
test,
|
|
30
|
+
BaseArea,
|
|
31
|
+
BaseTimeLine,
|
|
32
|
+
BaseUpload,
|
|
33
|
+
BaseUploadItem,
|
|
34
|
+
baseUploadTemplate,
|
|
35
|
+
},
|
|
26
36
|
data() {
|
|
27
37
|
return {
|
|
28
38
|
test: [],
|
|
39
|
+
test2: [],
|
|
29
40
|
items: [
|
|
30
41
|
{ type: '', label: '标签一' },
|
|
31
42
|
{ type: 'success', label: '标签二' },
|