Files
admin-vben5/apps/web-antd/src/views/sis/deviceManage/data.ts

184 lines
3.9 KiB
TypeScript
Raw Normal View History

2025-06-29 02:59:14 +08:00
import type { FormSchemaGetter } from '#/adapter/form';
import type { VxeGridProps } from '#/adapter/vxe-table';
import { getPopupContainer } from '@vben/utils';
import { getDictOptions } from '#/utils/dict';
import { DictEnum } from '@vben/constants';
2025-07-21 03:38:19 +08:00
import type { FactoryQuery } from '#/api/sis/factory/model';
import { factoryList } from '#/api/sis/factory';
import { deviceGroupList } from '#/api/sis/deviceGroup';
import type { DeviceGroupQuery } from '#/api/sis/deviceGroup/model';
2025-06-29 02:59:14 +08:00
export const querySchema: FormSchemaGetter = () => [
{
component: 'Input',
fieldName: 'deviceName',
label: '设备名称',
},
{
component: 'Input',
fieldName: 'deviceIp',
label: '设备ip',
},
2025-07-19 09:09:14 +08:00
{
2025-07-21 03:38:19 +08:00
component: 'Select',
2025-07-19 09:09:14 +08:00
fieldName: 'deviceType',
label: '设备类型',
2025-07-21 03:38:19 +08:00
componentProps: {
getPopupContainer,
options: getDictOptions(DictEnum.sis_ipc_device_type, true),
},
2025-07-19 09:09:14 +08:00
},
2025-06-29 02:59:14 +08:00
{
fieldName: 'deviceStatus',
label: '在线状态',
component: 'Select',
componentProps: {
getPopupContainer,
options: getDictOptions(DictEnum.sis_device_status),
},
},
];
// 需要使用i18n注意这里要改成getter形式 否则切换语言不会刷新
// export const columns: () => VxeGridProps['columns'] = () => [
export const columns: VxeGridProps['columns'] = [
{ type: 'checkbox', width: 60 },
{
title: '设备名称',
field: 'deviceName',
},
2025-07-19 09:09:14 +08:00
{
2025-07-21 03:38:19 +08:00
title: '设备厂商',
field: 'factoryName',
2025-07-19 09:09:14 +08:00
},
{
title: '设备类型',
2025-07-21 03:38:19 +08:00
field: 'deviceTypeName',
},
{
title: '设备组',
field: 'groupName',
2025-07-19 09:09:14 +08:00
},
2025-06-29 02:59:14 +08:00
{
title: '设备ip',
field: 'deviceIp',
},
{
title: '设备端口',
field: 'devicePort',
},
{
2025-07-19 09:09:14 +08:00
title: '设备mac',
2025-06-29 02:59:14 +08:00
field: 'deviceMac',
},
{
title: '在线状态',
field: 'deviceStatus',
},
{
field: 'action',
fixed: 'right',
slots: { default: 'action' },
title: '操作',
width: 180,
},
];
export const modalSchema: FormSchemaGetter = () => [
{
label: '主键id',
fieldName: 'id',
component: 'Input',
dependencies: {
show: () => false,
triggerFields: [''],
},
},
{
label: '设备名称',
fieldName: 'deviceName',
component: 'Input',
rules: 'required',
},
2025-07-19 09:09:14 +08:00
{
label: '设备厂商',
2025-07-21 03:38:19 +08:00
fieldName: 'factoryNo',
component: 'ApiSelect',
2025-07-19 09:09:14 +08:00
rules: 'required',
2025-07-21 03:38:19 +08:00
componentProps: {
allowClear: true,
resultField: 'list', // 根据API返回结构调整
labelField: 'factoryName',
valueField: 'factoryNo',
api: async () => {
const params: FactoryQuery = {
pageNum: 1,
pageSize: 500,
};
const res = await factoryList(params);
return res.rows;
},
},
2025-07-19 09:09:14 +08:00
},
{
label: '设备类型',
fieldName: 'deviceType',
2025-07-21 03:38:19 +08:00
component: 'Select',
rules: 'required',
componentProps: {
getPopupContainer,
options: getDictOptions(DictEnum.sis_ipc_device_type, true),
},
},
{
label: '设备组',
fieldName: 'groupId',
component: 'ApiSelect',
2025-07-19 09:09:14 +08:00
rules: 'required',
2025-07-21 03:38:19 +08:00
componentProps: {
allowClear: true,
resultField: 'list', // 根据API返回结构调整
labelField: 'name',
valueField: 'id',
api: async () => {
const params: DeviceGroupQuery = {
pageNum: 1,
pageSize: 500,
};
const res = await deviceGroupList(params);
return res.rows;
},
},
2025-07-19 09:09:14 +08:00
},
2025-06-29 02:59:14 +08:00
{
label: '设备ip',
fieldName: 'deviceIp',
component: 'Input',
rules: 'required',
},
{
label: '设备端口',
fieldName: 'devicePort',
component: 'Input',
rules: 'required',
},
{
label: '设备账号',
fieldName: 'deviceAccount',
component: 'Input',
rules: 'required',
},
{
label: '设备密码',
fieldName: 'devicePwd',
component: 'Input',
rules: 'required',
},
2025-07-19 09:09:14 +08:00
2025-06-29 02:59:14 +08:00
{
label: '设备Mac',
fieldName: 'deviceMac',
component: 'Input',
},
];