reactor:【system 系统管理】tenantPackage 进一步统一代码风格
parent
942c4ef389
commit
4cbbad4d40
|
@ -90,14 +90,17 @@ export function useGridColumns(): VxeTableGridOptions['columns'] {
|
||||||
{
|
{
|
||||||
field: 'id',
|
field: 'id',
|
||||||
title: '套餐编号',
|
title: '套餐编号',
|
||||||
|
minWidth: 100,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
field: 'name',
|
field: 'name',
|
||||||
title: '套餐名称',
|
title: '套餐名称',
|
||||||
|
minWidth: 180,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
field: 'status',
|
field: 'status',
|
||||||
title: '状态',
|
title: '状态',
|
||||||
|
minWidth: 100,
|
||||||
cellRender: {
|
cellRender: {
|
||||||
name: 'CellDict',
|
name: 'CellDict',
|
||||||
props: { type: DICT_TYPE.COMMON_STATUS },
|
props: { type: DICT_TYPE.COMMON_STATUS },
|
||||||
|
@ -106,15 +109,17 @@ export function useGridColumns(): VxeTableGridOptions['columns'] {
|
||||||
{
|
{
|
||||||
field: 'remark',
|
field: 'remark',
|
||||||
title: '备注',
|
title: '备注',
|
||||||
|
minWidth: 200,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
field: 'createTime',
|
field: 'createTime',
|
||||||
title: '创建时间',
|
title: '创建时间',
|
||||||
|
minWidth: 180,
|
||||||
formatter: 'formatDateTime',
|
formatter: 'formatDateTime',
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
title: '操作',
|
title: '操作',
|
||||||
width: 130,
|
width: 220,
|
||||||
fixed: 'right',
|
fixed: 'right',
|
||||||
slots: { default: 'actions' },
|
slots: { default: 'actions' },
|
||||||
},
|
},
|
||||||
|
|
|
@ -4,7 +4,7 @@ import type { SystemTenantPackageApi } from '#/api/system/tenant-package';
|
||||||
|
|
||||||
import { ref } from 'vue';
|
import { ref } from 'vue';
|
||||||
|
|
||||||
import { DocAlert, Page, useVbenModal } from '@vben/common-ui';
|
import { confirm, DocAlert, Page, useVbenModal } from '@vben/common-ui';
|
||||||
import { isEmpty } from '@vben/utils';
|
import { isEmpty } from '@vben/utils';
|
||||||
|
|
||||||
import { message } from 'ant-design-vue';
|
import { message } from 'ant-design-vue';
|
||||||
|
@ -26,7 +26,7 @@ const [FormModal, formModalApi] = useVbenModal({
|
||||||
});
|
});
|
||||||
|
|
||||||
/** 刷新表格 */
|
/** 刷新表格 */
|
||||||
function onRefresh() {
|
function handleRefresh() {
|
||||||
gridApi.query();
|
gridApi.query();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -48,11 +48,25 @@ async function handleDelete(row: SystemTenantPackageApi.TenantPackage) {
|
||||||
});
|
});
|
||||||
try {
|
try {
|
||||||
await deleteTenantPackage(row.id as number);
|
await deleteTenantPackage(row.id as number);
|
||||||
message.success({
|
message.success($t('ui.actionMessage.deleteSuccess', [row.name]));
|
||||||
content: $t('ui.actionMessage.deleteSuccess', [row.name]),
|
handleRefresh();
|
||||||
key: 'action_key_msg',
|
} finally {
|
||||||
|
hideLoading();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 批量删除租户套餐 */
|
||||||
|
async function handleDeleteBatch() {
|
||||||
|
await confirm($t('ui.actionMessage.deleteBatchConfirm'));
|
||||||
|
const hideLoading = message.loading({
|
||||||
|
content: $t('ui.actionMessage.deletingBatch'),
|
||||||
|
duration: 0,
|
||||||
});
|
});
|
||||||
onRefresh();
|
try {
|
||||||
|
await deleteTenantPackageList(checkedIds.value);
|
||||||
|
checkedIds.value = [];
|
||||||
|
message.success($t('ui.actionMessage.deleteSuccess'));
|
||||||
|
handleRefresh();
|
||||||
} finally {
|
} finally {
|
||||||
hideLoading();
|
hideLoading();
|
||||||
}
|
}
|
||||||
|
@ -67,23 +81,6 @@ function handleRowCheckboxChange({
|
||||||
checkedIds.value = records.map((item) => item.id!);
|
checkedIds.value = records.map((item) => item.id!);
|
||||||
}
|
}
|
||||||
|
|
||||||
/** 批量删除租户套餐 */
|
|
||||||
async function handleDeleteBatch() {
|
|
||||||
const hideLoading = message.loading({
|
|
||||||
content: $t('ui.actionMessage.deleting'),
|
|
||||||
duration: 0,
|
|
||||||
key: 'action_process_msg',
|
|
||||||
});
|
|
||||||
try {
|
|
||||||
await deleteTenantPackageList(checkedIds.value);
|
|
||||||
checkedIds.value = [];
|
|
||||||
message.success($t('ui.actionMessage.deleteSuccess'));
|
|
||||||
onRefresh();
|
|
||||||
} finally {
|
|
||||||
hideLoading();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
const [Grid, gridApi] = useVbenVxeGrid({
|
const [Grid, gridApi] = useVbenVxeGrid({
|
||||||
formOptions: {
|
formOptions: {
|
||||||
schema: useGridFormSchema(),
|
schema: useGridFormSchema(),
|
||||||
|
@ -125,7 +122,7 @@ const [Grid, gridApi] = useVbenVxeGrid({
|
||||||
<DocAlert title="SaaS 多租户" url="https://doc.iocoder.cn/saas-tenant/" />
|
<DocAlert title="SaaS 多租户" url="https://doc.iocoder.cn/saas-tenant/" />
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<FormModal @success="onRefresh" />
|
<FormModal @success="handleRefresh" />
|
||||||
<Grid table-title="租户套餐列表">
|
<Grid table-title="租户套餐列表">
|
||||||
<template #toolbar-tools>
|
<template #toolbar-tools>
|
||||||
<TableAction
|
<TableAction
|
||||||
|
@ -138,12 +135,12 @@ const [Grid, gridApi] = useVbenVxeGrid({
|
||||||
onClick: handleCreate,
|
onClick: handleCreate,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
label: '批量删除',
|
label: $t('ui.actionTitle.deleteBatch'),
|
||||||
type: 'primary',
|
type: 'primary',
|
||||||
danger: true,
|
danger: true,
|
||||||
disabled: isEmpty(checkedIds),
|
|
||||||
icon: ACTION_ICON.DELETE,
|
icon: ACTION_ICON.DELETE,
|
||||||
auth: ['system:tenant-package:delete'],
|
auth: ['system:tenant-package:delete'],
|
||||||
|
disabled: isEmpty(checkedIds),
|
||||||
onClick: handleDeleteBatch,
|
onClick: handleDeleteBatch,
|
||||||
},
|
},
|
||||||
]"
|
]"
|
||||||
|
|
|
@ -102,7 +102,7 @@ async function loadMenuTree() {
|
||||||
}
|
}
|
||||||
|
|
||||||
/** 全选/全不选 */
|
/** 全选/全不选 */
|
||||||
function toggleSelectAll() {
|
function handleSelectAll() {
|
||||||
isAllSelected.value = !isAllSelected.value;
|
isAllSelected.value = !isAllSelected.value;
|
||||||
if (isAllSelected.value) {
|
if (isAllSelected.value) {
|
||||||
const allIds = getAllNodeIds(menuTree.value);
|
const allIds = getAllNodeIds(menuTree.value);
|
||||||
|
@ -113,7 +113,7 @@ function toggleSelectAll() {
|
||||||
}
|
}
|
||||||
|
|
||||||
/** 展开/折叠所有节点 */
|
/** 展开/折叠所有节点 */
|
||||||
function toggleExpandAll() {
|
function handleExpandAll() {
|
||||||
isExpanded.value = !isExpanded.value;
|
isExpanded.value = !isExpanded.value;
|
||||||
expandedKeys.value = isExpanded.value ? getAllNodeIds(menuTree.value) : [];
|
expandedKeys.value = isExpanded.value ? getAllNodeIds(menuTree.value) : [];
|
||||||
}
|
}
|
||||||
|
@ -149,10 +149,10 @@ function getAllNodeIds(nodes: any[], ids: number[] = []): number[] {
|
||||||
</Form>
|
</Form>
|
||||||
<template #prepend-footer>
|
<template #prepend-footer>
|
||||||
<div class="flex flex-auto items-center">
|
<div class="flex flex-auto items-center">
|
||||||
<Checkbox :checked="isAllSelected" @change="toggleSelectAll">
|
<Checkbox :checked="isAllSelected" @change="handleSelectAll">
|
||||||
全选
|
全选
|
||||||
</Checkbox>
|
</Checkbox>
|
||||||
<Checkbox :checked="isExpanded" @change="toggleExpandAll">
|
<Checkbox :checked="isExpanded" @change="handleExpandAll">
|
||||||
全部展开
|
全部展开
|
||||||
</Checkbox>
|
</Checkbox>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -1,16 +1,12 @@
|
||||||
import type { VbenFormSchema } from '#/adapter/form';
|
import type { VbenFormSchema } from '#/adapter/form';
|
||||||
import type { OnActionClickFn, VxeTableGridOptions } from '#/adapter/vxe-table';
|
import type { VxeTableGridOptions } from '#/adapter/vxe-table';
|
||||||
import type { SystemTenantPackageApi } from '#/api/system/tenant-package';
|
|
||||||
|
|
||||||
import { useAccess } from '@vben/access';
|
|
||||||
import { CommonStatusEnum, DICT_TYPE } from '@vben/constants';
|
import { CommonStatusEnum, DICT_TYPE } from '@vben/constants';
|
||||||
import { getDictOptions } from '@vben/hooks';
|
import { getDictOptions } from '@vben/hooks';
|
||||||
|
|
||||||
import { z } from '#/adapter/form';
|
import { z } from '#/adapter/form';
|
||||||
import { getRangePickerDefaultProps } from '#/utils';
|
import { getRangePickerDefaultProps } from '#/utils';
|
||||||
|
|
||||||
const { hasAccessByCodes } = useAccess();
|
|
||||||
|
|
||||||
/** 新增/修改的表单 */
|
/** 新增/修改的表单 */
|
||||||
export function useFormSchema(): VbenFormSchema[] {
|
export function useFormSchema(): VbenFormSchema[] {
|
||||||
return [
|
return [
|
||||||
|
@ -88,14 +84,9 @@ export function useGridFormSchema(): VbenFormSchema[] {
|
||||||
}
|
}
|
||||||
|
|
||||||
/** 列表的字段 */
|
/** 列表的字段 */
|
||||||
export function useGridColumns<T = SystemTenantPackageApi.TenantPackage>(
|
export function useGridColumns(): VxeTableGridOptions['columns'] {
|
||||||
onActionClick: OnActionClickFn<T>,
|
|
||||||
): VxeTableGridOptions['columns'] {
|
|
||||||
return [
|
return [
|
||||||
{
|
{ type: 'checkbox', width: 40 },
|
||||||
type: 'checkbox',
|
|
||||||
width: 40,
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
field: 'id',
|
field: 'id',
|
||||||
title: '套餐编号',
|
title: '套餐编号',
|
||||||
|
@ -127,29 +118,10 @@ export function useGridColumns<T = SystemTenantPackageApi.TenantPackage>(
|
||||||
formatter: 'formatDateTime',
|
formatter: 'formatDateTime',
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
field: 'operation',
|
|
||||||
title: '操作',
|
title: '操作',
|
||||||
minWidth: 130,
|
width: 220,
|
||||||
align: 'center',
|
|
||||||
fixed: 'right',
|
fixed: 'right',
|
||||||
cellRender: {
|
slots: { default: 'actions' },
|
||||||
attrs: {
|
|
||||||
nameField: 'name',
|
|
||||||
nameTitle: '套餐',
|
|
||||||
onClick: onActionClick,
|
|
||||||
},
|
|
||||||
name: 'CellOperation',
|
|
||||||
options: [
|
|
||||||
{
|
|
||||||
code: 'edit',
|
|
||||||
show: hasAccessByCodes(['system:tenant-package:update']),
|
|
||||||
},
|
|
||||||
{
|
|
||||||
code: 'delete',
|
|
||||||
show: hasAccessByCodes(['system:tenant-package:delete']),
|
|
||||||
},
|
|
||||||
],
|
|
||||||
},
|
|
||||||
},
|
},
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,8 +1,5 @@
|
||||||
<script lang="ts" setup>
|
<script lang="ts" setup>
|
||||||
import type {
|
import type { VxeTableGridOptions } from '#/adapter/vxe-table';
|
||||||
OnActionClickParams,
|
|
||||||
VxeTableGridOptions,
|
|
||||||
} from '#/adapter/vxe-table';
|
|
||||||
import type { SystemTenantPackageApi } from '#/api/system/tenant-package';
|
import type { SystemTenantPackageApi } from '#/api/system/tenant-package';
|
||||||
|
|
||||||
import { ref } from 'vue';
|
import { ref } from 'vue';
|
||||||
|
@ -29,41 +26,48 @@ const [FormModal, formModalApi] = useVbenModal({
|
||||||
});
|
});
|
||||||
|
|
||||||
/** 刷新表格 */
|
/** 刷新表格 */
|
||||||
function onRefresh() {
|
function handleRefresh() {
|
||||||
gridApi.query();
|
gridApi.query();
|
||||||
}
|
}
|
||||||
|
|
||||||
/** 创建租户套餐 */
|
/** 创建租户套餐 */
|
||||||
function onCreate() {
|
function handleCreate() {
|
||||||
formModalApi.setData(null).open();
|
formModalApi.setData(null).open();
|
||||||
}
|
}
|
||||||
|
|
||||||
/** 编辑租户套餐 */
|
/** 编辑租户套餐 */
|
||||||
function onEdit(row: SystemTenantPackageApi.TenantPackage) {
|
function handleEdit(row: SystemTenantPackageApi.TenantPackage) {
|
||||||
formModalApi.setData(row).open();
|
formModalApi.setData(row).open();
|
||||||
}
|
}
|
||||||
|
|
||||||
/** 删除租户套餐 */
|
/** 删除租户套餐 */
|
||||||
async function onDelete(row: SystemTenantPackageApi.TenantPackage) {
|
async function handleDelete(row: SystemTenantPackageApi.TenantPackage) {
|
||||||
const loadingInstance = ElLoading.service({
|
const loadingInstance = ElLoading.service({
|
||||||
text: $t('ui.actionMessage.deleting', [row.name]),
|
text: $t('ui.actionMessage.deleting', [row.name]),
|
||||||
});
|
});
|
||||||
try {
|
try {
|
||||||
await deleteTenantPackage(row.id as number);
|
await deleteTenantPackage(row.id as number);
|
||||||
ElMessage.success($t('ui.actionMessage.deleteSuccess', [row.name]));
|
ElMessage.success($t('ui.actionMessage.deleteSuccess', [row.name]));
|
||||||
onRefresh();
|
handleRefresh();
|
||||||
} finally {
|
} finally {
|
||||||
loadingInstance.close();
|
loadingInstance.close();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/** 批量删除租户套餐 */
|
/** 批量删除租户套餐 */
|
||||||
async function onDeleteBatch() {
|
async function handleDeleteBatch() {
|
||||||
await confirm('确定要批量删除该租户套餐吗?');
|
await confirm($t('ui.actionMessage.deleteBatchConfirm'));
|
||||||
|
const loadingInstance = ElLoading.service({
|
||||||
|
text: $t('ui.actionMessage.deletingBatch'),
|
||||||
|
});
|
||||||
|
try {
|
||||||
await deleteTenantPackageList(checkedIds.value);
|
await deleteTenantPackageList(checkedIds.value);
|
||||||
checkedIds.value = [];
|
checkedIds.value = [];
|
||||||
ElMessage.success($t('ui.actionMessage.deleteSuccess'));
|
ElMessage.success($t('ui.actionMessage.deleteSuccess'));
|
||||||
onRefresh();
|
handleRefresh();
|
||||||
|
} finally {
|
||||||
|
loadingInstance.close();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const checkedIds = ref<number[]>([]);
|
const checkedIds = ref<number[]>([]);
|
||||||
|
@ -75,30 +79,12 @@ function handleRowCheckboxChange({
|
||||||
checkedIds.value = records.map((item) => item.id!);
|
checkedIds.value = records.map((item) => item.id!);
|
||||||
}
|
}
|
||||||
|
|
||||||
/** 表格操作按钮的回调函数 */
|
|
||||||
function onActionClick({
|
|
||||||
code,
|
|
||||||
row,
|
|
||||||
}: OnActionClickParams<SystemTenantPackageApi.TenantPackage>) {
|
|
||||||
switch (code) {
|
|
||||||
case 'delete': {
|
|
||||||
onDelete(row);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case 'edit': {
|
|
||||||
onEdit(row);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
const [Grid, gridApi] = useVbenVxeGrid({
|
const [Grid, gridApi] = useVbenVxeGrid({
|
||||||
formOptions: {
|
formOptions: {
|
||||||
schema: useGridFormSchema(),
|
schema: useGridFormSchema(),
|
||||||
// TODO @芋艿:时间筛选,后续处理;
|
|
||||||
},
|
},
|
||||||
gridOptions: {
|
gridOptions: {
|
||||||
columns: useGridColumns(onActionClick),
|
columns: useGridColumns(),
|
||||||
height: 'auto',
|
height: 'auto',
|
||||||
keepSource: true,
|
keepSource: true,
|
||||||
proxyConfig: {
|
proxyConfig: {
|
||||||
|
@ -114,6 +100,7 @@ const [Grid, gridApi] = useVbenVxeGrid({
|
||||||
},
|
},
|
||||||
rowConfig: {
|
rowConfig: {
|
||||||
keyField: 'id',
|
keyField: 'id',
|
||||||
|
isHover: true,
|
||||||
},
|
},
|
||||||
toolbarConfig: {
|
toolbarConfig: {
|
||||||
refresh: true,
|
refresh: true,
|
||||||
|
@ -133,7 +120,7 @@ const [Grid, gridApi] = useVbenVxeGrid({
|
||||||
<DocAlert title="SaaS 多租户" url="https://doc.iocoder.cn/saas-tenant/" />
|
<DocAlert title="SaaS 多租户" url="https://doc.iocoder.cn/saas-tenant/" />
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<FormModal @success="onRefresh" />
|
<FormModal @success="handleRefresh" />
|
||||||
<Grid table-title="租户套餐列表">
|
<Grid table-title="租户套餐列表">
|
||||||
<template #toolbar-tools>
|
<template #toolbar-tools>
|
||||||
<TableAction
|
<TableAction
|
||||||
|
@ -143,15 +130,40 @@ const [Grid, gridApi] = useVbenVxeGrid({
|
||||||
type: 'primary',
|
type: 'primary',
|
||||||
icon: ACTION_ICON.ADD,
|
icon: ACTION_ICON.ADD,
|
||||||
auth: ['system:tenant-package:create'],
|
auth: ['system:tenant-package:create'],
|
||||||
onClick: onCreate,
|
onClick: handleCreate,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
label: $t('ui.actionTitle.deleteBatch'),
|
label: $t('ui.actionTitle.deleteBatch'),
|
||||||
type: 'danger',
|
type: 'danger',
|
||||||
icon: ACTION_ICON.DELETE,
|
icon: ACTION_ICON.DELETE,
|
||||||
disabled: isEmpty(checkedIds),
|
|
||||||
auth: ['system:tenant-package:delete'],
|
auth: ['system:tenant-package:delete'],
|
||||||
onClick: onDeleteBatch,
|
disabled: isEmpty(checkedIds),
|
||||||
|
onClick: handleDeleteBatch,
|
||||||
|
},
|
||||||
|
]"
|
||||||
|
/>
|
||||||
|
</template>
|
||||||
|
<template #actions="{ row }">
|
||||||
|
<TableAction
|
||||||
|
:actions="[
|
||||||
|
{
|
||||||
|
label: $t('common.edit'),
|
||||||
|
type: 'primary',
|
||||||
|
link: true,
|
||||||
|
icon: ACTION_ICON.EDIT,
|
||||||
|
auth: ['system:tenant-package:update'],
|
||||||
|
onClick: handleEdit.bind(null, row),
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: $t('common.delete'),
|
||||||
|
type: 'danger',
|
||||||
|
link: true,
|
||||||
|
icon: ACTION_ICON.DELETE,
|
||||||
|
auth: ['system:tenant-package:delete'],
|
||||||
|
popConfirm: {
|
||||||
|
title: $t('ui.actionMessage.deleteConfirm', [row.name]),
|
||||||
|
confirm: handleDelete.bind(null, row),
|
||||||
|
},
|
||||||
},
|
},
|
||||||
]"
|
]"
|
||||||
/>
|
/>
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
<script lang="ts" setup>
|
<script lang="ts" setup>
|
||||||
import type { SystemDeptApi } from '#/api/system/dept';
|
import type { SystemMenuApi } from '#/api/system/menu';
|
||||||
import type { SystemTenantPackageApi } from '#/api/system/tenant-package';
|
import type { SystemTenantPackageApi } from '#/api/system/tenant-package';
|
||||||
|
|
||||||
import { computed, ref } from 'vue';
|
import { computed, ref } from 'vue';
|
||||||
|
@ -27,7 +27,7 @@ const getTitle = computed(() => {
|
||||||
? $t('ui.actionTitle.edit', ['套餐'])
|
? $t('ui.actionTitle.edit', ['套餐'])
|
||||||
: $t('ui.actionTitle.create', ['套餐']);
|
: $t('ui.actionTitle.create', ['套餐']);
|
||||||
});
|
});
|
||||||
const menuTree = ref<SystemDeptApi.Dept[]>([]); // 菜单树
|
const menuTree = ref<SystemMenuApi.Menu[]>([]); // 菜单树
|
||||||
const menuLoading = ref(false); // 加载菜单列表
|
const menuLoading = ref(false); // 加载菜单列表
|
||||||
const isAllSelected = ref(false); // 全选状态
|
const isAllSelected = ref(false); // 全选状态
|
||||||
const isExpanded = ref(false); // 展开状态
|
const isExpanded = ref(false); // 展开状态
|
||||||
|
@ -95,14 +95,14 @@ async function loadMenuTree() {
|
||||||
menuLoading.value = true;
|
menuLoading.value = true;
|
||||||
try {
|
try {
|
||||||
const data = await getMenuList();
|
const data = await getMenuList();
|
||||||
menuTree.value = handleTree(data) as SystemDeptApi.Dept[];
|
menuTree.value = handleTree(data) as SystemMenuApi.Menu[];
|
||||||
} finally {
|
} finally {
|
||||||
menuLoading.value = false;
|
menuLoading.value = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/** 全选/全不选 */
|
/** 全选/全不选 */
|
||||||
function toggleSelectAll() {
|
function handleSelectAll() {
|
||||||
isAllSelected.value = !isAllSelected.value;
|
isAllSelected.value = !isAllSelected.value;
|
||||||
if (isAllSelected.value) {
|
if (isAllSelected.value) {
|
||||||
const allIds = getAllNodeIds(menuTree.value);
|
const allIds = getAllNodeIds(menuTree.value);
|
||||||
|
@ -113,7 +113,7 @@ function toggleSelectAll() {
|
||||||
}
|
}
|
||||||
|
|
||||||
/** 展开/折叠所有节点 */
|
/** 展开/折叠所有节点 */
|
||||||
function toggleExpandAll() {
|
function handleExpandAll() {
|
||||||
isExpanded.value = !isExpanded.value;
|
isExpanded.value = !isExpanded.value;
|
||||||
expandedKeys.value = isExpanded.value ? getAllNodeIds(menuTree.value) : [];
|
expandedKeys.value = isExpanded.value ? getAllNodeIds(menuTree.value) : [];
|
||||||
}
|
}
|
||||||
|
@ -131,12 +131,11 @@ function getAllNodeIds(nodes: any[], ids: number[] = []): number[] {
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
<Modal :title="getTitle" class="w-[40%]">
|
<Modal :title="getTitle" class="w-2/5">
|
||||||
<Form class="mx-6">
|
<Form class="mx-6">
|
||||||
<template #menuIds="slotProps">
|
<template #menuIds="slotProps">
|
||||||
<!-- TODO @芋艿:可优化,使用 antd 的 tree?原因是,更原生 -->
|
|
||||||
<VbenTree
|
<VbenTree
|
||||||
class="max-h-[400px] overflow-y-auto"
|
class="max-h-96 overflow-y-auto"
|
||||||
:loading="menuLoading"
|
:loading="menuLoading"
|
||||||
:tree-data="menuTree"
|
:tree-data="menuTree"
|
||||||
multiple
|
multiple
|
||||||
|
@ -150,10 +149,10 @@ function getAllNodeIds(nodes: any[], ids: number[] = []): number[] {
|
||||||
</Form>
|
</Form>
|
||||||
<template #prepend-footer>
|
<template #prepend-footer>
|
||||||
<div class="flex flex-auto items-center">
|
<div class="flex flex-auto items-center">
|
||||||
<ElCheckbox :model-value="isAllSelected" @change="toggleSelectAll">
|
<ElCheckbox :model-value="isAllSelected" @change="handleSelectAll">
|
||||||
全选
|
全选
|
||||||
</ElCheckbox>
|
</ElCheckbox>
|
||||||
<ElCheckbox :model-value="isExpanded" @change="toggleExpandAll">
|
<ElCheckbox :model-value="isExpanded" @change="handleExpandAll">
|
||||||
全部展开
|
全部展开
|
||||||
</ElCheckbox>
|
</ElCheckbox>
|
||||||
</div>
|
</div>
|
||||||
|
|
Loading…
Reference in New Issue