vue2-client 1.2.91 → 1.2.93
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/CHANGELOG.md +6 -1
- package/package.json +16 -19
- package/src/base-client/components/common/XForm/XFormItem.vue +5 -5
- package/src/utils/util.js +230 -222
package/CHANGELOG.md
CHANGED
|
@@ -1,9 +1,14 @@
|
|
|
1
1
|
# Change Log
|
|
2
2
|
> 所有关于本项目的变化都在该文档里。
|
|
3
3
|
|
|
4
|
-
**1.2.
|
|
4
|
+
**1.2.93 -2022-08-03 @江超**
|
|
5
|
+
- 功能新增:
|
|
6
|
+
- util增加uuid方法
|
|
7
|
+
|
|
8
|
+
**1.2.90 - 1.2.92 -2022-08-01 @江超**
|
|
5
9
|
- 功能新增:
|
|
6
10
|
- XCard增加空状态显示
|
|
11
|
+
- 修复依赖
|
|
7
12
|
|
|
8
13
|
**1.2.89 - 1.2.90 -2022-07-31 @张振宇**
|
|
9
14
|
- 功能新增:
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "vue2-client",
|
|
3
|
-
"version": "1.2.
|
|
3
|
+
"version": "1.2.93",
|
|
4
4
|
"private": false,
|
|
5
5
|
"scripts": {
|
|
6
6
|
"serve": "vue-cli-service serve",
|
|
@@ -13,7 +13,6 @@
|
|
|
13
13
|
"@antv/data-set": "^0.11.8",
|
|
14
14
|
"@antv/f2": "^3.8.11",
|
|
15
15
|
"@antv/g2plot": "^2.4.20",
|
|
16
|
-
"@babel/core": "^7.18.5",
|
|
17
16
|
"@logicflow/core": "^1.1.20",
|
|
18
17
|
"@logicflow/extension": "^1.1.20",
|
|
19
18
|
"@vue/babel-helper-vue-jsx-merge-props": "^1.2.1",
|
|
@@ -22,14 +21,13 @@
|
|
|
22
21
|
"ant-design-vue": "^1.7.8",
|
|
23
22
|
"axios": "^0.27.2",
|
|
24
23
|
"clipboard": "^2.0.11",
|
|
25
|
-
"core-js": "^3.23.
|
|
26
|
-
"webpack": "^4.46.0",
|
|
24
|
+
"core-js": "^3.23.5",
|
|
27
25
|
"date-fns": "^2.28.0",
|
|
28
26
|
"default-passive-events": "^2.0.0",
|
|
29
27
|
"enquire.js": "^2.1.6",
|
|
30
28
|
"file-saver": "^2.0.5",
|
|
31
|
-
"highlight.js": "^
|
|
32
|
-
"js-cookie": "^
|
|
29
|
+
"highlight.js": "^10.7.3",
|
|
30
|
+
"js-cookie": "^2.2.1",
|
|
33
31
|
"jsencrypt": "^3.2.1",
|
|
34
32
|
"lodash.get": "^4.4.2",
|
|
35
33
|
"mockjs": "^1.1.0",
|
|
@@ -42,16 +40,16 @@
|
|
|
42
40
|
"vue-router": "^3.5.4",
|
|
43
41
|
"vuedraggable": "^2.24.3",
|
|
44
42
|
"vuex": "^3.6.2",
|
|
45
|
-
"xlsx": "
|
|
43
|
+
"xlsx": "0.18.5"
|
|
46
44
|
},
|
|
47
45
|
"devDependencies": {
|
|
48
|
-
"@ant-design/colors": "^
|
|
49
|
-
"@vue/cli-plugin-babel": "^4.5.
|
|
50
|
-
"@vue/cli-plugin-eslint": "^4.5.
|
|
51
|
-
"@vue/cli-plugin-router": "^4.5.
|
|
46
|
+
"@ant-design/colors": "^4.0.5",
|
|
47
|
+
"@vue/cli-plugin-babel": "^4.5.19",
|
|
48
|
+
"@vue/cli-plugin-eslint": "^4.5.19",
|
|
49
|
+
"@vue/cli-plugin-router": "^4.5.19",
|
|
52
50
|
"@vue/cli-plugin-unit-jest": "~4.5.19",
|
|
53
|
-
"@vue/cli-plugin-vuex": "^4.5.
|
|
54
|
-
"@vue/cli-service": "^4.5.
|
|
51
|
+
"@vue/cli-plugin-vuex": "^4.5.19",
|
|
52
|
+
"@vue/cli-service": "^4.5.19",
|
|
55
53
|
"@vue/eslint-config-standard": "^4.0.0",
|
|
56
54
|
"@vue/test-utils": "^1.3.0",
|
|
57
55
|
"@vue/vue2-jest": "^27.0.0",
|
|
@@ -60,7 +58,7 @@
|
|
|
60
58
|
"babel-jest": "^27.1.0",
|
|
61
59
|
"babel-plugin-transform-remove-console": "^6.9.4",
|
|
62
60
|
"babel-polyfill": "^6.26.0",
|
|
63
|
-
"compression-webpack-plugin": "^
|
|
61
|
+
"compression-webpack-plugin": "^4.0.1",
|
|
64
62
|
"deepmerge": "^4.2.2",
|
|
65
63
|
"echarts": "^5.3.3",
|
|
66
64
|
"eslint": "^6.8.0",
|
|
@@ -71,19 +69,18 @@
|
|
|
71
69
|
"fast-deep-equal": "^3.1.3",
|
|
72
70
|
"gh-pages": "^3.2.3",
|
|
73
71
|
"jest": "^27.1.0",
|
|
74
|
-
"less": "^
|
|
75
|
-
"less-loader": "^7.3.0",
|
|
72
|
+
"less-loader": "^6.2.0",
|
|
76
73
|
"react-bmap": "^1.0.130",
|
|
77
74
|
"script-loader": "^0.7.2",
|
|
78
75
|
"style-resources-loader": "^1.5.0",
|
|
79
76
|
"vue-amap": "^0.5.10",
|
|
80
77
|
"vue-baidu-map": "^0.21.22",
|
|
81
|
-
"vue-bmap-gl": "
|
|
78
|
+
"vue-bmap-gl": "0.0.30",
|
|
82
79
|
"vue-cli-plugin-style-resources-loader": "^0.1.5",
|
|
83
|
-
"vue-mapvgl": "
|
|
80
|
+
"vue-mapvgl": "0.0.34",
|
|
84
81
|
"vue-template-compiler": "2.6.14",
|
|
85
82
|
"vuepress": "^1.9.7",
|
|
86
|
-
"webpack-theme-color-replacer": "
|
|
83
|
+
"webpack-theme-color-replacer": "1.4.1",
|
|
87
84
|
"whatwg-fetch": "^3.6.2"
|
|
88
85
|
},
|
|
89
86
|
"browserslist": [
|
|
@@ -17,7 +17,7 @@
|
|
|
17
17
|
<a-select-option
|
|
18
18
|
v-for="(item,index) in attr.keys"
|
|
19
19
|
:key="index"
|
|
20
|
-
:value="
|
|
20
|
+
:value="item.value">{{ item.label }}
|
|
21
21
|
</a-select-option>
|
|
22
22
|
</a-select>
|
|
23
23
|
</a-input>
|
|
@@ -62,8 +62,8 @@
|
|
|
62
62
|
<a-select-option
|
|
63
63
|
v-for="(item,index) in attr.keys"
|
|
64
64
|
:key="index"
|
|
65
|
-
:value="
|
|
66
|
-
{{ item
|
|
65
|
+
:value="item.value">
|
|
66
|
+
{{ item.label }}
|
|
67
67
|
</a-select-option>
|
|
68
68
|
</template>
|
|
69
69
|
<template v-else>
|
|
@@ -71,7 +71,7 @@
|
|
|
71
71
|
<a-select-option
|
|
72
72
|
v-for="(item,index) in option"
|
|
73
73
|
:key="index"
|
|
74
|
-
:value="
|
|
74
|
+
:value="item.value">{{ item.label }}
|
|
75
75
|
</a-select-option>
|
|
76
76
|
</template>
|
|
77
77
|
<template v-else>
|
|
@@ -104,7 +104,7 @@
|
|
|
104
104
|
<a-select-option
|
|
105
105
|
v-for="(item,index) in option"
|
|
106
106
|
:key="index"
|
|
107
|
-
:value="
|
|
107
|
+
:value="item.value">{{ item.label }}
|
|
108
108
|
</a-select-option>
|
|
109
109
|
</a-select>
|
|
110
110
|
</a-form-model-item>
|
package/src/utils/util.js
CHANGED
|
@@ -1,222 +1,230 @@
|
|
|
1
|
-
import enquireJs from 'enquire.js'
|
|
2
|
-
|
|
3
|
-
const timeList = [
|
|
4
|
-
{
|
|
5
|
-
CN: '早上好',
|
|
6
|
-
HK: '早晨啊',
|
|
7
|
-
US: 'Good morning'
|
|
8
|
-
}, {
|
|
9
|
-
CN: '上午好',
|
|
10
|
-
HK: '上午好',
|
|
11
|
-
US: 'Good morning'
|
|
12
|
-
}, {
|
|
13
|
-
CN: '中午好',
|
|
14
|
-
HK: '中午好',
|
|
15
|
-
US: 'Good afternoon'
|
|
16
|
-
}, {
|
|
17
|
-
CN: '下午好',
|
|
18
|
-
HK: '下午好',
|
|
19
|
-
US: 'Good afternoon'
|
|
20
|
-
}, {
|
|
21
|
-
CN: '晚上好',
|
|
22
|
-
HK: '晚上好',
|
|
23
|
-
US: 'Good evening'
|
|
24
|
-
}
|
|
25
|
-
]
|
|
26
|
-
/**
|
|
27
|
-
* 数组去空值
|
|
28
|
-
*/
|
|
29
|
-
export function arrRemoveEmpty (arr) {
|
|
30
|
-
for (var i = 0; i < arr.length; i++) {
|
|
31
|
-
if (arr[i] == '' || typeof (arr[i]) == 'undefined') {
|
|
32
|
-
arr.splice(i, 1)
|
|
33
|
-
i--
|
|
34
|
-
}
|
|
35
|
-
}
|
|
36
|
-
return arr
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
export function isDef (v) {
|
|
40
|
-
return v !== undefined && v !== null
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
export function formatDate (dateStr, fmt) {
|
|
44
|
-
if (dateStr == null) {
|
|
45
|
-
return '--'
|
|
46
|
-
}
|
|
47
|
-
let date
|
|
48
|
-
if (dateStr === 'now') {
|
|
49
|
-
date = new Date()
|
|
50
|
-
} else {
|
|
51
|
-
date = new Date(dateStr)
|
|
52
|
-
}
|
|
53
|
-
const o = {
|
|
54
|
-
'M+': date.getMonth() + 1,
|
|
55
|
-
'd+': date.getDate(),
|
|
56
|
-
'h+': date.getHours(),
|
|
57
|
-
'm+': date.getMinutes(),
|
|
58
|
-
's+': date.getSeconds(),
|
|
59
|
-
'q+': Math.floor((date.getMonth() + 3) / 3),
|
|
60
|
-
'S': date.getMilliseconds()
|
|
61
|
-
}
|
|
62
|
-
if (!fmt) {
|
|
63
|
-
fmt = 'yyyy-MM-dd hh:mm:ss'
|
|
64
|
-
}
|
|
65
|
-
if (/(y+)/.test(fmt)) {
|
|
66
|
-
fmt = fmt.replace(RegExp.$1, (date.getFullYear() + '').substr(4 - RegExp.$1.length))
|
|
67
|
-
}
|
|
68
|
-
for (const k in o) {
|
|
69
|
-
if (new RegExp('(' + k + ')').test(fmt)) {
|
|
70
|
-
fmt = fmt.replace(RegExp.$1, (RegExp.$1.length === 1) ? (o[k]) : (('00' + o[k]).substr(('' + o[k]).length)))
|
|
71
|
-
}
|
|
72
|
-
}
|
|
73
|
-
return fmt
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
export function
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
text =
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
return '\n' + prefix +
|
|
158
|
-
})
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
for (const d of data) {
|
|
198
|
-
const parentId = d[config.parentId]
|
|
199
|
-
if (
|
|
200
|
-
|
|
201
|
-
}
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
}
|
|
221
|
-
|
|
222
|
-
const
|
|
1
|
+
import enquireJs from 'enquire.js'
|
|
2
|
+
|
|
3
|
+
const timeList = [
|
|
4
|
+
{
|
|
5
|
+
CN: '早上好',
|
|
6
|
+
HK: '早晨啊',
|
|
7
|
+
US: 'Good morning'
|
|
8
|
+
}, {
|
|
9
|
+
CN: '上午好',
|
|
10
|
+
HK: '上午好',
|
|
11
|
+
US: 'Good morning'
|
|
12
|
+
}, {
|
|
13
|
+
CN: '中午好',
|
|
14
|
+
HK: '中午好',
|
|
15
|
+
US: 'Good afternoon'
|
|
16
|
+
}, {
|
|
17
|
+
CN: '下午好',
|
|
18
|
+
HK: '下午好',
|
|
19
|
+
US: 'Good afternoon'
|
|
20
|
+
}, {
|
|
21
|
+
CN: '晚上好',
|
|
22
|
+
HK: '晚上好',
|
|
23
|
+
US: 'Good evening'
|
|
24
|
+
}
|
|
25
|
+
]
|
|
26
|
+
/**
|
|
27
|
+
* 数组去空值
|
|
28
|
+
*/
|
|
29
|
+
export function arrRemoveEmpty (arr) {
|
|
30
|
+
for (var i = 0; i < arr.length; i++) {
|
|
31
|
+
if (arr[i] == '' || typeof (arr[i]) == 'undefined') {
|
|
32
|
+
arr.splice(i, 1)
|
|
33
|
+
i--
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
return arr
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
export function isDef (v) {
|
|
40
|
+
return v !== undefined && v !== null
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
export function formatDate (dateStr, fmt) {
|
|
44
|
+
if (dateStr == null) {
|
|
45
|
+
return '--'
|
|
46
|
+
}
|
|
47
|
+
let date
|
|
48
|
+
if (dateStr === 'now') {
|
|
49
|
+
date = new Date()
|
|
50
|
+
} else {
|
|
51
|
+
date = new Date(dateStr)
|
|
52
|
+
}
|
|
53
|
+
const o = {
|
|
54
|
+
'M+': date.getMonth() + 1,
|
|
55
|
+
'd+': date.getDate(),
|
|
56
|
+
'h+': date.getHours(),
|
|
57
|
+
'm+': date.getMinutes(),
|
|
58
|
+
's+': date.getSeconds(),
|
|
59
|
+
'q+': Math.floor((date.getMonth() + 3) / 3),
|
|
60
|
+
'S': date.getMilliseconds()
|
|
61
|
+
}
|
|
62
|
+
if (!fmt) {
|
|
63
|
+
fmt = 'yyyy-MM-dd hh:mm:ss'
|
|
64
|
+
}
|
|
65
|
+
if (/(y+)/.test(fmt)) {
|
|
66
|
+
fmt = fmt.replace(RegExp.$1, (date.getFullYear() + '').substr(4 - RegExp.$1.length))
|
|
67
|
+
}
|
|
68
|
+
for (const k in o) {
|
|
69
|
+
if (new RegExp('(' + k + ')').test(fmt)) {
|
|
70
|
+
fmt = fmt.replace(RegExp.$1, (RegExp.$1.length === 1) ? (o[k]) : (('00' + o[k]).substr(('' + o[k]).length)))
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
return fmt
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
export function uuid () {
|
|
77
|
+
return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, function (c) {
|
|
78
|
+
const r = Math.random() * 16 | 0
|
|
79
|
+
const v = c === 'x' ? r : (r & 0x3 | 0x8)
|
|
80
|
+
return v.toString(16)
|
|
81
|
+
})
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
export function timeCompare (date1, date2) {
|
|
85
|
+
const date11 = new Date(date1)
|
|
86
|
+
const date22 = new Date(date2)
|
|
87
|
+
return date11.time > date22.time ? 1 : -1
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
export function timeFix () {
|
|
91
|
+
const time = new Date()
|
|
92
|
+
const hour = time.getHours()
|
|
93
|
+
return hour < 9
|
|
94
|
+
? timeList[0] : (hour <= 11 ? timeList[1] : (hour <= 13 ? timeList[2] : (hour <= 20 ? timeList[3] : timeList[4])))
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
/**
|
|
98
|
+
* Remove an item from an array.
|
|
99
|
+
*/
|
|
100
|
+
export function remove (arr, item) {
|
|
101
|
+
if (arr.length) {
|
|
102
|
+
const index = arr.indexOf(item)
|
|
103
|
+
if (index > -1) {
|
|
104
|
+
return arr.splice(index, 1)
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
export function isRegExp (v) {
|
|
110
|
+
return _toString.call(v) === '[object RegExp]'
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
export function enquireScreen (call) {
|
|
114
|
+
const handler = {
|
|
115
|
+
match: function () {
|
|
116
|
+
call && call(true)
|
|
117
|
+
},
|
|
118
|
+
unmatch: function () {
|
|
119
|
+
call && call(false)
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
enquireJs.register('only screen and (max-width: 767.99px)', handler)
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
export function showXml (str) {
|
|
126
|
+
let text = str
|
|
127
|
+
|
|
128
|
+
// 去掉多余的空格
|
|
129
|
+
text = '\n' + text.replace(/(<\w+)(\s.*?>)/g, function ($0, name, props) {
|
|
130
|
+
return name + props.replace(/\s+(\w+=)/g, ' $1')
|
|
131
|
+
}).replace(/>\s*?</g, '>\n<')
|
|
132
|
+
|
|
133
|
+
// 把注释编码
|
|
134
|
+
text = text.replace(/\n/g, '\r').replace(/<!--(.+?)-->/g, function ($0, text) {
|
|
135
|
+
return '<!--' + escape(text) + '-->'
|
|
136
|
+
}).replace(/\r/g, '\n')
|
|
137
|
+
|
|
138
|
+
// 调整格式
|
|
139
|
+
const rgx = /\n(<(([^?]).+?)(?:\s|\s*?>|\s*?(\/)>)(?:.*?(?:(\/)>|<(\/)\2>))?)/mg
|
|
140
|
+
const nodeStack = []
|
|
141
|
+
const output = text.replace(rgx, function ($0, all, name, isBegin, isCloseFull1, isCloseFull2, isFull1, isFull2) {
|
|
142
|
+
const isClosed = (isCloseFull1 === '/') || (isCloseFull2 === '/') || (isFull1 === '/') || (isFull2 === '/')
|
|
143
|
+
let prefix
|
|
144
|
+
if (isBegin === '!') {
|
|
145
|
+
prefix = getPrefix(nodeStack.length)
|
|
146
|
+
} else {
|
|
147
|
+
if (isBegin !== '/') {
|
|
148
|
+
prefix = getPrefix(nodeStack.length)
|
|
149
|
+
if (!isClosed) {
|
|
150
|
+
nodeStack.push(name)
|
|
151
|
+
}
|
|
152
|
+
} else {
|
|
153
|
+
nodeStack.pop()
|
|
154
|
+
prefix = getPrefix(nodeStack.length)
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
return '\n' + prefix + all
|
|
158
|
+
})
|
|
159
|
+
let outputText = output.substring(1)
|
|
160
|
+
|
|
161
|
+
// 把注释还原并解码,调格式
|
|
162
|
+
outputText = outputText.replace(/\n/g, '\r').replace(/(\s*)<!--(.+?)-->/g, function ($0, prefix, text) {
|
|
163
|
+
if (prefix.charAt(0) === '\r') { prefix = prefix.substring(1) }
|
|
164
|
+
text = unescape(text).replace(/\r/g, '\n')
|
|
165
|
+
return '\n' + prefix + '<!--' + text.replace(/^\s*/mg, prefix) + '-->'
|
|
166
|
+
})
|
|
167
|
+
// alert(outputText);
|
|
168
|
+
|
|
169
|
+
outputText = outputText.replace(/\s+$/g, '').replace(/\r/g, '\r\n')
|
|
170
|
+
|
|
171
|
+
return outputText
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
function getPrefix (prefixIndex) {
|
|
175
|
+
const span = ' '
|
|
176
|
+
const output = []
|
|
177
|
+
for (let i = 0; i < prefixIndex; ++i) {
|
|
178
|
+
output.push(span)
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
return output.join('')
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
/**
|
|
185
|
+
* 构造树型结构数据
|
|
186
|
+
* [label,value,children]
|
|
187
|
+
*/
|
|
188
|
+
export function handleTree (data, id, parentId, children) {
|
|
189
|
+
const config = {
|
|
190
|
+
id: id || 'id',
|
|
191
|
+
parentId: parentId || 'parent_id',
|
|
192
|
+
childrenList: children || 'children'
|
|
193
|
+
}
|
|
194
|
+
const childrenListMap = {}
|
|
195
|
+
const nodeIds = {}
|
|
196
|
+
const tree = []
|
|
197
|
+
for (const d of data) {
|
|
198
|
+
const parentId = d[config.parentId]
|
|
199
|
+
if (childrenListMap[parentId] == null) {
|
|
200
|
+
childrenListMap[parentId] = []
|
|
201
|
+
}
|
|
202
|
+
nodeIds[d[config.id]] = d
|
|
203
|
+
childrenListMap[parentId].push(d)
|
|
204
|
+
}
|
|
205
|
+
for (const d of data) {
|
|
206
|
+
const parentId = d[config.parentId]
|
|
207
|
+
if (nodeIds[parentId] == null) {
|
|
208
|
+
tree.push(d)
|
|
209
|
+
}
|
|
210
|
+
}
|
|
211
|
+
for (const t of tree) {
|
|
212
|
+
adaptToChildrenList(t)
|
|
213
|
+
}
|
|
214
|
+
|
|
215
|
+
function adaptToChildrenList (o) {
|
|
216
|
+
o.label = o.name
|
|
217
|
+
o.value = o.name
|
|
218
|
+
if (childrenListMap[o[config.id]] !== null) {
|
|
219
|
+
o[config.childrenList] = childrenListMap[o[config.id]]
|
|
220
|
+
}
|
|
221
|
+
if (o[config.childrenList]) {
|
|
222
|
+
for (const c of o[config.childrenList]) {
|
|
223
|
+
adaptToChildrenList(c)
|
|
224
|
+
}
|
|
225
|
+
}
|
|
226
|
+
}
|
|
227
|
+
return tree
|
|
228
|
+
}
|
|
229
|
+
|
|
230
|
+
const _toString = Object.prototype.toString
|