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'; 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'; export const querySchema: FormSchemaGetter = () => [ { component: 'Input', fieldName: 'deviceName', label: '设备名称', }, { component: 'Input', fieldName: 'deviceIp', label: '设备ip', }, { component: 'Select', fieldName: 'deviceType', label: '设备类型', componentProps: { getPopupContainer, options: getDictOptions(DictEnum.sis_ipc_device_type, true), }, }, { 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', }, { title: '设备厂商', field: 'factoryName', }, { title: '设备类型', field: 'deviceTypeName', }, { title: '设备组', field: 'groupName', }, { title: '设备ip', field: 'deviceIp', }, { title: '设备端口', field: 'devicePort', }, { title: '设备mac', 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', }, { label: '设备厂商', fieldName: 'factoryNo', component: 'ApiSelect', rules: 'required', 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; }, }, }, { label: '设备类型', fieldName: 'deviceType', component: 'Select', rules: 'required', componentProps: { getPopupContainer, options: getDictOptions(DictEnum.sis_ipc_device_type, true), }, }, { label: '设备组', fieldName: 'groupId', component: 'ApiSelect', rules: 'required', 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; }, }, }, { 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', }, { label: '设备Mac', fieldName: 'deviceMac', component: 'Input', }, ];