Files
iot-device-management-frontend/apps/web-ele/src/views/system/notice/data.ts

157 lines
3.6 KiB
TypeScript
Raw Normal View History

2025-05-12 00:35:02 +08:00
import type { VbenFormSchema } from '#/adapter/form';
import type { VxeTableGridOptions } from '#/adapter/vxe-table';
import type { SystemNoticeApi } from '#/api/system/notice';
2025-05-12 00:35:02 +08:00
import { DICT_TYPE, getDictOptions, getRangePickerDefaultProps, } from '#/utils';
2025-05-12 00:35:02 +08:00
/** 新增/修改的表单 */
export function useFormSchema(): VbenFormSchema[] {
return [
{
fieldName: 'id',
component: 'Input',
dependencies: {
triggerFields: [''],
show: () => false,
},
},
{
fieldName: 'title',
label: '公告标题',
rules: 'required',
component: 'Input',
2025-05-12 00:35:02 +08:00
componentProps: {
placeholder: '请输入公告标题',
2025-05-12 00:35:02 +08:00
},
},
{
fieldName: 'content',
label: '公告内容',
rules: 'required',
2025-05-12 00:35:02 +08:00
component: 'RichTextarea',
},
{
fieldName: 'type',
label: '公告类型1通知 2公告',
2025-05-12 00:35:02 +08:00
rules: 'required',
component: 'Select',
componentProps: {
options: getDictOptions(DICT_TYPE.SYSTEM_NOTICE_TYPE, 'number'),
placeholder: '请选择公告类型1通知 2公告',
},
2025-05-12 00:35:02 +08:00
},
{
fieldName: 'status',
label: '公告状态0正常 1关闭',
rules: 'required',
2025-05-12 00:35:02 +08:00
component: 'RadioGroup',
componentProps: {
options: [],
2025-05-12 00:35:02 +08:00
buttonStyle: 'solid',
optionType: 'button',
},
},
];
}
/** 列表的搜索表单 */
export function useGridFormSchema(): VbenFormSchema[] {
return [
{
fieldName: 'title',
label: '公告标题',
component: 'Input',
componentProps: {
allowClear: true,
2025-05-12 00:35:02 +08:00
placeholder: '请输入公告标题',
},
},
{
fieldName: 'content',
label: '公告内容',
component: 'Input',
componentProps: {
2025-05-12 00:35:02 +08:00
allowClear: true,
placeholder: '请输入公告内容',
},
},
{
fieldName: 'type',
label: '公告类型1通知 2公告',
component: 'Select',
componentProps: {
allowClear: true,
options: getDictOptions(DICT_TYPE.SYSTEM_NOTICE_TYPE, 'number'),
placeholder: '请选择公告类型1通知 2公告',
2025-05-12 00:35:02 +08:00
},
},
{
fieldName: 'status',
label: '公告状态0正常 1关闭',
2025-05-12 00:35:02 +08:00
component: 'Select',
componentProps: {
allowClear: true,
options: [],
placeholder: '请选择公告状态0正常 1关闭',
},
},
{
fieldName: 'createTime',
label: '创建时间',
component: 'RangePicker',
componentProps: {
...getRangePickerDefaultProps(),
2025-05-12 00:35:02 +08:00
allowClear: true,
},
},
];
}
/** 列表的字段 */
export function useGridColumns(): VxeTableGridOptions<SystemNoticeApi.Notice>['columns'] {
2025-05-12 00:35:02 +08:00
return [
{ type: 'checkbox', width: 40 },
2025-05-12 00:35:02 +08:00
{
field: 'id',
title: '公告ID',
minWidth: 120,
2025-05-12 00:35:02 +08:00
},
{
field: 'title',
title: '公告标题',
minWidth: 120,
},
{
field: 'content',
title: '公告内容',
minWidth: 120,
2025-05-12 00:35:02 +08:00
},
{
field: 'type',
title: '公告类型1通知 2公告',
minWidth: 120,
2025-05-12 00:35:02 +08:00
cellRender: {
name: 'CellDict',
props: { type: DICT_TYPE.SYSTEM_NOTICE_TYPE },
},
},
{
field: 'status',
title: '公告状态0正常 1关闭',
minWidth: 120,
2025-05-12 00:35:02 +08:00
},
{
field: 'createTime',
title: '创建时间',
minWidth: 120,
2025-05-12 00:35:02 +08:00
formatter: 'formatDateTime',
},
{
title: '操作',
width: 200,
2025-05-12 00:35:02 +08:00
fixed: 'right',
slots: { default: 'actions' },
2025-05-12 00:35:02 +08:00
},
];
}