|
2 | 2 | <div class="role-manage p-16-24"> |
3 | 3 | <h2 class="mb-16">{{ $t('views.role.title') }}</h2> |
4 | 4 | <el-card style="--el-card-padding: 0"> |
5 | | - <div class="flex main-calc-height"> |
6 | | - <div class="role-left border-r p-16"> |
7 | | - <div class="p-8 pb-0 mb-12"> |
| 5 | + <div class="flex h-full"> |
| 6 | + <div class="role-left border-r"> |
| 7 | + <div class="p-24 pb-0"> |
8 | 8 | <el-input |
9 | 9 | v-model="filterText" |
10 | 10 | :placeholder="$t('common.search')" |
|
14 | 14 | </div> |
15 | 15 | <div class="list-height-left"> |
16 | 16 | <el-scrollbar v-loading="loading"> |
17 | | - <div class="color-secondary lighter ml-8 mb-8"> |
18 | | - <span>{{ $t('views.role.internalRole') }}</span> |
19 | | - </div> |
20 | | - <common-list |
21 | | - :data="filterInternalRole" |
22 | | - @click="clickRole" |
23 | | - :default-active="currentRole?.id" |
24 | | - @mouseenter="mouseenter" |
25 | | - @mouseleave="mouseId = ''" |
26 | | - > |
27 | | - <template #default="{ row }"> |
28 | | - <div class="flex-between"> |
29 | | - <span class="mr-8">{{ row.role_name }}</span> |
30 | | - <div @click.stop v-show="mouseId === row.id"> |
31 | | - <el-dropdown :teleported="false"> |
32 | | - <el-button text> |
33 | | - <el-icon class="color-secondary"> |
34 | | - <MoreFilled /> |
35 | | - </el-icon> |
36 | | - </el-button> |
37 | | - <template #dropdown> |
38 | | - <el-dropdown-menu style="min-width: 80px"> |
39 | | - <el-dropdown-item @click.stop="createOrUpdateRole(row)" class="p-8"> |
40 | | - <el-icon><EditPen /></el-icon> |
41 | | - {{ $t('common.rename') }} |
42 | | - </el-dropdown-item> |
43 | | - <el-dropdown-item @click.stop="deleteRole(row)" class="border-t p-8"> |
44 | | - <el-icon><Delete /></el-icon> |
45 | | - {{ $t('common.delete') }} |
46 | | - </el-dropdown-item> |
47 | | - </el-dropdown-menu> |
48 | | - </template> |
49 | | - </el-dropdown> |
| 17 | + <div class="p-16"> |
| 18 | + <div class="color-secondary lighter ml-8 mb-8"> |
| 19 | + <span>{{ $t('views.role.internalRole') }}</span> |
| 20 | + </div> |
| 21 | + <common-list |
| 22 | + :data="filterInternalRole" |
| 23 | + @click="clickRole" |
| 24 | + :default-active="currentRole?.id" |
| 25 | + @mouseenter="mouseenter" |
| 26 | + @mouseleave="mouseId = ''" |
| 27 | + > |
| 28 | + <template #default="{ row }"> |
| 29 | + <div class="flex-between"> |
| 30 | + <span class="mr-8">{{ row.role_name }}</span> |
| 31 | + <div @click.stop v-show="mouseId === row.id"> |
| 32 | + <el-dropdown :teleported="false"> |
| 33 | + <el-button text> |
| 34 | + <el-icon class="color-secondary"> |
| 35 | + <MoreFilled /> |
| 36 | + </el-icon> |
| 37 | + </el-button> |
| 38 | + <template #dropdown> |
| 39 | + <el-dropdown-menu style="min-width: 80px"> |
| 40 | + <el-dropdown-item @click.stop="createOrUpdateRole(row)" class="p-8" |
| 41 | + v-if="hasPermission( |
| 42 | + new ComplexPermission( |
| 43 | + [RoleConst.ADMIN], |
| 44 | + [PermissionConst.ROLE_EDIT], |
| 45 | + [],'OR' |
| 46 | + ),'OR' |
| 47 | + )" |
| 48 | + > |
| 49 | + <el-icon><EditPen /></el-icon> |
| 50 | + {{ $t('common.rename') }} |
| 51 | + </el-dropdown-item> |
| 52 | + <el-dropdown-item @click.stop="deleteRole(row)" class="border-t p-8" |
| 53 | + v-if="hasPermission( |
| 54 | + new ComplexPermission( |
| 55 | + [RoleConst.ADMIN], |
| 56 | + [PermissionConst.ROLE_DELETE], |
| 57 | + [],'OR' |
| 58 | + ),'OR' |
| 59 | + )" |
| 60 | + > |
| 61 | + <el-icon><Delete /></el-icon> |
| 62 | + {{ $t('common.delete') }} |
| 63 | + </el-dropdown-item> |
| 64 | + </el-dropdown-menu> |
| 65 | + </template> |
| 66 | + </el-dropdown> |
| 67 | + </div> |
50 | 68 | </div> |
51 | | - </div> |
52 | | - </template> |
53 | | - <template #empty> |
54 | | - <span></span> |
55 | | - </template> |
56 | | - </common-list> |
| 69 | + </template> |
| 70 | + <template #empty> |
| 71 | + <span></span> |
| 72 | + </template> |
| 73 | + </common-list> |
57 | 74 |
|
58 | | - <div class="ml-8 border-t flex-between mb-8" style="padding-top: 12px"> |
59 | | - <span class="color-secondary lighter">{{ $t('views.role.customRole') }}</span> |
60 | | - <el-tooltip |
61 | | - effect="dark" |
62 | | - :content="`${$t('common.create')}${$t('views.role.customRole')}`" |
63 | | - placement="top" |
64 | | - > |
65 | | - <el-button |
66 | | - type="primary" |
67 | | - text |
68 | | - @click="createOrUpdateRole()" |
69 | | - v-hasPermission=" |
70 | | - new ComplexPermission( |
71 | | - [RoleConst.ADMIN, RoleConst.WORKSPACE_MANAGE.getWorkspaceRole], |
72 | | - [PermissionConst.ROLE_CREATE.getWorkspacePermission], |
73 | | - [], |
74 | | - 'OR', |
75 | | - ) |
76 | | - " |
| 75 | + <div class="ml-8 border-t flex-between mb-8" style="padding-top: 12px"> |
| 76 | + <span class="color-secondary lighter">{{ $t('views.role.customRole') }}</span> |
| 77 | + <el-tooltip |
| 78 | + effect="dark" |
| 79 | + :content="`${$t('common.create')}${$t('views.role.customRole')}`" |
| 80 | + placement="top" |
77 | 81 | > |
78 | | - <el-icon :size="18"><Plus /></el-icon> |
79 | | - </el-button> |
80 | | - </el-tooltip> |
81 | | - </div> |
82 | | - <common-list |
83 | | - :data="filterCustomRole" |
84 | | - @click="clickRole" |
85 | | - :default-active="currentRole?.id" |
86 | | - @mouseenter="mouseenter" |
87 | | - @mouseleave="mouseId = ''" |
88 | | - > |
89 | | - <template #default="{ row }"> |
90 | | - <div class="flex-between"> |
91 | | - <span> |
92 | | - {{ row.role_name }} |
93 | | - <span class="color-input-placeholder ml-4" |
94 | | - >({{ roleTypeMap[row.type as RoleTypeEnum] }})</span |
95 | | - > |
96 | | - </span> |
97 | | - <div @click.stop v-show="mouseId === row.id"> |
98 | | - <el-dropdown :teleported="false"> |
99 | | - <el-button text> |
100 | | - <el-icon class="color-secondary"> |
101 | | - <MoreFilled /> |
102 | | - </el-icon> |
103 | | - </el-button> |
104 | | - <template #dropdown> |
105 | | - <el-dropdown-menu style="min-width: 80px"> |
106 | | - <el-dropdown-item @click.stop="createOrUpdateRole(row)" class="p-8"> |
107 | | - <el-icon><EditPen /></el-icon> |
108 | | - {{ $t('common.rename') }} |
109 | | - </el-dropdown-item> |
110 | | - <el-dropdown-item @click.stop="deleteRole(row)" class="border-t p-8"> |
111 | | - <el-icon><Delete /></el-icon> |
112 | | - {{ $t('common.delete') }} |
113 | | - </el-dropdown-item> |
114 | | - </el-dropdown-menu> |
115 | | - </template> |
116 | | - </el-dropdown> |
| 82 | + <el-button |
| 83 | + type="primary" |
| 84 | + text |
| 85 | + @click="createOrUpdateRole()" |
| 86 | + v-hasPermission=" |
| 87 | + new ComplexPermission( |
| 88 | + [RoleConst.ADMIN], |
| 89 | + [PermissionConst.ROLE_CREATE], |
| 90 | + [], |
| 91 | + 'OR',)" |
| 92 | + > |
| 93 | + <el-icon :size="18"><Plus /></el-icon> |
| 94 | + </el-button> |
| 95 | + </el-tooltip> |
| 96 | + </div> |
| 97 | + <common-list |
| 98 | + :data="filterCustomRole" |
| 99 | + @click="clickRole" |
| 100 | + :default-active="currentRole?.id" |
| 101 | + @mouseenter="mouseenter" |
| 102 | + @mouseleave="mouseId = ''" |
| 103 | + > |
| 104 | + <template #default="{ row }"> |
| 105 | + <div class="flex-between"> |
| 106 | + <span> |
| 107 | + {{ row.role_name }} |
| 108 | + <span class="color-input-placeholder ml-4" |
| 109 | + >({{ roleTypeMap[row.type as RoleTypeEnum] }})</span |
| 110 | + > |
| 111 | + </span> |
| 112 | + <div @click.stop v-show="mouseId === row.id"> |
| 113 | + <el-dropdown :teleported="false"> |
| 114 | + <el-button text> |
| 115 | + <el-icon class="color-secondary"> |
| 116 | + <MoreFilled /> |
| 117 | + </el-icon> |
| 118 | + </el-button> |
| 119 | + <template #dropdown> |
| 120 | + <el-dropdown-menu style="min-width: 80px"> |
| 121 | + <el-dropdown-item @click.stop="createOrUpdateRole(row)" class="p-8" |
| 122 | + v-if="hasPermission( |
| 123 | + new ComplexPermission( |
| 124 | + [RoleConst.ADMIN], |
| 125 | + [PermissionConst.ROLE_EDIT], |
| 126 | + [],'OR' |
| 127 | + ),'OR' |
| 128 | + )" |
| 129 | + > |
| 130 | + <el-icon><EditPen /></el-icon> |
| 131 | + {{ $t('common.rename') }} |
| 132 | + </el-dropdown-item> |
| 133 | + <el-dropdown-item @click.stop="deleteRole(row)" class="border-t p-8" |
| 134 | + v-if="hasPermission( |
| 135 | + new ComplexPermission( |
| 136 | + [RoleConst.ADMIN], |
| 137 | + [PermissionConst.ROLE_DELETE], |
| 138 | + [],'OR' |
| 139 | + ),'OR' |
| 140 | + )" |
| 141 | + > |
| 142 | + <el-icon><Delete /></el-icon> |
| 143 | + {{ $t('common.delete') }} |
| 144 | + </el-dropdown-item> |
| 145 | + </el-dropdown-menu> |
| 146 | + </template> |
| 147 | + </el-dropdown> |
| 148 | + </div> |
117 | 149 | </div> |
118 | | - </div> |
119 | | - </template> |
120 | | - <template #empty> |
121 | | - <span></span> |
122 | | - </template> |
123 | | - </common-list> |
| 150 | + </template> |
| 151 | + <template #empty> |
| 152 | + <span></span> |
| 153 | + </template> |
| 154 | + </common-list> |
| 155 | + </div> |
124 | 156 | </el-scrollbar> |
125 | 157 | </div> |
126 | 158 | </div> |
@@ -176,6 +208,7 @@ import { MsgSuccess, MsgConfirm } from '@/utils/message' |
176 | 208 | import { loadPermissionApi } from '@/utils/dynamics-api/permission-api' |
177 | 209 | import { PermissionConst, RoleConst } from '@/utils/permission/data' |
178 | 210 | import { ComplexPermission } from '@/utils/permission/type' |
| 211 | +import { hasPermission } from '@/utils/permission/index' |
179 | 212 |
|
180 | 213 | const filterText = ref('') |
181 | 214 | const loading = ref(false) |
@@ -240,14 +273,12 @@ function deleteRole(item: RoleItem) { |
240 | 273 | }, |
241 | 274 | ) |
242 | 275 | .then(() => { |
243 | | - loadPermissionApi('role') |
244 | | - .deleteRole(item.id, loading) |
245 | | - .then(async () => { |
246 | | - MsgSuccess(t('common.deleteSuccess')) |
247 | | - await getRole() |
248 | | - currentRole.value = |
249 | | - item.id === currentRole.value?.id ? internalRoleList.value[0] : currentRole.value |
250 | | - }) |
| 276 | + loadPermissionApi('role').deleteRole(item.id, loading).then(async () => { |
| 277 | + MsgSuccess(t('common.deleteSuccess')) |
| 278 | + await getRole() |
| 279 | + currentRole.value = |
| 280 | + item.id === currentRole.value?.id ? internalRoleList.value[0] : currentRole.value |
| 281 | + }) |
251 | 282 | }) |
252 | 283 | .catch(() => {}) |
253 | 284 | } |
@@ -289,3 +320,4 @@ function mouseenter(row: any) { |
289 | 320 | } |
290 | 321 | } |
291 | 322 | </style> |
| 323 | + |
0 commit comments