feat: 【antd】【iot】设备分组代码迁移

This commit is contained in:
haohao
2025-10-26 18:26:41 +08:00
parent 60e199abf0
commit 8203f436cd
3 changed files with 38 additions and 31 deletions

View File

@@ -1,10 +1,11 @@
import type { VbenFormSchema } from '#/adapter/form';
import type { VxeTableGridOptions } from '#/adapter/vxe-table';
import { DICT_TYPE } from '@vben/constants';
import { CommonStatusEnum, DICT_TYPE } from '@vben/constants';
import { getDictOptions } from '@vben/hooks';
import { z } from '#/adapter/form';
import { getSimpleDeviceGroupList } from '#/api/iot/device/group';
import { getRangePickerDefaultProps } from '#/utils';
/** 新增/修改设备分组的表单 */
export function useFormSchema(): VbenFormSchema[] {
@@ -30,16 +31,15 @@ export function useFormSchema(): VbenFormSchema[] {
.max(64, '分组名称长度不能超过 64 个字符'),
},
{
fieldName: 'parentId',
label: '父级分组',
component: 'ApiTreeSelect',
fieldName: 'status',
label: '分组状态',
component: 'RadioGroup',
componentProps: {
api: getSimpleDeviceGroupList,
labelField: 'name',
valueField: 'id',
placeholder: '请选择父级分组',
allowClear: true,
options: getDictOptions(DICT_TYPE.COMMON_STATUS, 'number'),
buttonStyle: 'solid',
optionType: 'button',
},
rules: z.number().default(CommonStatusEnum.ENABLE),
},
{
fieldName: 'description',
@@ -65,6 +65,15 @@ export function useGridFormSchema(): VbenFormSchema[] {
allowClear: true,
},
},
{
fieldName: 'createTime',
label: '创建时间',
component: 'RangePicker',
componentProps: {
...getRangePickerDefaultProps(),
allowClear: true,
},
},
];
}
@@ -72,14 +81,13 @@ export function useGridFormSchema(): VbenFormSchema[] {
export function useGridColumns(): VxeTableGridOptions['columns'] {
return [
{
field: 'name',
title: '分组名称',
minWidth: 200,
treeNode: true,
field: 'id',
title: 'ID',
minWidth: 100,
},
{
field: 'description',
title: '分组描述',
field: 'name',
title: '分组名称',
minWidth: 200,
},
{
@@ -92,9 +100,9 @@ export function useGridColumns(): VxeTableGridOptions['columns'] {
},
},
{
field: 'deviceCount',
title: '设备数量',
minWidth: 100,
field: 'description',
title: '分组描述',
minWidth: 200,
},
{
field: 'createTime',
@@ -102,6 +110,11 @@ export function useGridColumns(): VxeTableGridOptions['columns'] {
minWidth: 180,
formatter: 'formatDateTime',
},
{
field: 'deviceCount',
title: '设备数量',
minWidth: 100,
},
{
title: '操作',
width: 200,