@netang/quasar 0.0.48 → 0.0.50
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/components/data/index.vue +23 -23
- package/components/dialog/index.vue +10 -10
- package/components/dialog-table/index.vue +1 -1
- package/components/dragger/index.vue +2 -2
- package/components/drawer/index.vue +7 -7
- package/components/editor-code/index.vue +282 -0
- package/components/empty/index.vue +22 -3
- package/components/field-date/index.vue +35 -35
- package/components/field-table/index.vue +34 -34
- package/components/field-text/index.vue +2 -2
- package/components/field-tree/index.vue +18 -18
- package/components/input-number/index.vue +2 -2
- package/components/list-menu/index.vue +2 -2
- package/components/private/components/move-to-tree/index.vue +2 -2
- package/components/private/edit-power-data/index.vue +50 -50
- package/components/private/table-visible-columns-button/index.vue +2 -2
- package/components/render/index.vue +6 -6
- package/components/search/index.vue +2 -2
- package/components/search-item/index.vue +5 -5
- package/components/select/index.vue +2 -2
- package/components/splitter/index.vue +7 -7
- package/components/table/index.vue +5 -5
- package/components/table-splitter/index.vue +4 -4
- package/components/table-summary/index.vue +3 -3
- package/components/thumbnail/index.vue +6 -6
- package/components/uploader/index.vue +1 -1
- package/components/uploader-query/index.vue +25 -25
- package/components/value-format/index.vue +12 -12
- package/package.json +1 -1
- package/sass/quasar/field.scss +5 -0
- package/sass/quasar/table.scss +6 -0
- package/utils/$area.js +13 -13
- package/utils/$auth.js +6 -6
- package/utils/$dialog.js +3 -3
- package/utils/$form.js +2 -2
- package/utils/$power.js +118 -118
- package/utils/$rule.js +4 -4
- package/utils/$search.js +50 -50
- package/utils/$table.js +79 -76
- package/utils/$tree.js +43 -43
- package/utils/$uploader.js +47 -47
- package/utils/alert.js +1 -1
- package/utils/arr.js +2 -2
- package/utils/bus.js +1 -1
- package/utils/config.js +4 -4
- package/utils/confrim.js +1 -1
- package/utils/dict.js +5 -5
- package/utils/getData.js +9 -9
- package/utils/getFile.js +5 -5
- package/utils/getImage.js +12 -12
- package/utils/getTime.js +4 -4
- package/utils/http.js +20 -20
- package/utils/loading.js +1 -1
- package/utils/notify.js +1 -1
- package/utils/previewImage.js +2 -2
- package/utils/price.js +3 -3
- package/utils/timestamp.js +1 -1
- package/utils/toast.js +1 -1
- package/utils/uploader/qiniu.js +11 -11
- package/utils/useAuth.js +2 -2
- package/utils/useRouter.js +4 -4
package/utils/$power.js
CHANGED
|
@@ -49,14 +49,14 @@ function create(params) {
|
|
|
49
49
|
const hasRender = !! $render
|
|
50
50
|
if (hasRender) {
|
|
51
51
|
// 如果有权限传参, 则合并参数
|
|
52
|
-
const powerProps =
|
|
53
|
-
if (
|
|
54
|
-
|
|
52
|
+
const powerProps = $n.get($render, 'props.powerProps')
|
|
53
|
+
if ($n.isValidObject(powerProps)) {
|
|
54
|
+
$n.merge(o, powerProps)
|
|
55
55
|
}
|
|
56
56
|
}
|
|
57
57
|
|
|
58
58
|
// 获取当前路由
|
|
59
|
-
const $currentRoute =
|
|
59
|
+
const $currentRoute = $n.router.getRoute()
|
|
60
60
|
|
|
61
61
|
// 权限路由
|
|
62
62
|
let $route
|
|
@@ -68,20 +68,20 @@ function create(params) {
|
|
|
68
68
|
$route = {
|
|
69
69
|
fullPath: '',
|
|
70
70
|
path: '',
|
|
71
|
-
query:
|
|
71
|
+
query: $n.isValidObject(o.query) ? o.query : {},
|
|
72
72
|
}
|
|
73
73
|
|
|
74
74
|
// 如果有自定义路径
|
|
75
|
-
} else if (
|
|
75
|
+
} else if ($n.isValidString(o.path)) {
|
|
76
76
|
|
|
77
77
|
// 获取自定义路由
|
|
78
|
-
$route =
|
|
78
|
+
$route = $n.router.resolve({
|
|
79
79
|
path: o.path,
|
|
80
|
-
query:
|
|
80
|
+
query: $n.isValidObject(o.query) ? o.query : {},
|
|
81
81
|
})
|
|
82
82
|
|
|
83
83
|
// 如果在渲染组件内 && 该渲染组件有自定义路由
|
|
84
|
-
} else if (hasRender &&
|
|
84
|
+
} else if (hasRender && $n.has($render, '$route')) {
|
|
85
85
|
|
|
86
86
|
// 设为渲染组件的路由
|
|
87
87
|
$route = $render.$route
|
|
@@ -206,13 +206,13 @@ function create(params) {
|
|
|
206
206
|
// 如果显示工具栏权限按钮
|
|
207
207
|
o.showToolbarPowerBtns
|
|
208
208
|
// 有权限按钮数据
|
|
209
|
-
&&
|
|
209
|
+
&& $n.isValidArray(data.powerBtns.value)
|
|
210
210
|
) {
|
|
211
211
|
|
|
212
|
-
const lists =
|
|
212
|
+
const lists = $n.filter(formatBtns(data.powerBtns.value), e => e.type > 2)
|
|
213
213
|
|
|
214
214
|
// 格式化权限按钮列表
|
|
215
|
-
|
|
215
|
+
$n.forEach(lists, function(item) {
|
|
216
216
|
|
|
217
217
|
if (! item.hidden) {
|
|
218
218
|
|
|
@@ -226,7 +226,7 @@ function create(params) {
|
|
|
226
226
|
item.show = false
|
|
227
227
|
|
|
228
228
|
// 如果有表格选中数据
|
|
229
|
-
if (
|
|
229
|
+
if ($n.isValidArray(data.tableSelected.value)) {
|
|
230
230
|
// 如果是单个显示
|
|
231
231
|
if (isSingle) {
|
|
232
232
|
item.show = data.tableSelected.value.length === 1
|
|
@@ -313,7 +313,7 @@ function create(params) {
|
|
|
313
313
|
function setData(data) {
|
|
314
314
|
|
|
315
315
|
// 如果没有角色数据
|
|
316
|
-
if (!
|
|
316
|
+
if (! $n.isValidObject(data)) {
|
|
317
317
|
return
|
|
318
318
|
}
|
|
319
319
|
|
|
@@ -322,7 +322,7 @@ function setData(data) {
|
|
|
322
322
|
v,
|
|
323
323
|
} = data
|
|
324
324
|
|
|
325
|
-
if (!
|
|
325
|
+
if (! $n.isValidArray(rows) || ! v) {
|
|
326
326
|
return
|
|
327
327
|
}
|
|
328
328
|
|
|
@@ -340,9 +340,9 @@ function setData(data) {
|
|
|
340
340
|
// 【格式化 start】
|
|
341
341
|
// --------------------------------------------------
|
|
342
342
|
if (item.data) {
|
|
343
|
-
item.data =
|
|
343
|
+
item.data = $n.json.parse(item.data)
|
|
344
344
|
}
|
|
345
|
-
item.data =
|
|
345
|
+
item.data = $n.isValidObject(item.data) ? $n.numberDeep(item.data) : {}
|
|
346
346
|
|
|
347
347
|
// 设置数据类型
|
|
348
348
|
item.data.type = item.data_type
|
|
@@ -352,10 +352,10 @@ function setData(data) {
|
|
|
352
352
|
item.name = ''
|
|
353
353
|
|
|
354
354
|
// 如果有 url
|
|
355
|
-
if (
|
|
355
|
+
if ($n.isValidString(item.url)) {
|
|
356
356
|
|
|
357
357
|
// url 首位加上反斜杠
|
|
358
|
-
item.url =
|
|
358
|
+
item.url = $n.slash($n.toLower($n.trimString(item.url)), 'start', true)
|
|
359
359
|
if (item.url) {
|
|
360
360
|
|
|
361
361
|
item.data.url = item.url
|
|
@@ -437,22 +437,22 @@ function setData(data) {
|
|
|
437
437
|
for (const item of rows) {
|
|
438
438
|
|
|
439
439
|
// 如果有跳转页面
|
|
440
|
-
if (
|
|
440
|
+
if ($n.has(item.data, 'toPage')) {
|
|
441
441
|
// 设置跳转页面地址
|
|
442
|
-
item.data.toPage =
|
|
442
|
+
item.data.toPage = $n.has(all, item.data.toPage) ? all[item.data.toPage].data.url : null
|
|
443
443
|
}
|
|
444
444
|
|
|
445
445
|
// 如果有请求成功执行类型
|
|
446
|
-
// else if (
|
|
446
|
+
// else if ($n.has(item.data, 'requestSuccess.type')) {
|
|
447
447
|
// // 如果请求成功执行类型是关闭窗口、跳转并刷新页面
|
|
448
448
|
// if (item.data.requestSuccess.type === 'closePushRefresh') {
|
|
449
449
|
// // 设置刷新页面地址
|
|
450
450
|
// item.data.requestSuccess.params =
|
|
451
451
|
// (
|
|
452
452
|
// // 如果有刷新页面的参数 id
|
|
453
|
-
//
|
|
453
|
+
// $n.has(item.data.requestSuccess, 'params')
|
|
454
454
|
// // 如果有页面数据
|
|
455
|
-
// &&
|
|
455
|
+
// && $n.has(all, item.data.requestSuccess.params)
|
|
456
456
|
// ) ? all[item.data.requestSuccess.params].data.url : null
|
|
457
457
|
// }
|
|
458
458
|
// }
|
|
@@ -461,10 +461,10 @@ function setData(data) {
|
|
|
461
461
|
// 数据/按钮
|
|
462
462
|
item.type > 1
|
|
463
463
|
// 有父级数据
|
|
464
|
-
&&
|
|
464
|
+
&& $n.has(all, item.pid)
|
|
465
465
|
) {
|
|
466
466
|
const pItem = all[item.pid]
|
|
467
|
-
if (
|
|
467
|
+
if ($n.has(btns, pItem.url)) {
|
|
468
468
|
btns[pItem.url].push(item)
|
|
469
469
|
} else {
|
|
470
470
|
btns[pItem.url] = [item]
|
|
@@ -496,7 +496,7 @@ async function getData() {
|
|
|
496
496
|
if (! statePower.value.v) {
|
|
497
497
|
|
|
498
498
|
// 获取权限数据
|
|
499
|
-
const res = await
|
|
499
|
+
const res = await $n.getData($n.config('powerName'))
|
|
500
500
|
if (res === false) {
|
|
501
501
|
statePower.value = {
|
|
502
502
|
// 权限版本
|
|
@@ -510,16 +510,16 @@ async function getData() {
|
|
|
510
510
|
// 菜单
|
|
511
511
|
menus: [],
|
|
512
512
|
}
|
|
513
|
-
return
|
|
513
|
+
return $n.fail()
|
|
514
514
|
}
|
|
515
515
|
}
|
|
516
516
|
|
|
517
517
|
// 如果有权限状态数据, 则直接返回
|
|
518
518
|
if (statePower.value.v) {
|
|
519
|
-
return
|
|
519
|
+
return $n.success($n.cloneDeep(statePower.value))
|
|
520
520
|
}
|
|
521
521
|
|
|
522
|
-
return
|
|
522
|
+
return $n.fail()
|
|
523
523
|
}
|
|
524
524
|
|
|
525
525
|
/**
|
|
@@ -528,42 +528,42 @@ async function getData() {
|
|
|
528
528
|
function parseQuery(data, settings) {
|
|
529
529
|
|
|
530
530
|
// 如果配置是字符串
|
|
531
|
-
if (
|
|
531
|
+
if ($n.isValidString(settings)) {
|
|
532
532
|
|
|
533
533
|
// 如果返回所有传参
|
|
534
534
|
if (settings === 'all') {
|
|
535
|
-
return
|
|
535
|
+
return $n.isValidObject(data) ? data : {}
|
|
536
536
|
}
|
|
537
537
|
|
|
538
538
|
// 将字符串放到数组中
|
|
539
539
|
settings = [settings]
|
|
540
540
|
|
|
541
541
|
// 如果配置是对象
|
|
542
|
-
} else if (
|
|
542
|
+
} else if ($n.isValidObject(settings)) {
|
|
543
543
|
settings = [settings]
|
|
544
544
|
}
|
|
545
545
|
|
|
546
546
|
const query = {}
|
|
547
547
|
|
|
548
548
|
// 如果配置是数组
|
|
549
|
-
if (
|
|
549
|
+
if ($n.isValidArray(settings)) {
|
|
550
550
|
|
|
551
551
|
// 别名
|
|
552
552
|
const alias = {}
|
|
553
553
|
|
|
554
554
|
for (let item of settings) {
|
|
555
555
|
// 如果是需要的字段
|
|
556
|
-
if (
|
|
556
|
+
if ($n.isValidString(item)) {
|
|
557
557
|
|
|
558
558
|
// 将字段转小写
|
|
559
|
-
item =
|
|
559
|
+
item = $n.toLower($n.trimString(item))
|
|
560
560
|
|
|
561
561
|
// 判断字段是否有 as 别名
|
|
562
|
-
const arr =
|
|
562
|
+
const arr = $n.split(item, ' as ')
|
|
563
563
|
|
|
564
564
|
// 如果有别名
|
|
565
565
|
if (arr.length === 2) {
|
|
566
|
-
alias[
|
|
566
|
+
alias[$n.trimString(arr[0])] = $n.trimString(arr[1])
|
|
567
567
|
|
|
568
568
|
// 否则别名就是当前字段本身
|
|
569
569
|
} else {
|
|
@@ -571,21 +571,21 @@ function parseQuery(data, settings) {
|
|
|
571
571
|
}
|
|
572
572
|
|
|
573
573
|
// 否则如果是自定义传参
|
|
574
|
-
} else if (
|
|
574
|
+
} else if ($n.isValidObject(item)) {
|
|
575
575
|
Object.assign(query, item)
|
|
576
576
|
}
|
|
577
577
|
}
|
|
578
578
|
|
|
579
579
|
if (
|
|
580
580
|
// 如果有参数数据
|
|
581
|
-
|
|
581
|
+
$n.isValidObject(data)
|
|
582
582
|
// 如果有定义别名
|
|
583
|
-
&&
|
|
583
|
+
&& $n.isValidObject(alias)
|
|
584
584
|
) {
|
|
585
|
-
|
|
585
|
+
$n.forIn(data, function(value, key) {
|
|
586
586
|
|
|
587
587
|
// 如果当前字段在别名中
|
|
588
|
-
if (
|
|
588
|
+
if ($n.has(alias, key)) {
|
|
589
589
|
query[alias[key]] = value
|
|
590
590
|
}
|
|
591
591
|
})
|
|
@@ -602,7 +602,7 @@ function formatBtns(powerBtns, filterBtns, toObject = false) {
|
|
|
602
602
|
|
|
603
603
|
const newLists = []
|
|
604
604
|
|
|
605
|
-
|
|
605
|
+
$n.forEach(powerBtns, function(item) {
|
|
606
606
|
|
|
607
607
|
const {
|
|
608
608
|
name,
|
|
@@ -613,9 +613,9 @@ function formatBtns(powerBtns, filterBtns, toObject = false) {
|
|
|
613
613
|
// 图标
|
|
614
614
|
icon: icon || undefined,
|
|
615
615
|
// 隐藏按钮
|
|
616
|
-
hidden:
|
|
616
|
+
hidden: $n.get(item, 'hidden') === true,
|
|
617
617
|
// 显示按钮类型
|
|
618
|
-
show:
|
|
618
|
+
show: $n.has(item, 'data.show') ? item.data.show : true,
|
|
619
619
|
})
|
|
620
620
|
|
|
621
621
|
// 是否固定按钮
|
|
@@ -623,22 +623,22 @@ function formatBtns(powerBtns, filterBtns, toObject = false) {
|
|
|
623
623
|
// 非隐藏按钮
|
|
624
624
|
! newItem.hidden
|
|
625
625
|
// 固定列
|
|
626
|
-
&&
|
|
626
|
+
&& $n.get(newItem, 'data.fixed') === true
|
|
627
627
|
// 单个按钮
|
|
628
628
|
&& newItem.show === 'single'
|
|
629
629
|
// 按钮有图标
|
|
630
630
|
&& !! newItem.icon
|
|
631
631
|
|
|
632
632
|
// 如果是对象
|
|
633
|
-
if (
|
|
634
|
-
if (
|
|
635
|
-
newLists.push(
|
|
633
|
+
if ($n.isValidObject(filterBtns)) {
|
|
634
|
+
if ($n.has(filterBtns, name)) {
|
|
635
|
+
newLists.push($n.merge(newItem, filterBtns[name]))
|
|
636
636
|
}
|
|
637
637
|
|
|
638
638
|
// 如果是数组
|
|
639
|
-
} else if (
|
|
640
|
-
if (
|
|
641
|
-
newLists.push(
|
|
639
|
+
} else if ($n.isValidArray(filterBtns)) {
|
|
640
|
+
if ($n.indexOf(filterBtns, name) > -1) {
|
|
641
|
+
newLists.push($n.merge(newItem, filterBtns[name]))
|
|
642
642
|
}
|
|
643
643
|
|
|
644
644
|
} else {
|
|
@@ -667,9 +667,9 @@ function getRequestQuery(o) {
|
|
|
667
667
|
const query = {}
|
|
668
668
|
|
|
669
669
|
// 如果有请求传参的传参设置
|
|
670
|
-
if (
|
|
670
|
+
if ($n.has(o.data, 'requestQuery.query')) {
|
|
671
671
|
const resQuery = parseQuery(o.query, o.data.requestQuery.query)
|
|
672
|
-
if (
|
|
672
|
+
if ($n.isValidObject(resQuery)) {
|
|
673
673
|
Object.assign(query, resQuery)
|
|
674
674
|
}
|
|
675
675
|
}
|
|
@@ -677,13 +677,13 @@ function getRequestQuery(o) {
|
|
|
677
677
|
// 获取表格数据
|
|
678
678
|
if (
|
|
679
679
|
// 如果按钮参数有显示类型
|
|
680
|
-
|
|
680
|
+
$n.has(o.data, 'show')
|
|
681
681
|
// 按钮参数的显示类型必须是单选或多选
|
|
682
|
-
&&
|
|
682
|
+
&& $n.indexOf(['single', 'multi'], o.data.show) > -1
|
|
683
683
|
// 如果有请求传参的表格设置
|
|
684
|
-
&&
|
|
684
|
+
&& $n.has(o.data, 'requestQuery.table')
|
|
685
685
|
// 如果有表格数据
|
|
686
|
-
&&
|
|
686
|
+
&& $n.isValidArray(o.tableSelected)
|
|
687
687
|
) {
|
|
688
688
|
let newQuery = {}
|
|
689
689
|
|
|
@@ -696,8 +696,8 @@ function getRequestQuery(o) {
|
|
|
696
696
|
} else {
|
|
697
697
|
// 合并表格选中的每一条数据
|
|
698
698
|
for (const item of o.tableSelected) {
|
|
699
|
-
|
|
700
|
-
if (
|
|
699
|
+
$n.forIn(item, function(value, key) {
|
|
700
|
+
if ($n.has(newQuery, key)) {
|
|
701
701
|
newQuery[key].push(value)
|
|
702
702
|
} else {
|
|
703
703
|
newQuery[key] = [value]
|
|
@@ -707,12 +707,12 @@ function getRequestQuery(o) {
|
|
|
707
707
|
}
|
|
708
708
|
|
|
709
709
|
const resTable = parseQuery(newQuery, o.data.requestQuery.table)
|
|
710
|
-
if (
|
|
710
|
+
if ($n.isValidObject(resTable)) {
|
|
711
711
|
Object.assign(query, resTable)
|
|
712
712
|
}
|
|
713
713
|
}
|
|
714
714
|
|
|
715
|
-
return
|
|
715
|
+
return $n.cloneDeep($n.numberDeep(query))
|
|
716
716
|
}
|
|
717
717
|
|
|
718
718
|
/**
|
|
@@ -723,32 +723,32 @@ function formatQuery(query, isJoinArr) {
|
|
|
723
723
|
const newQuery = {}
|
|
724
724
|
|
|
725
725
|
// 格式化参数
|
|
726
|
-
|
|
726
|
+
$n.forIn(query, function(value, key) {
|
|
727
727
|
|
|
728
728
|
// 如果是数字
|
|
729
|
-
if (
|
|
730
|
-
newQuery[key] =
|
|
729
|
+
if ($n.isNumeric(value)) {
|
|
730
|
+
newQuery[key] = $n.isNumber(value) ? value : Number(value)
|
|
731
731
|
|
|
732
732
|
// 如果是字符串
|
|
733
|
-
} else if (
|
|
734
|
-
newQuery[key] =
|
|
733
|
+
} else if ($n.isValidString(value)) {
|
|
734
|
+
newQuery[key] = $n.trimString(value)
|
|
735
735
|
|
|
736
736
|
// 如果是数组
|
|
737
|
-
} else if (
|
|
737
|
+
} else if ($n.isValidArray(value)) {
|
|
738
738
|
|
|
739
739
|
const arr = []
|
|
740
740
|
for (const val of value) {
|
|
741
741
|
|
|
742
742
|
// 如果为有效值
|
|
743
|
-
if (
|
|
743
|
+
if ($n.isRequired(val)) {
|
|
744
744
|
|
|
745
745
|
// 如果是数字
|
|
746
|
-
if (
|
|
747
|
-
arr.push(
|
|
746
|
+
if ($n.isNumeric(val)) {
|
|
747
|
+
arr.push($n.isNumber(val) ? val : Number(val))
|
|
748
748
|
|
|
749
749
|
// 如果是字符串
|
|
750
|
-
} else if (
|
|
751
|
-
arr.push(
|
|
750
|
+
} else if ($n.isValidString(val)) {
|
|
751
|
+
arr.push($n.trimString(val))
|
|
752
752
|
|
|
753
753
|
// 否则为数组或对象
|
|
754
754
|
} else {
|
|
@@ -757,7 +757,7 @@ function formatQuery(query, isJoinArr) {
|
|
|
757
757
|
}
|
|
758
758
|
}
|
|
759
759
|
if (arr.length) {
|
|
760
|
-
newQuery[key] = isJoinArr ?
|
|
760
|
+
newQuery[key] = isJoinArr ? $n.join(arr, ',') : arr
|
|
761
761
|
}
|
|
762
762
|
}
|
|
763
763
|
})
|
|
@@ -798,7 +798,7 @@ async function request(params) {
|
|
|
798
798
|
o.query = $route.query
|
|
799
799
|
|
|
800
800
|
// 判断类型
|
|
801
|
-
if (!
|
|
801
|
+
if (! $n.get(o.data, 'type')) {
|
|
802
802
|
|
|
803
803
|
// 【调试模式】
|
|
804
804
|
// --------------------------------------------------
|
|
@@ -811,17 +811,17 @@ async function request(params) {
|
|
|
811
811
|
}
|
|
812
812
|
|
|
813
813
|
// 克隆 data
|
|
814
|
-
o.data =
|
|
814
|
+
o.data = $n.cloneDeep(o.data)
|
|
815
815
|
|
|
816
816
|
// 判断 url
|
|
817
|
-
o.data.url =
|
|
817
|
+
o.data.url = $n.toLower($n.trimString(o.data.url))
|
|
818
818
|
if (! o.data.url) {
|
|
819
819
|
|
|
820
820
|
if (
|
|
821
821
|
// 如果没有跳转页面地址
|
|
822
|
-
!
|
|
822
|
+
! $n.has(o.data, 'toPage')
|
|
823
823
|
// 或跳转页面地址为空
|
|
824
|
-
|| !
|
|
824
|
+
|| ! $n.isValidString(o.data.toPage)
|
|
825
825
|
) {
|
|
826
826
|
// 【调试模式】
|
|
827
827
|
// --------------------------------------------------
|
|
@@ -849,13 +849,13 @@ async function request(params) {
|
|
|
849
849
|
query = formatQuery(query, true)
|
|
850
850
|
|
|
851
851
|
// 如果有增加来源页面参数
|
|
852
|
-
if (
|
|
852
|
+
if ($n.get(o.data, 'addFromPageQuery') === true) {
|
|
853
853
|
// 来源页面是当前路由的完整路径
|
|
854
854
|
query.n_frompage = encodeURIComponent($currentRoute.fullPath)
|
|
855
855
|
}
|
|
856
856
|
|
|
857
857
|
// 请求前执行
|
|
858
|
-
const resBefore = await
|
|
858
|
+
const resBefore = await $n.runAsync(o.requestBefore)({ params: o, requestData: query })
|
|
859
859
|
if (resBefore !== void 0) {
|
|
860
860
|
if (resBefore === false) {
|
|
861
861
|
return
|
|
@@ -863,7 +863,7 @@ async function request(params) {
|
|
|
863
863
|
query = resBefore
|
|
864
864
|
}
|
|
865
865
|
|
|
866
|
-
|
|
866
|
+
$n.router.push({
|
|
867
867
|
path: o.data.url,
|
|
868
868
|
query,
|
|
869
869
|
})
|
|
@@ -878,14 +878,14 @@ async function request(params) {
|
|
|
878
878
|
if (o.data.type === dicts.POWER_DATA_TYPE__FORM) {
|
|
879
879
|
|
|
880
880
|
// 获取表单注入
|
|
881
|
-
o.$form =
|
|
881
|
+
o.$form = $n.has(params, '$form') ? params.$form : inject(NFormKey)
|
|
882
882
|
|
|
883
883
|
if (! o.$form) {
|
|
884
884
|
throw new Error('没有创建表单实例')
|
|
885
885
|
}
|
|
886
886
|
|
|
887
887
|
// 如果验证表单
|
|
888
|
-
if (
|
|
888
|
+
if ($n.get(o.data, 'validate') !== false) {
|
|
889
889
|
|
|
890
890
|
if (! o.$form.formRef) {
|
|
891
891
|
throw new Error('没有绑定 fromRef')
|
|
@@ -898,47 +898,47 @@ async function request(params) {
|
|
|
898
898
|
}
|
|
899
899
|
|
|
900
900
|
// 验证表单数据
|
|
901
|
-
if (!
|
|
901
|
+
if (! $n.isValidObject(o.$form.formData.value)) {
|
|
902
902
|
throw new Error('没有获取到表单数据')
|
|
903
903
|
}
|
|
904
904
|
|
|
905
905
|
// 检查是否正在上传文件
|
|
906
|
-
if (
|
|
906
|
+
if ($n.isFunction(o.checkUploading) && o.checkUploading()) {
|
|
907
907
|
// 轻提示
|
|
908
|
-
|
|
908
|
+
$n.toast({
|
|
909
909
|
message: '文件上传中,请耐心等待',
|
|
910
910
|
})
|
|
911
911
|
return
|
|
912
912
|
}
|
|
913
913
|
|
|
914
914
|
// 获取请求数据
|
|
915
|
-
requestData =
|
|
915
|
+
requestData = $n.merge({}, formatQuery(query, false), o.$form.formData.value)
|
|
916
916
|
|
|
917
917
|
// 如果是请求数据
|
|
918
918
|
// --------------------------------------------------
|
|
919
919
|
} else {
|
|
920
920
|
// 获取表格注入
|
|
921
|
-
o.$table =
|
|
921
|
+
o.$table = $n.has(params, '$table') ? params.$table : inject(NTableKey)
|
|
922
922
|
|
|
923
923
|
// 获取请求数据
|
|
924
924
|
requestData = formatQuery(query, false)
|
|
925
925
|
}
|
|
926
926
|
|
|
927
927
|
// 判断是否有确认框
|
|
928
|
-
const isConfirm =
|
|
928
|
+
const isConfirm = $n.get(o.data, 'confirm')
|
|
929
929
|
if (
|
|
930
930
|
// 如果有确认框
|
|
931
931
|
isConfirm
|
|
932
932
|
// 如果有密码确认框
|
|
933
|
-
||
|
|
933
|
+
|| $n.get(o.data, 'confirmPassword')
|
|
934
934
|
) {
|
|
935
935
|
// 如果需要先弹出确认框
|
|
936
936
|
if (isConfirm) {
|
|
937
937
|
|
|
938
938
|
// 确认框
|
|
939
|
-
|
|
939
|
+
$n.confirm({
|
|
940
940
|
// 重要操作,请输入登录密码并确认后操作
|
|
941
|
-
message:
|
|
941
|
+
message: $n.isValidString(isConfirm) ? isConfirm : '确认要执行该操作吗?',
|
|
942
942
|
})
|
|
943
943
|
// 点击确认执行
|
|
944
944
|
.onOk(onRequest)
|
|
@@ -956,7 +956,7 @@ async function request(params) {
|
|
|
956
956
|
async function onRequest() {
|
|
957
957
|
|
|
958
958
|
// 请求前执行
|
|
959
|
-
const resBefore = await
|
|
959
|
+
const resBefore = await $n.runAsync(o.requestBefore)({ params: o, requestData })
|
|
960
960
|
if (resBefore !== void 0) {
|
|
961
961
|
if (resBefore === false) {
|
|
962
962
|
return
|
|
@@ -965,7 +965,7 @@ async function request(params) {
|
|
|
965
965
|
}
|
|
966
966
|
|
|
967
967
|
// 请求
|
|
968
|
-
const res = await
|
|
968
|
+
const res = await $n.http({
|
|
969
969
|
// 请求地址
|
|
970
970
|
url: o.data.url,
|
|
971
971
|
// 请求数据
|
|
@@ -981,7 +981,7 @@ async function request(params) {
|
|
|
981
981
|
}, res)
|
|
982
982
|
|
|
983
983
|
// 请求后执行
|
|
984
|
-
if (await
|
|
984
|
+
if (await $n.runAsync(o.requestAfter)(resultData) === false) {
|
|
985
985
|
return
|
|
986
986
|
}
|
|
987
987
|
|
|
@@ -993,14 +993,14 @@ async function request(params) {
|
|
|
993
993
|
|
|
994
994
|
// 轻提示
|
|
995
995
|
if (isNotify) {
|
|
996
|
-
|
|
996
|
+
$n.toast({
|
|
997
997
|
type: 'positive',
|
|
998
998
|
message: '恭喜您,操作成功',
|
|
999
999
|
})
|
|
1000
1000
|
}
|
|
1001
1001
|
|
|
1002
1002
|
// 判断是否有请求成功后的操作动作
|
|
1003
|
-
if (
|
|
1003
|
+
if ($n.has(o.data, 'requestSuccess.type')) {
|
|
1004
1004
|
switch (o.data.requestSuccess.type) {
|
|
1005
1005
|
|
|
1006
1006
|
// 关闭当前页面
|
|
@@ -1012,7 +1012,7 @@ async function request(params) {
|
|
|
1012
1012
|
|
|
1013
1013
|
// 如果是渲染页面
|
|
1014
1014
|
// 说明该页面在 <table-splitter> 组件内部被渲染, 则不需要关闭当前窗口
|
|
1015
|
-
if (
|
|
1015
|
+
if ($n.has($route.query, 'n_renderpage') && $route.query.n_renderpage === 1) {
|
|
1016
1016
|
// 则无任何操作
|
|
1017
1017
|
return
|
|
1018
1018
|
}
|
|
@@ -1025,8 +1025,8 @@ async function request(params) {
|
|
|
1025
1025
|
// 如果不是关闭当前页面, 则为关闭窗口并跳转页面
|
|
1026
1026
|
o.data.requestSuccess.type !== 'close'
|
|
1027
1027
|
// 如果有来源页面
|
|
1028
|
-
&&
|
|
1029
|
-
&&
|
|
1028
|
+
&& $n.has($route.query, 'n_frompage')
|
|
1029
|
+
&& $n.isValidString($route.query.n_frompage)
|
|
1030
1030
|
) {
|
|
1031
1031
|
Object.assign(opts, {
|
|
1032
1032
|
// 跳转页面地址
|
|
@@ -1036,30 +1036,30 @@ async function request(params) {
|
|
|
1036
1036
|
})
|
|
1037
1037
|
|
|
1038
1038
|
// 否则如果定义了跳转页面
|
|
1039
|
-
// else if (
|
|
1039
|
+
// else if ($n.has(o.data, 'requestSuccess.params') && $n.isValidString(o.data.requestSuccess.params)) {
|
|
1040
1040
|
// pushPage = o.data.requestSuccess.params
|
|
1041
1041
|
// }
|
|
1042
1042
|
}
|
|
1043
1043
|
|
|
1044
1044
|
// 关闭当前标签页
|
|
1045
|
-
|
|
1045
|
+
$n.bus.emit('main', opts)
|
|
1046
1046
|
break
|
|
1047
1047
|
|
|
1048
1048
|
// 重置表单
|
|
1049
1049
|
case 'resetForm':
|
|
1050
|
-
|
|
1050
|
+
$n.run(o.$form?.resetForm)()
|
|
1051
1051
|
break
|
|
1052
1052
|
|
|
1053
1053
|
// 刷新表格
|
|
1054
1054
|
case 'refreshTable':
|
|
1055
|
-
|
|
1055
|
+
$n.run(o.$table?.tableRefresh)()
|
|
1056
1056
|
break
|
|
1057
1057
|
}
|
|
1058
1058
|
}
|
|
1059
1059
|
}
|
|
1060
1060
|
|
|
1061
1061
|
// 请求成功执行
|
|
1062
|
-
if (await
|
|
1062
|
+
if (await $n.runAsync(o.requestSuccess)(Object.assign({ next }, resultData)) === false) {
|
|
1063
1063
|
return
|
|
1064
1064
|
}
|
|
1065
1065
|
|
|
@@ -1068,7 +1068,7 @@ async function request(params) {
|
|
|
1068
1068
|
|
|
1069
1069
|
} else {
|
|
1070
1070
|
// 请求失败执行
|
|
1071
|
-
|
|
1071
|
+
$n.run(o.requestFail)(resultData)
|
|
1072
1072
|
}
|
|
1073
1073
|
}
|
|
1074
1074
|
}
|
|
@@ -1079,34 +1079,34 @@ async function request(params) {
|
|
|
1079
1079
|
function getPageData($route) {
|
|
1080
1080
|
|
|
1081
1081
|
if (! $route) {
|
|
1082
|
-
$route =
|
|
1082
|
+
$route = $n.router.getRoute()
|
|
1083
1083
|
}
|
|
1084
1084
|
|
|
1085
|
-
const path =
|
|
1085
|
+
const path = $n.get($route, 'path')
|
|
1086
1086
|
if (! path) {
|
|
1087
|
-
return
|
|
1087
|
+
return $n.fail('路由参数错误')
|
|
1088
1088
|
}
|
|
1089
1089
|
|
|
1090
1090
|
if (! statePower.value.v) {
|
|
1091
|
-
return
|
|
1091
|
+
return $n.fail('没有获取到权限数据')
|
|
1092
1092
|
}
|
|
1093
1093
|
|
|
1094
1094
|
// 获取角色数据
|
|
1095
|
-
const { urls, btns } =
|
|
1096
|
-
if (!
|
|
1097
|
-
return
|
|
1095
|
+
const { urls, btns } = $n.cloneDeep(statePower.value)
|
|
1096
|
+
if (! $n.has(urls, path)) {
|
|
1097
|
+
return $n.fail('该页面没有权限')
|
|
1098
1098
|
}
|
|
1099
1099
|
|
|
1100
|
-
return
|
|
1100
|
+
return $n.success({
|
|
1101
1101
|
page: urls[path],
|
|
1102
|
-
btns:
|
|
1102
|
+
btns: $n.has(btns, path) ? btns[path] : [],
|
|
1103
1103
|
})
|
|
1104
1104
|
}
|
|
1105
1105
|
|
|
1106
1106
|
/**
|
|
1107
1107
|
* 权限业务
|
|
1108
1108
|
*/
|
|
1109
|
-
|
|
1109
|
+
$n.$power = {
|
|
1110
1110
|
// 创建
|
|
1111
1111
|
create,
|
|
1112
1112
|
// 设置权限数据
|