@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.
Files changed (162) hide show
  1. package/LICENSE +21 -21
  2. package/README.md +11 -11
  3. package/_docs/docs/.vuepress/client.js +8 -8
  4. package/_docs/docs/.vuepress/config.js +40 -40
  5. package/_docs/docs/.vuepress/configs/index.js +2 -2
  6. package/_docs/docs/.vuepress/configs/navbar/index.js +1 -1
  7. package/_docs/docs/.vuepress/configs/navbar/zh.js +16 -16
  8. package/_docs/docs/.vuepress/configs/sidebar/index.js +1 -1
  9. package/_docs/docs/.vuepress/configs/sidebar/zh.js +75 -75
  10. package/_docs/docs/.vuepress/public/css/index.css +3 -3
  11. package/_docs/docs/.vuepress/styles/index.scss +3 -3
  12. package/_docs/docs/components/column-title.md +25 -25
  13. package/_docs/docs/components/data.md +66 -66
  14. package/_docs/docs/components/dialog.md +59 -59
  15. package/_docs/docs/components/dragger.md +26 -26
  16. package/_docs/docs/components/editor-code.md +16 -16
  17. package/_docs/docs/components/empty.md +13 -13
  18. package/_docs/docs/components/field-date.md +16 -16
  19. package/_docs/docs/components/field-text.md +57 -57
  20. package/_docs/docs/components/field-tree.md +14 -14
  21. package/_docs/docs/components/img.md +25 -25
  22. package/_docs/docs/components/input-number.md +21 -21
  23. package/_docs/docs/components/list-menu-item.md +21 -21
  24. package/_docs/docs/components/list-menu.md +21 -21
  25. package/_docs/docs/components/power-page.md +21 -21
  26. package/_docs/docs/components/price.md +21 -21
  27. package/_docs/docs/components/render.md +12 -12
  28. package/_docs/docs/components/search-item.md +10 -10
  29. package/_docs/docs/components/search.md +12 -12
  30. package/_docs/docs/components/select.md +11 -11
  31. package/_docs/docs/components/splitter.md +15 -15
  32. package/_docs/docs/components/table-column-fixed.md +20 -20
  33. package/_docs/docs/components/table-pagination.md +20 -20
  34. package/_docs/docs/components/table-splitter.md +20 -20
  35. package/_docs/docs/components/table-summary.md +20 -20
  36. package/_docs/docs/components/table.md +25 -25
  37. package/_docs/docs/components/thumbnail.md +18 -18
  38. package/_docs/docs/components/toolbar.md +9 -9
  39. package/_docs/docs/components/uploader-query.md +19 -19
  40. package/_docs/docs/components/uploader.md +16 -16
  41. package/_docs/docs/components/value-format.md +26 -26
  42. package/_docs/docs/index.md +1 -1
  43. package/_docs/docs/utils/alert.md +26 -26
  44. package/_docs/docs/utils/area.md +112 -112
  45. package/_docs/docs/utils/arr.md +80 -80
  46. package/_docs/docs/utils/auth.md +101 -101
  47. package/_docs/docs/utils/bus.md +18 -18
  48. package/_docs/docs/utils/confirm.md +31 -31
  49. package/_docs/docs/utils/copy.md +22 -22
  50. package/_docs/docs/utils/dialog.md +98 -98
  51. package/_docs/docs/utils/dict.md +50 -50
  52. package/_docs/docs/utils/dictOptions.md +27 -27
  53. package/_docs/docs/utils/form.md +33 -33
  54. package/_docs/docs/utils/getData.md +60 -60
  55. package/_docs/docs/utils/getFile.md +21 -21
  56. package/_docs/docs/utils/getImage.md +33 -33
  57. package/_docs/docs/utils/getTime.md +51 -51
  58. package/_docs/docs/utils/index.md +1 -1
  59. package/_docs/docs/utils/loading.md +18 -18
  60. package/_docs/docs/utils/notify.md +29 -29
  61. package/_docs/docs/utils/power.md +353 -353
  62. package/_docs/docs/utils/previewImage.md +11 -11
  63. package/_docs/docs/utils/price.md +45 -45
  64. package/_docs/docs/utils/rule.md +30 -30
  65. package/_docs/docs/utils/ruleValid.md +31 -31
  66. package/_docs/docs/utils/symbols.md +30 -30
  67. package/_docs/docs/utils/table.md +194 -194
  68. package/_docs/docs/utils/timestamp.md +27 -27
  69. package/_docs/docs/utils/toast.md +27 -27
  70. package/_docs/docs/utils/tree.md +174 -174
  71. package/_docs/docs/utils/uploader.md +29 -29
  72. package/_docs/package.json +11 -11
  73. package/components/column-title/index.vue +37 -37
  74. package/components/data/index.vue +20 -20
  75. package/components/dialog/index.vue +372 -372
  76. package/components/dragger/index.vue +203 -203
  77. package/components/drawer/index.vue +303 -303
  78. package/components/editor-code/index.vue +289 -289
  79. package/components/empty/index.vue +71 -71
  80. package/components/field-date/index.vue +850 -850
  81. package/components/field-date/methods.js +100 -100
  82. package/components/field-table/index.vue +1222 -1222
  83. package/components/field-text/index.vue +165 -165
  84. package/components/field-tree/index.vue +103 -81
  85. package/components/img/index.vue +202 -202
  86. package/components/input-number/index.vue +546 -546
  87. package/components/list-menu/index.vue +149 -149
  88. package/components/list-menu-item/index.vue +79 -79
  89. package/components/power-page/index.vue +92 -92
  90. package/components/price/index.vue +188 -188
  91. package/components/private/components/index.js +11 -11
  92. package/components/private/components/move-to-tree/index.vue +154 -154
  93. package/components/private/edit-power-data/index.vue +816 -816
  94. package/components/private/table-visible-columns-button/index.vue +109 -109
  95. package/components/render/index.vue +150 -150
  96. package/components/search/index.vue +222 -222
  97. package/components/search-item/index.vue +210 -210
  98. package/components/splitter/index.vue +415 -415
  99. package/components/table/index.vue +456 -456
  100. package/components/table-column-fixed/index.vue +112 -112
  101. package/components/table-pagination/index.vue +192 -192
  102. package/components/table-splitter/index.vue +360 -360
  103. package/components/table-summary/index.vue +110 -110
  104. package/components/thumbnail/index.vue +72 -72
  105. package/components/toolbar/container.vue +31 -31
  106. package/components/toolbar/index.vue +136 -136
  107. package/components/uploader/index.vue +158 -158
  108. package/components/uploader-query/index.vue +758 -758
  109. package/components/value-format/index.vue +274 -274
  110. package/configs/area3.js +1 -1
  111. package/docs/css/index.css +3 -3
  112. package/package.json +1 -1
  113. package/sass/common.scss +174 -174
  114. package/sass/index.scss +14 -14
  115. package/sass/line.scss +39 -39
  116. package/sass/quasar/btn.scss +46 -46
  117. package/sass/quasar/common.scss +3 -3
  118. package/sass/quasar/dialog.scss +7 -7
  119. package/sass/quasar/drawer.scss +6 -6
  120. package/sass/quasar/field.scss +243 -243
  121. package/sass/quasar/loading.scss +6 -6
  122. package/sass/quasar/menu.scss +8 -8
  123. package/sass/quasar/table.scss +150 -150
  124. package/sass/quasar/toolbar.scss +22 -22
  125. package/store/index.js +29 -29
  126. package/utils/$auth.js +127 -127
  127. package/utils/$form.js +56 -56
  128. package/utils/$power.js +1215 -1215
  129. package/utils/$rule.js +13 -13
  130. package/utils/$ruleValid.js +10 -10
  131. package/utils/$table.js +999 -999
  132. package/utils/$tree.js +713 -713
  133. package/utils/alert.js +12 -12
  134. package/utils/area.js +400 -400
  135. package/utils/arr.js +51 -51
  136. package/utils/bus.js +6 -6
  137. package/utils/config.js +52 -52
  138. package/utils/confirm.js +11 -11
  139. package/utils/copy.js +30 -30
  140. package/utils/dialog.js +36 -36
  141. package/utils/dict.js +21 -21
  142. package/utils/dictOptions.js +28 -28
  143. package/utils/getData.js +73 -73
  144. package/utils/getFile.js +40 -40
  145. package/utils/getImage.js +153 -153
  146. package/utils/getTime.js +106 -106
  147. package/utils/index.js +61 -61
  148. package/utils/loading.js +15 -15
  149. package/utils/notify.js +13 -13
  150. package/utils/previewImage.js +10 -10
  151. package/utils/price.js +18 -18
  152. package/utils/symbols.js +18 -18
  153. package/utils/timestamp.js +18 -18
  154. package/utils/toast.js +13 -13
  155. package/utils/uploader/aliyun.js +6 -6
  156. package/utils/uploader/local.js +8 -8
  157. package/utils/uploader/qiniu.js +321 -321
  158. package/utils/uploader.js +1059 -1059
  159. package/utils/useAuth.js +30 -30
  160. package/utils/useRouter.js +47 -47
  161. package/utils/useSearch.js +0 -6
  162. package/utils/useUploader.js +53 -53
