This commit is contained in:
@@ -86,9 +86,18 @@
|
||||
<span class="dialog-title">分配角色</span>
|
||||
<div class="account-info">
|
||||
<span class="account-name">{{ currentAccountName }}</span>
|
||||
<ElTag v-if="currentAccountType === 1" type="danger" size="small" style="margin-left: 8px">
|
||||
超级管理员不能分配角色
|
||||
</ElTag>
|
||||
<ElTag v-if="currentAccountType === 2" type="info" size="small" style="margin-left: 8px">
|
||||
平台用户只能分配一个平台角色
|
||||
</ElTag>
|
||||
<ElTag v-if="currentAccountType === 3" type="warning" size="small" style="margin-left: 8px">
|
||||
代理账号只能分配一个客户角色
|
||||
</ElTag>
|
||||
<ElTag v-if="currentAccountType === 4" type="warning" size="small" style="margin-left: 8px">
|
||||
企业账号只能分配一个客户角色
|
||||
</ElTag>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
@@ -549,9 +558,15 @@
|
||||
let roles = allRoles.value
|
||||
|
||||
// 根据账号类型过滤角色
|
||||
if (currentAccountType.value === 3) {
|
||||
if (currentAccountType.value === 1) {
|
||||
// 超级管理员:不能分配任何角色
|
||||
return []
|
||||
} else if (currentAccountType.value === 3) {
|
||||
// 代理账号:只显示客户角色
|
||||
roles = roles.filter((role) => role.role_type === 2)
|
||||
} else if (currentAccountType.value === 4) {
|
||||
// 企业账号:只显示客户角色
|
||||
roles = roles.filter((role) => role.role_type === 2)
|
||||
} else if (currentAccountType.value === 2) {
|
||||
// 平台用户:只显示平台角色
|
||||
roles = roles.filter((role) => role.role_type === 1)
|
||||
@@ -605,21 +620,15 @@
|
||||
if (rolesToAdd.value.length === 0) return
|
||||
|
||||
try {
|
||||
let newRoles: number[]
|
||||
|
||||
// 代理账号只能分配一个角色,会覆盖之前的角色
|
||||
if (currentAccountType.value === 3) {
|
||||
if (rolesToAdd.value.length > 1) {
|
||||
ElMessage.warning('代理账号只能分配一个角色')
|
||||
return
|
||||
}
|
||||
// 只保留新选择的一个角色
|
||||
newRoles = rolesToAdd.value
|
||||
} else {
|
||||
// 其他账号类型可以分配多个角色
|
||||
newRoles = [...new Set([...selectedRoles.value, ...rolesToAdd.value])]
|
||||
// 所有账号只能分配一个角色
|
||||
if (rolesToAdd.value.length > 1) {
|
||||
ElMessage.warning('只能分配一个角色')
|
||||
return
|
||||
}
|
||||
|
||||
// 新角色会替换之前的角色
|
||||
const newRoles = rolesToAdd.value
|
||||
|
||||
await AccountService.assignRolesToAccount(currentAccountId.value, newRoles)
|
||||
|
||||
selectedRoles.value = newRoles
|
||||
|
||||
@@ -458,7 +458,7 @@
|
||||
{
|
||||
prop: 'operation',
|
||||
label: '操作',
|
||||
width: 280,
|
||||
width: 190,
|
||||
fixed: 'right',
|
||||
formatter: (row: EnterpriseItem) => {
|
||||
const buttons = []
|
||||
@@ -481,16 +481,6 @@
|
||||
)
|
||||
}
|
||||
|
||||
// 只要有编辑、修改密码权限之一,就显示更多操作按钮
|
||||
if (hasAuth('enterprise_customer:edit') || hasAuth('enterprise_customer:update_pwd')) {
|
||||
buttons.push(
|
||||
h(ArtButtonTable, {
|
||||
text: '更多操作',
|
||||
onContextmenu: (e: MouseEvent) => showEnterpriseOperationMenu(e, row)
|
||||
})
|
||||
)
|
||||
}
|
||||
|
||||
return h('div', { style: 'display: flex; gap: 8px;' }, buttons)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user