2024-09-28 22:28:46 +08:00
|
|
|
import { h, reactive } from 'vue';
|
|
|
|
import type { FormRules } from 'element-plus';
|
2024-10-18 13:51:03 +08:00
|
|
|
import { ElTag } from 'element-plus';
|
2024-09-28 22:28:46 +08:00
|
|
|
import { $t } from '@/plugins/i18n';
|
|
|
|
import { isAllEmpty } from '@pureadmin/utils';
|
2024-10-03 15:52:18 +08:00
|
|
|
import { getMenuType } from '@/views/system/menu/utils/hooks';
|
2024-10-03 13:44:52 +08:00
|
|
|
import { useRenderIcon } from '@/components/CommonIcon/src/hooks';
|
2024-09-28 22:28:46 +08:00
|
|
|
|
|
|
|
export const columns: TableColumnList = [
|
|
|
|
{
|
|
|
|
label: '菜单名称',
|
|
|
|
prop: 'title',
|
|
|
|
align: 'left',
|
|
|
|
cellRenderer: ({ row }) => (
|
|
|
|
<>
|
|
|
|
<span class='inline-block mr-1'>
|
|
|
|
{h(useRenderIcon(row.icon), {
|
|
|
|
style: { paddingTop: '1px' },
|
|
|
|
})}
|
|
|
|
</span>
|
|
|
|
<span>{$t(row.title)}</span>
|
|
|
|
</>
|
|
|
|
),
|
|
|
|
},
|
|
|
|
{
|
|
|
|
label: '菜单类型',
|
|
|
|
prop: 'menuType',
|
|
|
|
width: 100,
|
|
|
|
cellRenderer: ({ row, props }) => (
|
2024-10-18 13:51:03 +08:00
|
|
|
<ElTag size={props.size} type={getMenuType(row.menuType)} effect='plain'>
|
2024-09-28 22:28:46 +08:00
|
|
|
{getMenuType(row.menuType, true)}
|
2024-10-18 13:51:03 +08:00
|
|
|
</ElTag>
|
2024-09-28 22:28:46 +08:00
|
|
|
),
|
|
|
|
},
|
|
|
|
{ label: '路由路径', prop: 'path' },
|
|
|
|
{
|
|
|
|
label: '组件路径',
|
|
|
|
prop: 'component',
|
|
|
|
formatter: ({ path, component }) => (isAllEmpty(component) ? path : component),
|
|
|
|
},
|
2024-10-18 13:51:03 +08:00
|
|
|
{ label: '排序', prop: 'rank', width: 80, slot: 'rank' },
|
2024-10-03 13:44:52 +08:00
|
|
|
{ label: '隐藏', prop: 'visible', slot: 'visible', width: 100 },
|
2024-10-03 18:41:26 +08:00
|
|
|
{ label: $t('table.updateTime'), prop: 'updateTime', sortable: true },
|
|
|
|
{ label: $t('table.createTime'), prop: 'createTime', sortable: true },
|
|
|
|
{ label: $t('table.createUser'), prop: 'createUser', slot: 'createUser', width: 90 },
|
|
|
|
{ label: $t('table.updateUser'), prop: 'updateUser', slot: 'updateUser', width: 90 },
|
2024-10-18 13:51:03 +08:00
|
|
|
{ label: $t('table.operation'), fixed: 'right', width: 230, slot: 'operation' },
|
2024-09-28 22:28:46 +08:00
|
|
|
];
|
|
|
|
|
|
|
|
/** 自定义表单规则校验 */
|
|
|
|
export const formRules = reactive<FormRules>({
|
|
|
|
title: [{ required: true, message: '菜单名称为必填项', trigger: 'blur' }],
|
|
|
|
name: [{ required: true, message: '路由名称为必填项', trigger: 'blur' }],
|
|
|
|
path: [{ required: true, message: '路由路径为必填项', trigger: 'blur' }],
|
|
|
|
auths: [{ required: true, message: '权限标识为必填项', trigger: 'blur' }],
|
|
|
|
});
|