|
|
@ -1,3 +1,10 @@ |
|
|
|
|
|
|
|
/** |
|
|
|
|
|
|
|
* @program: kicc-ui |
|
|
|
|
|
|
|
* @description: 菜单动态生成配置 |
|
|
|
|
|
|
|
* @author: entfrm开发团队-王翔 |
|
|
|
|
|
|
|
* @create: 2022/4/21 |
|
|
|
|
|
|
|
*/ |
|
|
|
|
|
|
|
|
|
|
|
import { BasicColumn } from '/@/components/Table'; |
|
|
|
import { BasicColumn } from '/@/components/Table'; |
|
|
|
import { FormSchema } from '/@/components/Table'; |
|
|
|
import { FormSchema } from '/@/components/Table'; |
|
|
|
import { h } from 'vue'; |
|
|
|
import { h } from 'vue'; |
|
|
@ -8,52 +15,58 @@ export const columns: BasicColumn[] = [ |
|
|
|
{ |
|
|
|
{ |
|
|
|
title: '菜单名称', |
|
|
|
title: '菜单名称', |
|
|
|
dataIndex: 'name', |
|
|
|
dataIndex: 'name', |
|
|
|
width: 200, |
|
|
|
align: 'left' |
|
|
|
align: 'left', |
|
|
|
|
|
|
|
}, |
|
|
|
}, |
|
|
|
{ |
|
|
|
{ |
|
|
|
title: '图标', |
|
|
|
title: '图标', |
|
|
|
dataIndex: 'icon', |
|
|
|
dataIndex: 'icon', |
|
|
|
width: 50, |
|
|
|
width: 80, |
|
|
|
customRender: ({ record }) => { |
|
|
|
customRender: ({ record }) => { |
|
|
|
return h(Icon, { icon: record.icon }); |
|
|
|
return h(Icon, { icon: record.icon }); |
|
|
|
}, |
|
|
|
} |
|
|
|
|
|
|
|
}, |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
title: '排序', |
|
|
|
|
|
|
|
dataIndex: 'sort', |
|
|
|
|
|
|
|
width: 80 |
|
|
|
}, |
|
|
|
}, |
|
|
|
{ |
|
|
|
{ |
|
|
|
title: '权限标识', |
|
|
|
title: '权限标识', |
|
|
|
dataIndex: 'permission', |
|
|
|
dataIndex: 'permission', |
|
|
|
width: 180, |
|
|
|
customRender: ({record}) => { |
|
|
|
|
|
|
|
return record.permission || h(Tag, { color: 'red' }, () => '暂无数据'); |
|
|
|
|
|
|
|
} |
|
|
|
}, |
|
|
|
}, |
|
|
|
{ |
|
|
|
{ |
|
|
|
title: '组件', |
|
|
|
title: '组件', |
|
|
|
dataIndex: 'component', |
|
|
|
dataIndex: 'component', |
|
|
|
|
|
|
|
customRender: ({record}) => { |
|
|
|
|
|
|
|
return record.component || h(Tag, { color: 'red' }, () => '暂无数据'); |
|
|
|
|
|
|
|
} |
|
|
|
}, |
|
|
|
}, |
|
|
|
{ |
|
|
|
{ |
|
|
|
title: '排序', |
|
|
|
title: '是否隐藏', |
|
|
|
dataIndex: 'sort', |
|
|
|
dataIndex: 'hideMenu', |
|
|
|
width: 50, |
|
|
|
|
|
|
|
}, |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
title: '状态', |
|
|
|
|
|
|
|
dataIndex: 'status', |
|
|
|
|
|
|
|
width: 80, |
|
|
|
width: 80, |
|
|
|
customRender: ({ record }) => { |
|
|
|
customRender: ({ record }) => { |
|
|
|
const status = record.status; |
|
|
|
const hideMenu = record.hideMenu; |
|
|
|
const enable = ~~status === 0; |
|
|
|
// 采用二进制~~取反,只要为null或者0等等一些其他的空元素都会转为0
|
|
|
|
|
|
|
|
// 第一次取反会运算为-1,在后一次取反会运算为0
|
|
|
|
|
|
|
|
const enable = ~~hideMenu === 0; |
|
|
|
const color = enable ? 'green' : 'red'; |
|
|
|
const color = enable ? 'green' : 'red'; |
|
|
|
const text = enable ? '启用' : '停用'; |
|
|
|
const text = enable ? '显示' : '隐藏'; |
|
|
|
return h(Tag, { color: color }, () => text); |
|
|
|
return h(Tag, { color: color }, () => text); |
|
|
|
}, |
|
|
|
} |
|
|
|
}, |
|
|
|
}, |
|
|
|
{ |
|
|
|
{ |
|
|
|
title: '创建时间', |
|
|
|
title: '创建时间', |
|
|
|
dataIndex: 'createTime', |
|
|
|
dataIndex: 'createTime' |
|
|
|
width: 180, |
|
|
|
} |
|
|
|
}, |
|
|
|
|
|
|
|
]; |
|
|
|
]; |
|
|
|
|
|
|
|
|
|
|
|
const isDir = (type: string) => type === 'M'; |
|
|
|
/** 菜单类型 */ |
|
|
|
const isMenu = (type: string) => type === 'C'; |
|
|
|
const isMenu = (type: string) => type === 'C'; |
|
|
|
|
|
|
|
/** 按钮类型 */ |
|
|
|
const isButton = (type: string) => type === 'F'; |
|
|
|
const isButton = (type: string) => type === 'F'; |
|
|
|
|
|
|
|
|
|
|
|
export const searchFormSchema: FormSchema[] = [ |
|
|
|
export const searchFormSchema: FormSchema[] = [ |
|
|
@ -62,22 +75,33 @@ export const searchFormSchema: FormSchema[] = [ |
|
|
|
label: '菜单名', |
|
|
|
label: '菜单名', |
|
|
|
component: 'Input', |
|
|
|
component: 'Input', |
|
|
|
componentProps: { |
|
|
|
componentProps: { |
|
|
|
placeholder: '请输入名称', |
|
|
|
placeholder: '请输入菜单名称' |
|
|
|
}, |
|
|
|
}, |
|
|
|
colProps: { span: 8 }, |
|
|
|
colProps: { span: 8 } |
|
|
|
}, |
|
|
|
}, |
|
|
|
{ |
|
|
|
{ |
|
|
|
field: 'beginTime', |
|
|
|
field: 'hideMenu', |
|
|
|
label: '起始时间', |
|
|
|
label: '是否隐藏', |
|
|
|
component: 'DatePicker', |
|
|
|
component: 'Select', |
|
|
|
colProps: { span: 8 }, |
|
|
|
componentProps: { |
|
|
|
|
|
|
|
options: [ |
|
|
|
|
|
|
|
{ label: '显示', value: '0' }, |
|
|
|
|
|
|
|
{ label: '隐藏', value: '1' } |
|
|
|
|
|
|
|
] |
|
|
|
|
|
|
|
}, |
|
|
|
|
|
|
|
colProps: { span: 7 } |
|
|
|
}, |
|
|
|
}, |
|
|
|
{ |
|
|
|
{ |
|
|
|
field: 'endTime', |
|
|
|
field: 'dateRange', |
|
|
|
label: '截止时间', |
|
|
|
label: '创建时间', |
|
|
|
component: 'DatePicker', |
|
|
|
component: 'RangePicker', |
|
|
|
colProps: { span: 8 }, |
|
|
|
componentProps: { |
|
|
|
}, |
|
|
|
style: { width:'100%' }, |
|
|
|
|
|
|
|
format: 'yyyy-MM-dd', |
|
|
|
|
|
|
|
placeholder: ['开始日期','结束日期'] |
|
|
|
|
|
|
|
}, |
|
|
|
|
|
|
|
colProps: { span: 8 } |
|
|
|
|
|
|
|
} |
|
|
|
]; |
|
|
|
]; |
|
|
|
|
|
|
|
|
|
|
|
export const formSchema: FormSchema[] = [ |
|
|
|
export const formSchema: FormSchema[] = [ |
|
|
@ -85,29 +109,8 @@ export const formSchema: FormSchema[] = [ |
|
|
|
field: 'id', |
|
|
|
field: 'id', |
|
|
|
label: 'ID', |
|
|
|
label: 'ID', |
|
|
|
component: 'Input', |
|
|
|
component: 'Input', |
|
|
|
show: false, |
|
|
|
show: false |
|
|
|
}, |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
field: 'type', |
|
|
|
|
|
|
|
label: '菜单类型', |
|
|
|
|
|
|
|
component: 'RadioButtonGroup', |
|
|
|
|
|
|
|
defaultValue: 'M', |
|
|
|
|
|
|
|
componentProps: { |
|
|
|
|
|
|
|
options: [ |
|
|
|
|
|
|
|
{ label: '目录', value: 'M' }, |
|
|
|
|
|
|
|
{ label: '菜单', value: 'C' }, |
|
|
|
|
|
|
|
{ label: '按钮', value: 'F' }, |
|
|
|
|
|
|
|
], |
|
|
|
|
|
|
|
}, |
|
|
|
|
|
|
|
colProps: { lg: 24, md: 24 }, |
|
|
|
|
|
|
|
}, |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
field: 'name', |
|
|
|
|
|
|
|
label: '菜单名称', |
|
|
|
|
|
|
|
component: 'Input', |
|
|
|
|
|
|
|
required: true, |
|
|
|
|
|
|
|
}, |
|
|
|
}, |
|
|
|
|
|
|
|
|
|
|
|
{ |
|
|
|
{ |
|
|
|
field: 'parentId', |
|
|
|
field: 'parentId', |
|
|
|
label: '上级菜单', |
|
|
|
label: '上级菜单', |
|
|
@ -116,71 +119,80 @@ export const formSchema: FormSchema[] = [ |
|
|
|
replaceFields: { |
|
|
|
replaceFields: { |
|
|
|
title: 'name', |
|
|
|
title: 'name', |
|
|
|
key: 'id', |
|
|
|
key: 'id', |
|
|
|
value: 'id', |
|
|
|
value: 'id' |
|
|
|
}, |
|
|
|
}, |
|
|
|
getPopupContainer: () => document.body, |
|
|
|
getPopupContainer: () => document.body |
|
|
|
}, |
|
|
|
} |
|
|
|
}, |
|
|
|
}, |
|
|
|
|
|
|
|
|
|
|
|
{ |
|
|
|
{ |
|
|
|
field: 'sort', |
|
|
|
field: 'type', |
|
|
|
label: '排序', |
|
|
|
label: '菜单类型', |
|
|
|
component: 'InputNumber', |
|
|
|
component: 'RadioButtonGroup', |
|
|
|
required: true, |
|
|
|
defaultValue: 'M', |
|
|
|
|
|
|
|
componentProps: { |
|
|
|
|
|
|
|
options: [ |
|
|
|
|
|
|
|
{ label: '目录', value: 'M' }, |
|
|
|
|
|
|
|
{ label: '菜单', value: 'C' }, |
|
|
|
|
|
|
|
{ label: '按钮', value: 'F' } |
|
|
|
|
|
|
|
] |
|
|
|
|
|
|
|
} |
|
|
|
}, |
|
|
|
}, |
|
|
|
{ |
|
|
|
{ |
|
|
|
field: 'icon', |
|
|
|
field: 'icon', |
|
|
|
label: '图标', |
|
|
|
label: '菜单图标', |
|
|
|
component: 'IconPicker', |
|
|
|
component: 'IconPicker', |
|
|
|
required: true, |
|
|
|
required: true, |
|
|
|
ifShow: ({ values }) => !isButton(values.type), |
|
|
|
ifShow: ({ values }) => !isButton(values.type), |
|
|
|
}, |
|
|
|
}, |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
field: 'name', |
|
|
|
|
|
|
|
label: '菜单名称', |
|
|
|
|
|
|
|
component: 'Input', |
|
|
|
|
|
|
|
required: true, |
|
|
|
|
|
|
|
colProps: { |
|
|
|
|
|
|
|
span: 12 |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
}, |
|
|
|
{ |
|
|
|
{ |
|
|
|
field: 'path', |
|
|
|
field: 'path', |
|
|
|
label: '路由地址', |
|
|
|
label: '路由地址', |
|
|
|
component: 'Input', |
|
|
|
component: 'Input', |
|
|
|
required: true, |
|
|
|
required: true, |
|
|
|
ifShow: ({ values }) => !isButton(values.type), |
|
|
|
colProps: { |
|
|
|
|
|
|
|
span: 12 |
|
|
|
|
|
|
|
}, |
|
|
|
|
|
|
|
ifShow: ({ values }) => !isButton(values.type) |
|
|
|
}, |
|
|
|
}, |
|
|
|
{ |
|
|
|
{ |
|
|
|
field: 'component', |
|
|
|
field: 'component', |
|
|
|
label: '组件路径', |
|
|
|
label: '组件路径', |
|
|
|
component: 'Input', |
|
|
|
component: 'Input', |
|
|
|
ifShow: ({ values }) => !isButton(values.type), |
|
|
|
colProps: { |
|
|
|
|
|
|
|
span: 12 |
|
|
|
|
|
|
|
}, |
|
|
|
|
|
|
|
ifShow: ({ values }) => isMenu(values.type) |
|
|
|
}, |
|
|
|
}, |
|
|
|
{ |
|
|
|
{ |
|
|
|
field: 'permission', |
|
|
|
field: 'permission', |
|
|
|
label: '权限标识', |
|
|
|
label: '权限标识', |
|
|
|
component: 'Input', |
|
|
|
component: 'Input', |
|
|
|
ifShow: ({ values }) => isButton(values.type), |
|
|
|
colProps: { |
|
|
|
}, |
|
|
|
span: 12 |
|
|
|
{ |
|
|
|
|
|
|
|
field: 'status', |
|
|
|
|
|
|
|
label: '状态', |
|
|
|
|
|
|
|
component: 'RadioButtonGroup', |
|
|
|
|
|
|
|
defaultValue: '0', |
|
|
|
|
|
|
|
componentProps: { |
|
|
|
|
|
|
|
options: [ |
|
|
|
|
|
|
|
{ label: '启用', value: '0' }, |
|
|
|
|
|
|
|
{ label: '禁用', value: '1' }, |
|
|
|
|
|
|
|
], |
|
|
|
|
|
|
|
}, |
|
|
|
}, |
|
|
|
|
|
|
|
ifShow: ({ values }) => isButton(values.type) |
|
|
|
}, |
|
|
|
}, |
|
|
|
{ |
|
|
|
{ |
|
|
|
field: 'target', |
|
|
|
field: 'sort', |
|
|
|
label: '是否外链', |
|
|
|
label: '显示排序', |
|
|
|
component: 'RadioButtonGroup', |
|
|
|
component: 'InputNumber', |
|
|
|
defaultValue: '0', |
|
|
|
|
|
|
|
componentProps: { |
|
|
|
componentProps: { |
|
|
|
options: [ |
|
|
|
style: { width:'100%' } |
|
|
|
{ label: '否', value: '0' }, |
|
|
|
|
|
|
|
{ label: '是', value: '1' }, |
|
|
|
|
|
|
|
], |
|
|
|
|
|
|
|
}, |
|
|
|
}, |
|
|
|
ifShow: ({ values }) => !isButton(values.type), |
|
|
|
required: true, |
|
|
|
|
|
|
|
colProps: { |
|
|
|
|
|
|
|
span: 12 |
|
|
|
|
|
|
|
} |
|
|
|
}, |
|
|
|
}, |
|
|
|
|
|
|
|
|
|
|
|
{ |
|
|
|
{ |
|
|
|
field: 'keepalive', |
|
|
|
field: 'keepalive', |
|
|
|
label: '是否缓存', |
|
|
|
label: '是否缓存', |
|
|
@ -192,20 +204,25 @@ export const formSchema: FormSchema[] = [ |
|
|
|
{ label: '是', value: '1' }, |
|
|
|
{ label: '是', value: '1' }, |
|
|
|
], |
|
|
|
], |
|
|
|
}, |
|
|
|
}, |
|
|
|
ifShow: ({ values }) => isMenu(values.type), |
|
|
|
colProps: { |
|
|
|
|
|
|
|
span: 12 |
|
|
|
|
|
|
|
}, |
|
|
|
|
|
|
|
ifShow: ({ values }) => isMenu(values.type) |
|
|
|
}, |
|
|
|
}, |
|
|
|
|
|
|
|
|
|
|
|
{ |
|
|
|
{ |
|
|
|
field: 'show', |
|
|
|
field: 'hideMenu', |
|
|
|
label: '是否显示', |
|
|
|
label: '是否隐藏', |
|
|
|
component: 'RadioButtonGroup', |
|
|
|
component: 'RadioButtonGroup', |
|
|
|
defaultValue: '0', |
|
|
|
defaultValue: '0', |
|
|
|
componentProps: { |
|
|
|
componentProps: { |
|
|
|
options: [ |
|
|
|
options: [ |
|
|
|
{ label: '是', value: '0' }, |
|
|
|
{ label: '否', value: '0' }, |
|
|
|
{ label: '否', value: '1' }, |
|
|
|
{ label: '是', value: '1' }, |
|
|
|
], |
|
|
|
] |
|
|
|
}, |
|
|
|
}, |
|
|
|
ifShow: ({ values }) => !isButton(values.type), |
|
|
|
colProps: { |
|
|
|
}, |
|
|
|
span: 12 |
|
|
|
|
|
|
|
}, |
|
|
|
|
|
|
|
ifShow: ({ values }) => !isButton(values.type) |
|
|
|
|
|
|
|
} |
|
|
|
]; |
|
|
|
]; |
|
|
|