package/utils/$tree.js CHANGED
@@ -1,713 +1,713 @@
1
- import $n_has from 'lodash/has'
2
- import $n_get from 'lodash/get'
3
- import $n_isNil from 'lodash/isNil'
4
- import $n_findIndex from 'lodash/findIndex'
5
- import $n_cloneDeep from 'lodash/cloneDeep'
6
-
7
- import $n_router from '@netang/utils/vue/router'
8
-
9
- import $n_isValidArray from '@netang/utils/isValidArray'
10
- import $n_isValidObject from '@netang/utils/isValidObject'
11
- import $n_isValidString from '@netang/utils/isValidString'
12
- import $n_hasId from '@netang/utils/hasId'
13
- import $n_http from '@netang/utils/http'
14
- import $n_run from '@netang/utils/run'
15
- import $n_storage from '@netang/utils/storage'
16
-
17
- import $n_toast from './toast'
18
- import $n_confirm from './confirm'
19
- import $n_dialog from './dialog'
20
- import $n_alert from './alert'
21
-
22
- import { isRef, watch, inject, ref } from 'vue'
23
-
24
- import { NPowerKey } from './symbols'
25
-
26
- /**
27
- * 获取节点
28
- */
29
- function getTreeNode(data, nodeId) {
30
- for (const item of data) {
31
-
32
- if (item.id === nodeId) {
33
- return item
34
- }
35
-
36
- // 如果是父节点
37
- if (item.children.length) {
38
- const res = getTreeNode(item.children, nodeId)
39
- if (res) {
40
- return res
41
- }
42
- }
43
- }
44
-
45
- return false
46
- }
47
-
48
- /**
49
- * 获取子节点
50
- */
51
- function getChildren(data, callback) {
52
- for (const item of data) {
53
- if ($n_run(callback)(item) === false) {
54
- return false
55
- }
56
- // 如果是父节点
57
- if (item.children.length) {
58
- const res = getChildren(item.children, callback)
59
- if (res === false) {
60
- return false
61
- }
62
- }
63
- }
64
- return true
65
- }
66
-
67
- /**
68
- * 创建树实例
69
- */
70
- function create(options) {
71
-
72
- const {
73
- // 路由路径
74
- path,
75
- // 路由参数
76
- query,
77
- // 树节点列表
78
- nodes,
79
- // 树展开节点
80
- expanded,
81
- // 原始表单数据
82
- rawFormData,
83
- // 表单数据
84
- formData,
85
- // 重新加载
86
- reload,
87
- // 是否开启展开节点缓存
88
- cache,
89
- } = Object.assign({
90
- // 路由路径
91
- path: '',
92
- // 路由参数
93
- query: {},
94
- // 是否开启展开节点缓存
95
- cache: false,
96
- }, options)
97
-
98
- // 获取权限注入
99
- const $power = $n_has(options, '$power') ? options.$power : inject(NPowerKey)
100
- const hasPowr = !! $power
101
-
102
- // 获取权限路由
103
- const $route = $n_isValidString(path) ?
104
- // 如果为自定义路由
105
- $n_router.resolve({
106
- path,
107
- query,
108
- })
109
- // 否则获取当前路由
110
- : (hasPowr ? $power.getRoute() : $n_router.getRoute())
111
-
112
- // 权限按钮
113
- const powerBtns = hasPowr ? $power.powerBtns : ref([])
114
-
115
- // 是否有展开节点
116
- const hasExpanded = ! $n_isNil(expanded) && isRef(expanded)
117
-
118
- // 如果开启展开节点缓存
119
- if (hasExpanded && cache) {
120
-
121
- // 设置树展开节点初始缓存
122
- expanded.value = getExpandedCache(expanded.value)
123
-
124
- /**
125
- * 监听树展开节点
126
- */
127
- watch(expanded, function(val) {
128
- // 设置树展开节点缓存
129
- setExpandedCache(val)
130
- })
131
- }
132
-
133
- /**
134
- * 获取节点
135
- */
136
- function getNode(nodeId) {
137
- return getTreeNode(nodes.value, nodeId)
138
- }
139
-
140
- /**
141
- * 格式化节点
142
- */
143
- function formatNode(attr) {
144
-
145
- // 设置属性
146
- attr = Object.assign({}, attr)
147
-
148
- return {
149
- attr,
150
- id: attr.id,
151
- label: attr.title,
152
- children: [],
153
- }
154
- }
155
-
156
- /**
157
- * 更新节点
158
- */
159
- function updateNode(data) {
160
-
161
- // 获取 id
162
- const id = $n_get(formData.value, 'id')
163
-
164
- // 更新表单数据
165
- formData.value = Object.assign({}, formData.value, data)
166
-
167
- // 获取节点数据
168
- const nodeItem = getNode(data.id)
169
-
170
- // 如果为更新节点
171
- if (id) {
172
- if (nodeItem) {
173
- Object.assign(nodeItem, {
174
- attr: Object.assign({}, formData.value),
175
- label: formData.value.title,
176
- })
177
- }
178
-
179
- // 否则为新增节点
180
- } else if (
181
- // 如果为新增节点
182
- $n_get(data, 'id')
183
- // 没有节点存在
184
- && ! nodeItem
185
- ) {
186
- // 获取父级节点
187
- const parentNodeItem = getNode(formData.value.pid)
188
- if (! parentNodeItem) {
189
- return
190
- }
191
-
192
- // 新增节点
193
- parentNodeItem.children.push(formatNode(formData.value))
194
- }
195
- }
196
-
197
- /**
198
- * 删除节点
199
- */
200
- function deleteNode({ id, attr }) {
201
-
202
- // 获取父节点数据
203
- const parentNodeItem = getNode(attr.pid)
204
- if (! parentNodeItem) {
205
- return
206
- }
207
-
208
- // 获取节点索引
209
- const nodeIndex = $n_findIndex(parentNodeItem.children, { id })
210
- if (nodeIndex > -1) {
211
- parentNodeItem.children.splice(nodeIndex, 1)
212
- }
213
- }
214
-
215
- /**
216
- * 获取菜单状态
217
- */
218
- function getMenuStatus(options) {
219
-
220
- const o = Object.assign({
221
- updateName: 'update',
222
- moveName: 'move',
223
- copyName: 'copy',
224
- deleteName: 'realdel',
225
- statusName: 'status'
226
- }, options)
227
-
228
- const maps = {}
229
- maps[o.updateName] = 'update'
230
- maps[o.moveName] = 'move'
231
- maps[o.copyName] = 'copy'
232
- maps[o.deleteName] = 'delete'
233
- maps[o.statusName] = 'status'
234
-
235
- const allPowerBtn = {}
236
- for (const item of powerBtns.value) {
237
- if ($n_has(maps, $n_get(item, 'name'))) {
238
- allPowerBtn[maps[item.name]] = item
239
- }
240
- }
241
-
242
- return {
243
- all: $n_isValidObject(allPowerBtn),
244
- update: $n_has(allPowerBtn, 'update'),
245
- move: $n_has(allPowerBtn, 'move'),
246
- copy: $n_has(allPowerBtn, 'copy'),
247
- delete: $n_has(allPowerBtn, 'delete'),
248
- status: $n_has(allPowerBtn, 'status'),
249
- allPowerBtn,
250
- }
251
- }
252
-
253
- /**
254
- * 确认菜单
255
- */
256
- function confirmMenu(callback) {
257
- // 确认框
258
- $n_confirm({
259
- message: '确认要执行该操作吗?',
260
- })
261
- // 点击确认执行
262
- .onOk(callback)
263
- }
264
-
265
- /**
266
- * 菜单点击
267
- */
268
- function menuClick(options) {
269
-
270
- // 参数
271
- const o = Object.assign({
272
- // 菜单类型
273
- type: '',
274
- // 节点
275
- node: null,
276
- }, options)
277
-
278
- // 菜单类型
279
- switch (o.type) {
280
-
281
- // 添加下级
282
- case 'update':
283
- // 更新表单数据
284
- formData.value = Object.assign({}, rawFormData, {
285
- pid: o.node.attr.id,
286
- })
287
- break
288
-
289
- // 移至节点上
290
- case 'moveUp':
291
- // 移至节点内
292
- case 'moveIn':
293
- // 移至节点下
294
- case 'moveDown':
295
-
296
- if (! $n_get(o.menuStatus, 'value.allPowerBtn.move.url')) {
297
- console.error('没有找到复制地址')
298
- return
299
- }
300
-
301
- // 创建对话框
302
- $n_dialog.create({
303
- // 标题
304
- title: `移动至节点的${o.type === 'moveUp' ? '上方' : (o.type === 'moveDown' ? '下方' : '内部')}`,
305
- // 宽度
306
- width: 500,
307
- // 组件标识
308
- name: 'moveToTree',
309
- // 组件参数
310
- props: {
311
- // 树节点列表
312
- nodes,
313
- // 树展开节点
314
- expanded,
315
- },
316
- // 显示取消按钮
317
- cancel: true,
318
- // 点击确认执行
319
- async onConfirm({ value: moveNodeId }) {
320
-
321
- // 是否为正确的 id
322
- if (! $n_hasId(moveNodeId)) {
323
- $n_toast({
324
- message: '请选择节点',
325
- })
326
- return false
327
- }
328
-
329
- // 如果节点是自己
330
- if (moveNodeId === o.node.id) {
331
- $n_toast({
332
- message: '不能选择当前节点',
333
- })
334
- return false
335
- }
336
-
337
- // 获取需移动至的节点
338
- const moveNodeItem = getNode(moveNodeId)
339
- if (! moveNodeItem) {
340
- $n_alert({
341
- message: '移动至的节点不存在',
342
- })
343
- return false
344
- }
345
-
346
- // 克隆当前树列表数据
347
- const nodesClone = $n_cloneDeep(nodes.value)
348
-
349
- // 获取当前节点
350
- const nodeItem = getNode(o.node.id)
351
-
352
- // 获取当前节点的父节点
353
- const parentNodeItem = getNode(o.node.attr.pid)
354
-
355
- // 移动列表数据
356
- const moveLists = []
357
-
358
- // 如果是移动至节点内部
359
- // --------------------------------------------------
360
- if (o.type === 'moveIn') {
361
-
362
- // 修改当前节点数据
363
- nodeItem.attr.pid = moveNodeItem.attr.id
364
- // console.log('moveNodeItem.children', moveNodeItem.children)
365
-
366
- nodeItem.attr.sort =
367
- // 如果移动至的节点有子节点
368
- moveNodeItem.children.length
369
- // 则获取移动至的节点中最后一个子节点的排序号 + 1
370
- ? moveNodeItem.children[moveNodeItem.children.length - 1].attr.sort + 1
371
- // 否则排序号设为 1
372
- : 1
373
-
374
- // 添加移动列表数据
375
- moveLists.push({
376
- id: nodeItem.id,
377
- pid: nodeItem.attr.pid,
378
- sort: nodeItem.attr.sort,
379
- })
380
-
381
- // 将本节点从原父节点中删除
382
- const nodeItemIndex = $n_findIndex(parentNodeItem.children, { id: nodeItem.id })
383
- parentNodeItem.children.splice(nodeItemIndex, 1)
384
-
385
- // 将本节点添加至移动至的节点的子节点中
386
- moveNodeItem.children.push(nodeItem)
387
-
388
- // 否则移动至节点的上方/下方
389
- // --------------------------------------------------
390
- } else {
391
-
392
- // 获取移动至节点的父节点
393
- let moveParentNodeItem = getNode(moveNodeItem.attr.pid)
394
-
395
- // 修改当前节点数据
396
- nodeItem.attr.pid = moveNodeItem.attr.pid
397
- nodeItem.attr.sort = moveNodeItem.attr.sort + (o.type === 'moveUp' ? 0 : 1)
398
-
399
- // 添加移动列表数据
400
- moveLists.push({
401
- id: nodeItem.id,
402
- pid: nodeItem.attr.pid,
403
- sort: nodeItem.attr.sort,
404
- })
405
-
406
- // 将本节点从原父节点中删除
407
- const nodeItemIndex = $n_findIndex(parentNodeItem.children, { id: nodeItem.id })
408
- parentNodeItem.children.splice(nodeItemIndex, 1)
409
-
410
- // 获取移动至节点的索引
411
- const moveNodeItemIndex = $n_findIndex(moveParentNodeItem.children, { id: moveNodeId })
412
-
413
- for (let i = moveNodeItemIndex + (o.type === 'moveUp' ? 0 : 1); i < moveParentNodeItem.children.length; i++) {
414
- const item = moveParentNodeItem.children[i]
415
- item.attr.sort = item.attr.sort + 1
416
- moveLists.push({
417
- id: item.id,
418
- pid: item.attr.pid,
419
- sort: item.attr.sort,
420
- })
421
- }
422
-
423
- // 将本节点插入移动至位置
424
- moveParentNodeItem.children.splice(moveNodeItemIndex + (o.type === 'moveUp' ? 0 : 1), 0, nodeItem)
425
- }
426
-
427
- // 请求 - 移动
428
- const { status } = await $n_http({
429
- url: o.menuStatus.value.allPowerBtn.move.url,
430
- data: {
431
- data: moveLists,
432
- },
433
- })
434
- if (! status) {
435
- // 移动失败, 还原数据
436
- nodes.value = nodesClone
437
- return false
438
- }
439
- },
440
- })
441
- break
442
-
443
- // 复制
444
- case 'copy':
445
- // 确认菜单
446
- confirmMenu(async function() {
447
-
448
- if (! $n_get(o.menuStatus, 'value.allPowerBtn.copy.url')) {
449
- console.error('没有找到复制地址')
450
- return
451
- }
452
-
453
- // 复制的当前节点的属性
454
- const newAttr = Object.assign({}, o.node.attr, {
455
- title: '【复制】' + o.node.attr.title,
456
- })
457
-
458
- // 复制列表
459
- const copyLists = [ newAttr ]
460
-
461
- // 是否复制叶子节点
462
- const isLeafNode = ! o.node.children.length
463
-
464
- // 如果复制的是父级节点
465
- if (! isLeafNode) {
466
- getChildren(o.node.children, function(item) {
467
- copyLists.push(item.attr)
468
- })
469
- }
470
-
471
- // 请求 - 复制
472
- const { status, data: res } = await $n_http({
473
- url: o.menuStatus.value.allPowerBtn.copy.url,
474
- data: {
475
- data: copyLists,
476
- },
477
- })
478
- if (! status) {
479
- return
480
- }
481
-
482
- // 如果复制的是叶子节点
483
- if (isLeafNode) {
484
-
485
- // 如果返回了 id
486
- if ($n_hasId(res)) {
487
-
488
- // 更新数据
489
- Object.assign(newAttr, res)
490
-
491
- // 获取该叶子节点的父级节点
492
- const parentNodeItem = getNode(newAttr.pid)
493
- if (! parentNodeItem) {
494
- return
495
- }
496
-
497
- // 新增节点
498
- parentNodeItem.children.push(formatNode(newAttr))
499
-
500
- // 否则重新加载列表
501
- } else {
502
- reload()
503
- }
504
-
505
- // 否则重新加载列表
506
- } else {
507
- reload()
508
- }
509
-
510
- // 轻提示
511
- $n_toast({
512
- type: 'positive',
513
- message: '复制成功',
514
- })
515
- })
516
- break
517
-
518
- // 删除
519
- case 'delete':
520
-
521
- // 如果有子节点
522
- if (o.node.children.length) {
523
- // 提示框
524
- $n_alert({
525
- message: '请先删除该节点下的子节点',
526
- })
527
- return
528
- }
529
-
530
- if (! $n_get(o.menuStatus, 'value.allPowerBtn.delete.url')) {
531
- console.error('没有找到删除地址')
532
- return
533
- }
534
-
535
- // 确认菜单
536
- confirmMenu(async function() {
537
-
538
- // 请求 - 删除
539
- const { status } = await $n_http({
540
- url: o.menuStatus.value.allPowerBtn.delete.url,
541
- data: {
542
- id: o.node.id,
543
- },
544
- })
545
- if (! status) {
546
- return
547
- }
548
-
549
- // 删除节点
550
- deleteNode(o.node)
551
-
552
- // 轻提示
553
- $n_toast({
554
- type: 'positive',
555
- message: '删除成功',
556
- })
557
- })
558
- break
559
-
560
- // 全部禁用
561
- case 'statusDisable':
562
- // 全部正常
563
- case 'statusNormal':
564
-
565
- if (! $n_get(o.menuStatus, 'value.allPowerBtn.status.url')) {
566
- console.error('没有找到状态地址')
567
- return
568
- }
569
-
570
- // 确认菜单
571
- confirmMenu(async function() {
572
-
573
- // 设置状态 ids
574
- const statusIds = [ o.node.id ]
575
-
576
- // 新状态
577
- const newStatus = o.type === 'statusNormal' ? 1 : 0
578
-
579
- // 是否叶子节点
580
- const isLeafNode = ! o.node.children.length
581
-
582
- // 如果复制的是父级节点
583
- if (! isLeafNode) {
584
- getChildren(o.node.children, function(item) {
585
- statusIds.push(item.id)
586
- })
587
- }
588
-
589
- // 请求 - 全部禁用/正常
590
- const { status } = await $n_http({
591
- url: o.menuStatus.value.allPowerBtn.status.url,
592
- data: {
593
- // ids
594
- ids: statusIds,
595
- // 新状态值
596
- status: newStatus,
597
- },
598
- })
599
- if (! status) {
600
- return
601
- }
602
-
603
- // 设置当前节点状态
604
- o.node.attr.status = newStatus
605
-
606
- // 如果是父级节点
607
- if (! isLeafNode) {
608
- getChildren(o.node.children, function(item) {
609
- item.attr.status = newStatus
610
- })
611
- }
612
-
613
- // 轻提示
614
- $n_toast({
615
- type: 'positive',
616
- message: '恭喜您,操作成功',
617
- })
618
- })
619
- break
620
- }
621
- }
622
-
623
- /**
624
- * 获取展开节点缓存
625
- */
626
- function getExpandedCache(defaultValue = []) {
627
- // 获取展开节点缓存
628
- const res = $n_storage.get('tree_expanded_' + $route.fullPath)
629
- return $n_isValidArray(res) ? res : defaultValue
630
- }
631
-
632
- /**
633
- * 设置展开节点缓存
634
- */
635
- function setExpandedCache(expanded) {
636
- // 设置展开节点缓存(永久缓存)
637
- $n_storage.set('tree_expanded_' + $route.fullPath, expanded, 0)
638
- }
639
-
640
- /**
641
- * 展开全部
642
- */
643
- function expandAll() {
644
-
645
- // 展开节点 ids
646
- const ids = []
647
-
648
- function getChildren(data) {
649
- for (const { id, children } of data) {
650
- ids.push(id)
651
- if ($n_isValidArray(children)) {
652
- getChildren(children)
653
- }
654
- }
655
- }
656
-
657
- if ($n_isValidArray(nodes.value)) {
658
- getChildren(nodes.value)
659
- }
660
-
661
- // 设置展开节点数组
662
- expanded.value = ids
663
- }
664
-
665
- /**
666
- * 收起全部
667
- */
668
- function collapseAll() {
669
- // 设置展开节点数组
670
- expanded.value = [0]
671
- }
672
-
673
- return {
674
- // 当前路由全路径
675
- routeFullPath: $route.fullPath,
676
- // 当前路由路径
677
- routePath: $route.path,
678
- // 当前路由参数
679
- routeQuery: $route.query,
680
- // 获取当前路由
681
- getRoute() {
682
- return $route
683
- },
684
- // 获取节点
685
- getNode,
686
- // 更新节点
687
- updateNode,
688
- // 删除节点
689
- deleteNode,
690
- // 获取菜单状态
691
- getMenuStatus,
692
- // 菜单点击
693
- menuClick,
694
- // 获取展开节点缓存
695
- getExpandedCache,
696
- // 设置展开节点缓存
697
- setExpandedCache,
698
- // 展开全部
699
- expandAll,
700
- // 收起全部
701
- collapseAll,
702
- }
703
- }
704
-
705
- /**
706
- * 树业务
707
- */
708
- const $tree = {
709
- // 创建树实例
710
- create,
711
- }
712
-
713
- export default $tree
1
+ import $n_has from 'lodash/has'
2
+ import $n_get from 'lodash/get'
3
+ import $n_isNil from 'lodash/isNil'
4
+ import $n_findIndex from 'lodash/findIndex'
5
+ import $n_cloneDeep from 'lodash/cloneDeep'
6
+
7
+ import $n_router from '@netang/utils/vue/router'
8
+
9
+ import $n_isValidArray from '@netang/utils/isValidArray'
10
+ import $n_isValidObject from '@netang/utils/isValidObject'
11
+ import $n_isValidString from '@netang/utils/isValidString'
12
+ import $n_hasId from '@netang/utils/hasId'
13
+ import $n_http from '@netang/utils/http'
14
+ import $n_run from '@netang/utils/run'
15
+ import $n_storage from '@netang/utils/storage'
16
+
17
+ import $n_toast from './toast'
18
+ import $n_confirm from './confirm'
19
+ import $n_dialog from './dialog'
20
+ import $n_alert from './alert'
21
+
22
+ import { isRef, watch, inject, ref } from 'vue'
23
+
24
+ import { NPowerKey } from './symbols'
25
+
26
+ /**
27
+ * 获取节点
28
+ */
29
+ function getTreeNode(data, nodeId) {
30
+ for (const item of data) {
31
+
32
+ if (item.id === nodeId) {
33
+ return item
34
+ }
35
+
36
+ // 如果是父节点
37
+ if (item.children.length) {
38
+ const res = getTreeNode(item.children, nodeId)
39
+ if (res) {
40
+ return res
41
+ }
42
+ }
43
+ }
44
+
45
+ return false
46
+ }
47
+
48
+ /**
49
+ * 获取子节点
50
+ */
51
+ function getChildren(data, callback) {
52
+ for (const item of data) {
53
+ if ($n_run(callback)(item) === false) {
54
+ return false
55
+ }
56
+ // 如果是父节点
57
+ if (item.children.length) {
58
+ const res = getChildren(item.children, callback)
59
+ if (res === false) {
60
+ return false
61
+ }
62
+ }
63
+ }
64
+ return true
65
+ }
66
+
67
+ /**
68
+ * 创建树实例
69
+ */
70
+ function create(options) {
71
+
72
+ const {
73
+ // 路由路径
74
+ path,
75
+ // 路由参数
76
+ query,
77
+ // 树节点列表
78
+ nodes,
79
+ // 树展开节点
80
+ expanded,
81
+ // 原始表单数据
82
+ rawFormData,
83
+ // 表单数据
84
+ formData,
85
+ // 重新加载
86
+ reload,
87
+ // 是否开启展开节点缓存
88
+ cache,
89
+ } = Object.assign({
90
+ // 路由路径
91
+ path: '',
92
+ // 路由参数
93
+ query: {},
94
+ // 是否开启展开节点缓存
95
+ cache: false,
96
+ }, options)
97
+
98
+ // 获取权限注入
99
+ const $power = $n_has(options, '$power') ? options.$power : inject(NPowerKey)
100
+ const hasPowr = !! $power
101
+
102
+ // 获取权限路由
103
+ const $route = $n_isValidString(path) ?
104
+ // 如果为自定义路由
105
+ $n_router.resolve({
106
+ path,
107
+ query,
108
+ })
109
+ // 否则获取当前路由
110
+ : (hasPowr ? $power.getRoute() : $n_router.getRoute())
111
+
112
+ // 权限按钮
113
+ const powerBtns = hasPowr ? $power.powerBtns : ref([])
114
+
115
+ // 是否有展开节点
116
+ const hasExpanded = ! $n_isNil(expanded) && isRef(expanded)
117
+
118
+ // 如果开启展开节点缓存
119
+ if (hasExpanded && cache) {
120
+
121
+ // 设置树展开节点初始缓存
122
+ expanded.value = getExpandedCache(expanded.value)
123
+
124
+ /**
125
+ * 监听树展开节点
126
+ */
127
+ watch(expanded, function(val) {
128
+ // 设置树展开节点缓存
129
+ setExpandedCache(val)
130
+ })
131
+ }
132
+
133
+ /**
134
+ * 获取节点
135
+ */
136
+ function getNode(nodeId) {
137
+ return getTreeNode(nodes.value, nodeId)
138
+ }
139
+
140
+ /**
141
+ * 格式化节点
142
+ */
143
+ function formatNode(attr) {
144
+
145
+ // 设置属性
146
+ attr = Object.assign({}, attr)
147
+
148
+ return {
149
+ attr,
150
+ id: attr.id,
151
+ label: attr.title,
152
+ children: [],
153
+ }
154
+ }
155
+
156
+ /**
157
+ * 更新节点
158
+ */
159
+ function updateNode(data) {
160
+
161
+ // 获取 id
162
+ const id = $n_get(formData.value, 'id')
163
+
164
+ // 更新表单数据
165
+ formData.value = Object.assign({}, formData.value, data)
166
+
167
+ // 获取节点数据
168
+ const nodeItem = getNode(data.id)
169
+
170
+ // 如果为更新节点
171
+ if (id) {
172
+ if (nodeItem) {
173
+ Object.assign(nodeItem, {
174
+ attr: Object.assign({}, formData.value),
175
+ label: formData.value.title,
176
+ })
177
+ }
178
+
179
+ // 否则为新增节点
180
+ } else if (
181
+ // 如果为新增节点
182
+ $n_get(data, 'id')
183
+ // 没有节点存在
184
+ && ! nodeItem
185
+ ) {
186
+ // 获取父级节点
187
+ const parentNodeItem = getNode(formData.value.pid)
188
+ if (! parentNodeItem) {
189
+ return
190
+ }
191
+
192
+ // 新增节点
193
+ parentNodeItem.children.push(formatNode(formData.value))
194
+ }
195
+ }
196
+
197
+ /**
198
+ * 删除节点
199
+ */
200
+ function deleteNode({ id, attr }) {
201
+
202
+ // 获取父节点数据
203
+ const parentNodeItem = getNode(attr.pid)
204
+ if (! parentNodeItem) {
205
+ return
206
+ }
207
+
208
+ // 获取节点索引
209
+ const nodeIndex = $n_findIndex(parentNodeItem.children, { id })
210
+ if (nodeIndex > -1) {
211
+ parentNodeItem.children.splice(nodeIndex, 1)
212
+ }
213
+ }
214
+
215
+ /**
216
+ * 获取菜单状态
217
+ */
218
+ function getMenuStatus(options) {
219
+
220
+ const o = Object.assign({
221
+ updateName: 'update',
222
+ moveName: 'move',
223
+ copyName: 'copy',
224
+ deleteName: 'realdel',
225
+ statusName: 'status'
226
+ }, options)
227
+
228
+ const maps = {}
229
+ maps[o.updateName] = 'update'
230
+ maps[o.moveName] = 'move'
231
+ maps[o.copyName] = 'copy'
232
+ maps[o.deleteName] = 'delete'
233
+ maps[o.statusName] = 'status'
234
+
235
+ const allPowerBtn = {}
236
+ for (const item of powerBtns.value) {
237
+ if ($n_has(maps, $n_get(item, 'name'))) {
238
+ allPowerBtn[maps[item.name]] = item
239
+ }
240
+ }
241
+
242
+ return {
243
+ all: $n_isValidObject(allPowerBtn),
244
+ update: $n_has(allPowerBtn, 'update'),
245
+ move: $n_has(allPowerBtn, 'move'),
246
+ copy: $n_has(allPowerBtn, 'copy'),
247
+ delete: $n_has(allPowerBtn, 'delete'),
248
+ status: $n_has(allPowerBtn, 'status'),
249
+ allPowerBtn,
250
+ }
251
+ }
252
+
253
+ /**
254
+ * 确认菜单
255
+ */
256
+ function confirmMenu(callback) {
257
+ // 确认框
258
+ $n_confirm({
259
+ message: '确认要执行该操作吗?',
260
+ })
261
+ // 点击确认执行
262
+ .onOk(callback)
263
+ }
264
+
265
+ /**
266
+ * 菜单点击
267
+ */
268
+ function menuClick(options) {
269
+
270
+ // 参数
271
+ const o = Object.assign({
272
+ // 菜单类型
273
+ type: '',
274
+ // 节点
275
+ node: null,
276
+ }, options)
277
+
278
+ // 菜单类型
279
+ switch (o.type) {
280
+
281
+ // 添加下级
282
+ case 'update':
283
+ // 更新表单数据
284
+ formData.value = Object.assign({}, rawFormData, {
285
+ pid: o.node.attr.id,
286
+ })
287
+ break
288
+
289
+ // 移至节点上
290
+ case 'moveUp':
291
+ // 移至节点内
292
+ case 'moveIn':
293
+ // 移至节点下
294
+ case 'moveDown':
295
+
296
+ if (! $n_get(o.menuStatus, 'value.allPowerBtn.move.url')) {
297
+ console.error('没有找到复制地址')
298
+ return
299
+ }
300
+
301
+ // 创建对话框
302
+ $n_dialog.create({
303
+ // 标题
304
+ title: `移动至节点的${o.type === 'moveUp' ? '上方' : (o.type === 'moveDown' ? '下方' : '内部')}`,
305
+ // 宽度
306
+ width: 500,
307
+ // 组件标识
308
+ name: 'moveToTree',
309
+ // 组件参数
310
+ props: {
311
+ // 树节点列表
312
+ nodes,
313
+ // 树展开节点
314
+ expanded,
315
+ },
316
+ // 显示取消按钮
317
+ cancel: true,
318
+ // 点击确认执行
319
+ async onConfirm({ value: moveNodeId }) {
320
+
321
+ // 是否为正确的 id
322
+ if (! $n_hasId(moveNodeId)) {
323
+ $n_toast({
324
+ message: '请选择节点',
325
+ })
326
+ return false
327
+ }
328
+
329
+ // 如果节点是自己
330
+ if (moveNodeId === o.node.id) {
331
+ $n_toast({
332
+ message: '不能选择当前节点',
333
+ })
334
+ return false
335
+ }
336
+
337
+ // 获取需移动至的节点
338
+ const moveNodeItem = getNode(moveNodeId)
339
+ if (! moveNodeItem) {
340
+ $n_alert({
341
+ message: '移动至的节点不存在',
342
+ })
343
+ return false
344
+ }
345
+
346
+ // 克隆当前树列表数据
347
+ const nodesClone = $n_cloneDeep(nodes.value)
348
+
349
+ // 获取当前节点
350
+ const nodeItem = getNode(o.node.id)
351
+
352
+ // 获取当前节点的父节点
353
+ const parentNodeItem = getNode(o.node.attr.pid)
354
+
355
+ // 移动列表数据
356
+ const moveLists = []
357
+
358
+ // 如果是移动至节点内部
359
+ // --------------------------------------------------
360
+ if (o.type === 'moveIn') {
361
+
362
+ // 修改当前节点数据
363
+ nodeItem.attr.pid = moveNodeItem.attr.id
364
+ // console.log('moveNodeItem.children', moveNodeItem.children)
365
+
366
+ nodeItem.attr.sort =
367
+ // 如果移动至的节点有子节点
368
+ moveNodeItem.children.length
369
+ // 则获取移动至的节点中最后一个子节点的排序号 + 1
370
+ ? moveNodeItem.children[moveNodeItem.children.length - 1].attr.sort + 1
371
+ // 否则排序号设为 1
372
+ : 1
373
+
374
+ // 添加移动列表数据
375
+ moveLists.push({
376
+ id: nodeItem.id,
377
+ pid: nodeItem.attr.pid,
378
+ sort: nodeItem.attr.sort,
379
+ })
380
+
381
+ // 将本节点从原父节点中删除
382
+ const nodeItemIndex = $n_findIndex(parentNodeItem.children, { id: nodeItem.id })
383
+ parentNodeItem.children.splice(nodeItemIndex, 1)
384
+
385
+ // 将本节点添加至移动至的节点的子节点中
386
+ moveNodeItem.children.push(nodeItem)
387
+
388
+ // 否则移动至节点的上方/下方
389
+ // --------------------------------------------------
390
+ } else {
391
+
392
+ // 获取移动至节点的父节点
393
+ let moveParentNodeItem = getNode(moveNodeItem.attr.pid)
394
+
395
+ // 修改当前节点数据
396
+ nodeItem.attr.pid = moveNodeItem.attr.pid
397
+ nodeItem.attr.sort = moveNodeItem.attr.sort + (o.type === 'moveUp' ? 0 : 1)
398
+
399
+ // 添加移动列表数据
400
+ moveLists.push({
401
+ id: nodeItem.id,
402
+ pid: nodeItem.attr.pid,
403
+ sort: nodeItem.attr.sort,
404
+ })
405
+
406
+ // 将本节点从原父节点中删除
407
+ const nodeItemIndex = $n_findIndex(parentNodeItem.children, { id: nodeItem.id })
408
+ parentNodeItem.children.splice(nodeItemIndex, 1)
409
+
410
+ // 获取移动至节点的索引
411
+ const moveNodeItemIndex = $n_findIndex(moveParentNodeItem.children, { id: moveNodeId })
412
+
413
+ for (let i = moveNodeItemIndex + (o.type === 'moveUp' ? 0 : 1); i < moveParentNodeItem.children.length; i++) {
414
+ const item = moveParentNodeItem.children[i]
415
+ item.attr.sort = item.attr.sort + 1
416
+ moveLists.push({
417
+ id: item.id,
418
+ pid: item.attr.pid,
419
+ sort: item.attr.sort,
420
+ })
421
+ }
422
+
423
+ // 将本节点插入移动至位置
424
+ moveParentNodeItem.children.splice(moveNodeItemIndex + (o.type === 'moveUp' ? 0 : 1), 0, nodeItem)
425
+ }
426
+
427
+ // 请求 - 移动
428
+ const { status } = await $n_http({
429
+ url: o.menuStatus.value.allPowerBtn.move.url,
430
+ data: {
431
+ data: moveLists,
432
+ },
433
+ })
434
+ if (! status) {
435
+ // 移动失败, 还原数据
436
+ nodes.value = nodesClone
437
+ return false
438
+ }
439
+ },
440
+ })
441
+ break
442
+
443
+ // 复制
444
+ case 'copy':
445
+ // 确认菜单
446
+ confirmMenu(async function() {
447
+
448
+ if (! $n_get(o.menuStatus, 'value.allPowerBtn.copy.url')) {
449
+ console.error('没有找到复制地址')
450
+ return
451
+ }
452
+
453
+ // 复制的当前节点的属性
454
+ const newAttr = Object.assign({}, o.node.attr, {
455
+ title: '【复制】' + o.node.attr.title,
456
+ })
457
+
458
+ // 复制列表
459
+ const copyLists = [ newAttr ]
460
+
461
+ // 是否复制叶子节点
462
+ const isLeafNode = ! o.node.children.length
463
+
464
+ // 如果复制的是父级节点
465
+ if (! isLeafNode) {
466
+ getChildren(o.node.children, function(item) {
467
+ copyLists.push(item.attr)
468
+ })
469
+ }
470
+
471
+ // 请求 - 复制
472
+ const { status, data: res } = await $n_http({
473
+ url: o.menuStatus.value.allPowerBtn.copy.url,
474
+ data: {
475
+ data: copyLists,
476
+ },
477
+ })
478
+ if (! status) {
479
+ return
480
+ }
481
+
482
+ // 如果复制的是叶子节点
483
+ if (isLeafNode) {
484
+
485
+ // 如果返回了 id
486
+ if ($n_hasId(res)) {
487
+
488
+ // 更新数据
489
+ Object.assign(newAttr, res)
490
+
491
+ // 获取该叶子节点的父级节点
492
+ const parentNodeItem = getNode(newAttr.pid)
493
+ if (! parentNodeItem) {
494
+ return
495
+ }
496
+
497
+ // 新增节点
498
+ parentNodeItem.children.push(formatNode(newAttr))
499
+
500
+ // 否则重新加载列表
501
+ } else {
502
+ reload()
503
+ }
504
+
505
+ // 否则重新加载列表
506
+ } else {
507
+ reload()
508
+ }
509
+
510
+ // 轻提示
511
+ $n_toast({
512
+ type: 'positive',
513
+ message: '复制成功',
514
+ })
515
+ })
516
+ break
517
+
518
+ // 删除
519
+ case 'delete':
520
+
521
+ // 如果有子节点
522
+ if (o.node.children.length) {
523
+ // 提示框
524
+ $n_alert({
525
+ message: '请先删除该节点下的子节点',
526
+ })
527
+ return
528
+ }
529
+
530
+ if (! $n_get(o.menuStatus, 'value.allPowerBtn.delete.url')) {
531
+ console.error('没有找到删除地址')
532
+ return
533
+ }
534
+
535
+ // 确认菜单
536
+ confirmMenu(async function() {
537
+
538
+ // 请求 - 删除
539
+ const { status } = await $n_http({
540
+ url: o.menuStatus.value.allPowerBtn.delete.url,
541
+ data: {
542
+ id: o.node.id,
543
+ },
544
+ })
545
+ if (! status) {
546
+ return
547
+ }
548
+
549
+ // 删除节点
550
+ deleteNode(o.node)
551
+
552
+ // 轻提示
553
+ $n_toast({
554
+ type: 'positive',
555
+ message: '删除成功',
556
+ })
557
+ })
558
+ break
559
+
560
+ // 全部禁用
561
+ case 'statusDisable':
562
+ // 全部正常
563
+ case 'statusNormal':
564
+
565
+ if (! $n_get(o.menuStatus, 'value.allPowerBtn.status.url')) {
566
+ console.error('没有找到状态地址')
567
+ return
568
+ }
569
+
570
+ // 确认菜单
571
+ confirmMenu(async function() {
572
+
573
+ // 设置状态 ids
574
+ const statusIds = [ o.node.id ]
575
+
576
+ // 新状态
577
+ const newStatus = o.type === 'statusNormal' ? 1 : 0
578
+
579
+ // 是否叶子节点
580
+ const isLeafNode = ! o.node.children.length
581
+
582
+ // 如果复制的是父级节点
583
+ if (! isLeafNode) {
584
+ getChildren(o.node.children, function(item) {
585
+ statusIds.push(item.id)
586
+ })
587
+ }
588
+
589
+ // 请求 - 全部禁用/正常
590
+ const { status } = await $n_http({
591
+ url: o.menuStatus.value.allPowerBtn.status.url,
592
+ data: {
593
+ // ids
594
+ ids: statusIds,
595
+ // 新状态值
596
+ status: newStatus,
597
+ },
598
+ })
599
+ if (! status) {
600
+ return
601
+ }
602
+
603
+ // 设置当前节点状态
604
+ o.node.attr.status = newStatus
605
+
606
+ // 如果是父级节点
607
+ if (! isLeafNode) {
608
+ getChildren(o.node.children, function(item) {
609
+ item.attr.status = newStatus
610
+ })
611
+ }
612
+
613
+ // 轻提示
614
+ $n_toast({
615
+ type: 'positive',
616
+ message: '恭喜您,操作成功',
617
+ })
618
+ })
619
+ break
620
+ }
621
+ }
622
+
623
+ /**
624
+ * 获取展开节点缓存
625
+ */
626
+ function getExpandedCache(defaultValue = []) {
627
+ // 获取展开节点缓存
628
+ const res = $n_storage.get('tree_expanded_' + $route.fullPath)
629
+ return $n_isValidArray(res) ? res : defaultValue
630
+ }
631
+
632
+ /**
633
+ * 设置展开节点缓存
634
+ */
635
+ function setExpandedCache(expanded) {
636
+ // 设置展开节点缓存(永久缓存)
637
+ $n_storage.set('tree_expanded_' + $route.fullPath, expanded, 0)
638
+ }
639
+
640
+ /**
641
+ * 展开全部
642
+ */
643
+ function expandAll() {
644
+
645
+ // 展开节点 ids
646
+ const ids = []
647
+
648
+ function getChildren(data) {
649
+ for (const { id, children } of data) {
650
+ ids.push(id)
651
+ if ($n_isValidArray(children)) {
652
+ getChildren(children)
653
+ }
654
+ }
655
+ }
656
+
657
+ if ($n_isValidArray(nodes.value)) {
658
+ getChildren(nodes.value)
659
+ }
660
+
661
+ // 设置展开节点数组
662
+ expanded.value = ids
663
+ }
664
+
665
+ /**
666
+ * 收起全部
667
+ */
668
+ function collapseAll() {
669
+ // 设置展开节点数组
670
+ expanded.value = [0]
671
+ }
672
+
673
+ return {
674
+ // 当前路由全路径
675
+ routeFullPath: $route.fullPath,
676
+ // 当前路由路径
677
+ routePath: $route.path,
678
+ // 当前路由参数
679
+ routeQuery: $route.query,
680
+ // 获取当前路由
681
+ getRoute() {
682
+ return $route
683
+ },
684
+ // 获取节点
685
+ getNode,
686
+ // 更新节点
687
+ updateNode,
688
+ // 删除节点
689
+ deleteNode,
690
+ // 获取菜单状态
691
+ getMenuStatus,
692
+ // 菜单点击
693
+ menuClick,
694
+ // 获取展开节点缓存
695
+ getExpandedCache,
696
+ // 设置展开节点缓存
697
+ setExpandedCache,
698
+ // 展开全部
699
+ expandAll,
700
+ // 收起全部
701
+ collapseAll,
702
+ }
703
+ }
704
+
705
+ /**
706
+ * 树业务
707
+ */
708
+ const $tree = {
709
+ // 创建树实例
710
+ create,
711
+ }
712
+
713
+ export default $tree