Skip to content

Commit ac2483a

Browse files
authored
Merge pull request #186 from mfish-qf/develop
fix: 租户增删改权限与管理员增删改权限剥离
2 parents d65fd67 + 2542aea commit ac2483a

File tree

3 files changed

+51
-13
lines changed

3 files changed

+51
-13
lines changed

src/views/sys/account/index.vue

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,21 @@
88
:class="$props.source === 1 ? prefixCls : ''"
99
>
1010
<template #toolbar>
11-
<a-button type="primary" @click="handleCreate" v-auth="['sys:account:insert', 'sys:tenantUser:insert']"
11+
<a-button
12+
type="primary"
13+
@click="handleCreate"
14+
v-if="
15+
(source === 1 && hasPermission('sys:tenantUser:insert')) ||
16+
(source !== 1 && hasPermission('sys:account:insert'))
17+
"
1218
>新建账号
1319
</a-button>
14-
<a-button type="primary" @click="handleSelectAccount" v-auth="'sys:tenantUser:insert'">添加成员 </a-button>
20+
<a-button
21+
type="primary"
22+
@click="handleSelectAccount"
23+
v-if="source === 1 && hasPermission('sys:tenantUser:insert')"
24+
>添加成员
25+
</a-button>
1526
</template>
1627
<template #bodyCell="{ column, record }">
1728
<template v-if="column.key === 'action'">
@@ -22,7 +33,7 @@
2233
tooltip: '编辑用户资料',
2334
onClick: handleEdit.bind(null, record),
2435
auth: 'sys:account:update',
25-
ifShow: $props.source !== 1
36+
ifShow: source !== 1
2637
},
2738
{
2839
icon: 'ant-design:delete-outlined',
@@ -53,7 +64,7 @@
5364
confirm: handleRemoveUser.bind(null, record)
5465
},
5566
auth: 'sys:tenantUser:delete',
56-
ifShow: $props.source === 1
67+
ifShow: source === 1
5768
}
5869
]"
5970
/>
@@ -93,7 +104,7 @@
93104
default: null
94105
}
95106
});
96-
const { hasRole, SUPER_ROLE } = usePermission();
107+
const { hasRole, SUPER_ROLE, hasPermission } = usePermission();
97108
const [registerModal, { openModal }] = useModal();
98109
const [registerSelectModal, { openModal: openSelectModal }] = useModal();
99110
const [registerPwdModal, { openModal: openPwdModal }] = useModal();

src/views/sys/org/index.vue

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,12 @@
22
<div>
33
<BasicTable @register="registerTable" @fetch-success="onFetchSuccess" :class="$props.source === 1 ? prefixCls : ''">
44
<template #toolbar>
5-
<a-button type="primary" @click="handleCreate" v-auth="['sys:org:insert', 'sys:tenantOrg:insert']"
5+
<a-button
6+
type="primary"
7+
@click="handleCreate"
8+
v-if="
9+
(source === 1 && hasPermission('sys:tenantOrg:insert')) || (source !== 1 && hasPermission('sys:org:insert'))
10+
"
611
>新增组织
712
</a-button>
813
</template>
@@ -13,7 +18,9 @@
1318
{
1419
icon: 'ant-design:edit-outlined',
1520
onClick: handleEdit.bind(null, record),
16-
auth: ['sys:org:update', 'sys:tenantOrg:update']
21+
ifShow:
22+
(source === 1 && hasPermission('sys:tenantOrg:update')) ||
23+
(source !== 1 && hasPermission('sys:org:update'))
1724
},
1825
{
1926
icon: 'ant-design:delete-outlined',
@@ -23,7 +30,11 @@
2330
placement: 'left',
2431
confirm: handleDelete.bind(null, record)
2532
},
26-
ifShow: !record?.tenantId && hasPermission(['sys:org:delete', 'sys:tenantOrg:delete'])
33+
//最顶层租户组织不允许删除
34+
ifShow:
35+
!record?.tenantId &&
36+
((source === 1 && hasPermission('sys:tenantOrg:delete')) ||
37+
(source !== 1 && hasPermission('sys:org:delete')))
2738
}
2839
]"
2940
/>

src/views/sys/role/index.vue

Lines changed: 21 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,13 @@
22
<div>
33
<BasicTable @register="registerTable" :class="$props.source === 1 ? prefixCls : ''">
44
<template #toolbar>
5-
<a-button type="primary" @click="handleCreate" v-auth="['sys:role:insert', 'sys:tenantRole:insert']"
5+
<a-button
6+
type="primary"
7+
@click="handleCreate"
8+
v-if="
9+
(source === 1 && hasPermission('sys:tenantRole:insert')) ||
10+
(source !== 1 && hasPermission('sys:role:insert'))
11+
"
612
>新增角色
713
</a-button>
814
</template>
@@ -13,7 +19,9 @@
1319
{
1420
icon: 'ant-design:edit-outlined',
1521
onClick: handleEdit.bind(null, record),
16-
auth: ['sys:role:update', 'sys:tenantRole:update']
22+
ifShow:
23+
(source === 1 && hasPermission('sys:tenantRole:update')) ||
24+
(source !== 1 && hasPermission('sys:role:update'))
1725
},
1826
{
1927
icon: 'ant-design:delete-outlined',
@@ -23,7 +31,10 @@
2331
placement: 'left',
2432
confirm: handleDelete.bind(null, record)
2533
},
26-
ifShow: record.id !== '1' && hasPermission(['sys:role:delete', 'sys:tenantRole:delete'])
34+
ifShow:
35+
!isSuperRole(record.id) &&
36+
((source === 1 && hasPermission('sys:tenantRole:delete')) ||
37+
(source !== 1 && hasPermission('sys:role:delete')))
2738
}
2839
]"
2940
/>
@@ -63,7 +74,7 @@
6374
default: null
6475
}
6576
});
66-
const { hasPermission } = usePermission();
77+
const { hasPermission, isSuperRole } = usePermission();
6778
const [registerModal, { openModal }] = useModal();
6879
const { prefixCls } = useDesign("role");
6980
const api = ref();
@@ -108,7 +119,12 @@
108119
});
109120
}
110121
const statusLoading = ref(false);
111-
const statusDisabled = (record) => record.id === "1" || !hasPermission(["sys:role:update", "sys:tenantRole:update"]);
122+
const statusDisabled = (record) =>
123+
isSuperRole(record.id) ||
124+
!(
125+
(props.source === 1 && hasPermission("sys:tenantRole:update")) ||
126+
(props.source !== 1 && hasPermission("sys:role:update"))
127+
);
112128
113129
function handleStatus(record: SsoRole) {
114130
statusLoading.value = true;

0 commit comments

Comments
 (0)