Compare commits

..

No commits in common. "6c1fdb7adb9e61b58b2ab0ecd20f017cfc52ba1f" and "a7c4a19eb5f8b13cecf1319148b9c6a47bfc0df7" have entirely different histories.

12 changed files with 301 additions and 57 deletions

View File

@ -218,8 +218,8 @@
"IoTDataType": "数据类型",
"DataBaseName": "所属数据库",
"DeviceType": "设备类型",
"Timestamps": "UTC时标(纳秒)",
"FormattedTimestamps": "本地时间",
"Timestamps": "时标(纳秒)",
"FormattedTimestamps": "时标",
"DevicePath": "设备路径",
"DeviceAddress": "设备地址"
},

View File

@ -186,11 +186,6 @@ async function onEdit(record: any) {
//
const formValues = { ...record };
// ioTPlatformApiSelectvalueField'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;

View File

@ -104,8 +104,6 @@ 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)) {

View File

@ -136,9 +136,11 @@ const formOptions: VbenFormProps = {
//
const relevantFields = new Set([
'DeviceId',
'DeviceType',
'EndCreationTime',
'IoTDataType',
'StartCreationTime',
'DataBaseName',
]);
const hasRelevantChange = changedFields.some((field) =>
relevantFields.has(field),
@ -181,7 +183,9 @@ const gridOptions: VxeGridProps<any> = {
const currentFormValues = gridApi?.formApi ? await gridApi.formApi.getValues() : {};
//
let deviceAddress = currentFormValues.DeviceId || '';
let deviceId = currentFormValues.DeviceId || '';
let dataBaseName = '';
const deviceType = currentFormValues.DeviceType || '';
// 使
const deviceInfo =
@ -191,17 +195,28 @@ const gridOptions: VxeGridProps<any> = {
: null);
if (deviceInfo) {
deviceAddress = deviceInfo.deviceAddress || deviceAddress;
dataBaseName = deviceInfo.businessSystemName || '';
// id
if (Number(deviceType) === 10) {
// 使 focusId
deviceId = deviceInfo.focusId || deviceId;
} else {
// 使 meterId
deviceId = deviceInfo.meterId || deviceId;
}
}
//
const queryParams = {
pageIndex: page.currentPage,
pageSize: page.pageSize,
SearchKeyword: currentFormValues.SearchKeyword || '',
DeviceType: deviceType,
IoTDataType: currentFormValues.IoTDataType || '',
DeviceId: deviceAddress, // 使
DeviceId: deviceId,
DataBaseName: dataBaseName || currentFormValues.DataBaseName || '',
StartCreationTime: formatDate(currentFormValues.StartCreationTime),
EndCreationTime: formatDate(currentFormValues.EndCreationTime),
FocusAddress: currentFormValues.FocusAddress || '',
};
if (DeviceType) queryParams.DeviceType = DeviceType;

View File

@ -10,21 +10,88 @@ import { $t } from '#/locales';
export const querySchema = computed(() => [
{
component: 'ApiSelect',
fieldName: 'IoTDataType',
label: $t('abp.IoTDBBase.IoTDataType'),
fieldName: 'DataBaseName',
label: $t('abp.IoTDBBase.DataBaseName'),
componentProps: {
api: getCommonGetSelectList,
params: {
query: {
typeName: 'IoTDBDataTypeConst',
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',
label: $t('abp.IoTDBBase.IoTDataType'),
componentProps: {
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)) {
@ -94,7 +161,12 @@ 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'),

View File

@ -59,8 +59,8 @@ const fetchData = async () => {
if (data?.items) {
options.value = data.items.map((item) => ({
label: `${item.deviceName || item.deviceAddress} (${item.deviceAddress})`,
value: item.deviceAddress, // 使
label: item.meterName,
value: item.id,
...item, //
}));
total.value = data.totalCount || 0;

View File

@ -42,12 +42,12 @@ const fetchDeviceOptions = async () => {
}
};
//
const getDeviceInfoByAddress = (deviceAddress: string) => {
if (!deviceAddress || !deviceOptions.value || deviceOptions.value.length === 0) {
// ID
const getDeviceInfoById = (deviceId: string) => {
if (!deviceId || !deviceOptions.value || deviceOptions.value.length === 0) {
return null;
}
return deviceOptions.value.find((device) => device.deviceAddress === deviceAddress);
return deviceOptions.value.find((device) => device.id === deviceId);
};
// yyyy-MM-dd HH:mm:ss
@ -68,7 +68,7 @@ const formatDate = (date: Date | string) => {
};
const route = useRoute();
const { DeviceType, DeviceId } = route.query;
const { DeviceType, DeviceId, FocusAddress, DataBaseName } = route.query;
//
const dynamicColumns = ref<any[]>([]);
@ -90,6 +90,13 @@ const fixedColumns = [
showOverflow: true,
slots: {},
},
{
field: 'DataBaseName',
title: $t('abp.IoTDBBase.DataBaseName'),
minWidth: 150,
showOverflow: true,
slots: {},
},
{
field: 'DeviceType',
title: $t('abp.IoTDBBase.DeviceType'),
@ -153,8 +160,10 @@ initDefaultColumns();
const formOptions: VbenFormProps = {
schema: querySchema.value,
initialValues: {
FocusAddress: FocusAddress as string,
DeviceType: DeviceType ? Number(DeviceType) : undefined,
DeviceAddress: DeviceId as string, // 使DeviceIdDeviceAddress
DeviceId: DeviceId as string,
DataBaseName: DataBaseName as string,
},
// 使
submitOnChange: false,
@ -162,25 +171,27 @@ const formOptions: VbenFormProps = {
handleValuesChange: async (values, changedFields) => {
//
const relevantFields = new Set([
'DeviceAddress',
'DeviceId',
'DeviceType',
'EndCreationTime',
'FocusAddress',
'IoTDataType',
'StartCreationTime',
'DataBaseName',
]);
const hasRelevantChange = changedFields.some((field) =>
relevantFields.has(field),
);
// DeviceAddressselectedDeviceInfo
if (changedFields.includes('DeviceAddress')) {
const deviceAddress = values.DeviceAddress;
// DeviceIdselectedDeviceInfo
if (changedFields.includes('DeviceId')) {
const deviceId = values.DeviceId;
if (deviceAddress) {
if (deviceId) {
// deviceOptions
let device =
deviceOptions.value.length > 0
? deviceOptions.value.find((d) => d.deviceAddress === deviceAddress)
? deviceOptions.value.find((d) => d.id === deviceId)
: null;
// DeviceSelect
@ -188,7 +199,7 @@ const formOptions: VbenFormProps = {
try {
// DeviceSelect
const deviceSelectRef =
gridApi.formApi.getFieldComponentRef('DeviceAddress');
gridApi.formApi.getFieldComponentRef('DeviceId');
if (deviceSelectRef && deviceSelectRef.getSelectedDevice) {
device = deviceSelectRef.getSelectedDevice();
}
@ -204,7 +215,7 @@ const formOptions: VbenFormProps = {
setTimeout(() => {
try {
const deviceSelectRef =
gridApi.formApi.getFieldComponentRef('DeviceAddress');
gridApi.formApi.getFieldComponentRef('DeviceId');
if (deviceSelectRef && deviceSelectRef.getSelectedDevice) {
const delayedDevice = deviceSelectRef.getSelectedDevice();
if (delayedDevice) {
@ -267,7 +278,7 @@ const gridOptions: VxeGridProps<any> = {
(gridApi?.formApi ? await gridApi.formApi.getValues() : {}) ||
{};
// DeviceTypeIoTDataType
const deviceTypeValue = currentFormValues.DeviceType;
const deviceTypeValue = currentFormValues.DeviceType || DeviceType;
const deviceTypeNumber = deviceTypeValue
? Number(deviceTypeValue)
: undefined;
@ -282,27 +293,43 @@ const gridOptions: VxeGridProps<any> = {
? formatDate(currentFormValues.EndCreationTime)
: undefined;
//
let deviceAddress = currentFormValues.DeviceAddress || '';
// DeviceId(10)使focusId
let finalDeviceId = currentFormValues.DeviceId || DeviceId || '';
let finalFocusAddress = currentFormValues.FocusAddress || '';
// 使
const deviceInfo =
selectedDeviceInfo.value ||
(currentFormValues.DeviceAddress && deviceOptions.value.length > 0
? getDeviceInfoByAddress(currentFormValues.DeviceAddress)
(currentFormValues.DeviceId && deviceOptions.value.length > 0
? getDeviceInfoById(currentFormValues.DeviceId)
: null);
if (deviceInfo) {
deviceAddress = deviceInfo.deviceAddress || deviceAddress;
finalFocusAddress = deviceInfo.focusAddress || '';
if (deviceTypeNumber === 10) {
// 使focusId
if (deviceInfo.focusId) {
finalDeviceId = deviceInfo.focusId;
}
} else {
// 使meterId
if (deviceInfo.meterId) {
finalDeviceId = deviceInfo.meterId;
}
}
}
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,
@ -409,7 +436,7 @@ const initializeGrid = async () => {
}
//
if (DeviceType || DeviceId) {
if (DeviceType || DeviceId || FocusAddress || DataBaseName) {
//
setTimeout(() => {
if (gridApi) {
@ -424,7 +451,7 @@ const initializeGrid = async () => {
//
watch(
() => [DeviceType, DeviceId],
() => [DeviceType, DeviceId, FocusAddress, DataBaseName],
async (newValues, oldValues) => {
//
if (newValues.some(Boolean) && gridApi && isGridInitialized.value) {

View File

@ -6,6 +6,39 @@ 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',
@ -14,15 +47,13 @@ export const querySchema = computed(() => [
api: getCommonGetSelectList,
params: {
query: {
typeName: 'DeviceTypeEnum',
typeName: 'MeterTypeEnum',
},
},
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)) {
@ -56,8 +87,6 @@ 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)) {
@ -78,7 +107,7 @@ export const querySchema = computed(() => [
},
{
component: 'DeviceSelect',
fieldName: 'DeviceAddress',
fieldName: 'DeviceId',
label: $t('abp.log.deviceInfo'),
componentProps: {
placeholder: $t('common.pleaseSelect') + $t('abp.log.deviceInfo'),
@ -117,6 +146,11 @@ 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'),

View File

@ -135,9 +135,11 @@ const formOptions: VbenFormProps = {
//
const relevantFields = new Set([
'DeviceId',
'DeviceType',
'EndCreationTime',
'IoTDataType',
'StartCreationTime',
'DataBaseName',
]);
const hasRelevantChange = changedFields.some((field) =>
relevantFields.has(field),
@ -179,7 +181,9 @@ const gridOptions: VxeGridProps<any> = {
const currentFormValues = gridApi?.formApi ? await gridApi.formApi.getValues() : {};
//
let deviceAddress = currentFormValues.DeviceId || '';
let deviceId = currentFormValues.DeviceId || '';
let dataBaseName = '';
const deviceType = currentFormValues.DeviceType || '';
// 使
const deviceInfo =
@ -189,7 +193,15 @@ const gridOptions: VxeGridProps<any> = {
: null);
if (deviceInfo) {
deviceAddress = deviceInfo.deviceAddress || deviceAddress;
dataBaseName = deviceInfo.businessSystemName || '';
// id
if (Number(deviceType) === 10) {
// 使 focusId
deviceId = deviceInfo.focusId || deviceId;
} else {
// 使 meterId
deviceId = deviceInfo.meterId || deviceId;
}
}
//
@ -197,8 +209,10 @@ const gridOptions: VxeGridProps<any> = {
pageIndex: page.currentPage,
pageSize: page.pageSize,
SearchKeyword: currentFormValues.SearchKeyword || '',
DeviceType: deviceType,
IoTDataType: currentFormValues.IoTDataType || '',
DeviceId: deviceAddress, // 使
DeviceId: deviceId,
DataBaseName: dataBaseName || currentFormValues.DataBaseName || '',
StartCreationTime: formatDate(currentFormValues.StartCreationTime),
EndCreationTime: formatDate(currentFormValues.EndCreationTime),
};

View File

@ -8,6 +8,72 @@ 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',
@ -23,8 +89,6 @@ 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)) {
@ -94,7 +158,12 @@ 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'),

View File

@ -58,6 +58,9 @@ 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'),

View File

@ -19,11 +19,28 @@ 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: 'deviceAddress',
field: 'projectId',
title: $t('abp.log.projectId'),
minWidth: '150',
},
{
field: 'meterAddress',
title: $t('abp.meters.meterAddress'),
minWidth: '150',
},
{
field: 'focusAddress',
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'),