@netang/quasar 0.0.102 → 0.0.103
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/LICENSE +21 -21
- package/README.md +11 -11
- package/_docs/docs/.vuepress/client.js +8 -8
- package/_docs/docs/.vuepress/config.js +40 -40
- package/_docs/docs/.vuepress/configs/index.js +2 -2
- package/_docs/docs/.vuepress/configs/navbar/index.js +1 -1
- package/_docs/docs/.vuepress/configs/navbar/zh.js +16 -16
- package/_docs/docs/.vuepress/configs/sidebar/index.js +1 -1
- package/_docs/docs/.vuepress/configs/sidebar/zh.js +75 -75
- package/_docs/docs/.vuepress/public/css/index.css +3 -3
- package/_docs/docs/.vuepress/styles/index.scss +3 -3
- package/_docs/docs/components/column-title.md +25 -25
- package/_docs/docs/components/data.md +66 -66
- package/_docs/docs/components/dialog.md +59 -59
- package/_docs/docs/components/dragger.md +26 -26
- package/_docs/docs/components/editor-code.md +16 -16
- package/_docs/docs/components/empty.md +13 -13
- package/_docs/docs/components/field-date.md +16 -16
- package/_docs/docs/components/field-text.md +57 -57
- package/_docs/docs/components/field-tree.md +14 -14
- package/_docs/docs/components/img.md +25 -25
- package/_docs/docs/components/input-number.md +21 -21
- package/_docs/docs/components/list-menu-item.md +21 -21
- package/_docs/docs/components/list-menu.md +21 -21
- package/_docs/docs/components/power-page.md +21 -21
- package/_docs/docs/components/price.md +21 -21
- package/_docs/docs/components/render.md +12 -12
- package/_docs/docs/components/search-item.md +10 -10
- package/_docs/docs/components/search.md +12 -12
- package/_docs/docs/components/select.md +11 -11
- package/_docs/docs/components/splitter.md +15 -15
- package/_docs/docs/components/table-column-fixed.md +20 -20
- package/_docs/docs/components/table-pagination.md +20 -20
- package/_docs/docs/components/table-splitter.md +20 -20
- package/_docs/docs/components/table-summary.md +20 -20
- package/_docs/docs/components/table.md +25 -25
- package/_docs/docs/components/thumbnail.md +18 -18
- package/_docs/docs/components/toolbar.md +9 -9
- package/_docs/docs/components/uploader-query.md +19 -19
- package/_docs/docs/components/uploader.md +16 -16
- package/_docs/docs/components/value-format.md +26 -26
- package/_docs/docs/index.md +1 -1
- package/_docs/docs/utils/alert.md +26 -26
- package/_docs/docs/utils/area.md +112 -112
- package/_docs/docs/utils/arr.md +80 -80
- package/_docs/docs/utils/auth.md +101 -101
- package/_docs/docs/utils/bus.md +18 -18
- package/_docs/docs/utils/confirm.md +31 -31
- package/_docs/docs/utils/copy.md +22 -22
- package/_docs/docs/utils/dialog.md +98 -98
- package/_docs/docs/utils/dict.md +50 -50
- package/_docs/docs/utils/dictOptions.md +27 -27
- package/_docs/docs/utils/form.md +33 -33
- package/_docs/docs/utils/getData.md +60 -60
- package/_docs/docs/utils/getFile.md +21 -21
- package/_docs/docs/utils/getImage.md +33 -33
- package/_docs/docs/utils/getTime.md +51 -51
- package/_docs/docs/utils/index.md +1 -1
- package/_docs/docs/utils/loading.md +18 -18
- package/_docs/docs/utils/notify.md +29 -29
- package/_docs/docs/utils/power.md +353 -353
- package/_docs/docs/utils/previewImage.md +11 -11
- package/_docs/docs/utils/price.md +45 -45
- package/_docs/docs/utils/rule.md +30 -30
- package/_docs/docs/utils/ruleValid.md +31 -31
- package/_docs/docs/utils/symbols.md +30 -30
- package/_docs/docs/utils/table.md +194 -194
- package/_docs/docs/utils/timestamp.md +27 -27
- package/_docs/docs/utils/toast.md +27 -27
- package/_docs/docs/utils/tree.md +174 -174
- package/_docs/docs/utils/uploader.md +29 -29
- package/_docs/package.json +11 -11
- package/components/column-title/index.vue +37 -37
- package/components/data/index.vue +20 -20
- package/components/dialog/index.vue +372 -372
- package/components/dragger/index.vue +203 -203
- package/components/drawer/index.vue +303 -303
- package/components/editor-code/index.vue +289 -289
- package/components/empty/index.vue +71 -71
- package/components/field-date/index.vue +850 -850
- package/components/field-date/methods.js +100 -100
- package/components/field-table/index.vue +1222 -1222
- package/components/field-text/index.vue +165 -165
- package/components/field-tree/index.vue +103 -81
- package/components/img/index.vue +202 -202
- package/components/input-number/index.vue +546 -546
- package/components/list-menu/index.vue +149 -149
- package/components/list-menu-item/index.vue +79 -79
- package/components/power-page/index.vue +92 -92
- package/components/price/index.vue +188 -188
- package/components/private/components/index.js +11 -11
- package/components/private/components/move-to-tree/index.vue +154 -154
- package/components/private/edit-power-data/index.vue +816 -816
- package/components/private/table-visible-columns-button/index.vue +109 -109
- package/components/render/index.vue +150 -150
- package/components/search/index.vue +222 -222
- package/components/search-item/index.vue +210 -210
- package/components/splitter/index.vue +415 -415
- package/components/table/index.vue +456 -456
- package/components/table-column-fixed/index.vue +112 -112
- package/components/table-pagination/index.vue +192 -192
- package/components/table-splitter/index.vue +360 -360
- package/components/table-summary/index.vue +110 -110
- package/components/thumbnail/index.vue +72 -72
- package/components/toolbar/container.vue +31 -31
- package/components/toolbar/index.vue +136 -136
- package/components/uploader/index.vue +158 -158
- package/components/uploader-query/index.vue +758 -758
- package/components/value-format/index.vue +274 -274
- package/configs/area3.js +1 -1
- package/docs/css/index.css +3 -3
- package/package.json +1 -1
- package/sass/common.scss +174 -174
- package/sass/index.scss +14 -14
- package/sass/line.scss +39 -39
- package/sass/quasar/btn.scss +46 -46
- package/sass/quasar/common.scss +3 -3
- package/sass/quasar/dialog.scss +7 -7
- package/sass/quasar/drawer.scss +6 -6
- package/sass/quasar/field.scss +243 -243
- package/sass/quasar/loading.scss +6 -6
- package/sass/quasar/menu.scss +8 -8
- package/sass/quasar/table.scss +150 -150
- package/sass/quasar/toolbar.scss +22 -22
- package/store/index.js +29 -29
- package/utils/$auth.js +127 -127
- package/utils/$form.js +56 -56
- package/utils/$power.js +1215 -1215
- package/utils/$rule.js +13 -13
- package/utils/$ruleValid.js +10 -10
- package/utils/$table.js +999 -999
- package/utils/$tree.js +713 -713
- package/utils/alert.js +12 -12
- package/utils/area.js +400 -400
- package/utils/arr.js +51 -51
- package/utils/bus.js +6 -6
- package/utils/config.js +52 -52
- package/utils/confirm.js +11 -11
- package/utils/copy.js +30 -30
- package/utils/dialog.js +36 -36
- package/utils/dict.js +21 -21
- package/utils/dictOptions.js +28 -28
- package/utils/getData.js +73 -73
- package/utils/getFile.js +40 -40
- package/utils/getImage.js +153 -153
- package/utils/getTime.js +106 -106
- package/utils/index.js +61 -61
- package/utils/loading.js +15 -15
- package/utils/notify.js +13 -13
- package/utils/previewImage.js +10 -10
- package/utils/price.js +18 -18
- package/utils/symbols.js +18 -18
- package/utils/timestamp.js +18 -18
- package/utils/toast.js +13 -13
- package/utils/uploader/aliyun.js +6 -6
- package/utils/uploader/local.js +8 -8
- package/utils/uploader/qiniu.js +321 -321
- package/utils/uploader.js +1059 -1059
- package/utils/useAuth.js +30 -30
- package/utils/useRouter.js +47 -47
- package/utils/useSearch.js +0 -6
- package/utils/useUploader.js +53 -53
|
@@ -1,165 +1,165 @@
|
|
|
1
|
-
<template>
|
|
2
|
-
<q-field
|
|
3
|
-
class="n-field-fieldset"
|
|
4
|
-
:label="label"
|
|
5
|
-
:stack-label="stackLabel"
|
|
6
|
-
:outlined="outlined"
|
|
7
|
-
:dense="dense"
|
|
8
|
-
:readonly="readonly"
|
|
9
|
-
v-bind="$attrs"
|
|
10
|
-
>
|
|
11
|
-
<template v-slot:control>
|
|
12
|
-
|
|
13
|
-
<!-- 如果有默认插槽 -->
|
|
14
|
-
<template v-if="$slots.default">
|
|
15
|
-
|
|
16
|
-
<!-- 如果开启复制 -->
|
|
17
|
-
<div
|
|
18
|
-
class="full-width"
|
|
19
|
-
:class="valueClass"
|
|
20
|
-
:style="valueStyle"
|
|
21
|
-
@click="onCopy"
|
|
22
|
-
v-if="! noCopy"
|
|
23
|
-
>
|
|
24
|
-
<slot
|
|
25
|
-
:value="value"
|
|
26
|
-
/>
|
|
27
|
-
</div>
|
|
28
|
-
|
|
29
|
-
<!-- 否则仅展示 -->
|
|
30
|
-
<div
|
|
31
|
-
class="full-width"
|
|
32
|
-
:class="valueClass"
|
|
33
|
-
:style="valueStyle"
|
|
34
|
-
v-else
|
|
35
|
-
>
|
|
36
|
-
<slot
|
|
37
|
-
:value="value"
|
|
38
|
-
/>
|
|
39
|
-
</div>
|
|
40
|
-
</template>
|
|
41
|
-
|
|
42
|
-
<!-- 否则如果开启复制 -->
|
|
43
|
-
<div
|
|
44
|
-
class="full-width"
|
|
45
|
-
:class="valueClass"
|
|
46
|
-
:style="valueStyle"
|
|
47
|
-
@click="onCopy"
|
|
48
|
-
v-else-if="! noCopy"
|
|
49
|
-
>{{value}}</div>
|
|
50
|
-
|
|
51
|
-
<!-- 否则仅展示 -->
|
|
52
|
-
<div
|
|
53
|
-
class="full-width"
|
|
54
|
-
:class="valueClass"
|
|
55
|
-
:style="valueStyle"
|
|
56
|
-
v-else
|
|
57
|
-
>{{value}}</div>
|
|
58
|
-
|
|
59
|
-
</template>
|
|
60
|
-
|
|
61
|
-
<template
|
|
62
|
-
v-for="slotName in slotNames"
|
|
63
|
-
v-slot:[slotName]
|
|
64
|
-
>
|
|
65
|
-
<slot
|
|
66
|
-
:name="slotName"
|
|
67
|
-
:value="value"
|
|
68
|
-
/>
|
|
69
|
-
</template>
|
|
70
|
-
</q-field>
|
|
71
|
-
</template>
|
|
72
|
-
|
|
73
|
-
<script>
|
|
74
|
-
import { computed } from 'vue'
|
|
75
|
-
|
|
76
|
-
import $n_omit from 'lodash/omit'
|
|
77
|
-
|
|
78
|
-
import $n_isValidObject from '@netang/utils/isValidObject'
|
|
79
|
-
|
|
80
|
-
import $n_copy from '../../utils/copy'
|
|
81
|
-
|
|
82
|
-
export default {
|
|
83
|
-
|
|
84
|
-
/**
|
|
85
|
-
* 标识
|
|
86
|
-
*/
|
|
87
|
-
name: 'NFieldText',
|
|
88
|
-
|
|
89
|
-
/**
|
|
90
|
-
* 声明属性
|
|
91
|
-
*/
|
|
92
|
-
props: {
|
|
93
|
-
// 标签
|
|
94
|
-
label: [Array, String, Number],
|
|
95
|
-
// 值
|
|
96
|
-
value: [String, Number],
|
|
97
|
-
// 复制文字
|
|
98
|
-
copyText: [String, Number],
|
|
99
|
-
// 标签始终显示在字段上方
|
|
100
|
-
stackLabel: {
|
|
101
|
-
type: Boolean,
|
|
102
|
-
default: true,
|
|
103
|
-
},
|
|
104
|
-
// 线条
|
|
105
|
-
outlined: {
|
|
106
|
-
type: Boolean,
|
|
107
|
-
default: true,
|
|
108
|
-
},
|
|
109
|
-
// 紧凑模式
|
|
110
|
-
dense: {
|
|
111
|
-
type: Boolean,
|
|
112
|
-
default: true,
|
|
113
|
-
},
|
|
114
|
-
// 只读模式
|
|
115
|
-
readonly: {
|
|
116
|
-
type: Boolean,
|
|
117
|
-
default: true,
|
|
118
|
-
},
|
|
119
|
-
// 禁止复制
|
|
120
|
-
noCopy: Boolean,
|
|
121
|
-
// 值类名
|
|
122
|
-
valueClass: String,
|
|
123
|
-
// 值样式
|
|
124
|
-
valueStyle: [String, Object, Array],
|
|
125
|
-
},
|
|
126
|
-
|
|
127
|
-
/**
|
|
128
|
-
* 组合式
|
|
129
|
-
*/
|
|
130
|
-
setup(props, { slots }) {
|
|
131
|
-
|
|
132
|
-
// ==========【计算属性】==========================================================================================
|
|
133
|
-
|
|
134
|
-
/**
|
|
135
|
-
* 插槽标识数组
|
|
136
|
-
*/
|
|
137
|
-
const slotNames = computed(function() {
|
|
138
|
-
return $n_isValidObject(slots) ? Object.keys($n_omit(slots, [ 'default' ])) : []
|
|
139
|
-
})
|
|
140
|
-
|
|
141
|
-
// ==========【方法】=============================================================================================
|
|
142
|
-
|
|
143
|
-
/**
|
|
144
|
-
* 复制
|
|
145
|
-
*/
|
|
146
|
-
function onCopy() {
|
|
147
|
-
const val = props.copyText || props.value
|
|
148
|
-
if (val) {
|
|
149
|
-
$n_copy(val, `复制【${props.label}】成功`)
|
|
150
|
-
}
|
|
151
|
-
}
|
|
152
|
-
|
|
153
|
-
// ==========【返回】=============================================================================================
|
|
154
|
-
|
|
155
|
-
return {
|
|
156
|
-
// 字段组件传参
|
|
157
|
-
// fieldProps,
|
|
158
|
-
// 插槽标识数组
|
|
159
|
-
slotNames,
|
|
160
|
-
// 复制
|
|
161
|
-
onCopy,
|
|
162
|
-
}
|
|
163
|
-
},
|
|
164
|
-
}
|
|
165
|
-
</script>
|
|
1
|
+
<template>
|
|
2
|
+
<q-field
|
|
3
|
+
class="n-field-fieldset"
|
|
4
|
+
:label="label"
|
|
5
|
+
:stack-label="stackLabel"
|
|
6
|
+
:outlined="outlined"
|
|
7
|
+
:dense="dense"
|
|
8
|
+
:readonly="readonly"
|
|
9
|
+
v-bind="$attrs"
|
|
10
|
+
>
|
|
11
|
+
<template v-slot:control>
|
|
12
|
+
|
|
13
|
+
<!-- 如果有默认插槽 -->
|
|
14
|
+
<template v-if="$slots.default">
|
|
15
|
+
|
|
16
|
+
<!-- 如果开启复制 -->
|
|
17
|
+
<div
|
|
18
|
+
class="full-width"
|
|
19
|
+
:class="valueClass"
|
|
20
|
+
:style="valueStyle"
|
|
21
|
+
@click="onCopy"
|
|
22
|
+
v-if="! noCopy"
|
|
23
|
+
>
|
|
24
|
+
<slot
|
|
25
|
+
:value="value"
|
|
26
|
+
/>
|
|
27
|
+
</div>
|
|
28
|
+
|
|
29
|
+
<!-- 否则仅展示 -->
|
|
30
|
+
<div
|
|
31
|
+
class="full-width"
|
|
32
|
+
:class="valueClass"
|
|
33
|
+
:style="valueStyle"
|
|
34
|
+
v-else
|
|
35
|
+
>
|
|
36
|
+
<slot
|
|
37
|
+
:value="value"
|
|
38
|
+
/>
|
|
39
|
+
</div>
|
|
40
|
+
</template>
|
|
41
|
+
|
|
42
|
+
<!-- 否则如果开启复制 -->
|
|
43
|
+
<div
|
|
44
|
+
class="full-width"
|
|
45
|
+
:class="valueClass"
|
|
46
|
+
:style="valueStyle"
|
|
47
|
+
@click="onCopy"
|
|
48
|
+
v-else-if="! noCopy"
|
|
49
|
+
>{{value}}</div>
|
|
50
|
+
|
|
51
|
+
<!-- 否则仅展示 -->
|
|
52
|
+
<div
|
|
53
|
+
class="full-width"
|
|
54
|
+
:class="valueClass"
|
|
55
|
+
:style="valueStyle"
|
|
56
|
+
v-else
|
|
57
|
+
>{{value}}</div>
|
|
58
|
+
|
|
59
|
+
</template>
|
|
60
|
+
|
|
61
|
+
<template
|
|
62
|
+
v-for="slotName in slotNames"
|
|
63
|
+
v-slot:[slotName]
|
|
64
|
+
>
|
|
65
|
+
<slot
|
|
66
|
+
:name="slotName"
|
|
67
|
+
:value="value"
|
|
68
|
+
/>
|
|
69
|
+
</template>
|
|
70
|
+
</q-field>
|
|
71
|
+
</template>
|
|
72
|
+
|
|
73
|
+
<script>
|
|
74
|
+
import { computed } from 'vue'
|
|
75
|
+
|
|
76
|
+
import $n_omit from 'lodash/omit'
|
|
77
|
+
|
|
78
|
+
import $n_isValidObject from '@netang/utils/isValidObject'
|
|
79
|
+
|
|
80
|
+
import $n_copy from '../../utils/copy'
|
|
81
|
+
|
|
82
|
+
export default {
|
|
83
|
+
|
|
84
|
+
/**
|
|
85
|
+
* 标识
|
|
86
|
+
*/
|
|
87
|
+
name: 'NFieldText',
|
|
88
|
+
|
|
89
|
+
/**
|
|
90
|
+
* 声明属性
|
|
91
|
+
*/
|
|
92
|
+
props: {
|
|
93
|
+
// 标签
|
|
94
|
+
label: [Array, String, Number],
|
|
95
|
+
// 值
|
|
96
|
+
value: [String, Number],
|
|
97
|
+
// 复制文字
|
|
98
|
+
copyText: [String, Number],
|
|
99
|
+
// 标签始终显示在字段上方
|
|
100
|
+
stackLabel: {
|
|
101
|
+
type: Boolean,
|
|
102
|
+
default: true,
|
|
103
|
+
},
|
|
104
|
+
// 线条
|
|
105
|
+
outlined: {
|
|
106
|
+
type: Boolean,
|
|
107
|
+
default: true,
|
|
108
|
+
},
|
|
109
|
+
// 紧凑模式
|
|
110
|
+
dense: {
|
|
111
|
+
type: Boolean,
|
|
112
|
+
default: true,
|
|
113
|
+
},
|
|
114
|
+
// 只读模式
|
|
115
|
+
readonly: {
|
|
116
|
+
type: Boolean,
|
|
117
|
+
default: true,
|
|
118
|
+
},
|
|
119
|
+
// 禁止复制
|
|
120
|
+
noCopy: Boolean,
|
|
121
|
+
// 值类名
|
|
122
|
+
valueClass: String,
|
|
123
|
+
// 值样式
|
|
124
|
+
valueStyle: [String, Object, Array],
|
|
125
|
+
},
|
|
126
|
+
|
|
127
|
+
/**
|
|
128
|
+
* 组合式
|
|
129
|
+
*/
|
|
130
|
+
setup(props, { slots }) {
|
|
131
|
+
|
|
132
|
+
// ==========【计算属性】==========================================================================================
|
|
133
|
+
|
|
134
|
+
/**
|
|
135
|
+
* 插槽标识数组
|
|
136
|
+
*/
|
|
137
|
+
const slotNames = computed(function() {
|
|
138
|
+
return $n_isValidObject(slots) ? Object.keys($n_omit(slots, [ 'default' ])) : []
|
|
139
|
+
})
|
|
140
|
+
|
|
141
|
+
// ==========【方法】=============================================================================================
|
|
142
|
+
|
|
143
|
+
/**
|
|
144
|
+
* 复制
|
|
145
|
+
*/
|
|
146
|
+
function onCopy() {
|
|
147
|
+
const val = props.copyText || props.value
|
|
148
|
+
if (val) {
|
|
149
|
+
$n_copy(val, `复制【${props.label}】成功`)
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
// ==========【返回】=============================================================================================
|
|
154
|
+
|
|
155
|
+
return {
|
|
156
|
+
// 字段组件传参
|
|
157
|
+
// fieldProps,
|
|
158
|
+
// 插槽标识数组
|
|
159
|
+
slotNames,
|
|
160
|
+
// 复制
|
|
161
|
+
onCopy,
|
|
162
|
+
}
|
|
163
|
+
},
|
|
164
|
+
}
|
|
165
|
+
</script>
|
|
@@ -100,7 +100,7 @@
|
|
|
100
100
|
:ticked="treeTicked"
|
|
101
101
|
@update:ticked="emitModelValue"
|
|
102
102
|
v-model:expanded="treeExpanded"
|
|
103
|
-
:tick-strategy="
|
|
103
|
+
:tick-strategy="multiple ? (strict ? 'strict' : 'leaf') : 'none'"
|
|
104
104
|
:accordion="accordion"
|
|
105
105
|
v-bind="treeProps"
|
|
106
106
|
v-if="showTree"
|
|
@@ -137,11 +137,11 @@ import $n_uniq from 'lodash/uniq'
|
|
|
137
137
|
import $n_concat from 'lodash/concat'
|
|
138
138
|
import $n_isFunction from 'lodash/isFunction'
|
|
139
139
|
|
|
140
|
-
import $n_forEach from '@netang/utils/forEach'
|
|
141
|
-
import $n_isValidArray from '@netang/utils/isValidArray'
|
|
142
140
|
import $n_indexOf from '@netang/utils/indexOf'
|
|
143
141
|
import $n_isRequired from '@netang/utils/isRequired'
|
|
142
|
+
import $n_isValidArray from '@netang/utils/isValidArray'
|
|
144
143
|
import $n_isValidValue from '@netang/utils/isValidValue'
|
|
144
|
+
import $n_isValidObject from '@netang/utils/isValidObject'
|
|
145
145
|
import $n_runAsync from '@netang/utils/runAsync'
|
|
146
146
|
|
|
147
147
|
export default {
|
|
@@ -161,7 +161,7 @@ export default {
|
|
|
161
161
|
},
|
|
162
162
|
// 树展开节点
|
|
163
163
|
expanded: Array, // v-model:expanded
|
|
164
|
-
//
|
|
164
|
+
// 节点数组
|
|
165
165
|
// Array: 初始节点数据数据组
|
|
166
166
|
// Function: 获取初始节点数据的方法
|
|
167
167
|
nodes: [ Array, Function ],
|
|
@@ -212,7 +212,7 @@ export default {
|
|
|
212
212
|
/**
|
|
213
213
|
* 组合式
|
|
214
214
|
*/
|
|
215
|
-
setup(props, {
|
|
215
|
+
setup(props, { emit }) {
|
|
216
216
|
|
|
217
217
|
// ==========【计算属性】=========================================================================================
|
|
218
218
|
|
|
@@ -251,6 +251,9 @@ export default {
|
|
|
251
251
|
// 树节点
|
|
252
252
|
const treeRef = ref(null)
|
|
253
253
|
|
|
254
|
+
// tree all
|
|
255
|
+
const treeAll = ref({})
|
|
256
|
+
|
|
254
257
|
// 树展开数据
|
|
255
258
|
const treeExpanded = ref(getExpanded())
|
|
256
259
|
|
|
@@ -260,19 +263,18 @@ export default {
|
|
|
260
263
|
// 当前树节点数据
|
|
261
264
|
const currentTreeNodes = ref(isDefaultLoadNodes ? [] : props.nodes)
|
|
262
265
|
|
|
263
|
-
//
|
|
264
|
-
let
|
|
266
|
+
// 树节点是否已加载
|
|
267
|
+
let __treeNodesLoaded = false
|
|
265
268
|
|
|
266
|
-
//
|
|
269
|
+
// 如果为初始加载树节点树
|
|
270
|
+
if (isDefaultLoadNodes) {
|
|
267
271
|
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
) : 'none'
|
|
275
|
-
})
|
|
272
|
+
// 初始加载节点
|
|
273
|
+
defaultLoadNodes()
|
|
274
|
+
.finally()
|
|
275
|
+
}
|
|
276
|
+
|
|
277
|
+
// ==========【计算属性】=========================================================================================
|
|
276
278
|
|
|
277
279
|
/**
|
|
278
280
|
* 树选择节点数据
|
|
@@ -281,16 +283,19 @@ export default {
|
|
|
281
283
|
|
|
282
284
|
const lists = []
|
|
283
285
|
|
|
284
|
-
$
|
|
286
|
+
if ($n_isValidObject(treeAll.value)) {
|
|
287
|
+
|
|
288
|
+
for (const treeKey of treeTicked.value) {
|
|
285
289
|
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
290
|
+
// 获取树选择的节点
|
|
291
|
+
if ($n_has(treeAll.value, treeKey)) {
|
|
292
|
+
lists.push({
|
|
293
|
+
id: treeKey,
|
|
294
|
+
label: treeAll.value[treeKey][props.showAllLevels ? 'path' : 'label'],
|
|
295
|
+
})
|
|
296
|
+
}
|
|
292
297
|
}
|
|
293
|
-
}
|
|
298
|
+
}
|
|
294
299
|
|
|
295
300
|
return lists
|
|
296
301
|
})
|
|
@@ -302,14 +307,6 @@ export default {
|
|
|
302
307
|
*/
|
|
303
308
|
watch(() => props.nodes, defaultLoadNodes)
|
|
304
309
|
|
|
305
|
-
/**
|
|
306
|
-
* 监听当前节点数组
|
|
307
|
-
*/
|
|
308
|
-
watch(currentTreeNodes, function () {
|
|
309
|
-
// 更新 tree all
|
|
310
|
-
treeAll = getTreeAll()
|
|
311
|
-
})
|
|
312
|
-
|
|
313
310
|
/**
|
|
314
311
|
* 监听声明值
|
|
315
312
|
*/
|
|
@@ -343,45 +340,43 @@ export default {
|
|
|
343
340
|
// ==========【方法】=============================================================================================
|
|
344
341
|
|
|
345
342
|
/**
|
|
346
|
-
*
|
|
343
|
+
* 获取树子节点
|
|
347
344
|
*/
|
|
348
|
-
function
|
|
345
|
+
function _getTreeChildren(all, data, pid, pPath) {
|
|
346
|
+
for (const item of data) {
|
|
349
347
|
|
|
350
|
-
|
|
348
|
+
const label = item[props.labelKey]
|
|
351
349
|
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
for (const item of data) {
|
|
361
|
-
|
|
362
|
-
const label = item[props.labelKey]
|
|
363
|
-
|
|
364
|
-
const path = pPath ? (pPath + ' / ' + label) : label
|
|
365
|
-
|
|
366
|
-
all[item[props.nodeKey]] = {
|
|
367
|
-
id: item[props.nodeKey],
|
|
368
|
-
pid,
|
|
369
|
-
label,
|
|
370
|
-
children: item.children,
|
|
371
|
-
path,
|
|
372
|
-
}
|
|
373
|
-
|
|
374
|
-
// 如果是父节点
|
|
375
|
-
if ($n_isValidArray(item.children)) {
|
|
376
|
-
getChildren(item.children, item.id, path)
|
|
377
|
-
}
|
|
378
|
-
}
|
|
350
|
+
const path = pPath ? (pPath + ' / ' + label) : label
|
|
351
|
+
|
|
352
|
+
all[item[props.nodeKey]] = {
|
|
353
|
+
id: item[props.nodeKey],
|
|
354
|
+
pid,
|
|
355
|
+
label,
|
|
356
|
+
children: item.children,
|
|
357
|
+
path,
|
|
379
358
|
}
|
|
380
359
|
|
|
381
|
-
|
|
360
|
+
// 如果是父节点
|
|
361
|
+
if ($n_isValidArray(item.children)) {
|
|
362
|
+
_getTreeChildren(all, item.children, item.id, path)
|
|
363
|
+
}
|
|
382
364
|
}
|
|
365
|
+
}
|
|
366
|
+
|
|
367
|
+
/**
|
|
368
|
+
* 设置 tree all
|
|
369
|
+
*/
|
|
370
|
+
function setTreeAll() {
|
|
383
371
|
|
|
384
|
-
|
|
372
|
+
const all = {}
|
|
373
|
+
|
|
374
|
+
// 如果当前树节点数据为有效数组
|
|
375
|
+
if ($n_isValidArray(currentTreeNodes.value)) {
|
|
376
|
+
_getTreeChildren(all, currentTreeNodes.value, 0, '')
|
|
377
|
+
}
|
|
378
|
+
|
|
379
|
+
treeAll.value = all
|
|
385
380
|
}
|
|
386
381
|
|
|
387
382
|
/**
|
|
@@ -396,8 +391,10 @@ export default {
|
|
|
396
391
|
! props.multiple
|
|
397
392
|
// 如果有值
|
|
398
393
|
&& $n_isRequired(props.modelValue)
|
|
394
|
+
// 如果有 tree all
|
|
395
|
+
&& $n_isValidObject(treeAll.value)
|
|
399
396
|
// 存在节点
|
|
400
|
-
&& $n_has(treeAll, props.modelValue)
|
|
397
|
+
&& $n_has(treeAll.value, props.modelValue)
|
|
401
398
|
) {
|
|
402
399
|
// 获取父节点
|
|
403
400
|
function getParent({ id, pid, children }) {
|
|
@@ -409,16 +406,16 @@ export default {
|
|
|
409
406
|
}
|
|
410
407
|
|
|
411
408
|
// 如果有父节点, 则继续向上寻找
|
|
412
|
-
if (pid && $n_has(treeAll, pid)) {
|
|
413
|
-
getParent(treeAll[pid])
|
|
409
|
+
if (pid && $n_has(treeAll.value, pid)) {
|
|
410
|
+
getParent(treeAll.value[pid])
|
|
414
411
|
}
|
|
415
412
|
}
|
|
416
413
|
|
|
417
|
-
getParent(treeAll[props.modelValue])
|
|
418
|
-
}
|
|
414
|
+
getParent(treeAll.value[props.modelValue])
|
|
419
415
|
|
|
420
|
-
|
|
421
|
-
|
|
416
|
+
if (props.expanded) {
|
|
417
|
+
expanded = $n_uniq($n_concat(expanded, props.expanded))
|
|
418
|
+
}
|
|
422
419
|
}
|
|
423
420
|
|
|
424
421
|
return expanded
|
|
@@ -577,7 +574,6 @@ export default {
|
|
|
577
574
|
/**
|
|
578
575
|
* 弹出层显示回调
|
|
579
576
|
*/
|
|
580
|
-
let __treeLoaded = false
|
|
581
577
|
async function onPopupShow() {
|
|
582
578
|
|
|
583
579
|
// 显示弹出层
|
|
@@ -588,7 +584,7 @@ export default {
|
|
|
588
584
|
|
|
589
585
|
if (
|
|
590
586
|
// 如果树已加载过了
|
|
591
|
-
|
|
587
|
+
__treeNodesLoaded
|
|
592
588
|
// 如果树已显示
|
|
593
589
|
|| showTree.value
|
|
594
590
|
) {
|
|
@@ -644,8 +640,6 @@ export default {
|
|
|
644
640
|
*/
|
|
645
641
|
async function defaultLoadNodes() {
|
|
646
642
|
|
|
647
|
-
let resNodes = props.nodes
|
|
648
|
-
|
|
649
643
|
// 如果是初始加载树节点树
|
|
650
644
|
if ($n_isFunction(props.nodes)) {
|
|
651
645
|
|
|
@@ -655,14 +649,44 @@ export default {
|
|
|
655
649
|
// 下次 DOM 更新
|
|
656
650
|
await nextTick()
|
|
657
651
|
|
|
658
|
-
|
|
659
|
-
|
|
652
|
+
// 通过自定义方法获取树节点数组
|
|
653
|
+
const resNodes = await $n_runAsync(props.nodes)()
|
|
654
|
+
|
|
655
|
+
if ($n_isValidArray(resNodes)) {
|
|
660
656
|
|
|
661
|
-
|
|
662
|
-
|
|
657
|
+
// 设置当前树节点数组
|
|
658
|
+
currentTreeNodes.value = resNodes
|
|
659
|
+
|
|
660
|
+
// 设置 tree all
|
|
661
|
+
setTreeAll()
|
|
662
|
+
|
|
663
|
+
// 设置开数据
|
|
664
|
+
treeExpanded.value = getExpanded()
|
|
665
|
+
|
|
666
|
+
} else {
|
|
667
|
+
|
|
668
|
+
// 设置当前树节点数组
|
|
669
|
+
currentTreeNodes.value = []
|
|
670
|
+
|
|
671
|
+
// 设置 tree all
|
|
672
|
+
setTreeAll()
|
|
673
|
+
}
|
|
674
|
+
|
|
675
|
+
// 否则为节点数组数据
|
|
676
|
+
} else {
|
|
677
|
+
|
|
678
|
+
// 设置当前树节点数组
|
|
679
|
+
currentTreeNodes.value = $n_isValidArray(props.nodes) ? props.nodes : []
|
|
680
|
+
|
|
681
|
+
// 设置 tree all
|
|
682
|
+
setTreeAll()
|
|
683
|
+
}
|
|
663
684
|
|
|
664
685
|
// 设置显示树
|
|
665
686
|
showTree.value = true
|
|
687
|
+
|
|
688
|
+
// 树已加载
|
|
689
|
+
__treeNodesLoaded = true
|
|
666
690
|
}
|
|
667
691
|
|
|
668
692
|
// ==========【生命周期】=========================================================================================
|
|
@@ -701,8 +725,6 @@ export default {
|
|
|
701
725
|
treeExpanded,
|
|
702
726
|
// 当前树节点数据
|
|
703
727
|
currentTreeNodes,
|
|
704
|
-
// 当前节点选择策略
|
|
705
|
-
currentTickStrategy,
|
|
706
728
|
|
|
707
729
|
// 触发更新值
|
|
708
730
|
emitModelValue,
|