style: system views code style
This commit is contained in:
@@ -1,20 +1,22 @@
|
||||
import type { OnActionClickFn, VxeTableGridOptions } from '#/adapter/vxe-table';
|
||||
import type { SystemMenuApi } from '#/api/system/menu';
|
||||
import type { VbenFormSchema } from '#/adapter/form';
|
||||
import type { Recordable } from '@vben/types';
|
||||
|
||||
import { IconifyIcon } from '@vben/icons';
|
||||
import type { VbenFormSchema } from '#/adapter/form';
|
||||
import type { OnActionClickFn, VxeTableGridOptions } from '#/adapter/vxe-table';
|
||||
import type { SystemMenuApi } from '#/api/system/menu';
|
||||
|
||||
import { $t } from '#/locales';
|
||||
import { h } from 'vue';
|
||||
|
||||
import { useAccess } from '@vben/access';
|
||||
import { IconifyIcon } from '@vben/icons';
|
||||
import { isHttpUrl } from '@vben/utils';
|
||||
|
||||
import { z } from '#/adapter/form';
|
||||
import { componentKeys } from '#/router/routes';
|
||||
import { getMenuList } from '#/api/system/menu';
|
||||
import { $t } from '#/locales';
|
||||
import { componentKeys } from '#/router/routes';
|
||||
import { CommonStatusEnum, SystemMenuTypeEnum } from '#/utils/constants';
|
||||
import { DICT_TYPE, getDictOptions } from '#/utils/dict';
|
||||
import { handleTree } from '#/utils/tree';
|
||||
import { CommonStatusEnum, SystemMenuTypeEnum } from '#/utils/constants';
|
||||
import { isHttpUrl } from '@vben/utils';
|
||||
import { useAccess } from '@vben/access';
|
||||
|
||||
const { hasAccessByCodes } = useAccess();
|
||||
|
||||
@@ -62,7 +64,7 @@ export function useFormSchema(): VbenFormSchema[] {
|
||||
rules: 'selectRequired',
|
||||
renderComponentContent() {
|
||||
return {
|
||||
title({ label, icon }: { label: string; icon: string }) {
|
||||
title({ label, icon }: { icon: string; label: string }) {
|
||||
const components = [];
|
||||
if (!label) return '';
|
||||
if (icon) {
|
||||
@@ -106,7 +108,9 @@ export function useFormSchema(): VbenFormSchema[] {
|
||||
dependencies: {
|
||||
triggerFields: ['type'],
|
||||
show: (values) => {
|
||||
return [SystemMenuTypeEnum.DIR, SystemMenuTypeEnum.MENU].includes(values.type);
|
||||
return [SystemMenuTypeEnum.DIR, SystemMenuTypeEnum.MENU].includes(
|
||||
values.type,
|
||||
);
|
||||
},
|
||||
},
|
||||
},
|
||||
@@ -122,7 +126,9 @@ export function useFormSchema(): VbenFormSchema[] {
|
||||
dependencies: {
|
||||
triggerFields: ['type', 'parentId'],
|
||||
show: (values) => {
|
||||
return [SystemMenuTypeEnum.DIR, SystemMenuTypeEnum.MENU].includes(values.type);
|
||||
return [SystemMenuTypeEnum.DIR, SystemMenuTypeEnum.MENU].includes(
|
||||
values.type,
|
||||
);
|
||||
},
|
||||
rules: (values) => {
|
||||
const schema = z.string().min(1, '路由地址不能为空');
|
||||
@@ -130,11 +136,17 @@ export function useFormSchema(): VbenFormSchema[] {
|
||||
return schema;
|
||||
}
|
||||
if (values.parentId === 0) {
|
||||
return schema.refine((path) => path.charAt(0) === '/', '路径必须以 / 开头');
|
||||
return schema.refine(
|
||||
(path) => path.charAt(0) === '/',
|
||||
'路径必须以 / 开头',
|
||||
);
|
||||
}
|
||||
return schema.refine((path) => path.charAt(0) !== '/', '路径不能以 / 开头');
|
||||
return schema.refine(
|
||||
(path) => path.charAt(0) !== '/',
|
||||
'路径不能以 / 开头',
|
||||
);
|
||||
},
|
||||
}
|
||||
},
|
||||
},
|
||||
{
|
||||
fieldName: 'component',
|
||||
@@ -147,7 +159,7 @@ export function useFormSchema(): VbenFormSchema[] {
|
||||
triggerFields: ['type'],
|
||||
show: (values) => {
|
||||
return [SystemMenuTypeEnum.MENU].includes(values.type);
|
||||
}
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
@@ -167,7 +179,7 @@ export function useFormSchema(): VbenFormSchema[] {
|
||||
triggerFields: ['type'],
|
||||
show: (values) => {
|
||||
return [SystemMenuTypeEnum.MENU].includes(values.type);
|
||||
}
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
@@ -179,7 +191,7 @@ export function useFormSchema(): VbenFormSchema[] {
|
||||
},
|
||||
dependencies: {
|
||||
show: (values) => {
|
||||
return [SystemMenuTypeEnum.MENU, SystemMenuTypeEnum.BUTTON].includes(
|
||||
return [SystemMenuTypeEnum.BUTTON, SystemMenuTypeEnum.MENU].includes(
|
||||
values.type,
|
||||
);
|
||||
},
|
||||
@@ -253,7 +265,7 @@ export function useFormSchema(): VbenFormSchema[] {
|
||||
},
|
||||
},
|
||||
},
|
||||
]
|
||||
];
|
||||
}
|
||||
|
||||
/** 列表的字段 */
|
||||
|
||||
@@ -1,20 +1,25 @@
|
||||
<script lang="ts" setup>
|
||||
import type { OnActionClickParams, VxeTableGridOptions } from '#/adapter/vxe-table';
|
||||
import type {
|
||||
OnActionClickParams,
|
||||
VxeTableGridOptions,
|
||||
} from '#/adapter/vxe-table';
|
||||
import type { SystemMenuApi } from '#/api/system/menu';
|
||||
|
||||
import { Page, useVbenModal } from '@vben/common-ui';
|
||||
import { Button, message } from 'ant-design-vue';
|
||||
import { IconifyIcon, Plus } from '@vben/icons';
|
||||
import Form from './modules/form.vue';
|
||||
import { DocAlert } from '#/components/doc-alert';
|
||||
|
||||
import { ref } from 'vue';
|
||||
import { $t } from '#/locales';
|
||||
|
||||
import { Page, useVbenModal } from '@vben/common-ui';
|
||||
import { IconifyIcon, Plus } from '@vben/icons';
|
||||
|
||||
import { Button, message } from 'ant-design-vue';
|
||||
|
||||
import { useVbenVxeGrid } from '#/adapter/vxe-table';
|
||||
import { getMenuList, deleteMenu } from '#/api/system/menu';
|
||||
import { deleteMenu, getMenuList } from '#/api/system/menu';
|
||||
import { DocAlert } from '#/components/doc-alert';
|
||||
import { $t } from '#/locales';
|
||||
import { SystemMenuTypeEnum } from '#/utils/constants';
|
||||
|
||||
import { useGridColumns } from './data';
|
||||
import Form from './modules/form.vue';
|
||||
|
||||
const [FormModal, formModalApi] = useVbenModal({
|
||||
connectedComponent: Form,
|
||||
@@ -55,29 +60,29 @@ async function onDelete(row: SystemMenuApi.SystemMenu) {
|
||||
key: 'action_process_msg',
|
||||
});
|
||||
onRefresh();
|
||||
} catch (error) {
|
||||
} catch {
|
||||
hideLoading();
|
||||
}
|
||||
}
|
||||
|
||||
/** 表格操作按钮的回调函数 */
|
||||
function onActionClick({
|
||||
code,
|
||||
row,
|
||||
code,
|
||||
row,
|
||||
}: OnActionClickParams<SystemMenuApi.SystemMenu>) {
|
||||
switch (code) {
|
||||
case 'append': {
|
||||
onAppend(row);
|
||||
break;
|
||||
}
|
||||
case 'edit': {
|
||||
onEdit(row);
|
||||
break;
|
||||
}
|
||||
case 'delete': {
|
||||
onDelete(row);
|
||||
break;
|
||||
}
|
||||
case 'edit': {
|
||||
onEdit(row);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -121,13 +126,20 @@ 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/vue3/route/" />
|
||||
|
||||
<FormModal @success="onRefresh" />
|
||||
<Grid>
|
||||
<template #toolbar-tools>
|
||||
<Button type="primary" @click="onCreate" v-access:code="['system:menu:create']">
|
||||
<Button
|
||||
type="primary"
|
||||
@click="onCreate"
|
||||
v-access:code="['system:menu:create']"
|
||||
>
|
||||
<Plus class="size-5" />
|
||||
{{ $t('ui.actionTitle.create', ['菜单']) }}
|
||||
</Button>
|
||||
|
||||
@@ -1,14 +1,16 @@
|
||||
<script lang="ts" setup>
|
||||
import type { SystemMenuApi } from '#/api/system/menu';
|
||||
|
||||
import { $t } from '#/locales';
|
||||
import { computed, ref } from 'vue';
|
||||
import { useVbenForm } from '#/adapter/form';
|
||||
import { createMenu, getMenu, updateMenu } from '#/api/system/menu';
|
||||
|
||||
import { useVbenModal } from '@vben/common-ui';
|
||||
|
||||
import { message } from 'ant-design-vue';
|
||||
|
||||
import { useVbenForm } from '#/adapter/form';
|
||||
import { createMenu, getMenu, updateMenu } from '#/api/system/menu';
|
||||
import { $t } from '#/locales';
|
||||
|
||||
import { useFormSchema } from '../data';
|
||||
|
||||
const emit = defineEmits(['success']);
|
||||
|
||||
Reference in New Issue
Block a user