签入版本

This commit is contained in:
2026-09-16 17:25:03 +08:00
parent f953e82e09
commit 0d560e5122
46 changed files with 1106 additions and 911 deletions
@@ -90,15 +90,15 @@ export function usePermission() {
### v-perm(满足任一权限)
```vue
<el-button v-perm="['sys:position:add']">添加岗位</el-button>
<el-button v-perm="['sys:position:batchDelete']">删除</el-button>
<el-button v-perm="['sys:position:export']">导出</el-button>
<n-button v-perm="['sys:position:add']">添加岗位</n-button>
<n-button v-perm="['sys:position:batchDelete']">删除</n-button>
<n-button v-perm="['sys:position:export']">导出</n-button>
```
### v-perms(满足所有权限)
```vue
<el-button v-perms="['sys:user:add', 'sys:user:import']">高级操作</el-button>
<n-button v-perms="['sys:user:add', 'sys:user:import']">高级操作</n-button>
```
### 与 v-if 结合
@@ -113,7 +113,7 @@ const showAddBtn = computed(() => hasPermission(['sys:position:add']));
```
```vue
<el-button v-if="showAddBtn">添加岗位</el-button>
<n-button v-if="showAddBtn">添加岗位</n-button>
```
## 实际用法(position 模块)
@@ -123,17 +123,20 @@ const showAddBtn = computed(() => hasPermission(['sys:position:add']));
```vue
<!-- src/views/system/position/index.vue -->
<template>
<BasicTable :columns="columns" :request="loadDataTable" ref="tableRef" :actionColumn="actionColumn">
<BasicTable :columns="columns" :request="loadDataTable" ref="basicTableRef" :actionColumn="actionColumn"
@update:checked-row-keys="onCheckedRow">
<template #tableTitle>
<el-button type="primary" @click="handleAdd" v-perm="['sys:position:add']">
<template #icon><el-icon><PlusOutlined /></el-icon></template>
添加岗位
</el-button>
<el-button type="danger" @click="handleDelete()" :disabled="!selectionData.length"
v-perm="['sys:position:batchDelete']">
<template #icon><el-icon><Delete /></el-icon></template>
删除
</el-button>
<n-space>
<n-button type="primary" @click="handleAdd" v-perm="['sys:position:add']">
<template #icon><n-icon><PlusOutlined /></n-icon></template>
新建
</n-button>
<n-button type="error" @click="handleDelete" :disabled="!rowKeys.length"
v-perm="['sys:position:batchDelete']">
<template #icon><n-icon><DeleteOutlined /></n-icon></template>
删除
</n-button>
</n-space>
</template>
</BasicTable>
</template>
@@ -142,25 +145,30 @@ const showAddBtn = computed(() => hasPermission(['sys:position:add']));
操作列中的权限控制通过 `auth` 属性实现:
```typescript
import { renderIcon } from '@/utils';
import { FormOutlined, DeleteOutlined } from '@vicons/antd';
const actionColumn = reactive({
width: 200,
label: '操作',
title: '操作',
align: 'center',
key: 'action',
fixed: 'right',
render(record) {
return h(TableAction, {
return h(TableAction as any, {
style: 'button',
actions: [
{
label: '编辑',
icon: 'Edit',
type: 'warning',
icon: renderIcon(FormOutlined),
type: 'info',
onClick: handleEdit.bind(null, record),
auth: ['sys:position:update'], // 权限节点
},
{
label: '删除',
icon: 'Delete',
type: 'danger',
icon: renderIcon(DeleteOutlined),
type: 'error',
onClick: handleDelete.bind(null, record),
auth: ['sys:position:delete'], // 权限节点
},
@@ -202,7 +210,7 @@ class PositionAddHandler(BaseHandler):
```vue
<!-- 前端 -->
<el-button v-perm="['sys:position:add']">添加岗位</el-button>
<n-button v-perm="['sys:position:add']">添加岗位</n-button>
```
## 超级管理员