mirror of
https://gitee.com/qqtt-ah/ecom-dmb.git
synced 2026-11-25 00:29:19 +08:00
feat(前端): 增加按钮级权限控制
This commit is contained in:
@@ -35,6 +35,11 @@ import {
|
||||
} from '#/api/sys/account';
|
||||
|
||||
import SuperAccountFormModal from './components/SuperAccountFormModal.vue';
|
||||
import { PermissionGate } from '#/components/permission';
|
||||
import {
|
||||
syncVxeGridColumns,
|
||||
useActionColumnVisible,
|
||||
} from '#/composables/use-vxe-action-column';
|
||||
import {
|
||||
SIDEBAR_LIST_SHELL_CLASS,
|
||||
sidebarListRowClass,
|
||||
@@ -82,8 +87,15 @@ const selectedCompanyLabel = computed(() => {
|
||||
return currentCompany.value.name;
|
||||
});
|
||||
|
||||
const gridOptions: VxeGridProps<SuperAccountVO.AccountInfoVO> = {
|
||||
columns: [
|
||||
const accountActionCodes = [
|
||||
'org:account:create',
|
||||
'org:account:update',
|
||||
'org:account:delete',
|
||||
];
|
||||
const showActionColumn = useActionColumnVisible(accountActionCodes);
|
||||
|
||||
const accountTableBaseColumns: VxeGridProps<SuperAccountVO.AccountInfoVO>['columns'] =
|
||||
[
|
||||
{ type: 'seq' as const, minWidth: 56, title: '序号' },
|
||||
{
|
||||
field: 'loginCode',
|
||||
@@ -139,13 +151,25 @@ const gridOptions: VxeGridProps<SuperAccountVO.AccountInfoVO> = {
|
||||
minWidth: 160,
|
||||
showOverflow: 'tooltip' as const,
|
||||
},
|
||||
{
|
||||
title: '操作',
|
||||
minWidth: 140,
|
||||
fixed: 'right' as const,
|
||||
slots: { default: 'action' },
|
||||
},
|
||||
],
|
||||
];
|
||||
|
||||
const accountActionColumn: NonNullable<
|
||||
VxeGridProps<SuperAccountVO.AccountInfoVO>['columns']
|
||||
>[number] = {
|
||||
title: '操作',
|
||||
minWidth: 140,
|
||||
fixed: 'right' as const,
|
||||
slots: { default: 'action' },
|
||||
};
|
||||
|
||||
const accountTableColumns = computed(() =>
|
||||
showActionColumn.value
|
||||
? [...(accountTableBaseColumns ?? []), accountActionColumn]
|
||||
: (accountTableBaseColumns ?? []),
|
||||
);
|
||||
|
||||
const gridOptions: VxeGridProps<SuperAccountVO.AccountInfoVO> = {
|
||||
columns: accountTableColumns.value,
|
||||
height: '100%',
|
||||
border: true,
|
||||
stripe: true,
|
||||
@@ -220,6 +244,7 @@ const [Grid, gridApi] = useVbenVxeGrid({
|
||||
showSearchForm: false,
|
||||
tableTitle: '账户列表',
|
||||
});
|
||||
syncVxeGridColumns(gridApi, accountTableColumns);
|
||||
|
||||
async function searchCompanies() {
|
||||
companyLoading.value = true;
|
||||
@@ -345,10 +370,12 @@ onMounted(() => {
|
||||
|
||||
<template #extra>
|
||||
<Space>
|
||||
<Button type="primary" @click="handleAdd">
|
||||
<PlusIcon class="mr-2 h-4 w-4" />
|
||||
新增账户
|
||||
</Button>
|
||||
<PermissionGate code="org:account:create">
|
||||
<Button type="primary" @click="handleAdd">
|
||||
<PlusIcon class="mr-2 h-4 w-4" />
|
||||
新增账户
|
||||
</Button>
|
||||
</PermissionGate>
|
||||
</Space>
|
||||
</template>
|
||||
|
||||
@@ -431,15 +458,17 @@ onMounted(() => {
|
||||
{{ company.status === 1 ? '启用' : '禁用' }}
|
||||
</span>
|
||||
</button>
|
||||
<Button
|
||||
type="link"
|
||||
size="small"
|
||||
class="!h-7 shrink-0 !px-1 !text-xs font-semibold opacity-80 group-hover:opacity-100"
|
||||
@click.stop="handleAddForCompany(company)"
|
||||
>
|
||||
<PlusIcon class="mr-0.5 inline h-3.5 w-3.5" />
|
||||
添加
|
||||
</Button>
|
||||
<PermissionGate code="org:account:create">
|
||||
<Button
|
||||
type="link"
|
||||
size="small"
|
||||
class="!h-7 shrink-0 !px-1 !text-xs font-semibold opacity-80 group-hover:opacity-100"
|
||||
@click.stop="handleAddForCompany(company)"
|
||||
>
|
||||
<PlusIcon class="mr-0.5 inline h-3.5 w-3.5" />
|
||||
添加
|
||||
</Button>
|
||||
</PermissionGate>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@@ -537,15 +566,19 @@ onMounted(() => {
|
||||
</Tag>
|
||||
</template>
|
||||
|
||||
<template #action="{ row }">
|
||||
<template v-if="showActionColumn" #action="{ row }">
|
||||
<Space>
|
||||
<Button size="small" @click="handleEdit(row)">编辑</Button>
|
||||
<Popconfirm
|
||||
title="确定要删除这个账户吗?"
|
||||
@confirm="handleDelete(row)"
|
||||
>
|
||||
<Button size="small" danger>删除</Button>
|
||||
</Popconfirm>
|
||||
<PermissionGate code="org:account:update">
|
||||
<Button size="small" @click="handleEdit(row)">编辑</Button>
|
||||
</PermissionGate>
|
||||
<PermissionGate code="org:account:delete">
|
||||
<Popconfirm
|
||||
title="确定要删除这个账户吗?"
|
||||
@confirm="handleDelete(row)"
|
||||
>
|
||||
<Button size="small" danger>删除</Button>
|
||||
</Popconfirm>
|
||||
</PermissionGate>
|
||||
</Space>
|
||||
</template>
|
||||
</Grid>
|
||||
|
||||
@@ -15,6 +15,11 @@ import {
|
||||
admin_deleteAccountApi,
|
||||
admin_getAccountPageApi,
|
||||
} from '#/api/company/account';
|
||||
import { PermissionGate } from '#/components/permission';
|
||||
import {
|
||||
syncVxeGridColumns,
|
||||
useActionColumnVisible,
|
||||
} from '#/composables/use-vxe-action-column';
|
||||
|
||||
import AccountFormModal from './components/AccountFormModal.vue';
|
||||
|
||||
@@ -51,6 +56,13 @@ const statusOptions = [
|
||||
{ label: '停用', value: 0 },
|
||||
];
|
||||
|
||||
const accountActionCodes = [
|
||||
'org:account:create',
|
||||
'org:account:update',
|
||||
'org:account:delete',
|
||||
];
|
||||
const showActionColumn = useActionColumnVisible(accountActionCodes);
|
||||
|
||||
// 搜索表单配置
|
||||
const gridReloadRef = ref<(() => void) | null>(null);
|
||||
const formOptions = computed(() => ({
|
||||
@@ -108,9 +120,7 @@ const formOptions = computed(() => ({
|
||||
collapsedRows: 1,
|
||||
}));
|
||||
|
||||
// VbenVxeGrid 表格配置
|
||||
const gridOptions: VxeGridProps<any> = {
|
||||
columns: [
|
||||
const accountTableBaseColumns: VxeGridProps<any>['columns'] = [
|
||||
{
|
||||
type: 'seq' as const,
|
||||
minWidth: 'auto',
|
||||
@@ -163,13 +173,24 @@ const gridOptions: VxeGridProps<any> = {
|
||||
title: '创建时间',
|
||||
minWidth: 160,
|
||||
},
|
||||
{
|
||||
title: '操作',
|
||||
width: 120,
|
||||
fixed: 'right' as const,
|
||||
slots: { default: 'action' },
|
||||
},
|
||||
],
|
||||
];
|
||||
|
||||
const accountActionColumn: NonNullable<VxeGridProps<any>['columns']>[number] = {
|
||||
title: '操作',
|
||||
width: 120,
|
||||
fixed: 'right' as const,
|
||||
slots: { default: 'action' },
|
||||
};
|
||||
|
||||
const accountTableColumns = computed(() =>
|
||||
showActionColumn.value
|
||||
? [...(accountTableBaseColumns ?? []), accountActionColumn]
|
||||
: (accountTableBaseColumns ?? []),
|
||||
);
|
||||
|
||||
// VbenVxeGrid 表格配置
|
||||
const gridOptions: VxeGridProps<any> = {
|
||||
columns: accountTableColumns.value,
|
||||
height: 'auto',
|
||||
border: true,
|
||||
stripe: true,
|
||||
@@ -246,6 +267,7 @@ const [Grid, gridApi] = useVbenVxeGrid({
|
||||
tableTitle: '账户管理',
|
||||
});
|
||||
gridReloadRef.value = () => gridApi.reload();
|
||||
syncVxeGridColumns(gridApi, accountTableColumns);
|
||||
|
||||
// 计算属性
|
||||
const hasSelected = computed(() => {
|
||||
@@ -352,13 +374,17 @@ function handleModalSuccess() {
|
||||
<!-- 工具栏工具 -->
|
||||
<template #toolbar-tools>
|
||||
<Space>
|
||||
<Button type="primary" @click="handleAdd">
|
||||
<PlusIcon />
|
||||
添加账户
|
||||
</Button>
|
||||
<Button v-if="hasSelected" danger @click="handleBatchDelete">
|
||||
批量删除
|
||||
</Button>
|
||||
<PermissionGate code="org:account:create">
|
||||
<Button type="primary" @click="handleAdd">
|
||||
<PlusIcon />
|
||||
添加账户
|
||||
</Button>
|
||||
</PermissionGate>
|
||||
<PermissionGate code="org:account:delete">
|
||||
<Button v-if="hasSelected" danger @click="handleBatchDelete">
|
||||
批量删除
|
||||
</Button>
|
||||
</PermissionGate>
|
||||
</Space>
|
||||
</template>
|
||||
|
||||
@@ -377,15 +403,19 @@ function handleModalSuccess() {
|
||||
</template>
|
||||
|
||||
<!-- 操作列 -->
|
||||
<template #action="{ row }">
|
||||
<template v-if="showActionColumn" #action="{ row }">
|
||||
<Space>
|
||||
<Button size="small" @click="handleEdit(row)"> 编辑 </Button>
|
||||
<Popconfirm
|
||||
title="确定要删除这个账户吗?"
|
||||
@confirm="handleDelete(row)"
|
||||
>
|
||||
<Button size="small" danger> 删除 </Button>
|
||||
</Popconfirm>
|
||||
<PermissionGate code="org:account:update">
|
||||
<Button size="small" @click="handleEdit(row)"> 编辑 </Button>
|
||||
</PermissionGate>
|
||||
<PermissionGate code="org:account:delete">
|
||||
<Popconfirm
|
||||
title="确定要删除这个账户吗?"
|
||||
@confirm="handleDelete(row)"
|
||||
>
|
||||
<Button size="small" danger> 删除 </Button>
|
||||
</Popconfirm>
|
||||
</PermissionGate>
|
||||
</Space>
|
||||
</template>
|
||||
</Grid>
|
||||
|
||||
@@ -17,6 +17,11 @@ import {
|
||||
} from '#/api/company';
|
||||
import CompanyMenuDrawer from '#/components/CompanyMenuDrawer.vue';
|
||||
import CompanyPermissionDrawer from '#/components/CompanyPermissionDrawer.vue';
|
||||
import { PermissionGate } from '#/components/permission';
|
||||
import {
|
||||
syncVxeGridColumns,
|
||||
useActionColumnVisible,
|
||||
} from '#/composables/use-vxe-action-column';
|
||||
import CompanyLogoAvatar from '#/views/company/components/CompanyLogoAvatar.vue';
|
||||
|
||||
import CompanyFormModal from './components/CompanyFormModal.vue';
|
||||
@@ -46,9 +51,16 @@ const statusOptions = [
|
||||
{ label: '正常', value: 1 },
|
||||
];
|
||||
|
||||
// VbenVxeGrid 表格配置
|
||||
const gridOptions: VxeGridProps<any> = {
|
||||
columns: [
|
||||
const companyActionCodes = [
|
||||
'org:company:create',
|
||||
'org:company:update',
|
||||
'org:company:delete',
|
||||
'org:company:menu:assign',
|
||||
'org:company:permission:assign',
|
||||
];
|
||||
const showActionColumn = useActionColumnVisible(companyActionCodes);
|
||||
|
||||
const companyTableBaseColumns: VxeGridProps<any>['columns'] = [
|
||||
{
|
||||
type: 'seq' as const,
|
||||
minWidth: 'auto',
|
||||
@@ -108,13 +120,24 @@ const gridOptions: VxeGridProps<any> = {
|
||||
title: '创建时间',
|
||||
minWidth: 180,
|
||||
},
|
||||
{
|
||||
title: '操作',
|
||||
minWidth: 200,
|
||||
fixed: 'right' as const,
|
||||
slots: { default: 'action' },
|
||||
},
|
||||
],
|
||||
];
|
||||
|
||||
const companyActionColumn: NonNullable<VxeGridProps<any>['columns']>[number] = {
|
||||
title: '操作',
|
||||
minWidth: 200,
|
||||
fixed: 'right' as const,
|
||||
slots: { default: 'action' },
|
||||
};
|
||||
|
||||
const companyTableColumns = computed(() =>
|
||||
showActionColumn.value
|
||||
? [...(companyTableBaseColumns ?? []), companyActionColumn]
|
||||
: (companyTableBaseColumns ?? []),
|
||||
);
|
||||
|
||||
// VbenVxeGrid 表格配置
|
||||
const gridOptions: VxeGridProps<any> = {
|
||||
columns: companyTableColumns.value,
|
||||
height: 'auto',
|
||||
border: true,
|
||||
stripe: true,
|
||||
@@ -320,6 +343,7 @@ const [Grid, gridApi] = useVbenVxeGrid({
|
||||
tableTitle: '公司管理',
|
||||
});
|
||||
gridReloadRef.value = () => gridApi.reload();
|
||||
syncVxeGridColumns(gridApi, companyTableColumns);
|
||||
</script>
|
||||
|
||||
<template>
|
||||
@@ -335,10 +359,12 @@ gridReloadRef.value = () => gridApi.reload();
|
||||
<!-- 工具栏工具 -->
|
||||
<template #toolbar-tools>
|
||||
<Space>
|
||||
<Button type="primary" @click="handleAdd">
|
||||
<PlusIcon />
|
||||
添加公司
|
||||
</Button>
|
||||
<PermissionGate code="org:company:create">
|
||||
<Button type="primary" @click="handleAdd">
|
||||
<PlusIcon />
|
||||
添加公司
|
||||
</Button>
|
||||
</PermissionGate>
|
||||
</Space>
|
||||
</template>
|
||||
|
||||
@@ -372,26 +398,34 @@ gridReloadRef.value = () => gridApi.reload();
|
||||
</template>
|
||||
|
||||
<!-- 操作列 -->
|
||||
<template #action="{ row }: { row: any }">
|
||||
<template v-if="showActionColumn" #action="{ row }: { row: any }">
|
||||
<Space>
|
||||
<Button size="small" @click="handleEdit(row)"> 编辑 </Button>
|
||||
<Button size="small" type="primary" @click="handleMenuManage(row)">
|
||||
菜单
|
||||
</Button>
|
||||
<Button
|
||||
size="small"
|
||||
type="primary"
|
||||
ghost
|
||||
@click="handlePermissionManage(row)"
|
||||
>
|
||||
权限
|
||||
</Button>
|
||||
<Popconfirm
|
||||
title="确定要删除这个公司吗?"
|
||||
@confirm="handleDelete(row)"
|
||||
>
|
||||
<Button size="small" danger> 删除 </Button>
|
||||
</Popconfirm>
|
||||
<PermissionGate code="org:company:update">
|
||||
<Button size="small" @click="handleEdit(row)"> 编辑 </Button>
|
||||
</PermissionGate>
|
||||
<PermissionGate code="org:company:menu:assign">
|
||||
<Button size="small" type="primary" @click="handleMenuManage(row)">
|
||||
菜单
|
||||
</Button>
|
||||
</PermissionGate>
|
||||
<PermissionGate code="org:company:permission:assign">
|
||||
<Button
|
||||
size="small"
|
||||
type="primary"
|
||||
ghost
|
||||
@click="handlePermissionManage(row)"
|
||||
>
|
||||
权限
|
||||
</Button>
|
||||
</PermissionGate>
|
||||
<PermissionGate code="org:company:delete">
|
||||
<Popconfirm
|
||||
title="确定要删除这个公司吗?"
|
||||
@confirm="handleDelete(row)"
|
||||
>
|
||||
<Button size="small" danger> 删除 </Button>
|
||||
</Popconfirm>
|
||||
</PermissionGate>
|
||||
</Space>
|
||||
</template>
|
||||
</Grid>
|
||||
|
||||
@@ -18,6 +18,11 @@ import {
|
||||
deleteDepartmentApi,
|
||||
getDepartmentPageApi,
|
||||
} from '#/api/org/department';
|
||||
import { PermissionGate } from '#/components/permission';
|
||||
import {
|
||||
syncVxeGridColumns,
|
||||
useActionColumnVisible,
|
||||
} from '#/composables/use-vxe-action-column';
|
||||
|
||||
import DepartmentModal from './components/DepartmentModal.vue';
|
||||
|
||||
@@ -70,9 +75,14 @@ const parentDepartmentOptions = computed(() => {
|
||||
return options;
|
||||
});
|
||||
|
||||
// VbenVxeGrid 表格配置
|
||||
const gridOptions: VxeGridProps<any> = {
|
||||
columns: [
|
||||
const departmentActionCodes = [
|
||||
'org:department:create',
|
||||
'org:department:update',
|
||||
'org:department:delete',
|
||||
];
|
||||
const showActionColumn = useActionColumnVisible(departmentActionCodes);
|
||||
|
||||
const departmentTableBaseColumns: VxeGridProps<any>['columns'] = [
|
||||
{
|
||||
type: 'seq' as const,
|
||||
minWidth: 'auto',
|
||||
@@ -105,13 +115,26 @@ const gridOptions: VxeGridProps<any> = {
|
||||
title: '创建时间',
|
||||
minWidth: 180,
|
||||
},
|
||||
{
|
||||
title: '操作',
|
||||
minWidth: 200,
|
||||
fixed: 'right' as const,
|
||||
slots: { default: 'action' },
|
||||
},
|
||||
],
|
||||
];
|
||||
|
||||
const departmentActionColumn: NonNullable<
|
||||
VxeGridProps<any>['columns']
|
||||
>[number] = {
|
||||
title: '操作',
|
||||
minWidth: 200,
|
||||
fixed: 'right' as const,
|
||||
slots: { default: 'action' },
|
||||
};
|
||||
|
||||
const departmentTableColumns = computed(() =>
|
||||
showActionColumn.value
|
||||
? [...(departmentTableBaseColumns ?? []), departmentActionColumn]
|
||||
: (departmentTableBaseColumns ?? []),
|
||||
);
|
||||
|
||||
// VbenVxeGrid 表格配置
|
||||
const gridOptions: VxeGridProps<any> = {
|
||||
columns: departmentTableColumns.value,
|
||||
height: 'auto',
|
||||
border: true,
|
||||
stripe: true,
|
||||
@@ -285,6 +308,7 @@ const [Grid, gridApi] = useVbenVxeGrid({
|
||||
tableTitle: '部门管理',
|
||||
});
|
||||
gridReloadRef.value = () => gridApi.reload();
|
||||
syncVxeGridColumns(gridApi, departmentTableColumns);
|
||||
</script>
|
||||
|
||||
<template>
|
||||
@@ -300,10 +324,12 @@ gridReloadRef.value = () => gridApi.reload();
|
||||
<!-- 工具栏工具 -->
|
||||
<template #toolbar-tools>
|
||||
<Space>
|
||||
<Button type="primary" @click="handleAdd">
|
||||
<PlusIcon />
|
||||
添加部门
|
||||
</Button>
|
||||
<PermissionGate code="org:department:create">
|
||||
<Button type="primary" @click="handleAdd">
|
||||
<PlusIcon />
|
||||
添加部门
|
||||
</Button>
|
||||
</PermissionGate>
|
||||
</Space>
|
||||
</template>
|
||||
|
||||
@@ -325,15 +351,19 @@ gridReloadRef.value = () => gridApi.reload();
|
||||
</template>
|
||||
|
||||
<!-- 操作列 -->
|
||||
<template #action="{ row }: { row: any }">
|
||||
<template v-if="showActionColumn" #action="{ row }: { row: any }">
|
||||
<Space>
|
||||
<Button size="small" @click="handleEdit(row)"> 编辑 </Button>
|
||||
<Popconfirm
|
||||
title="确定要删除这个部门吗?"
|
||||
@confirm="handleDelete(row)"
|
||||
>
|
||||
<Button size="small" danger> 删除 </Button>
|
||||
</Popconfirm>
|
||||
<PermissionGate code="org:department:update">
|
||||
<Button size="small" @click="handleEdit(row)"> 编辑 </Button>
|
||||
</PermissionGate>
|
||||
<PermissionGate code="org:department:delete">
|
||||
<Popconfirm
|
||||
title="确定要删除这个部门吗?"
|
||||
@confirm="handleDelete(row)"
|
||||
>
|
||||
<Button size="small" danger> 删除 </Button>
|
||||
</Popconfirm>
|
||||
</PermissionGate>
|
||||
</Space>
|
||||
</template>
|
||||
</Grid>
|
||||
|
||||
@@ -15,6 +15,11 @@ import {
|
||||
deletePositionApi,
|
||||
getPositionPageApi,
|
||||
} from '#/api/org/position';
|
||||
import { PermissionGate } from '#/components/permission';
|
||||
import {
|
||||
syncVxeGridColumns,
|
||||
useActionColumnVisible,
|
||||
} from '#/composables/use-vxe-action-column';
|
||||
|
||||
import PositionModal from './components/PositionModal.vue';
|
||||
|
||||
@@ -47,9 +52,14 @@ const departmentOptions = ref([
|
||||
{ label: '市场部', value: 4 },
|
||||
]);
|
||||
|
||||
// VbenVxeGrid 表格配置
|
||||
const gridOptions: VxeGridProps<any> = {
|
||||
columns: [
|
||||
const positionActionCodes = [
|
||||
'org:position:create',
|
||||
'org:position:update',
|
||||
'org:position:delete',
|
||||
];
|
||||
const showActionColumn = useActionColumnVisible(positionActionCodes);
|
||||
|
||||
const positionTableBaseColumns: VxeGridProps<any>['columns'] = [
|
||||
{
|
||||
type: 'seq' as const,
|
||||
minWidth: 'auto',
|
||||
@@ -87,13 +97,25 @@ const gridOptions: VxeGridProps<any> = {
|
||||
title: '创建时间',
|
||||
minWidth: 180,
|
||||
},
|
||||
{
|
||||
title: '操作',
|
||||
minWidth: 200,
|
||||
fixed: 'right' as const,
|
||||
slots: { default: 'action' },
|
||||
},
|
||||
],
|
||||
];
|
||||
|
||||
const positionActionColumn: NonNullable<VxeGridProps<any>['columns']>[number] =
|
||||
{
|
||||
title: '操作',
|
||||
minWidth: 200,
|
||||
fixed: 'right' as const,
|
||||
slots: { default: 'action' },
|
||||
};
|
||||
|
||||
const positionTableColumns = computed(() =>
|
||||
showActionColumn.value
|
||||
? [...(positionTableBaseColumns ?? []), positionActionColumn]
|
||||
: (positionTableBaseColumns ?? []),
|
||||
);
|
||||
|
||||
// VbenVxeGrid 表格配置
|
||||
const gridOptions: VxeGridProps<any> = {
|
||||
columns: positionTableColumns.value,
|
||||
height: 'auto',
|
||||
border: true,
|
||||
stripe: true,
|
||||
@@ -231,6 +253,7 @@ const [Grid, gridApi] = useVbenVxeGrid({
|
||||
showSearchForm: true,
|
||||
tableTitle: '职位管理',
|
||||
});
|
||||
syncVxeGridColumns(gridApi, positionTableColumns);
|
||||
</script>
|
||||
|
||||
<template>
|
||||
@@ -246,10 +269,12 @@ const [Grid, gridApi] = useVbenVxeGrid({
|
||||
<!-- 工具栏工具 -->
|
||||
<template #toolbar-tools>
|
||||
<Space>
|
||||
<Button type="primary" @click="handleAdd">
|
||||
<PlusIcon />
|
||||
添加职位
|
||||
</Button>
|
||||
<PermissionGate code="org:position:create">
|
||||
<Button type="primary" @click="handleAdd">
|
||||
<PlusIcon />
|
||||
添加职位
|
||||
</Button>
|
||||
</PermissionGate>
|
||||
</Space>
|
||||
</template>
|
||||
|
||||
@@ -272,15 +297,19 @@ const [Grid, gridApi] = useVbenVxeGrid({
|
||||
</template>
|
||||
|
||||
<!-- 操作列 -->
|
||||
<template #action="{ row }: { row: any }">
|
||||
<template v-if="showActionColumn" #action="{ row }: { row: any }">
|
||||
<Space>
|
||||
<Button size="small" @click="handleEdit(row)"> 编辑 </Button>
|
||||
<Popconfirm
|
||||
title="确定要删除这个职位吗?"
|
||||
@confirm="handleDelete(row)"
|
||||
>
|
||||
<Button size="small" danger> 删除 </Button>
|
||||
</Popconfirm>
|
||||
<PermissionGate code="org:position:update">
|
||||
<Button size="small" @click="handleEdit(row)"> 编辑 </Button>
|
||||
</PermissionGate>
|
||||
<PermissionGate code="org:position:delete">
|
||||
<Popconfirm
|
||||
title="确定要删除这个职位吗?"
|
||||
@confirm="handleDelete(row)"
|
||||
>
|
||||
<Button size="small" danger> 删除 </Button>
|
||||
</Popconfirm>
|
||||
</PermissionGate>
|
||||
</Space>
|
||||
</template>
|
||||
</Grid>
|
||||
|
||||
@@ -27,6 +27,8 @@ import {
|
||||
batchUpdatePositionMenusApi,
|
||||
getPositionMenuIdsApi,
|
||||
} from '#/api/org/position/menu';
|
||||
import { PermissionGate } from '#/components/permission';
|
||||
import { usePermission } from '#/composables/use-permission';
|
||||
|
||||
defineOptions({
|
||||
name: 'PositionMenuManagePage',
|
||||
@@ -34,6 +36,9 @@ defineOptions({
|
||||
|
||||
const BriefcaseIcon = createIconifyIcon('lucide:briefcase');
|
||||
|
||||
const { hasPermission } = usePermission();
|
||||
const canAssignMenu = computed(() => hasPermission('org:position:menu:assign'));
|
||||
|
||||
const searchForm = ref({
|
||||
name: '',
|
||||
status: undefined as number | undefined,
|
||||
@@ -306,23 +311,25 @@ onMounted(() => {
|
||||
|
||||
<template #extra>
|
||||
<Space>
|
||||
<Button :disabled="!currentPosition" @click="handleSelectNone">
|
||||
取消全选
|
||||
</Button>
|
||||
<Button
|
||||
type="primary"
|
||||
:disabled="!currentPosition"
|
||||
@click="handleSelectAll"
|
||||
>
|
||||
一键全选
|
||||
</Button>
|
||||
<Button
|
||||
type="primary"
|
||||
:disabled="!currentPosition || !stats.changed"
|
||||
@click="savePositionPermissions"
|
||||
>
|
||||
保存配置
|
||||
</Button>
|
||||
<PermissionGate code="org:position:menu:assign">
|
||||
<Button :disabled="!currentPosition" @click="handleSelectNone">
|
||||
取消全选
|
||||
</Button>
|
||||
<Button
|
||||
type="primary"
|
||||
:disabled="!currentPosition"
|
||||
@click="handleSelectAll"
|
||||
>
|
||||
一键全选
|
||||
</Button>
|
||||
<Button
|
||||
type="primary"
|
||||
:disabled="!currentPosition || !stats.changed"
|
||||
@click="savePositionPermissions"
|
||||
>
|
||||
保存配置
|
||||
</Button>
|
||||
</PermissionGate>
|
||||
</Space>
|
||||
</template>
|
||||
|
||||
@@ -511,7 +518,7 @@ onMounted(() => {
|
||||
v-model:checked-keys="checkedKeys"
|
||||
v-model:expanded-keys="expandedKeys"
|
||||
:tree-data="menuTreeData"
|
||||
checkable
|
||||
:checkable="canAssignMenu"
|
||||
block-node
|
||||
:selectable="false"
|
||||
@check="handleTreeCheckChange"
|
||||
|
||||
@@ -27,11 +27,18 @@ import {
|
||||
getPositionAssignablePermissionTreeApi,
|
||||
getPositionPermissionIdsApi,
|
||||
} from '#/api/org/position/permission';
|
||||
import { PermissionGate } from '#/components/permission';
|
||||
import { usePermission } from '#/composables/use-permission';
|
||||
|
||||
defineOptions({ name: 'PositionPermissionManagePage' });
|
||||
|
||||
const BriefcaseIcon = createIconifyIcon('lucide:briefcase');
|
||||
|
||||
const { hasPermission } = usePermission();
|
||||
const canAssignPermission = computed(() =>
|
||||
hasPermission('org:position:permission:assign'),
|
||||
);
|
||||
|
||||
type PermissionTreeNode = {
|
||||
key: number;
|
||||
title: string;
|
||||
@@ -260,17 +267,19 @@ onMounted(() => {
|
||||
|
||||
<template #extra>
|
||||
<Space>
|
||||
<Button :disabled="!currentPosition" @click="selectNone">取消全选</Button>
|
||||
<Button type="primary" :disabled="!currentPosition" @click="selectAll">
|
||||
一键全选
|
||||
</Button>
|
||||
<Button
|
||||
type="primary"
|
||||
:disabled="!currentPosition || !stats.changed"
|
||||
@click="handleSave"
|
||||
>
|
||||
保存配置
|
||||
</Button>
|
||||
<PermissionGate code="org:position:permission:assign">
|
||||
<Button :disabled="!currentPosition" @click="selectNone">取消全选</Button>
|
||||
<Button type="primary" :disabled="!currentPosition" @click="selectAll">
|
||||
一键全选
|
||||
</Button>
|
||||
<Button
|
||||
type="primary"
|
||||
:disabled="!currentPosition || !stats.changed"
|
||||
@click="handleSave"
|
||||
>
|
||||
保存配置
|
||||
</Button>
|
||||
</PermissionGate>
|
||||
</Space>
|
||||
</template>
|
||||
|
||||
@@ -450,7 +459,7 @@ onMounted(() => {
|
||||
v-model:checked-keys="selectedPermissionIds"
|
||||
v-model:expanded-keys="expandedKeys"
|
||||
:tree-data="permissionTreeData"
|
||||
checkable
|
||||
:checkable="canAssignPermission"
|
||||
block-node
|
||||
:selectable="false"
|
||||
@check="handleTreeCheckChange"
|
||||
|
||||
Reference in New Issue
Block a user