87 lines
1.7 KiB
TypeScript
87 lines
1.7 KiB
TypeScript
import { BasicColumn, FormSchema } from '@/components/Table';
|
|
import { h } from 'vue';
|
|
import { Switch, Tag } from 'ant-design-vue';
|
|
import { setRoleStatus } from '@/api/demo/system';
|
|
import { useMessage } from '@/hooks/web/useMessage';
|
|
|
|
type CheckedType = boolean | string | number;
|
|
export const columns: BasicColumn[] = [
|
|
{
|
|
title: '内容',
|
|
dataIndex: 'content',
|
|
},
|
|
{
|
|
title: '状态',
|
|
dataIndex: 'isRead',
|
|
width: 80,
|
|
customRender: ({ record }) => {
|
|
const isRead = record.isRead;
|
|
const enable = ~~isRead === 1;
|
|
const color = enable ? 'green' : 'red';
|
|
const text = enable ? '已读' : '未读';
|
|
return h(Tag, { color: color }, () => text);
|
|
},
|
|
},
|
|
{
|
|
title: '时间',
|
|
dataIndex: 'createDate',
|
|
width: 180,
|
|
},
|
|
];
|
|
|
|
export const searchFormSchema: FormSchema[] = [
|
|
{
|
|
field: 'key',
|
|
label: '关键字',
|
|
component: 'Input',
|
|
colProps: { span: 8 },
|
|
},
|
|
{
|
|
field: 'isDelete',
|
|
component: 'Select',
|
|
label: '是否回收',
|
|
defaultValue: 0,
|
|
componentProps: {
|
|
options: [
|
|
{
|
|
label: '否',
|
|
value: 0,
|
|
},
|
|
{
|
|
label: '是',
|
|
value: 1,
|
|
},
|
|
],
|
|
},
|
|
colProps: { span: 8 },
|
|
},
|
|
];
|
|
|
|
export const formSchema: FormSchema[] = [
|
|
{
|
|
field: 'id',
|
|
label: '角色名称',
|
|
required: true,
|
|
component: 'Input',
|
|
ifShow: false,
|
|
},
|
|
{
|
|
field: 'name',
|
|
label: '角色名称',
|
|
required: true,
|
|
component: 'Input',
|
|
},
|
|
{
|
|
field: 'status',
|
|
label: '状态',
|
|
component: 'RadioButtonGroup',
|
|
defaultValue: 0,
|
|
componentProps: {
|
|
options: [
|
|
{ label: '启用', value: 0 },
|
|
{ label: '停用', value: 1 },
|
|
],
|
|
},
|
|
},
|
|
];
|