web-component-gallery 2.3.6 → 2.3.8
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/dist/index.umd.js +1 -1
- package/dist/js.umd.js +1 -1
- package/lib/browse/index.jsx +75 -132
- package/lib/browse/style/index.less +9 -0
- package/lib/form-comp/ASelectCustom.vue +5 -5
- package/lib/form-comp/AUpload.vue +146 -85
- package/lib/form-comp/style/ARangePicker.less +2 -2
- package/lib/form-comp/style/ASelectCustom.less +32 -8
- package/lib/form-comp/style/AUpload.less +14 -11
- package/lib/model/style/index.less +4 -7
- package/lib/model/utils/render.js +2 -2
- package/lib/search/index.vue +1 -1
- package/lib/search/style/index.less +25 -25
- package/package.json +1 -1
- package/utils/Axios.js +1 -1
- package/utils/File.js +146 -0
- package/utils/Filter.js +590 -133
- package/utils/Tree.js +13 -12
- package/utils/Utils.js +41 -11
package/utils/Tree.js
CHANGED
|
@@ -96,7 +96,7 @@ export function joinTreeMessage(
|
|
|
96
96
|
node[replaceField] = fields
|
|
97
97
|
.filter(field => node[field])
|
|
98
98
|
.map(field => node[field])
|
|
99
|
-
.join(' ')
|
|
99
|
+
.join(' ')
|
|
100
100
|
|
|
101
101
|
if (Array.isArray(node[childNode])) {
|
|
102
102
|
node[childNode].forEach(processNode)
|
|
@@ -151,9 +151,7 @@ export function getAllParents(tree, nodeId, { children = 'children', key = 'id'
|
|
|
151
151
|
metaInfo.set(node, { parentId })
|
|
152
152
|
nodeMap.set(node[key], { node, metaInfo })
|
|
153
153
|
|
|
154
|
-
if (node[children]
|
|
155
|
-
buildMap(node[children], node[key])
|
|
156
|
-
}
|
|
154
|
+
if (node[children]?.length) buildMap(node[children], node[key])
|
|
157
155
|
})
|
|
158
156
|
}
|
|
159
157
|
buildMap(tree)
|
|
@@ -162,14 +160,17 @@ export function getAllParents(tree, nodeId, { children = 'children', key = 'id'
|
|
|
162
160
|
const path = []
|
|
163
161
|
let current = nodeMap.get(nodeId)
|
|
164
162
|
while (current) {
|
|
165
|
-
returnObjects
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
163
|
+
if (returnObjects) {
|
|
164
|
+
// 直接返回原对象
|
|
165
|
+
path.unshift(current.node)
|
|
166
|
+
} else {
|
|
167
|
+
path.unshift(current.node[key])
|
|
168
|
+
}
|
|
169
|
+
current = current.metaInfo.get(current.node).parentId
|
|
170
|
+
? nodeMap.get(current.metaInfo.get(current.node).parentId)
|
|
171
|
+
: null
|
|
171
172
|
}
|
|
172
173
|
|
|
173
174
|
// 对象集合则返回父级
|
|
174
|
-
return returnObjects ? path
|
|
175
|
-
}
|
|
175
|
+
return returnObjects ? path[0] : path
|
|
176
|
+
}
|
package/utils/Utils.js
CHANGED
|
@@ -17,35 +17,65 @@ export function chunkArray(arr, size) {
|
|
|
17
17
|
return result
|
|
18
18
|
}
|
|
19
19
|
|
|
20
|
+
|
|
20
21
|
/**
|
|
21
22
|
* 下载文件
|
|
22
|
-
* @param {Blob} response -
|
|
23
|
+
* @param {Blob|Object} response - 文档流或包含data和headers的对象
|
|
23
24
|
* @param {string} name - 文件名称
|
|
24
25
|
* @param {string} type - 文件类型
|
|
25
26
|
* @returns {void}
|
|
26
27
|
*/
|
|
27
|
-
export function downLoadFn(
|
|
28
|
-
|
|
28
|
+
export function downLoadFn(response, name, type = "application/vnd.ms-excel") {
|
|
29
|
+
// 兼容新写法:从response对象中解析data和headers
|
|
30
|
+
let fileData = response
|
|
31
|
+
let fileName = name
|
|
32
|
+
let fileType = type
|
|
33
|
+
|
|
34
|
+
// 如果response是对象且包含data属性,则使用新写法
|
|
35
|
+
if (response && typeof response === 'object' && response.data) {
|
|
36
|
+
fileData = response.data
|
|
37
|
+
|
|
38
|
+
// 从headers中解析文件名和类型
|
|
39
|
+
if (response.headers) {
|
|
40
|
+
const headers = response.headers
|
|
41
|
+
|
|
42
|
+
// 解析文件类型
|
|
43
|
+
if (headers['content-type']) {
|
|
44
|
+
fileType = headers['content-type']
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
// 解析文件名
|
|
48
|
+
if (headers['content-disposition']) {
|
|
49
|
+
const contentDisposition = headers['content-disposition']
|
|
50
|
+
const match = contentDisposition.match(/filename=([^;]+)/)
|
|
51
|
+
if (match && match[1]) {
|
|
52
|
+
fileName = decodeURIComponent(match[1].replace(/['"]/g, ''))
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
|
|
29
58
|
let reader = new FileReader()
|
|
30
59
|
|
|
31
|
-
reader.readAsText(
|
|
60
|
+
reader.readAsText(fileData, "utf-8")
|
|
32
61
|
|
|
33
62
|
reader.onload = function () {
|
|
34
63
|
try {
|
|
35
|
-
message.error(
|
|
64
|
+
message.error(JSON.parse(reader.result).msg)
|
|
36
65
|
} catch (err) {
|
|
37
|
-
message.success(
|
|
38
|
-
let blob = new Blob(
|
|
39
|
-
let url = window.URL.createObjectURL(
|
|
40
|
-
const link = document.createElement(
|
|
66
|
+
message.success("下载中...")
|
|
67
|
+
let blob = new Blob([fileData], { type: fileType })
|
|
68
|
+
let url = window.URL.createObjectURL(blob)
|
|
69
|
+
const link = document.createElement("a")
|
|
41
70
|
link.href = url
|
|
42
|
-
link.download =
|
|
71
|
+
link.download = fileName
|
|
43
72
|
link.click()
|
|
44
|
-
window.URL.revokeObjectURL(
|
|
73
|
+
window.URL.revokeObjectURL(url)
|
|
45
74
|
}
|
|
46
75
|
}
|
|
47
76
|
}
|
|
48
77
|
|
|
78
|
+
|
|
49
79
|
/**
|
|
50
80
|
* 获取图片宽高 (如超出限制高度,则根据高度比计算出对应的宽度比)
|
|
51
81
|
* @param {string} url - 图片地址
|