File tree Expand file tree Collapse file tree 3 files changed +141
-245
lines changed Expand file tree Collapse file tree 3 files changed +141
-245
lines changed Original file line number Diff line number Diff line change @@ -5,18 +5,10 @@ const { t } = useI18n() // 国际化
5
5
6
6
export function hasPermi ( app : App < Element > ) {
7
7
app . directive ( 'hasPermi' , ( el , binding ) => {
8
- const { wsCache } = useCache ( )
9
8
const { value } = binding
10
- const all_permission = '*:*:*'
11
- const userInfo = wsCache . get ( CACHE_KEY . USER )
12
- const permissions = userInfo ?. permissions || [ ]
13
9
14
10
if ( value && value instanceof Array && value . length > 0 ) {
15
- const permissionFlag = value
16
-
17
- const hasPermissions = permissions . some ( ( permission : string ) => {
18
- return all_permission === permission || permissionFlag . includes ( permission )
19
- } )
11
+ const hasPermissions = hasPermission ( value )
20
12
21
13
if ( ! hasPermissions ) {
22
14
el . parentNode && el . parentNode . removeChild ( el )
@@ -26,3 +18,14 @@ export function hasPermi(app: App<Element>) {
26
18
}
27
19
} )
28
20
}
21
+
22
+ export const hasPermission = ( permission : string [ ] ) => {
23
+ const { wsCache } = useCache ( )
24
+ const all_permission = '*:*:*'
25
+ const userInfo = wsCache . get ( CACHE_KEY . USER )
26
+ const permissions = userInfo ?. permissions || [ ]
27
+
28
+ return permissions . some ( ( p : string ) => {
29
+ return all_permission === p || permission . includes ( p )
30
+ } )
31
+ }
Original file line number Diff line number Diff line change 16
16
<template #default =" { height , width } " >
17
17
<!-- Virtualized Table 虚拟化表格:高性能,解决表格在大数据量下的卡顿问题 -->
18
18
<el-table-v2
19
+ v-loading =" loading"
19
20
:columns =" columns"
20
21
:data =" list"
21
22
:width =" width"
31
32
<AreaForm ref =" formRef" />
32
33
</template >
33
34
<script setup lang="tsx">
34
- import type { Column } from ' element-plus'
35
+ import { Column } from ' element-plus'
35
36
import AreaForm from ' ./AreaForm.vue'
36
37
import * as AreaApi from ' @/api/system/area'
37
38
@@ -40,7 +41,7 @@ defineOptions({ name: 'SystemArea' })
40
41
// 表格的 column 字段
41
42
const columns: Column [] = [
42
43
{
43
- dataKey: ' id' , // 需要渲染当前列的数据字段。例如说:{id:9527, name:'Mike'},则填 id
44
+ dataKey: ' id' , // 需要渲染当前列的数据字段
44
45
title: ' 编号' , // 显示在单元格表头的文本
45
46
width: 400 , // 当前列的宽度,必须设置
46
47
fixed: true , // 是否固定列
@@ -52,14 +53,17 @@ const columns: Column[] = [
52
53
width: 200
53
54
}
54
55
]
55
- // 表格的数据
56
- const list = ref ([])
56
+ const loading = ref ( true ) // 列表的加载中
57
+ const list = ref ([]) // 表格的数据
57
58
58
- /**
59
- * 获得数据列表
60
- */
59
+ /** 获得数据列表 */
61
60
const getList = async () => {
62
- list .value = await AreaApi .getAreaTree ()
61
+ loading .value = true
62
+ try {
63
+ list .value = await AreaApi .getAreaTree ()
64
+ } finally {
65
+ loading .value = false
66
+ }
63
67
}
64
68
65
69
/** 添加/修改操作 */
You can’t perform that action at this time.
0 commit comments