import type { VxeGridProps } from '#/adapter/vxe-table'; import { computed } from 'vue'; import { getSelectResultList, postMetersPage } from '#/api-client'; import { $t } from '#/locales'; export const querySchema = computed(() => [ { component: 'ApiSelect', fieldName: 'SystemName', label: $t('abp.IoTDBBase.SystemName'), componentProps: { api: getSelectResultList, params: { query: { TypeName: 'BusinessSystemEnum', }, }, labelField: 'secondValue', valueField: 'value', optionsPropName: 'options', immediate: true, afterFetch: (res: any) => { // 确保返回的是数组格式 if (Array.isArray(res)) { return res; } // 如果是包装在 items 中的,提取出来 if (res && Array.isArray(res.items)) { return res.items; } // 如果是包装在 data 中的,提取出来 if (res && Array.isArray(res.data)) { return res.data; } // 如果都不是,返回空数组 return []; }, }, }, { component: 'ApiSelect', fieldName: 'DeviceType', label: $t('abp.IoTDBBase.DeviceType'), componentProps: { api: getSelectResultList, params: { query: { TypeName: 'MeterTypeEnum', }, }, labelField: 'value', valueField: 'key', optionsPropName: 'options', immediate: true, afterFetch: (res: any) => { // 确保返回的是数组格式 if (Array.isArray(res)) { return res; } // 如果是包装在 items 中的,提取出来 if (res && Array.isArray(res.items)) { return res.items; } // 如果是包装在 data 中的,提取出来 if (res && Array.isArray(res.data)) { return res.data; } // 如果都不是,返回空数组 return []; }, }, }, { component: 'ApiSelect', fieldName: 'IoTDataType', label: $t('abp.IoTDBBase.IoTDataType'), componentProps: { api: getSelectResultList, params: { query: { TypeName: 'IoTDBDataTypeConst', }, }, labelField: 'value', valueField: 'key', optionsPropName: 'options', immediate: true, afterFetch: (res: any) => { // 确保返回的是数组格式 if (Array.isArray(res)) { return res; } // 如果是包装在 items 中的,提取出来 if (res && Array.isArray(res.items)) { return res.items; } // 如果是包装在 data 中的,提取出来 if (res && Array.isArray(res.data)) { return res.data; } // 如果都不是,返回空数组 return []; }, }, }, { component: 'DeviceSelect', fieldName: 'DeviceId', label: $t('abp.log.deviceInfo'), componentProps: { placeholder: $t('common.pleaseSelect') + $t('abp.log.deviceInfo'), allowClear: true, onDeviceChange: 'handleDeviceChange', }, }, ]); export const tableSchema: any = computed((): VxeGridProps['columns'] => [ { title: $t('common.seq'), type: 'seq', width: 50 }, { field: 'Timestamps', title: $t('abp.IoTDBBase.Timestamps'), minWidth: '150', }, { field: 'SystemName', title: $t('abp.IoTDBBase.SystemName'), minWidth: '150', }, { field: 'ProjectId', title: $t('abp.IoTDBBase.ProjectId'), minWidth: '150', }, { field: 'DeviceType', title: $t('abp.IoTDBBase.DeviceType'), minWidth: '150', }, { field: 'IoTDataType', title: $t('abp.IoTDBBase.IoTDataType'), minWidth: '150', }, { field: 'DeviceId', title: $t('abp.IoTDBBase.DeviceId'), minWidth: '150', }, ]);