-
+
@@ -114,6 +114,7 @@
+
@@ -693,6 +696,11 @@ import {
} from '@/service/api/system/role'
import type { RoleVo } from '@/service/api/system/role'
import { coiMsgBox, coiMsgError, coiMsgInfo, coiMsgSuccess, coiMsgWarning } from '@/utils/coi'
+import { PERMISSIONS } from '@/constants/permissions'
+import { usePermission } from '@/hooks/usePermission'
+
+// 权限相关
+const { hasButton } = usePermission()
// 响应式数据
const loading = ref(false)
@@ -974,16 +982,23 @@ const columns: DataTableColumns = [
align: 'center',
fixed: 'right',
render: (row) => {
- return h('div', { class: 'flex items-center justify-center gap-2' }, [
- h(NButton, {
+ const buttons = []
+
+ // 编辑按钮
+ if (hasButton(PERMISSIONS.USER.UPDATE)) {
+ buttons.push(h(NButton, {
type: 'primary',
size: 'small',
onClick: () => handleEdit(row),
}, {
icon: () => h(NIcon, { size: 14, style: 'transform: translateY(-1px)' }, { default: () => h('icon-park-outline:edit') }),
default: () => '编辑',
- }),
- h(NPopconfirm, {
+ }))
+ }
+
+ // 删除按钮
+ if (hasButton(PERMISSIONS.USER.DELETE)) {
+ buttons.push(h(NPopconfirm, {
onPositiveClick: () => handleDelete(row.userId),
negativeText: '取消',
positiveText: '确定',
@@ -996,24 +1011,34 @@ const columns: DataTableColumns = [
icon: () => h(NIcon, { size: 14, style: 'transform: translateY(-1px)' }, { default: () => h('icon-park-outline:delete') }),
default: () => '删除',
}),
- }),
- h(NButton, {
+ }))
+ }
+
+ // 重置密码按钮
+ if (hasButton(PERMISSIONS.USER.RESET_PWD)) {
+ buttons.push(h(NButton, {
type: 'warning',
size: 'small',
onClick: () => handleResetPassword(row),
}, {
icon: () => h(NIcon, { size: 14, style: 'transform: translateY(-1px)' }, { default: () => h('icon-park-outline:refresh') }),
default: () => '重置密码',
- }),
- h(NButton, {
+ }))
+ }
+
+ // 分配角色按钮
+ if (hasButton(PERMISSIONS.USER.ROLE)) {
+ buttons.push(h(NButton, {
type: 'info',
size: 'small',
onClick: () => handleAssignRole(row),
}, {
icon: () => h(NIcon, { size: 14, style: 'transform: translateY(-1px)' }, { default: () => h('icon-park-outline:setting') }),
default: () => '分配角色',
- }),
- ])
+ }))
+ }
+
+ return h('div', { class: 'flex items-center justify-center gap-2' }, buttons)
},
},
]