@idooel/components 0.0.2-beta.15 → 0.0.2-beta.16
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
|
@@ -19,9 +19,14 @@
|
|
|
19
19
|
</div>
|
|
20
20
|
</div>
|
|
21
21
|
<div v-if="!isFileEmpty && statusList.length > 0 && mode === 'sync'" class="ele-modal-import__errors">
|
|
22
|
-
<
|
|
23
|
-
|
|
24
|
-
|
|
22
|
+
<template v-if="statusList.length > 0">
|
|
23
|
+
<div v-for="(value, idx) in statusList" :key="idx">
|
|
24
|
+
{{ value.message }}
|
|
25
|
+
</div>
|
|
26
|
+
</template>
|
|
27
|
+
<template v-else>
|
|
28
|
+
<ele-alert :type="hooks.uploaded.messages.type" :message="hooks.uploaded.messages.message"></ele-alert>
|
|
29
|
+
</template>
|
|
25
30
|
</div>
|
|
26
31
|
</ele-modal>
|
|
27
32
|
</template>
|
|
@@ -56,9 +61,17 @@ export default {
|
|
|
56
61
|
url: '',
|
|
57
62
|
requestType: 'POST',
|
|
58
63
|
params: {},
|
|
59
|
-
fieldMap: {}
|
|
64
|
+
fieldMap: {},
|
|
65
|
+
messages: {
|
|
66
|
+
type: 'success',
|
|
67
|
+
message: '文件上传成功'
|
|
68
|
+
}
|
|
60
69
|
}
|
|
61
70
|
})
|
|
71
|
+
},
|
|
72
|
+
errorList: {
|
|
73
|
+
type: Array,
|
|
74
|
+
default: () => []
|
|
62
75
|
}
|
|
63
76
|
},
|
|
64
77
|
data() {
|
|
@@ -84,6 +97,9 @@ export default {
|
|
|
84
97
|
},
|
|
85
98
|
statusList () {
|
|
86
99
|
// 0 default
|
|
100
|
+
if (this.errorList.length > 0) {
|
|
101
|
+
return this.buildErrorList(this.errorList)
|
|
102
|
+
}
|
|
87
103
|
return this.innerErrorList
|
|
88
104
|
}
|
|
89
105
|
},
|
|
@@ -110,6 +126,20 @@ export default {
|
|
|
110
126
|
const ctx = { _route: this.$route.query, route: this.$route, ...payloads }
|
|
111
127
|
return parseFieldMap(fieldMap, ctx)
|
|
112
128
|
},
|
|
129
|
+
buildErrorList (dataSrouce = []) {
|
|
130
|
+
const ret = dataSrouce.map(item => {
|
|
131
|
+
if (type.isStr(item)) {
|
|
132
|
+
return {
|
|
133
|
+
statusCode: '0',
|
|
134
|
+
message: item
|
|
135
|
+
}
|
|
136
|
+
} else {
|
|
137
|
+
// TODO
|
|
138
|
+
console.warn('not support error list type', item)
|
|
139
|
+
}
|
|
140
|
+
})
|
|
141
|
+
return ret
|
|
142
|
+
},
|
|
113
143
|
uploadFileSuccess (props) {
|
|
114
144
|
const { uploaded } = this.hooks
|
|
115
145
|
const { url, requestType = 'POST', params = {}, fieldMap = {} } = uploaded
|
|
@@ -124,16 +154,7 @@ export default {
|
|
|
124
154
|
net[requestType.toLowerCase()](url, formData , { headers: { 'Content-Type': 'multipart/form-data' } }).then(resp => {
|
|
125
155
|
const { code, data } = resp
|
|
126
156
|
if (code !== '2000') {
|
|
127
|
-
this.innerErrorList =
|
|
128
|
-
if (type.isStr(item)) {
|
|
129
|
-
return {
|
|
130
|
-
statusCode: '0',
|
|
131
|
-
message: item
|
|
132
|
-
}
|
|
133
|
-
} else {
|
|
134
|
-
// TODO
|
|
135
|
-
}
|
|
136
|
-
})
|
|
157
|
+
this.innerErrorList = this.buildErrorList(data)
|
|
137
158
|
} else {
|
|
138
159
|
this.innerErrorList = []
|
|
139
160
|
}
|
package/vitest.config.js
CHANGED
|
@@ -1,17 +1,17 @@
|
|
|
1
|
-
import { defineConfig } from 'vitest/config'
|
|
2
|
-
import vue from '@vitejs/plugin-vue2'
|
|
3
|
-
import path from 'path'
|
|
4
|
-
|
|
5
|
-
export default defineConfig({
|
|
6
|
-
plugins: [vue()],
|
|
7
|
-
resolve: {
|
|
8
|
-
alias: {
|
|
9
|
-
'@': path.resolve(__dirname, 'packages')
|
|
10
|
-
}
|
|
11
|
-
},
|
|
12
|
-
test: {
|
|
13
|
-
environment: 'jsdom',
|
|
14
|
-
globals: true,
|
|
15
|
-
setupFiles: ['__tests__/setup.js']
|
|
16
|
-
}
|
|
17
|
-
})
|
|
1
|
+
import { defineConfig } from 'vitest/config'
|
|
2
|
+
import vue from '@vitejs/plugin-vue2'
|
|
3
|
+
import path from 'path'
|
|
4
|
+
|
|
5
|
+
export default defineConfig({
|
|
6
|
+
plugins: [vue()],
|
|
7
|
+
resolve: {
|
|
8
|
+
alias: {
|
|
9
|
+
'@': path.resolve(__dirname, 'packages')
|
|
10
|
+
}
|
|
11
|
+
},
|
|
12
|
+
test: {
|
|
13
|
+
environment: 'jsdom',
|
|
14
|
+
globals: true,
|
|
15
|
+
setupFiles: ['__tests__/setup.js']
|
|
16
|
+
}
|
|
17
|
+
})
|