style: system views code style
This commit is contained in:
@@ -2,11 +2,12 @@ import type { VbenFormSchema } from '#/adapter/form';
|
||||
import type { OnActionClickFn, VxeTableGridOptions } from '#/adapter/vxe-table';
|
||||
import type { SystemRoleApi } from '#/api/system/role';
|
||||
|
||||
import { useAccess } from '@vben/access';
|
||||
|
||||
import { z } from '#/adapter/form';
|
||||
import { CommonStatusEnum, SystemDataScopeEnum } from '#/utils/constants';
|
||||
import { DICT_TYPE, getDictOptions } from '#/utils/dict';
|
||||
import { getRangePickerDefaultProps } from '#/utils/date';
|
||||
import { useAccess } from '@vben/access';
|
||||
import { DICT_TYPE, getDictOptions } from '#/utils/dict';
|
||||
|
||||
const { hasAccessByCodes } = useAccess();
|
||||
|
||||
@@ -264,7 +265,9 @@ export function useGridColumns<T = SystemRoleApi.SystemRole>(
|
||||
{
|
||||
code: 'assign-data-permission',
|
||||
text: '数据权限',
|
||||
show: hasAccessByCodes(['system:permission:assign-role-data-scope']),
|
||||
show: hasAccessByCodes([
|
||||
'system:permission:assign-role-data-scope',
|
||||
]),
|
||||
},
|
||||
{
|
||||
code: 'assign-menu',
|
||||
|
||||
@@ -1,36 +1,41 @@
|
||||
<script lang="ts" setup>
|
||||
import type { OnActionClickParams, VxeTableGridOptions } from '#/adapter/vxe-table';
|
||||
import type {
|
||||
OnActionClickParams,
|
||||
VxeTableGridOptions,
|
||||
} from '#/adapter/vxe-table';
|
||||
import type { SystemRoleApi } from '#/api/system/role';
|
||||
|
||||
import { Page, useVbenModal } from '@vben/common-ui';
|
||||
import { Button, message } from 'ant-design-vue';
|
||||
import { Plus, Download } from '@vben/icons';
|
||||
import Form from './modules/form.vue';
|
||||
import { DocAlert } from '#/components/doc-alert';
|
||||
import { Download, Plus } from '@vben/icons';
|
||||
|
||||
import { Button, message } from 'ant-design-vue';
|
||||
|
||||
import { $t } from '#/locales';
|
||||
import { useVbenVxeGrid } from '#/adapter/vxe-table';
|
||||
import { getRolePage, deleteRole, exportRole } from '#/api/system/role';
|
||||
import AssignDataPermissionForm from './modules/assign-data-permission-form.vue';
|
||||
import AssignMenuForm from './modules/assign-menu-form.vue';
|
||||
import { deleteRole, exportRole, getRolePage } from '#/api/system/role';
|
||||
import { DocAlert } from '#/components/doc-alert';
|
||||
import { $t } from '#/locales';
|
||||
import { downloadByData } from '#/utils/download';
|
||||
|
||||
import { useGridColumns, useGridFormSchema } from './data';
|
||||
import AssignDataPermissionForm from './modules/assign-data-permission-form.vue';
|
||||
import AssignMenuForm from './modules/assign-menu-form.vue';
|
||||
import Form from './modules/form.vue';
|
||||
|
||||
const [FormModal, formModalApi] = useVbenModal({
|
||||
connectedComponent: Form,
|
||||
destroyOnClose: true,
|
||||
});
|
||||
|
||||
const [AssignDataPermissionFormModel, assignDataPermissionFormApi] = useVbenModal({
|
||||
connectedComponent: AssignDataPermissionForm,
|
||||
destroyOnClose: true,
|
||||
});
|
||||
const [AssignDataPermissionFormModel, assignDataPermissionFormApi] =
|
||||
useVbenModal({
|
||||
connectedComponent: AssignDataPermissionForm,
|
||||
destroyOnClose: true,
|
||||
});
|
||||
|
||||
const [AssignMenuFormModel, assignMenuFormApi] = useVbenModal({
|
||||
connectedComponent: AssignMenuForm,
|
||||
destroyOnClose: true,
|
||||
})
|
||||
});
|
||||
|
||||
/** 刷新表格 */
|
||||
function onRefresh() {
|
||||
@@ -67,7 +72,7 @@ async function onDelete(row: SystemRoleApi.SystemRole) {
|
||||
key: 'action_process_msg',
|
||||
});
|
||||
onRefresh();
|
||||
} catch (error) {
|
||||
} catch {
|
||||
hideLoading();
|
||||
}
|
||||
}
|
||||
@@ -84,18 +89,10 @@ function onAssignMenu(row: SystemRoleApi.SystemRole) {
|
||||
|
||||
/** 表格操作按钮的回调函数 */
|
||||
function onActionClick({
|
||||
code,
|
||||
row
|
||||
code,
|
||||
row,
|
||||
}: OnActionClickParams<SystemRoleApi.SystemRole>) {
|
||||
switch (code) {
|
||||
case 'delete': {
|
||||
onDelete(row);
|
||||
break;
|
||||
}
|
||||
case 'edit': {
|
||||
onEdit(row);
|
||||
break;
|
||||
}
|
||||
case 'assign-data-permission': {
|
||||
onAssignDataPermission(row);
|
||||
break;
|
||||
@@ -104,6 +101,14 @@ function onActionClick({
|
||||
onAssignMenu(row);
|
||||
break;
|
||||
}
|
||||
case 'delete': {
|
||||
onDelete(row);
|
||||
break;
|
||||
}
|
||||
case 'edit': {
|
||||
onEdit(row);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -139,7 +144,10 @@ const [Grid, gridApi] = useVbenVxeGrid({
|
||||
|
||||
<template>
|
||||
<Page auto-content-height>
|
||||
<DocAlert title="功能权限" url="https://doc.iocoder.cn/resource-permission" />
|
||||
<DocAlert
|
||||
title="功能权限"
|
||||
url="https://doc.iocoder.cn/resource-permission"
|
||||
/>
|
||||
<DocAlert title="数据权限" url="https://doc.iocoder.cn/data-permission" />
|
||||
|
||||
<FormModal @success="onRefresh" />
|
||||
@@ -147,11 +155,20 @@ const [Grid, gridApi] = useVbenVxeGrid({
|
||||
<AssignMenuFormModel @success="onRefresh" />
|
||||
<Grid table-title="角色列表">
|
||||
<template #toolbar-tools>
|
||||
<Button type="primary" @click="onCreate" v-access:code="['system:role:create']">
|
||||
<Button
|
||||
type="primary"
|
||||
@click="onCreate"
|
||||
v-access:code="['system:role:create']"
|
||||
>
|
||||
<Plus class="size-5" />
|
||||
{{ $t('ui.actionTitle.create', ['角色']) }}
|
||||
</Button>
|
||||
<Button type="primary" class="ml-2" @click="onExport" v-access:code="['system:role:export']">
|
||||
<Button
|
||||
type="primary"
|
||||
class="ml-2"
|
||||
@click="onExport"
|
||||
v-access:code="['system:role:export']"
|
||||
>
|
||||
<Download class="size-5" />
|
||||
{{ $t('ui.actionTitle.export') }}
|
||||
</Button>
|
||||
|
||||
@@ -1,19 +1,20 @@
|
||||
<script lang="ts" setup>
|
||||
import type { SystemRoleApi } from '#/api/system/role';
|
||||
import type { SystemDeptApi } from '#/api/system/dept';
|
||||
|
||||
import { VbenTree } from '@vben/common-ui';
|
||||
import { useVbenModal } from '@vben/common-ui';
|
||||
import { message, Checkbox } from 'ant-design-vue';
|
||||
import type { SystemRoleApi } from '#/api/system/role';
|
||||
|
||||
import { ref } from 'vue';
|
||||
import { $t } from '#/locales';
|
||||
|
||||
import { useVbenModal, VbenTree } from '@vben/common-ui';
|
||||
|
||||
import { Checkbox, message } from 'ant-design-vue';
|
||||
|
||||
import { useVbenForm } from '#/adapter/form';
|
||||
import { getRole } from '#/api/system/role';
|
||||
import { assignRoleDataScope } from '#/api/system/permission';
|
||||
import { getDeptList } from '#/api/system/dept';
|
||||
import { handleTree } from '#/utils/tree';
|
||||
import { assignRoleDataScope } from '#/api/system/permission';
|
||||
import { getRole } from '#/api/system/role';
|
||||
import { $t } from '#/locales';
|
||||
import { SystemDataScopeEnum } from '#/utils/constants';
|
||||
import { handleTree } from '#/utils/tree';
|
||||
|
||||
import { useAssignDataPermissionFormSchema } from '../data';
|
||||
|
||||
@@ -85,7 +86,7 @@ async function loadDeptTree() {
|
||||
deptLoading.value = true;
|
||||
try {
|
||||
const data = await getDeptList();
|
||||
deptTree.value = handleTree(data);
|
||||
deptTree.value = handleTree(data) as SystemDeptApi.SystemDept[];
|
||||
} finally {
|
||||
deptLoading.value = false;
|
||||
}
|
||||
@@ -105,12 +106,8 @@ function toggleSelectAll() {
|
||||
/** 展开/折叠所有节点 */
|
||||
function toggleExpandAll() {
|
||||
isExpanded.value = !isExpanded.value;
|
||||
if (isExpanded.value) {
|
||||
// 获取所有节点的 ID
|
||||
expandedKeys.value = getAllNodeIds(deptTree.value);
|
||||
} else {
|
||||
expandedKeys.value = [];
|
||||
}
|
||||
// 获取所有节点的 ID
|
||||
expandedKeys.value = isExpanded.value ? getAllNodeIds(deptTree.value) : [];
|
||||
}
|
||||
|
||||
/** 切换父子联动 */
|
||||
|
||||
@@ -1,16 +1,17 @@
|
||||
<script lang="ts" setup>
|
||||
import type { SystemRoleApi } from '#/api/system/role';
|
||||
import type { SystemDeptApi } from '#/api/system/dept';
|
||||
|
||||
import { VbenTree } from '@vben/common-ui';
|
||||
import { useVbenModal } from '@vben/common-ui';
|
||||
import { message, Checkbox } from 'ant-design-vue';
|
||||
import type { SystemRoleApi } from '#/api/system/role';
|
||||
|
||||
import { ref } from 'vue';
|
||||
import { $t } from '#/locales';
|
||||
|
||||
import { useVbenModal, VbenTree } from '@vben/common-ui';
|
||||
|
||||
import { Checkbox, message } from 'ant-design-vue';
|
||||
|
||||
import { useVbenForm } from '#/adapter/form';
|
||||
import { assignRoleMenu, getRoleMenuList } from '#/api/system/permission';
|
||||
import { getMenuList } from '#/api/system/menu';
|
||||
import { assignRoleMenu, getRoleMenuList } from '#/api/system/permission';
|
||||
import { $t } from '#/locales';
|
||||
import { handleTree } from '#/utils/tree';
|
||||
|
||||
import { useAssignMenuFormSchema } from '../data';
|
||||
@@ -41,7 +42,7 @@ const [Modal, modalApi] = useVbenModal({
|
||||
try {
|
||||
await assignRoleMenu({
|
||||
roleId: data.id,
|
||||
menuIds: data.menuIds
|
||||
menuIds: data.menuIds,
|
||||
});
|
||||
// 关闭并提示
|
||||
await modalApi.close();
|
||||
@@ -82,7 +83,7 @@ async function loadMenuTree() {
|
||||
menuLoading.value = true;
|
||||
try {
|
||||
const data = await getMenuList();
|
||||
menuTree.value = handleTree(data);
|
||||
menuTree.value = handleTree(data) as SystemDeptApi.SystemDept[];
|
||||
} finally {
|
||||
menuLoading.value = false;
|
||||
}
|
||||
@@ -102,12 +103,8 @@ function toggleSelectAll() {
|
||||
/** 展开/折叠所有节点 */
|
||||
function toggleExpandAll() {
|
||||
isExpanded.value = !isExpanded.value;
|
||||
if (isExpanded.value) {
|
||||
// 获取所有节点的 ID
|
||||
expandedKeys.value = getAllNodeIds(menuTree.value);
|
||||
} else {
|
||||
expandedKeys.value = [];
|
||||
}
|
||||
// 获取所有节点的 ID
|
||||
expandedKeys.value = isExpanded.value ? getAllNodeIds(menuTree.value) : [];
|
||||
}
|
||||
|
||||
/** 递归获取所有节点 ID */
|
||||
|
||||
@@ -1,13 +1,15 @@
|
||||
<script lang="ts" setup>
|
||||
import type { SystemRoleApi } from '#/api/system/role';
|
||||
|
||||
import { computed, ref } from 'vue';
|
||||
|
||||
import { useVbenModal } from '@vben/common-ui';
|
||||
|
||||
import { message } from 'ant-design-vue';
|
||||
|
||||
import { $t } from '#/locales';
|
||||
import { computed, ref } from 'vue';
|
||||
import { useVbenForm } from '#/adapter/form';
|
||||
import { createRole, updateRole, getRole } from '#/api/system/role';
|
||||
import { createRole, getRole, updateRole } from '#/api/system/role';
|
||||
import { $t } from '#/locales';
|
||||
|
||||
import { useFormSchema } from '../data';
|
||||
|
||||
|
||||
Reference in New Issue
Block a user