fix: id兼容, 通知入口
All checks were successful
构建并部署前端到测试环境 / build-and-deploy (push) Successful in 5m0s
All checks were successful
构建并部署前端到测试环境 / build-and-deploy (push) Successful in 5m0s
This commit is contained in:
@@ -82,9 +82,9 @@
|
||||
>
|
||||
<ElOption
|
||||
v-for="role in availableRolesForCreate"
|
||||
:key="role.ID"
|
||||
:key="getRoleId(role)"
|
||||
:label="role.role_name"
|
||||
:value="role.ID"
|
||||
:value="getRoleId(role)"
|
||||
>
|
||||
<div style="display: flex; align-items: center; justify-content: space-between">
|
||||
<span>{{ role.role_name }}</span>
|
||||
@@ -133,8 +133,15 @@
|
||||
<ElEmpty v-if="filteredAvailableRoles.length === 0" description="暂无角色" />
|
||||
<template v-else-if="isPlatformUser">
|
||||
<ElCheckboxGroup v-model="rolesToAdd" class="role-list">
|
||||
<div v-for="role in filteredAvailableRoles" :key="role.ID" class="role-item">
|
||||
<ElCheckbox :label="role.ID" :disabled="selectedRoles.includes(role.ID)">
|
||||
<div
|
||||
v-for="role in filteredAvailableRoles"
|
||||
:key="getRoleId(role)"
|
||||
class="role-item"
|
||||
>
|
||||
<ElCheckbox
|
||||
:label="getRoleId(role)"
|
||||
:disabled="selectedRoles.includes(getRoleId(role))"
|
||||
>
|
||||
<span class="role-info">
|
||||
<span>{{ role.role_name }}</span>
|
||||
<ElTag :type="role.role_type === 1 ? 'primary' : 'success'" size="small">
|
||||
@@ -147,8 +154,15 @@
|
||||
</template>
|
||||
<template v-else>
|
||||
<ElRadioGroup v-model="roleToAdd" class="role-list">
|
||||
<div v-for="role in filteredAvailableRoles" :key="role.ID" class="role-item">
|
||||
<ElRadio :label="role.ID" :disabled="selectedRoles.includes(role.ID)">
|
||||
<div
|
||||
v-for="role in filteredAvailableRoles"
|
||||
:key="getRoleId(role)"
|
||||
class="role-item"
|
||||
>
|
||||
<ElRadio
|
||||
:label="getRoleId(role)"
|
||||
:disabled="selectedRoles.includes(getRoleId(role))"
|
||||
>
|
||||
<span class="role-info">
|
||||
<span>{{ role.role_name }}</span>
|
||||
<ElTag :type="role.role_type === 1 ? 'primary' : 'success'" size="small">
|
||||
@@ -190,7 +204,7 @@
|
||||
<div class="role-list">
|
||||
<div
|
||||
v-for="role in filteredAssignedRoles"
|
||||
:key="role.ID"
|
||||
:key="getRoleId(role)"
|
||||
class="role-item assigned-role-item"
|
||||
>
|
||||
<span class="role-info">
|
||||
@@ -199,7 +213,12 @@
|
||||
{{ role.role_type === 1 ? '平台角色' : '客户角色' }}
|
||||
</ElTag>
|
||||
</span>
|
||||
<ElButton type="danger" size="small" link @click="removeSingleRole(role.ID)">
|
||||
<ElButton
|
||||
type="danger"
|
||||
size="small"
|
||||
link
|
||||
@click="removeSingleRole(getRoleId(role))"
|
||||
>
|
||||
移除
|
||||
</ElButton>
|
||||
</div>
|
||||
@@ -310,6 +329,7 @@
|
||||
import type { SearchFormItem } from '@/types'
|
||||
import type { PlatformRole, WecomApplication, WecomMember } from '@/types/api'
|
||||
import { formatDateTime } from '@/utils/business/format'
|
||||
import { getCompatibleNumericId } from '@/utils/business/id'
|
||||
import {
|
||||
CommonStatus,
|
||||
getStatusText,
|
||||
@@ -356,6 +376,9 @@
|
||||
// 是否为平台用户(平台用户可多选,其他单选)
|
||||
const isPlatformUser = computed(() => currentAccountType.value === 2)
|
||||
|
||||
const getAccountId = (account: any) => getCompatibleNumericId(account) ?? 0
|
||||
const getRoleId = (role: PlatformRole | any) => getCompatibleNumericId(role) ?? 0
|
||||
|
||||
// 定义表单搜索初始值
|
||||
const initialSearchState = {
|
||||
name: '',
|
||||
@@ -631,14 +654,6 @@
|
||||
const getActions = (row: any) => {
|
||||
const actions: any[] = []
|
||||
|
||||
if (row.user_type === 2 && hasAuth(JULY_PERMISSIONS.wecom.binding)) {
|
||||
actions.push({
|
||||
label: '绑定账号',
|
||||
handler: () => showWecomBindingDialog(row),
|
||||
type: 'primary'
|
||||
})
|
||||
}
|
||||
|
||||
if (hasAuth('account:patch_role')) {
|
||||
actions.push({
|
||||
label: '分配角色',
|
||||
@@ -647,6 +662,14 @@
|
||||
})
|
||||
}
|
||||
|
||||
if (row.user_type === 2 && hasAuth(JULY_PERMISSIONS.wecom.binding)) {
|
||||
actions.push({
|
||||
label: '绑定账号',
|
||||
handler: () => showWecomBindingDialog(row),
|
||||
type: 'primary'
|
||||
})
|
||||
}
|
||||
|
||||
if (hasAuth('account:edit')) {
|
||||
actions.push({
|
||||
label: '编辑',
|
||||
@@ -716,7 +739,7 @@
|
||||
return
|
||||
}
|
||||
|
||||
const accountId = Number(currentWecomAccount.value.id ?? currentWecomAccount.value.ID)
|
||||
const accountId = getAccountId(currentWecomAccount.value)
|
||||
if (!accountId) {
|
||||
ElMessage.error('当前账号缺少账号标识,无法绑定企微')
|
||||
return
|
||||
@@ -823,7 +846,9 @@
|
||||
|
||||
// 计算属性:过滤后的已分配角色
|
||||
const filteredAssignedRoles = computed(() => {
|
||||
const assignedRolesList = allRoles.value.filter((role) => selectedRoles.value.includes(role.ID))
|
||||
const assignedRolesList = allRoles.value.filter((role) =>
|
||||
selectedRoles.value.includes(getRoleId(role))
|
||||
)
|
||||
if (!rightRoleFilter.value) return assignedRolesList
|
||||
const keyword = rightRoleFilter.value.toLowerCase()
|
||||
return assignedRolesList.filter((role) => role.role_name.toLowerCase().includes(keyword))
|
||||
@@ -835,7 +860,12 @@
|
||||
ElMessage.warning('超级管理员无法分配角色')
|
||||
return
|
||||
}
|
||||
currentAccountId.value = row.id
|
||||
const accountId = getAccountId(row)
|
||||
if (!accountId) {
|
||||
ElMessage.error('当前账号缺少账号标识,无法分配角色')
|
||||
return
|
||||
}
|
||||
currentAccountId.value = accountId
|
||||
currentAccountName.value = row.username
|
||||
currentAccountType.value = row.user_type
|
||||
selectedRoles.value = []
|
||||
@@ -852,12 +882,12 @@
|
||||
await loadAllRoles('', roleType)
|
||||
|
||||
// 先加载当前账号的角色,再打开对话框
|
||||
const res = await AccountService.getAccountRoles(row.id)
|
||||
const res = await AccountService.getAccountRoles(accountId)
|
||||
if (res.code === 0) {
|
||||
// 提取角色ID数组
|
||||
const roles = res.data || []
|
||||
// 兼容 ID 和 id 两种字段名
|
||||
selectedRoles.value = roles.map((role: any) => role.ID || role.id)
|
||||
selectedRoles.value = roles.map((role: any) => getRoleId(role)).filter(Boolean)
|
||||
// 数据加载完成后再打开对话框
|
||||
roleDialogVisible.value = true
|
||||
}
|
||||
@@ -1013,7 +1043,7 @@
|
||||
|
||||
// 创建成功后分配角色(如果选择了)
|
||||
if (createRes.code === 0) {
|
||||
const accountId = createRes.data?.ID || createRes.data?.id
|
||||
const accountId = getCompatibleNumericId(createRes.data)
|
||||
if (formData.role_id && accountId) {
|
||||
try {
|
||||
await AccountService.assignRolesToAccount(accountId, [formData.role_id])
|
||||
|
||||
Reference in New Issue
Block a user