Compare commits
2 Commits
a7c4a19eb5
...
6c1fdb7adb
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
6c1fdb7adb | ||
|
|
67261b19c9 |
@ -218,8 +218,8 @@
|
||||
"IoTDataType": "数据类型",
|
||||
"DataBaseName": "所属数据库",
|
||||
"DeviceType": "设备类型",
|
||||
"Timestamps": "时标(纳秒)",
|
||||
"FormattedTimestamps": "时标",
|
||||
"Timestamps": "UTC时标(纳秒)",
|
||||
"FormattedTimestamps": "本地时间",
|
||||
"DevicePath": "设备路径",
|
||||
"DeviceAddress": "设备地址"
|
||||
},
|
||||
|
||||
@ -186,6 +186,11 @@ async function onEdit(record: any) {
|
||||
// 根据平台类型设置表单值
|
||||
const formValues = { ...record };
|
||||
|
||||
// 确保ioTPlatform是字符串格式,因为ApiSelect组件的valueField是'key'
|
||||
if (formValues.ioTPlatform !== undefined && formValues.ioTPlatform !== null) {
|
||||
formValues.ioTPlatform = String(formValues.ioTPlatform);
|
||||
}
|
||||
|
||||
if (record.ioTPlatform === 2 || record.ioTPlatform === '2') {
|
||||
// OneNET平台
|
||||
formValues.oneNETAccountId = record.ioTPlatformAccountId;
|
||||
|
||||
@ -104,6 +104,8 @@ export const addDeviceFormSchema: any = computed(() => [
|
||||
valueField: 'key',
|
||||
optionsPropName: 'options',
|
||||
immediate: true,
|
||||
allowClear: true,
|
||||
placeholder: $t('common.pleaseSelect') + $t('abp.deviceInfos.ioTPlatform'),
|
||||
afterFetch: (res: any) => {
|
||||
// 确保返回的是数组格式
|
||||
if (Array.isArray(res)) {
|
||||
|
||||
@ -136,11 +136,9 @@ const formOptions: VbenFormProps = {
|
||||
// 当任何相关字段发生变化时,刷新表格数据
|
||||
const relevantFields = new Set([
|
||||
'DeviceId',
|
||||
'DeviceType',
|
||||
'EndCreationTime',
|
||||
'IoTDataType',
|
||||
'StartCreationTime',
|
||||
'DataBaseName',
|
||||
]);
|
||||
const hasRelevantChange = changedFields.some((field) =>
|
||||
relevantFields.has(field),
|
||||
@ -183,9 +181,7 @@ const gridOptions: VxeGridProps<any> = {
|
||||
const currentFormValues = gridApi?.formApi ? await gridApi.formApi.getValues() : {};
|
||||
|
||||
// 获取选中的设备信息
|
||||
let deviceId = currentFormValues.DeviceId || '';
|
||||
let dataBaseName = '';
|
||||
const deviceType = currentFormValues.DeviceType || '';
|
||||
let deviceAddress = currentFormValues.DeviceId || '';
|
||||
|
||||
// 优先使用选中的设备信息
|
||||
const deviceInfo =
|
||||
@ -195,28 +191,17 @@ const gridOptions: VxeGridProps<any> = {
|
||||
: null);
|
||||
|
||||
if (deviceInfo) {
|
||||
dataBaseName = deviceInfo.businessSystemName || '';
|
||||
// 根据设备类型获取正确的 id
|
||||
if (Number(deviceType) === 10) {
|
||||
// 集中器类型使用 focusId
|
||||
deviceId = deviceInfo.focusId || deviceId;
|
||||
} else {
|
||||
// 其他设备类型使用 meterId
|
||||
deviceId = deviceInfo.meterId || deviceId;
|
||||
}
|
||||
deviceAddress = deviceInfo.deviceAddress || deviceAddress;
|
||||
}
|
||||
// 构建查询参数
|
||||
const queryParams = {
|
||||
pageIndex: page.currentPage,
|
||||
pageSize: page.pageSize,
|
||||
SearchKeyword: currentFormValues.SearchKeyword || '',
|
||||
DeviceType: deviceType,
|
||||
IoTDataType: currentFormValues.IoTDataType || '',
|
||||
DeviceId: deviceId,
|
||||
DataBaseName: dataBaseName || currentFormValues.DataBaseName || '',
|
||||
DeviceId: deviceAddress, // 直接使用设备地址
|
||||
StartCreationTime: formatDate(currentFormValues.StartCreationTime),
|
||||
EndCreationTime: formatDate(currentFormValues.EndCreationTime),
|
||||
FocusAddress: currentFormValues.FocusAddress || '',
|
||||
};
|
||||
|
||||
if (DeviceType) queryParams.DeviceType = DeviceType;
|
||||
|
||||
@ -8,73 +8,6 @@ import { getCommonGetSelectList } from '#/api-client';
|
||||
import { $t } from '#/locales';
|
||||
|
||||
export const querySchema = computed(() => [
|
||||
{
|
||||
component: 'ApiSelect',
|
||||
fieldName: 'DataBaseName',
|
||||
label: $t('abp.IoTDBBase.DataBaseName'),
|
||||
componentProps: {
|
||||
api: getCommonGetSelectList,
|
||||
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: getCommonGetSelectList,
|
||||
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',
|
||||
@ -83,15 +16,15 @@ export const querySchema = computed(() => [
|
||||
api: getCommonGetSelectList,
|
||||
params: {
|
||||
query: {
|
||||
input: {
|
||||
typeName: 'IoTDBDataTypeConst',
|
||||
},
|
||||
},
|
||||
},
|
||||
labelField: 'value',
|
||||
valueField: 'key',
|
||||
optionsPropName: 'options',
|
||||
immediate: true,
|
||||
allowClear: true,
|
||||
placeholder: $t('common.pleaseSelect') + $t('abp.IoTDBBase.IoTDataType'),
|
||||
afterFetch: (res: any) => {
|
||||
// 确保返回的是数组格式
|
||||
if (Array.isArray(res)) {
|
||||
@ -161,12 +94,7 @@ export const tableSchema: any = computed((): VxeGridProps['columns'] => [
|
||||
return cellValue ? dayjs(cellValue).format('YYYY-MM-DD HH:mm:ss') : '';
|
||||
},
|
||||
},
|
||||
{
|
||||
field: 'deviceType',
|
||||
title: $t('abp.IoTDBBase.DeviceType'),
|
||||
minWidth: 150,
|
||||
slots: {},
|
||||
},
|
||||
|
||||
{
|
||||
field: 'ioTDataType',
|
||||
title: $t('abp.IoTDBBase.IoTDataType'),
|
||||
|
||||
@ -59,8 +59,8 @@ const fetchData = async () => {
|
||||
|
||||
if (data?.items) {
|
||||
options.value = data.items.map((item) => ({
|
||||
label: item.meterName,
|
||||
value: item.id,
|
||||
label: `${item.deviceName || item.deviceAddress} (${item.deviceAddress})`,
|
||||
value: item.deviceAddress, // 使用设备地址作为值
|
||||
...item, // 保留完整数据
|
||||
}));
|
||||
total.value = data.totalCount || 0;
|
||||
|
||||
@ -42,12 +42,12 @@ const fetchDeviceOptions = async () => {
|
||||
}
|
||||
};
|
||||
|
||||
// 根据设备ID获取设备信息对象
|
||||
const getDeviceInfoById = (deviceId: string) => {
|
||||
if (!deviceId || !deviceOptions.value || deviceOptions.value.length === 0) {
|
||||
// 根据设备地址获取设备信息对象
|
||||
const getDeviceInfoByAddress = (deviceAddress: string) => {
|
||||
if (!deviceAddress || !deviceOptions.value || deviceOptions.value.length === 0) {
|
||||
return null;
|
||||
}
|
||||
return deviceOptions.value.find((device) => device.id === deviceId);
|
||||
return deviceOptions.value.find((device) => device.deviceAddress === deviceAddress);
|
||||
};
|
||||
|
||||
// 格式化日期为 yyyy-MM-dd HH:mm:ss 格式
|
||||
@ -68,7 +68,7 @@ const formatDate = (date: Date | string) => {
|
||||
};
|
||||
|
||||
const route = useRoute();
|
||||
const { DeviceType, DeviceId, FocusAddress, DataBaseName } = route.query;
|
||||
const { DeviceType, DeviceId } = route.query;
|
||||
|
||||
// 动态列定义
|
||||
const dynamicColumns = ref<any[]>([]);
|
||||
@ -90,13 +90,6 @@ const fixedColumns = [
|
||||
showOverflow: true,
|
||||
slots: {},
|
||||
},
|
||||
{
|
||||
field: 'DataBaseName',
|
||||
title: $t('abp.IoTDBBase.DataBaseName'),
|
||||
minWidth: 150,
|
||||
showOverflow: true,
|
||||
slots: {},
|
||||
},
|
||||
{
|
||||
field: 'DeviceType',
|
||||
title: $t('abp.IoTDBBase.DeviceType'),
|
||||
@ -160,10 +153,8 @@ initDefaultColumns();
|
||||
const formOptions: VbenFormProps = {
|
||||
schema: querySchema.value,
|
||||
initialValues: {
|
||||
FocusAddress: FocusAddress as string,
|
||||
DeviceType: DeviceType ? Number(DeviceType) : undefined,
|
||||
DeviceId: DeviceId as string,
|
||||
DataBaseName: DataBaseName as string,
|
||||
DeviceAddress: DeviceId as string, // 使用DeviceId作为DeviceAddress的初始值
|
||||
},
|
||||
// 禁用表单值变化时自动提交,使用自定义处理函数
|
||||
submitOnChange: false,
|
||||
@ -171,27 +162,25 @@ const formOptions: VbenFormProps = {
|
||||
handleValuesChange: async (values, changedFields) => {
|
||||
// 当任何相关字段发生变化时,刷新表格数据
|
||||
const relevantFields = new Set([
|
||||
'DeviceId',
|
||||
'DeviceAddress',
|
||||
'DeviceType',
|
||||
'EndCreationTime',
|
||||
'FocusAddress',
|
||||
'IoTDataType',
|
||||
'StartCreationTime',
|
||||
'DataBaseName',
|
||||
]);
|
||||
const hasRelevantChange = changedFields.some((field) =>
|
||||
relevantFields.has(field),
|
||||
);
|
||||
|
||||
// 新增:DeviceId变化时同步selectedDeviceInfo
|
||||
if (changedFields.includes('DeviceId')) {
|
||||
const deviceId = values.DeviceId;
|
||||
// 新增:DeviceAddress变化时同步selectedDeviceInfo
|
||||
if (changedFields.includes('DeviceAddress')) {
|
||||
const deviceAddress = values.DeviceAddress;
|
||||
|
||||
if (deviceId) {
|
||||
if (deviceAddress) {
|
||||
// 先尝试从 deviceOptions 中查找(备用方案)
|
||||
let device =
|
||||
deviceOptions.value.length > 0
|
||||
? deviceOptions.value.find((d) => d.id === deviceId)
|
||||
? deviceOptions.value.find((d) => d.deviceAddress === deviceAddress)
|
||||
: null;
|
||||
|
||||
// 如果没找到,尝试从 DeviceSelect 组件中获取
|
||||
@ -199,7 +188,7 @@ const formOptions: VbenFormProps = {
|
||||
try {
|
||||
// 获取 DeviceSelect 组件的实例
|
||||
const deviceSelectRef =
|
||||
gridApi.formApi.getFieldComponentRef('DeviceId');
|
||||
gridApi.formApi.getFieldComponentRef('DeviceAddress');
|
||||
if (deviceSelectRef && deviceSelectRef.getSelectedDevice) {
|
||||
device = deviceSelectRef.getSelectedDevice();
|
||||
}
|
||||
@ -215,7 +204,7 @@ const formOptions: VbenFormProps = {
|
||||
setTimeout(() => {
|
||||
try {
|
||||
const deviceSelectRef =
|
||||
gridApi.formApi.getFieldComponentRef('DeviceId');
|
||||
gridApi.formApi.getFieldComponentRef('DeviceAddress');
|
||||
if (deviceSelectRef && deviceSelectRef.getSelectedDevice) {
|
||||
const delayedDevice = deviceSelectRef.getSelectedDevice();
|
||||
if (delayedDevice) {
|
||||
@ -278,7 +267,7 @@ const gridOptions: VxeGridProps<any> = {
|
||||
(gridApi?.formApi ? await gridApi.formApi.getValues() : {}) ||
|
||||
{};
|
||||
// 处理DeviceType和IoTDataType,确保传递数字类型
|
||||
const deviceTypeValue = currentFormValues.DeviceType || DeviceType;
|
||||
const deviceTypeValue = currentFormValues.DeviceType;
|
||||
const deviceTypeNumber = deviceTypeValue
|
||||
? Number(deviceTypeValue)
|
||||
: undefined;
|
||||
@ -293,43 +282,27 @@ const gridOptions: VxeGridProps<any> = {
|
||||
? formatDate(currentFormValues.EndCreationTime)
|
||||
: undefined;
|
||||
|
||||
// 处理DeviceId,当设备类型为集中器(10)时,使用focusId
|
||||
let finalDeviceId = currentFormValues.DeviceId || DeviceId || '';
|
||||
let finalFocusAddress = currentFormValues.FocusAddress || '';
|
||||
// 获取选中的设备信息
|
||||
let deviceAddress = currentFormValues.DeviceAddress || '';
|
||||
|
||||
// 优先使用选中的设备信息
|
||||
const deviceInfo =
|
||||
selectedDeviceInfo.value ||
|
||||
(currentFormValues.DeviceId && deviceOptions.value.length > 0
|
||||
? getDeviceInfoById(currentFormValues.DeviceId)
|
||||
(currentFormValues.DeviceAddress && deviceOptions.value.length > 0
|
||||
? getDeviceInfoByAddress(currentFormValues.DeviceAddress)
|
||||
: null);
|
||||
|
||||
if (deviceInfo) {
|
||||
finalFocusAddress = deviceInfo.focusAddress || '';
|
||||
|
||||
if (deviceTypeNumber === 10) {
|
||||
// 集中器类型使用focusId
|
||||
if (deviceInfo.focusId) {
|
||||
finalDeviceId = deviceInfo.focusId;
|
||||
}
|
||||
} else {
|
||||
// 其他设备类型使用meterId
|
||||
if (deviceInfo.meterId) {
|
||||
finalDeviceId = deviceInfo.meterId;
|
||||
}
|
||||
}
|
||||
deviceAddress = deviceInfo.deviceAddress || deviceAddress;
|
||||
}
|
||||
try {
|
||||
const { data } = await postTreeModelDeviceDataInfoPage({
|
||||
body: {
|
||||
pageIndex: page.currentPage,
|
||||
pageSize: page.pageSize,
|
||||
// 优先使用表单中的值,如果没有则使用路由参数
|
||||
// 使用设备地址作为DeviceAddress
|
||||
DeviceAddress: deviceAddress,
|
||||
DeviceType: deviceTypeNumber || undefined,
|
||||
DeviceId: finalDeviceId ? finalDeviceId.toString() : '',
|
||||
FocusAddress: finalFocusAddress || FocusAddress || '',
|
||||
// 添加其他表单参数
|
||||
DataBaseName: currentFormValues.DataBaseName || DataBaseName,
|
||||
IoTDataType: ioTDataTypeValue || undefined,
|
||||
// 添加日期范围参数
|
||||
StartCreationTime: startCreationTime || undefined,
|
||||
@ -436,7 +409,7 @@ const initializeGrid = async () => {
|
||||
}
|
||||
|
||||
// 如果有路由参数,自动触发查询
|
||||
if (DeviceType || DeviceId || FocusAddress || DataBaseName) {
|
||||
if (DeviceType || DeviceId) {
|
||||
// 延迟一下确保表格已完全初始化
|
||||
setTimeout(() => {
|
||||
if (gridApi) {
|
||||
@ -451,7 +424,7 @@ const initializeGrid = async () => {
|
||||
|
||||
// 监听路由参数变化,当有路由参数时自动触发查询
|
||||
watch(
|
||||
() => [DeviceType, DeviceId, FocusAddress, DataBaseName],
|
||||
() => [DeviceType, DeviceId],
|
||||
async (newValues, oldValues) => {
|
||||
// 如果有路由参数,等待设备信息加载完成后自动触发查询
|
||||
if (newValues.some(Boolean) && gridApi && isGridInitialized.value) {
|
||||
|
||||
@ -6,39 +6,6 @@ import { getCommonGetSelectList } from '#/api-client';
|
||||
import { $t } from '#/locales';
|
||||
|
||||
export const querySchema = computed(() => [
|
||||
{
|
||||
component: 'ApiSelect',
|
||||
fieldName: 'DataBaseName',
|
||||
label: $t('abp.IoTDBBase.DataBaseName'),
|
||||
componentProps: {
|
||||
api: getCommonGetSelectList,
|
||||
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',
|
||||
@ -47,13 +14,15 @@ export const querySchema = computed(() => [
|
||||
api: getCommonGetSelectList,
|
||||
params: {
|
||||
query: {
|
||||
typeName: 'MeterTypeEnum',
|
||||
typeName: 'DeviceTypeEnum',
|
||||
},
|
||||
},
|
||||
labelField: 'value',
|
||||
valueField: 'key',
|
||||
optionsPropName: 'options',
|
||||
immediate: true,
|
||||
allowClear: true,
|
||||
placeholder: $t('common.pleaseSelect') + $t('abp.IoTDBBase.DeviceType'),
|
||||
afterFetch: (res: any) => {
|
||||
// 确保返回的是数组格式
|
||||
if (Array.isArray(res)) {
|
||||
@ -87,6 +56,8 @@ export const querySchema = computed(() => [
|
||||
valueField: 'key',
|
||||
optionsPropName: 'options',
|
||||
immediate: true,
|
||||
allowClear: true,
|
||||
placeholder: $t('common.pleaseSelect') + $t('abp.IoTDBBase.IoTDataType'),
|
||||
afterFetch: (res: any) => {
|
||||
// 确保返回的是数组格式
|
||||
if (Array.isArray(res)) {
|
||||
@ -107,7 +78,7 @@ export const querySchema = computed(() => [
|
||||
},
|
||||
{
|
||||
component: 'DeviceSelect',
|
||||
fieldName: 'DeviceId',
|
||||
fieldName: 'DeviceAddress',
|
||||
label: $t('abp.log.deviceInfo'),
|
||||
componentProps: {
|
||||
placeholder: $t('common.pleaseSelect') + $t('abp.log.deviceInfo'),
|
||||
@ -146,11 +117,6 @@ export const tableSchema: any = computed((): VxeGridProps['columns'] => [
|
||||
title: $t('abp.IoTDBBase.Timestamps'),
|
||||
minWidth: '150',
|
||||
},
|
||||
{
|
||||
field: 'DataBaseName',
|
||||
title: $t('abp.IoTDBBase.DataBaseName'),
|
||||
minWidth: '150',
|
||||
},
|
||||
{
|
||||
field: 'DeviceType',
|
||||
title: $t('abp.IoTDBBase.DeviceType'),
|
||||
|
||||
@ -135,11 +135,9 @@ const formOptions: VbenFormProps = {
|
||||
// 当任何相关字段发生变化时,刷新表格数据
|
||||
const relevantFields = new Set([
|
||||
'DeviceId',
|
||||
'DeviceType',
|
||||
'EndCreationTime',
|
||||
'IoTDataType',
|
||||
'StartCreationTime',
|
||||
'DataBaseName',
|
||||
]);
|
||||
const hasRelevantChange = changedFields.some((field) =>
|
||||
relevantFields.has(field),
|
||||
@ -181,9 +179,7 @@ const gridOptions: VxeGridProps<any> = {
|
||||
const currentFormValues = gridApi?.formApi ? await gridApi.formApi.getValues() : {};
|
||||
|
||||
// 获取选中的设备信息
|
||||
let deviceId = currentFormValues.DeviceId || '';
|
||||
let dataBaseName = '';
|
||||
const deviceType = currentFormValues.DeviceType || '';
|
||||
let deviceAddress = currentFormValues.DeviceId || '';
|
||||
|
||||
// 优先使用选中的设备信息
|
||||
const deviceInfo =
|
||||
@ -193,15 +189,7 @@ const gridOptions: VxeGridProps<any> = {
|
||||
: null);
|
||||
|
||||
if (deviceInfo) {
|
||||
dataBaseName = deviceInfo.businessSystemName || '';
|
||||
// 根据设备类型获取正确的 id
|
||||
if (Number(deviceType) === 10) {
|
||||
// 集中器类型使用 focusId
|
||||
deviceId = deviceInfo.focusId || deviceId;
|
||||
} else {
|
||||
// 其他设备类型使用 meterId
|
||||
deviceId = deviceInfo.meterId || deviceId;
|
||||
}
|
||||
deviceAddress = deviceInfo.deviceAddress || deviceAddress;
|
||||
}
|
||||
|
||||
// 构建查询参数
|
||||
@ -209,10 +197,8 @@ const gridOptions: VxeGridProps<any> = {
|
||||
pageIndex: page.currentPage,
|
||||
pageSize: page.pageSize,
|
||||
SearchKeyword: currentFormValues.SearchKeyword || '',
|
||||
DeviceType: deviceType,
|
||||
IoTDataType: currentFormValues.IoTDataType || '',
|
||||
DeviceId: deviceId,
|
||||
DataBaseName: dataBaseName || currentFormValues.DataBaseName || '',
|
||||
DeviceId: deviceAddress, // 直接使用设备地址
|
||||
StartCreationTime: formatDate(currentFormValues.StartCreationTime),
|
||||
EndCreationTime: formatDate(currentFormValues.EndCreationTime),
|
||||
};
|
||||
|
||||
@ -8,72 +8,6 @@ import { getCommonGetSelectList } from '#/api-client';
|
||||
import { $t } from '#/locales';
|
||||
|
||||
export const querySchema = computed(() => [
|
||||
{
|
||||
component: 'ApiSelect',
|
||||
fieldName: 'DataBaseName',
|
||||
label: $t('abp.IoTDBBase.DataBaseName'),
|
||||
componentProps: {
|
||||
api: getCommonGetSelectList,
|
||||
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: getCommonGetSelectList,
|
||||
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',
|
||||
@ -89,6 +23,8 @@ export const querySchema = computed(() => [
|
||||
valueField: 'key',
|
||||
optionsPropName: 'options',
|
||||
immediate: true,
|
||||
allowClear: true,
|
||||
placeholder: $t('common.pleaseSelect') + $t('abp.IoTDBBase.IoTDataType'),
|
||||
afterFetch: (res: any) => {
|
||||
// 确保返回的是数组格式
|
||||
if (Array.isArray(res)) {
|
||||
@ -158,12 +94,7 @@ export const tableSchema: any = computed((): VxeGridProps['columns'] => [
|
||||
return cellValue ? dayjs(cellValue).format('YYYY-MM-DD HH:mm:ss') : '';
|
||||
},
|
||||
},
|
||||
{
|
||||
field: 'deviceType',
|
||||
title: $t('abp.IoTDBBase.DeviceType'),
|
||||
minWidth: '120',
|
||||
slots: {},
|
||||
},
|
||||
|
||||
{
|
||||
field: 'ioTDataType',
|
||||
title: $t('abp.IoTDBBase.IoTDataType'),
|
||||
|
||||
@ -58,9 +58,6 @@ const [Grid] = useVbenVxeGrid({ formOptions, gridOptions });
|
||||
<template>
|
||||
<Page auto-content-height>
|
||||
<Grid>
|
||||
<template #isdeviceType="{ row }">
|
||||
{{ row.deviceType }}
|
||||
</template>
|
||||
<template #ismanualOrNot="{ row }">
|
||||
<component :is="h(Tag, { color: row.manualOrNot ? 'green' : 'red' }, () =>
|
||||
row.manualOrNot ? $t('common.yes') : $t('common.no'),
|
||||
|
||||
@ -19,28 +19,11 @@ export const querySchema = computed(() => [
|
||||
|
||||
export const tableSchema: any = computed((): VxeGridProps['columns'] => [
|
||||
{ title: $t('common.seq'), type: 'seq', width: 50 },
|
||||
{ field: 'dataBaseName', title: $t('abp.log.dataBaseName'), minWidth: '150' },
|
||||
{
|
||||
field: 'projectId',
|
||||
title: $t('abp.log.projectId'),
|
||||
minWidth: '150',
|
||||
},
|
||||
{
|
||||
field: 'meterAddress',
|
||||
title: $t('abp.meters.meterAddress'),
|
||||
minWidth: '150',
|
||||
},
|
||||
{
|
||||
field: 'focusAddress',
|
||||
field: 'deviceAddress',
|
||||
title: $t('abp.focus.focusAddress'),
|
||||
minWidth: '100',
|
||||
},
|
||||
{
|
||||
field: 'deviceType',
|
||||
title: $t('abp.log.deviceType'),
|
||||
minWidth: '100',
|
||||
slots: { default: 'isdeviceType' },
|
||||
},
|
||||
{
|
||||
field: 'timestamps',
|
||||
title: $t('abp.log.timestamps'),
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user