@netang/quasar 0.0.53 → 0.0.55
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/_docs/docs/.vuepress/client.js +39 -0
- package/_docs/docs/.vuepress/components/test.vue +23 -0
- package/_docs/docs/.vuepress/config.js +40 -0
- package/_docs/docs/.vuepress/configs/index.js +2 -0
- package/_docs/docs/.vuepress/configs/navbar/index.js +1 -0
- package/_docs/docs/.vuepress/configs/navbar/zh.js +16 -0
- package/_docs/docs/.vuepress/configs/sidebar/index.js +1 -0
- package/_docs/docs/.vuepress/configs/sidebar/zh.js +20 -0
- package/_docs/docs/.vuepress/public/css/index.css +3 -0
- package/_docs/docs/.vuepress/styles/index.scss +3 -0
- package/_docs/docs/components/field-table.md +63 -0
- package/_docs/docs/components/field-tree.md +1 -0
- package/{docs → _docs}/docs/index.md +0 -0
- package/{docs → _docs}/docs/utils/alert.md +0 -0
- package/{docs → _docs}/docs/utils/confirm.md +0 -0
- package/_docs/docs/utils/index.md +1 -0
- package/_docs/package.json +17 -0
- package/components/column-title/index.vue +2 -2
- package/components/data/index.vue +20 -23
- package/components/dialog/index.vue +26 -12
- package/components/dialog-table/index.vue +4 -2
- package/components/dragger/index.vue +3 -2
- package/components/drawer/index.vue +16 -9
- package/components/editor-code/index.vue +12 -5
- package/components/empty/index.vue +16 -1
- package/components/field-date/index.vue +48 -36
- package/components/field-table/index.vue +69 -43
- package/components/field-text/index.vue +6 -2
- package/components/field-tree/index.vue +40 -22
- package/components/input-number/index.vue +5 -4
- package/components/list-menu/index.vue +14 -2
- package/components/power-page/index.vue +10 -0
- package/components/private/components/index.js +7 -2
- package/components/private/components/move-to-tree/index.vue +7 -3
- package/components/private/edit-power-data/index.vue +92 -52
- package/components/private/table-visible-columns-button/index.vue +6 -2
- package/components/render/index.vue +21 -7
- package/components/search/index.vue +30 -2
- package/components/search-item/index.vue +24 -8
- package/components/select/index.vue +5 -2
- package/components/splitter/index.vue +13 -9
- package/components/table/index.vue +32 -5
- package/components/table-pagination/index.vue +0 -1
- package/components/table-splitter/index.vue +22 -3
- package/components/table-summary/index.vue +10 -3
- package/components/thumbnail/index.vue +16 -6
- package/components/toolbar/index.vue +0 -2
- package/components/uploader/index.vue +5 -2
- package/components/uploader-query/index.vue +48 -27
- package/components/value-format/index.vue +19 -12
- package/configs/area3.js +1 -0
- package/docs/404.html +33 -0
- package/docs/assets/404.html-60b35caa.js +1 -0
- package/docs/assets/404.html-d1e63d77.js +1 -0
- package/docs/assets/alert.html-568d4e94.js +1 -0
- package/docs/assets/alert.html-f5dbc3e9.js +1 -0
- package/docs/assets/app-8c3ae4de.js +6 -0
- package/docs/assets/back-to-top-8efcbe56.svg +1 -0
- package/docs/assets/confirm.html-7a1566f6.js +1 -0
- package/docs/assets/confirm.html-96f1b004.js +1 -0
- package/docs/assets/field-table.html-68d610b0.js +1 -0
- package/docs/assets/field-table.html-86cc3511.js +1 -0
- package/docs/assets/field-tree.html-45410c3c.js +1 -0
- package/docs/assets/field-tree.html-c98ac993.js +1 -0
- package/docs/assets/framework-204010b2.js +5 -0
- package/docs/assets/index.html-1695dd7c.js +1 -0
- package/docs/assets/index.html-65a4aa67.js +1 -0
- package/docs/assets/style-ac5a9aa6.css +1 -0
- package/docs/components/field-table.html +33 -0
- package/docs/components/field-tree.html +33 -0
- package/docs/index.html +33 -0
- package/docs/utils/alert.html +33 -0
- package/docs/utils/confirm.html +33 -0
- package/package.json +1 -1
- package/package2.json +30 -0
- package/store/index.js +3 -20
- package/utils/alert.js +3 -1
- package/utils/area.js +27 -14
- package/utils/arr.js +6 -2
- package/utils/auth.js +40 -35
- package/utils/bus.js +1 -1
- package/utils/config.js +42 -15
- package/utils/{confrim.js → confirm.js} +1 -1
- package/utils/copy.js +18 -0
- package/utils/dialog.js +7 -3
- package/utils/dict.js +5 -28
- package/utils/dictOptions.js +24 -0
- package/utils/form.js +6 -2
- package/utils/getData.js +21 -9
- package/utils/getFile.js +11 -5
- package/utils/getImage.js +23 -12
- package/utils/getTime.js +9 -4
- package/utils/index.js +61 -0
- package/utils/loading.js +3 -1
- package/utils/notify.js +1 -1
- package/utils/power.js +164 -118
- package/utils/previewImage.js +4 -2
- package/utils/price.js +12 -3
- package/utils/rule.js +5 -9
- package/utils/ruleValid.js +10 -0
- package/utils/search.js +81 -50
- package/utils/table.js +119 -87
- package/utils/timestamp.js +2 -2
- package/utils/toast.js +1 -1
- package/utils/tree.js +69 -46
- package/utils/uploader/qiniu.js +31 -15
- package/utils/uploader.js +87 -56
- package/utils/useAuth.js +12 -5
- package/utils/useRouter.js +16 -5
- package/utils/useUploader.js +0 -5
- package/docs/docs/.vuepress/config.js +0 -32
- package/docs/docs/components/field-table.md +0 -1
- package/docs/docs/components/field-tree.md +0 -1
- package/docs/package.json +0 -11
- package/utils/http.js +0 -251
package/utils/power.js
CHANGED
|
@@ -1,9 +1,53 @@
|
|
|
1
1
|
import { provide, inject, ref, computed } from 'vue'
|
|
2
2
|
import { useQuasar } from 'quasar'
|
|
3
3
|
|
|
4
|
+
import $n_has from 'lodash/has'
|
|
5
|
+
import $n_get from 'lodash/get'
|
|
6
|
+
import $n_merge from 'lodash/merge'
|
|
7
|
+
import $n_filter from 'lodash/filter'
|
|
8
|
+
import $n_toLower from 'lodash/toLower'
|
|
9
|
+
import $n_isNumber from 'lodash/isNumber'
|
|
10
|
+
import $n_cloneDeep from 'lodash/cloneDeep'
|
|
11
|
+
import $n_isFunction from 'lodash/isFunction'
|
|
12
|
+
|
|
13
|
+
import $n_router from '@netang/vue-utils/router'
|
|
14
|
+
|
|
15
|
+
import $n_isValidArray from '@netang/utils/isValidArray'
|
|
16
|
+
import $n_isValidObject from '@netang/utils/isValidObject'
|
|
17
|
+
import $n_isValidString from '@netang/utils/isValidString'
|
|
18
|
+
import $n_isRequired from '@netang/utils/isRequired'
|
|
19
|
+
import $n_isNumeric from '@netang/utils/isNumeric'
|
|
20
|
+
import $n_forEach from '@netang/utils/forEach'
|
|
21
|
+
import $n_forIn from '@netang/utils/forIn'
|
|
22
|
+
import $n_slash from '@netang/utils/slash'
|
|
23
|
+
import $n_json from '@netang/utils/json'
|
|
24
|
+
import $n_join from '@netang/utils/join'
|
|
25
|
+
import $n_fail from '@netang/utils/fail'
|
|
26
|
+
import $n_success from '@netang/utils/success'
|
|
27
|
+
import $n_split from '@netang/utils/split'
|
|
28
|
+
import $n_trimString from '@netang/utils/trimString'
|
|
29
|
+
import $n_numberDeep from '@netang/utils/numberDeep'
|
|
30
|
+
import $n_indexOf from '@netang/utils/indexOf'
|
|
31
|
+
import $n_runAsync from '@netang/utils/runAsync'
|
|
32
|
+
import $n_run from '@netang/utils/run'
|
|
33
|
+
import $n_http from '@netang/utils/http'
|
|
34
|
+
|
|
4
35
|
import { statePower } from '../store'
|
|
5
36
|
import { NRenderKey, NPowerKey, NFormKey, NTableKey } from './symbols'
|
|
6
37
|
|
|
38
|
+
import $n_config from './config'
|
|
39
|
+
import $n_getData from './getData'
|
|
40
|
+
import $n_toast from './toast'
|
|
41
|
+
import $n_confirm from './confirm'
|
|
42
|
+
import $n_bus from './bus'
|
|
43
|
+
|
|
44
|
+
import { configs } from './config'
|
|
45
|
+
|
|
46
|
+
const {
|
|
47
|
+
// 字典常量
|
|
48
|
+
dicts,
|
|
49
|
+
} = configs
|
|
50
|
+
|
|
7
51
|
/**
|
|
8
52
|
* 创建权限实例
|
|
9
53
|
*/
|
|
@@ -49,14 +93,14 @@ function create(params) {
|
|
|
49
93
|
const hasRender = !! $render
|
|
50
94
|
if (hasRender) {
|
|
51
95
|
// 如果有权限传参, 则合并参数
|
|
52
|
-
const powerProps = $
|
|
53
|
-
if ($
|
|
54
|
-
$
|
|
96
|
+
const powerProps = $n_get($render, 'props.powerProps')
|
|
97
|
+
if ($n_isValidObject(powerProps)) {
|
|
98
|
+
$n_merge(o, powerProps)
|
|
55
99
|
}
|
|
56
100
|
}
|
|
57
101
|
|
|
58
102
|
// 获取当前路由
|
|
59
|
-
const $currentRoute = $
|
|
103
|
+
const $currentRoute = $n_router.getRoute()
|
|
60
104
|
|
|
61
105
|
// 权限路由
|
|
62
106
|
let $route
|
|
@@ -68,20 +112,20 @@ function create(params) {
|
|
|
68
112
|
$route = {
|
|
69
113
|
fullPath: '',
|
|
70
114
|
path: '',
|
|
71
|
-
query: $
|
|
115
|
+
query: $n_isValidObject(o.query) ? o.query : {},
|
|
72
116
|
}
|
|
73
117
|
|
|
74
118
|
// 如果有自定义路径
|
|
75
|
-
} else if ($
|
|
119
|
+
} else if ($n_isValidString(o.path)) {
|
|
76
120
|
|
|
77
121
|
// 获取自定义路由
|
|
78
|
-
$route = $
|
|
122
|
+
$route = $n_router.resolve({
|
|
79
123
|
path: o.path,
|
|
80
|
-
query: $
|
|
124
|
+
query: $n_isValidObject(o.query) ? o.query : {},
|
|
81
125
|
})
|
|
82
126
|
|
|
83
127
|
// 如果在渲染组件内 && 该渲染组件有自定义路由
|
|
84
|
-
} else if (hasRender && $
|
|
128
|
+
} else if (hasRender && $n_has($render, '$route')) {
|
|
85
129
|
|
|
86
130
|
// 设为渲染组件的路由
|
|
87
131
|
$route = $render.$route
|
|
@@ -206,13 +250,13 @@ function create(params) {
|
|
|
206
250
|
// 如果显示工具栏权限按钮
|
|
207
251
|
o.showToolbarPowerBtns
|
|
208
252
|
// 有权限按钮数据
|
|
209
|
-
&& $
|
|
253
|
+
&& $n_isValidArray(data.powerBtns.value)
|
|
210
254
|
) {
|
|
211
255
|
|
|
212
|
-
const lists = $
|
|
256
|
+
const lists = $n_filter(formatBtns(data.powerBtns.value), e => e.type > 2)
|
|
213
257
|
|
|
214
258
|
// 格式化权限按钮列表
|
|
215
|
-
$
|
|
259
|
+
$n_forEach(lists, function(item) {
|
|
216
260
|
|
|
217
261
|
if (! item.hidden) {
|
|
218
262
|
|
|
@@ -226,7 +270,7 @@ function create(params) {
|
|
|
226
270
|
item.show = false
|
|
227
271
|
|
|
228
272
|
// 如果有表格选中数据
|
|
229
|
-
if ($
|
|
273
|
+
if ($n_isValidArray(data.tableSelected.value)) {
|
|
230
274
|
// 如果是单个显示
|
|
231
275
|
if (isSingle) {
|
|
232
276
|
item.show = data.tableSelected.value.length === 1
|
|
@@ -313,7 +357,7 @@ function create(params) {
|
|
|
313
357
|
function setData(data) {
|
|
314
358
|
|
|
315
359
|
// 如果没有角色数据
|
|
316
|
-
if (! $
|
|
360
|
+
if (! $n_isValidObject(data)) {
|
|
317
361
|
return
|
|
318
362
|
}
|
|
319
363
|
|
|
@@ -322,7 +366,7 @@ function setData(data) {
|
|
|
322
366
|
v,
|
|
323
367
|
} = data
|
|
324
368
|
|
|
325
|
-
if (! $
|
|
369
|
+
if (! $n_isValidArray(rows) || ! v) {
|
|
326
370
|
return
|
|
327
371
|
}
|
|
328
372
|
|
|
@@ -340,9 +384,9 @@ function setData(data) {
|
|
|
340
384
|
// 【格式化 start】
|
|
341
385
|
// --------------------------------------------------
|
|
342
386
|
if (item.data) {
|
|
343
|
-
item.data = $
|
|
387
|
+
item.data = $n_json.parse(item.data)
|
|
344
388
|
}
|
|
345
|
-
item.data = $
|
|
389
|
+
item.data = $n_isValidObject(item.data) ? $n_numberDeep(item.data) : {}
|
|
346
390
|
|
|
347
391
|
// 设置数据类型
|
|
348
392
|
item.data.type = item.data_type
|
|
@@ -352,10 +396,10 @@ function setData(data) {
|
|
|
352
396
|
item.name = ''
|
|
353
397
|
|
|
354
398
|
// 如果有 url
|
|
355
|
-
if ($
|
|
399
|
+
if ($n_isValidString(item.url)) {
|
|
356
400
|
|
|
357
401
|
// url 首位加上反斜杠
|
|
358
|
-
item.url = $
|
|
402
|
+
item.url = $n_slash($n_toLower($n_trimString(item.url)), 'start', true)
|
|
359
403
|
if (item.url) {
|
|
360
404
|
|
|
361
405
|
item.data.url = item.url
|
|
@@ -437,22 +481,22 @@ function setData(data) {
|
|
|
437
481
|
for (const item of rows) {
|
|
438
482
|
|
|
439
483
|
// 如果有跳转页面
|
|
440
|
-
if ($
|
|
484
|
+
if ($n_has(item.data, 'toPage')) {
|
|
441
485
|
// 设置跳转页面地址
|
|
442
|
-
item.data.toPage = $
|
|
486
|
+
item.data.toPage = $n_has(all, item.data.toPage) ? all[item.data.toPage].data.url : null
|
|
443
487
|
}
|
|
444
488
|
|
|
445
489
|
// 如果有请求成功执行类型
|
|
446
|
-
// else if ($
|
|
490
|
+
// else if ($n_has(item.data, 'requestSuccess.type')) {
|
|
447
491
|
// // 如果请求成功执行类型是关闭窗口、跳转并刷新页面
|
|
448
492
|
// if (item.data.requestSuccess.type === 'closePushRefresh') {
|
|
449
493
|
// // 设置刷新页面地址
|
|
450
494
|
// item.data.requestSuccess.params =
|
|
451
495
|
// (
|
|
452
496
|
// // 如果有刷新页面的参数 id
|
|
453
|
-
// $
|
|
497
|
+
// $n_has(item.data.requestSuccess, 'params')
|
|
454
498
|
// // 如果有页面数据
|
|
455
|
-
// && $
|
|
499
|
+
// && $n_has(all, item.data.requestSuccess.params)
|
|
456
500
|
// ) ? all[item.data.requestSuccess.params].data.url : null
|
|
457
501
|
// }
|
|
458
502
|
// }
|
|
@@ -461,10 +505,10 @@ function setData(data) {
|
|
|
461
505
|
// 数据/按钮
|
|
462
506
|
item.type > 1
|
|
463
507
|
// 有父级数据
|
|
464
|
-
&& $
|
|
508
|
+
&& $n_has(all, item.pid)
|
|
465
509
|
) {
|
|
466
510
|
const pItem = all[item.pid]
|
|
467
|
-
if ($
|
|
511
|
+
if ($n_has(btns, pItem.url)) {
|
|
468
512
|
btns[pItem.url].push(item)
|
|
469
513
|
} else {
|
|
470
514
|
btns[pItem.url] = [item]
|
|
@@ -496,7 +540,7 @@ async function getData() {
|
|
|
496
540
|
if (! statePower.value.v) {
|
|
497
541
|
|
|
498
542
|
// 获取权限数据
|
|
499
|
-
const res = await $
|
|
543
|
+
const res = await $n_getData($n_config('powerName'))
|
|
500
544
|
if (res === false) {
|
|
501
545
|
statePower.value = {
|
|
502
546
|
// 权限版本
|
|
@@ -510,16 +554,16 @@ async function getData() {
|
|
|
510
554
|
// 菜单
|
|
511
555
|
menus: [],
|
|
512
556
|
}
|
|
513
|
-
return $
|
|
557
|
+
return $n_fail()
|
|
514
558
|
}
|
|
515
559
|
}
|
|
516
560
|
|
|
517
561
|
// 如果有权限状态数据, 则直接返回
|
|
518
562
|
if (statePower.value.v) {
|
|
519
|
-
return $
|
|
563
|
+
return $n_success($n_cloneDeep(statePower.value))
|
|
520
564
|
}
|
|
521
565
|
|
|
522
|
-
return $
|
|
566
|
+
return $n_fail()
|
|
523
567
|
}
|
|
524
568
|
|
|
525
569
|
/**
|
|
@@ -528,42 +572,42 @@ async function getData() {
|
|
|
528
572
|
function parseQuery(data, settings) {
|
|
529
573
|
|
|
530
574
|
// 如果配置是字符串
|
|
531
|
-
if ($
|
|
575
|
+
if ($n_isValidString(settings)) {
|
|
532
576
|
|
|
533
577
|
// 如果返回所有传参
|
|
534
578
|
if (settings === 'all') {
|
|
535
|
-
return $
|
|
579
|
+
return $n_isValidObject(data) ? data : {}
|
|
536
580
|
}
|
|
537
581
|
|
|
538
582
|
// 将字符串放到数组中
|
|
539
583
|
settings = [settings]
|
|
540
584
|
|
|
541
585
|
// 如果配置是对象
|
|
542
|
-
} else if ($
|
|
586
|
+
} else if ($n_isValidObject(settings)) {
|
|
543
587
|
settings = [settings]
|
|
544
588
|
}
|
|
545
589
|
|
|
546
590
|
const query = {}
|
|
547
591
|
|
|
548
592
|
// 如果配置是数组
|
|
549
|
-
if ($
|
|
593
|
+
if ($n_isValidArray(settings)) {
|
|
550
594
|
|
|
551
595
|
// 别名
|
|
552
596
|
const alias = {}
|
|
553
597
|
|
|
554
598
|
for (let item of settings) {
|
|
555
599
|
// 如果是需要的字段
|
|
556
|
-
if ($
|
|
600
|
+
if ($n_isValidString(item)) {
|
|
557
601
|
|
|
558
602
|
// 将字段转小写
|
|
559
|
-
item = $
|
|
603
|
+
item = $n_toLower($n_trimString(item))
|
|
560
604
|
|
|
561
605
|
// 判断字段是否有 as 别名
|
|
562
|
-
const arr = $
|
|
606
|
+
const arr = $n_split(item, ' as ')
|
|
563
607
|
|
|
564
608
|
// 如果有别名
|
|
565
609
|
if (arr.length === 2) {
|
|
566
|
-
alias[$
|
|
610
|
+
alias[$n_trimString(arr[0])] = $n_trimString(arr[1])
|
|
567
611
|
|
|
568
612
|
// 否则别名就是当前字段本身
|
|
569
613
|
} else {
|
|
@@ -571,21 +615,21 @@ function parseQuery(data, settings) {
|
|
|
571
615
|
}
|
|
572
616
|
|
|
573
617
|
// 否则如果是自定义传参
|
|
574
|
-
} else if ($
|
|
618
|
+
} else if ($n_isValidObject(item)) {
|
|
575
619
|
Object.assign(query, item)
|
|
576
620
|
}
|
|
577
621
|
}
|
|
578
622
|
|
|
579
623
|
if (
|
|
580
624
|
// 如果有参数数据
|
|
581
|
-
$
|
|
625
|
+
$n_isValidObject(data)
|
|
582
626
|
// 如果有定义别名
|
|
583
|
-
&& $
|
|
627
|
+
&& $n_isValidObject(alias)
|
|
584
628
|
) {
|
|
585
|
-
$
|
|
629
|
+
$n_forIn(data, function(value, key) {
|
|
586
630
|
|
|
587
631
|
// 如果当前字段在别名中
|
|
588
|
-
if ($
|
|
632
|
+
if ($n_has(alias, key)) {
|
|
589
633
|
query[alias[key]] = value
|
|
590
634
|
}
|
|
591
635
|
})
|
|
@@ -602,7 +646,7 @@ function formatBtns(powerBtns, filterBtns, toObject = false) {
|
|
|
602
646
|
|
|
603
647
|
const newLists = []
|
|
604
648
|
|
|
605
|
-
$
|
|
649
|
+
$n_forEach(powerBtns, function(item) {
|
|
606
650
|
|
|
607
651
|
const {
|
|
608
652
|
name,
|
|
@@ -613,9 +657,9 @@ function formatBtns(powerBtns, filterBtns, toObject = false) {
|
|
|
613
657
|
// 图标
|
|
614
658
|
icon: icon || undefined,
|
|
615
659
|
// 隐藏按钮
|
|
616
|
-
hidden: $
|
|
660
|
+
hidden: $n_get(item, 'hidden') === true,
|
|
617
661
|
// 显示按钮类型
|
|
618
|
-
show: $
|
|
662
|
+
show: $n_has(item, 'data.show') ? item.data.show : true,
|
|
619
663
|
})
|
|
620
664
|
|
|
621
665
|
// 是否固定按钮
|
|
@@ -623,22 +667,22 @@ function formatBtns(powerBtns, filterBtns, toObject = false) {
|
|
|
623
667
|
// 非隐藏按钮
|
|
624
668
|
! newItem.hidden
|
|
625
669
|
// 固定列
|
|
626
|
-
&& $
|
|
670
|
+
&& $n_get(newItem, 'data.fixed') === true
|
|
627
671
|
// 单个按钮
|
|
628
672
|
&& newItem.show === 'single'
|
|
629
673
|
// 按钮有图标
|
|
630
674
|
&& !! newItem.icon
|
|
631
675
|
|
|
632
676
|
// 如果是对象
|
|
633
|
-
if ($
|
|
634
|
-
if ($
|
|
635
|
-
newLists.push($
|
|
677
|
+
if ($n_isValidObject(filterBtns)) {
|
|
678
|
+
if ($n_has(filterBtns, name)) {
|
|
679
|
+
newLists.push($n_merge(newItem, filterBtns[name]))
|
|
636
680
|
}
|
|
637
681
|
|
|
638
682
|
// 如果是数组
|
|
639
|
-
} else if ($
|
|
640
|
-
if ($
|
|
641
|
-
newLists.push($
|
|
683
|
+
} else if ($n_isValidArray(filterBtns)) {
|
|
684
|
+
if ($n_indexOf(filterBtns, name) > -1) {
|
|
685
|
+
newLists.push($n_merge(newItem, filterBtns[name]))
|
|
642
686
|
}
|
|
643
687
|
|
|
644
688
|
} else {
|
|
@@ -667,9 +711,9 @@ function getRequestQuery(o) {
|
|
|
667
711
|
const query = {}
|
|
668
712
|
|
|
669
713
|
// 如果有请求传参的传参设置
|
|
670
|
-
if ($
|
|
714
|
+
if ($n_has(o.data, 'requestQuery.query')) {
|
|
671
715
|
const resQuery = parseQuery(o.query, o.data.requestQuery.query)
|
|
672
|
-
if ($
|
|
716
|
+
if ($n_isValidObject(resQuery)) {
|
|
673
717
|
Object.assign(query, resQuery)
|
|
674
718
|
}
|
|
675
719
|
}
|
|
@@ -677,13 +721,13 @@ function getRequestQuery(o) {
|
|
|
677
721
|
// 获取列表数据
|
|
678
722
|
if (
|
|
679
723
|
// 如果按钮参数有显示类型
|
|
680
|
-
$
|
|
724
|
+
$n_has(o.data, 'show')
|
|
681
725
|
// 按钮参数的显示类型必须是单选或多选
|
|
682
|
-
&& $
|
|
726
|
+
&& $n_indexOf(['single', 'multiple'], o.data.show) > -1
|
|
683
727
|
// 如果有请求传参的列表设置
|
|
684
|
-
&& $
|
|
728
|
+
&& $n_has(o.data, 'requestQuery.list')
|
|
685
729
|
// 如果有表格数据
|
|
686
|
-
&& $
|
|
730
|
+
&& $n_isValidArray(o.tableSelected)
|
|
687
731
|
) {
|
|
688
732
|
let newQuery = {}
|
|
689
733
|
|
|
@@ -696,8 +740,8 @@ function getRequestQuery(o) {
|
|
|
696
740
|
} else {
|
|
697
741
|
// 合并表格选中的每一条数据
|
|
698
742
|
for (const item of o.tableSelected) {
|
|
699
|
-
$
|
|
700
|
-
if ($
|
|
743
|
+
$n_forIn(item, function(value, key) {
|
|
744
|
+
if ($n_has(newQuery, key)) {
|
|
701
745
|
newQuery[key].push(value)
|
|
702
746
|
} else {
|
|
703
747
|
newQuery[key] = [value]
|
|
@@ -707,12 +751,12 @@ function getRequestQuery(o) {
|
|
|
707
751
|
}
|
|
708
752
|
|
|
709
753
|
const resTable = parseQuery(newQuery, o.data.requestQuery.list)
|
|
710
|
-
if ($
|
|
754
|
+
if ($n_isValidObject(resTable)) {
|
|
711
755
|
Object.assign(query, resTable)
|
|
712
756
|
}
|
|
713
757
|
}
|
|
714
758
|
|
|
715
|
-
return $
|
|
759
|
+
return $n_cloneDeep($n_numberDeep(query))
|
|
716
760
|
}
|
|
717
761
|
|
|
718
762
|
/**
|
|
@@ -723,32 +767,32 @@ function formatQuery(query, isJoinArr) {
|
|
|
723
767
|
const newQuery = {}
|
|
724
768
|
|
|
725
769
|
// 格式化参数
|
|
726
|
-
$
|
|
770
|
+
$n_forIn(query, function(value, key) {
|
|
727
771
|
|
|
728
772
|
// 如果是数字
|
|
729
|
-
if ($
|
|
730
|
-
newQuery[key] = $
|
|
773
|
+
if ($n_isNumeric(value)) {
|
|
774
|
+
newQuery[key] = $n_isNumber(value) ? value : Number(value)
|
|
731
775
|
|
|
732
776
|
// 如果是字符串
|
|
733
|
-
} else if ($
|
|
734
|
-
newQuery[key] = $
|
|
777
|
+
} else if ($n_isValidString(value)) {
|
|
778
|
+
newQuery[key] = $n_trimString(value)
|
|
735
779
|
|
|
736
780
|
// 如果是数组
|
|
737
|
-
} else if ($
|
|
781
|
+
} else if ($n_isValidArray(value)) {
|
|
738
782
|
|
|
739
783
|
const arr = []
|
|
740
784
|
for (const val of value) {
|
|
741
785
|
|
|
742
786
|
// 如果为有效值
|
|
743
|
-
if ($
|
|
787
|
+
if ($n_isRequired(val)) {
|
|
744
788
|
|
|
745
789
|
// 如果是数字
|
|
746
|
-
if ($
|
|
747
|
-
arr.push($
|
|
790
|
+
if ($n_isNumeric(val)) {
|
|
791
|
+
arr.push($n_isNumber(val) ? val : Number(val))
|
|
748
792
|
|
|
749
793
|
// 如果是字符串
|
|
750
|
-
} else if ($
|
|
751
|
-
arr.push($
|
|
794
|
+
} else if ($n_isValidString(val)) {
|
|
795
|
+
arr.push($n_trimString(val))
|
|
752
796
|
|
|
753
797
|
// 否则为数组或对象
|
|
754
798
|
} else {
|
|
@@ -757,7 +801,7 @@ function formatQuery(query, isJoinArr) {
|
|
|
757
801
|
}
|
|
758
802
|
}
|
|
759
803
|
if (arr.length) {
|
|
760
|
-
newQuery[key] = isJoinArr ? $
|
|
804
|
+
newQuery[key] = isJoinArr ? $n_join(arr, ',') : arr
|
|
761
805
|
}
|
|
762
806
|
}
|
|
763
807
|
})
|
|
@@ -798,7 +842,7 @@ async function request(params) {
|
|
|
798
842
|
o.query = $route.query
|
|
799
843
|
|
|
800
844
|
// 判断类型
|
|
801
|
-
if (! $
|
|
845
|
+
if (! $n_get(o.data, 'type')) {
|
|
802
846
|
|
|
803
847
|
// 【调试模式】
|
|
804
848
|
// --------------------------------------------------
|
|
@@ -811,17 +855,17 @@ async function request(params) {
|
|
|
811
855
|
}
|
|
812
856
|
|
|
813
857
|
// 克隆 data
|
|
814
|
-
o.data = $
|
|
858
|
+
o.data = $n_cloneDeep(o.data)
|
|
815
859
|
|
|
816
860
|
// 判断 url
|
|
817
|
-
o.data.url = $
|
|
861
|
+
o.data.url = $n_toLower($n_trimString(o.data.url))
|
|
818
862
|
if (! o.data.url) {
|
|
819
863
|
|
|
820
864
|
if (
|
|
821
865
|
// 如果没有跳转页面地址
|
|
822
|
-
! $
|
|
866
|
+
! $n_has(o.data, 'toPage')
|
|
823
867
|
// 或跳转页面地址为空
|
|
824
|
-
|| ! $
|
|
868
|
+
|| ! $n_isValidString(o.data.toPage)
|
|
825
869
|
) {
|
|
826
870
|
// 【调试模式】
|
|
827
871
|
// --------------------------------------------------
|
|
@@ -849,13 +893,13 @@ async function request(params) {
|
|
|
849
893
|
query = formatQuery(query, true)
|
|
850
894
|
|
|
851
895
|
// 如果有增加来源页面参数
|
|
852
|
-
if ($
|
|
896
|
+
if ($n_get(o.data, 'addFromPageQuery') === true) {
|
|
853
897
|
// 来源页面是当前路由的完整路径
|
|
854
898
|
query.n_frompage = encodeURIComponent($currentRoute.fullPath)
|
|
855
899
|
}
|
|
856
900
|
|
|
857
901
|
// 请求前执行
|
|
858
|
-
const resBefore = await $
|
|
902
|
+
const resBefore = await $n_runAsync(o.requestBefore)({ params: o, requestData: query })
|
|
859
903
|
if (resBefore !== void 0) {
|
|
860
904
|
if (resBefore === false) {
|
|
861
905
|
return
|
|
@@ -863,7 +907,7 @@ async function request(params) {
|
|
|
863
907
|
query = resBefore
|
|
864
908
|
}
|
|
865
909
|
|
|
866
|
-
$
|
|
910
|
+
$n_router.push({
|
|
867
911
|
path: o.data.url,
|
|
868
912
|
query,
|
|
869
913
|
})
|
|
@@ -878,14 +922,14 @@ async function request(params) {
|
|
|
878
922
|
if (o.data.type === dicts.POWER_DATA_TYPE__FORM) {
|
|
879
923
|
|
|
880
924
|
// 获取表单注入
|
|
881
|
-
o.$form = $
|
|
925
|
+
o.$form = $n_has(params, '$form') ? params.$form : inject(NFormKey)
|
|
882
926
|
|
|
883
927
|
if (! o.$form) {
|
|
884
928
|
throw new Error('没有创建表单实例')
|
|
885
929
|
}
|
|
886
930
|
|
|
887
931
|
// 如果验证表单
|
|
888
|
-
if ($
|
|
932
|
+
if ($n_get(o.data, 'validate') !== false) {
|
|
889
933
|
|
|
890
934
|
if (! o.$form.formRef) {
|
|
891
935
|
throw new Error('没有绑定 fromRef')
|
|
@@ -898,47 +942,47 @@ async function request(params) {
|
|
|
898
942
|
}
|
|
899
943
|
|
|
900
944
|
// 验证表单数据
|
|
901
|
-
if (! $
|
|
945
|
+
if (! $n_isValidObject(o.$form.formData.value)) {
|
|
902
946
|
throw new Error('没有获取到表单数据')
|
|
903
947
|
}
|
|
904
948
|
|
|
905
949
|
// 检查是否正在上传文件
|
|
906
|
-
if ($
|
|
950
|
+
if ($n_isFunction(o.checkUploading) && o.checkUploading()) {
|
|
907
951
|
// 轻提示
|
|
908
|
-
$
|
|
952
|
+
$n_toast({
|
|
909
953
|
message: '文件上传中,请耐心等待',
|
|
910
954
|
})
|
|
911
955
|
return
|
|
912
956
|
}
|
|
913
957
|
|
|
914
958
|
// 获取请求数据
|
|
915
|
-
requestData = $
|
|
959
|
+
requestData = $n_merge({}, formatQuery(query, false), o.$form.formData.value)
|
|
916
960
|
|
|
917
961
|
// 如果是请求数据
|
|
918
962
|
// --------------------------------------------------
|
|
919
963
|
} else {
|
|
920
964
|
// 获取表格注入
|
|
921
|
-
o.$table = $
|
|
965
|
+
o.$table = $n_has(params, '$table') ? params.$table : inject(NTableKey)
|
|
922
966
|
|
|
923
967
|
// 获取请求数据
|
|
924
968
|
requestData = formatQuery(query, false)
|
|
925
969
|
}
|
|
926
970
|
|
|
927
971
|
// 判断是否有确认框
|
|
928
|
-
const isConfirm = $
|
|
972
|
+
const isConfirm = $n_get(o.data, 'confirm')
|
|
929
973
|
if (
|
|
930
974
|
// 如果有确认框
|
|
931
975
|
isConfirm
|
|
932
976
|
// 如果有密码确认框
|
|
933
|
-
|| $
|
|
977
|
+
|| $n_get(o.data, 'confirmPassword')
|
|
934
978
|
) {
|
|
935
979
|
// 如果需要先弹出确认框
|
|
936
980
|
if (isConfirm) {
|
|
937
981
|
|
|
938
982
|
// 确认框
|
|
939
|
-
$
|
|
983
|
+
$n_confirm({
|
|
940
984
|
// 重要操作,请输入登录密码并确认后操作
|
|
941
|
-
message: $
|
|
985
|
+
message: $n_isValidString(isConfirm) ? isConfirm : '确认要执行该操作吗?',
|
|
942
986
|
})
|
|
943
987
|
// 点击确认执行
|
|
944
988
|
.onOk(onRequest)
|
|
@@ -956,7 +1000,7 @@ async function request(params) {
|
|
|
956
1000
|
async function onRequest() {
|
|
957
1001
|
|
|
958
1002
|
// 请求前执行
|
|
959
|
-
const resBefore = await $
|
|
1003
|
+
const resBefore = await $n_runAsync(o.requestBefore)({ params: o, requestData })
|
|
960
1004
|
if (resBefore !== void 0) {
|
|
961
1005
|
if (resBefore === false) {
|
|
962
1006
|
return
|
|
@@ -965,7 +1009,7 @@ async function request(params) {
|
|
|
965
1009
|
}
|
|
966
1010
|
|
|
967
1011
|
// 请求
|
|
968
|
-
const res = await $
|
|
1012
|
+
const res = await $n_http({
|
|
969
1013
|
// 请求地址
|
|
970
1014
|
url: o.data.url,
|
|
971
1015
|
// 请求数据
|
|
@@ -981,7 +1025,7 @@ async function request(params) {
|
|
|
981
1025
|
}, res)
|
|
982
1026
|
|
|
983
1027
|
// 请求后执行
|
|
984
|
-
if (await $
|
|
1028
|
+
if (await $n_runAsync(o.requestAfter)(resultData) === false) {
|
|
985
1029
|
return
|
|
986
1030
|
}
|
|
987
1031
|
|
|
@@ -993,14 +1037,14 @@ async function request(params) {
|
|
|
993
1037
|
|
|
994
1038
|
// 轻提示
|
|
995
1039
|
if (isNotify) {
|
|
996
|
-
$
|
|
1040
|
+
$n_toast({
|
|
997
1041
|
type: 'positive',
|
|
998
1042
|
message: '恭喜您,操作成功',
|
|
999
1043
|
})
|
|
1000
1044
|
}
|
|
1001
1045
|
|
|
1002
1046
|
// 判断是否有请求成功后的操作动作
|
|
1003
|
-
if ($
|
|
1047
|
+
if ($n_has(o.data, 'requestSuccess.type')) {
|
|
1004
1048
|
switch (o.data.requestSuccess.type) {
|
|
1005
1049
|
|
|
1006
1050
|
// 关闭当前页面
|
|
@@ -1012,7 +1056,7 @@ async function request(params) {
|
|
|
1012
1056
|
|
|
1013
1057
|
// 如果是渲染页面
|
|
1014
1058
|
// 说明该页面在 <table-splitter> 组件内部被渲染, 则不需要关闭当前窗口
|
|
1015
|
-
if ($
|
|
1059
|
+
if ($n_has($route.query, 'n_renderpage') && $route.query.n_renderpage === 1) {
|
|
1016
1060
|
// 则无任何操作
|
|
1017
1061
|
return
|
|
1018
1062
|
}
|
|
@@ -1025,8 +1069,8 @@ async function request(params) {
|
|
|
1025
1069
|
// 如果不是关闭当前页面, 则为关闭窗口并跳转页面
|
|
1026
1070
|
o.data.requestSuccess.type !== 'close'
|
|
1027
1071
|
// 如果有来源页面
|
|
1028
|
-
&& $
|
|
1029
|
-
&& $
|
|
1072
|
+
&& $n_has($route.query, 'n_frompage')
|
|
1073
|
+
&& $n_isValidString($route.query.n_frompage)
|
|
1030
1074
|
) {
|
|
1031
1075
|
Object.assign(opts, {
|
|
1032
1076
|
// 跳转页面地址
|
|
@@ -1036,30 +1080,30 @@ async function request(params) {
|
|
|
1036
1080
|
})
|
|
1037
1081
|
|
|
1038
1082
|
// 否则如果定义了跳转页面
|
|
1039
|
-
// else if ($
|
|
1083
|
+
// else if ($n_has(o.data, 'requestSuccess.params') && $n_isValidString(o.data.requestSuccess.params)) {
|
|
1040
1084
|
// pushPage = o.data.requestSuccess.params
|
|
1041
1085
|
// }
|
|
1042
1086
|
}
|
|
1043
1087
|
|
|
1044
1088
|
// 关闭当前标签页
|
|
1045
|
-
$
|
|
1089
|
+
$n_bus.emit('main', opts)
|
|
1046
1090
|
break
|
|
1047
1091
|
|
|
1048
1092
|
// 重置表单
|
|
1049
1093
|
case 'resetForm':
|
|
1050
|
-
$
|
|
1094
|
+
$n_run(o.$form?.resetForm)()
|
|
1051
1095
|
break
|
|
1052
1096
|
|
|
1053
1097
|
// 刷新列表
|
|
1054
1098
|
case 'refreshList':
|
|
1055
|
-
$
|
|
1099
|
+
$n_run(o.$table?.tableRefresh)()
|
|
1056
1100
|
break
|
|
1057
1101
|
}
|
|
1058
1102
|
}
|
|
1059
1103
|
}
|
|
1060
1104
|
|
|
1061
1105
|
// 请求成功执行
|
|
1062
|
-
if (await $
|
|
1106
|
+
if (await $n_runAsync(o.requestSuccess)(Object.assign({ next }, resultData)) === false) {
|
|
1063
1107
|
return
|
|
1064
1108
|
}
|
|
1065
1109
|
|
|
@@ -1068,7 +1112,7 @@ async function request(params) {
|
|
|
1068
1112
|
|
|
1069
1113
|
} else {
|
|
1070
1114
|
// 请求失败执行
|
|
1071
|
-
$
|
|
1115
|
+
$n_run(o.requestFail)(resultData)
|
|
1072
1116
|
}
|
|
1073
1117
|
}
|
|
1074
1118
|
}
|
|
@@ -1079,34 +1123,34 @@ async function request(params) {
|
|
|
1079
1123
|
function getPageData($route) {
|
|
1080
1124
|
|
|
1081
1125
|
if (! $route) {
|
|
1082
|
-
$route = $
|
|
1126
|
+
$route = $n_router.getRoute()
|
|
1083
1127
|
}
|
|
1084
1128
|
|
|
1085
|
-
const path = $
|
|
1129
|
+
const path = $n_get($route, 'path')
|
|
1086
1130
|
if (! path) {
|
|
1087
|
-
return $
|
|
1131
|
+
return $n_fail('路由参数错误')
|
|
1088
1132
|
}
|
|
1089
1133
|
|
|
1090
1134
|
if (! statePower.value.v) {
|
|
1091
|
-
return $
|
|
1135
|
+
return $n_fail('没有获取到权限数据')
|
|
1092
1136
|
}
|
|
1093
1137
|
|
|
1094
1138
|
// 获取角色数据
|
|
1095
|
-
const { urls, btns } = $
|
|
1096
|
-
if (! $
|
|
1097
|
-
return $
|
|
1139
|
+
const { urls, btns } = $n_cloneDeep(statePower.value)
|
|
1140
|
+
if (! $n_has(urls, path)) {
|
|
1141
|
+
return $n_fail('该页面没有权限')
|
|
1098
1142
|
}
|
|
1099
1143
|
|
|
1100
|
-
return $
|
|
1144
|
+
return $n_success({
|
|
1101
1145
|
page: urls[path],
|
|
1102
|
-
btns: $
|
|
1146
|
+
btns: $n_has(btns, path) ? btns[path] : [],
|
|
1103
1147
|
})
|
|
1104
1148
|
}
|
|
1105
1149
|
|
|
1106
1150
|
/**
|
|
1107
1151
|
* 权限业务
|
|
1108
1152
|
*/
|
|
1109
|
-
|
|
1153
|
+
const power = {
|
|
1110
1154
|
// 创建
|
|
1111
1155
|
create,
|
|
1112
1156
|
// 设置权限数据
|
|
@@ -1120,3 +1164,5 @@ $n.power = {
|
|
|
1120
1164
|
// 请求
|
|
1121
1165
|
request,
|
|
1122
1166
|
}
|
|
1167
|
+
|
|
1168
|
+
export default power
|