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