Compare commits

..

No commits in common. "a5781829e97003b802af05c7fa96c77a084d9edf" and "12d28955bf6ef314e1c7367d02cbf46786b8dd07" have entirely different histories.

4 changed files with 193 additions and 195 deletions

View File

@ -2,22 +2,17 @@
import type { VbenFormProps } from '#/adapter/form';
import type { VxeGridProps } from '#/adapter/vxe-table';
import { computed, nextTick, ref, watch, onMounted } from 'vue';
import { computed, nextTick, ref, watch } from 'vue';
import { useRoute } from 'vue-router';
import { Page } from '@vben/common-ui';
import { useVbenVxeGrid } from '#/adapter/vxe-table';
import { postMetersPage, postTreeModelDeviceDataInfoPage } from '#/api-client';
import { $t } from '#/locales';
import { postTreeModelDeviceDataInfoPage, postMetersPage } from '#/api-client';
import { generateDynamicColumns } from './dynamicColumns';
import { querySchema } from './schema';
defineOptions({
name: 'DeviceData',
});
//
const deviceOptions = ref<any[]>([]);
@ -30,7 +25,7 @@ const fetchDeviceOptions = async () => {
pageSize: 1000,
},
});
if (data?.items) {
deviceOptions.value = data.items;
console.log('设备信息选项:', deviceOptions.value);
@ -42,28 +37,30 @@ const fetchDeviceOptions = async () => {
// ID
const getDeviceInfoById = (deviceId: string) => {
return deviceOptions.value.find((device) => device.id === deviceId);
return deviceOptions.value.find(device => device.id === deviceId);
};
defineOptions({
name: 'DeviceData',
});
const route = useRoute();
const { DeviceType, DeviceId, FocusAddress, SystemName } = route.query;
const { DeviceType, DeviceId, FocusAddress } = route.query;
//
const dynamicColumns = ref<any[]>([]);
// - IoTDBTreeModelDeviceDataDto
const fixedColumns = [
{ title: '序号', 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 },
{ field: 'Timestamps', title: '时间戳', minWidth: 150 },
{ field: 'SystemName', title: '系统名称', minWidth: 150 },
{ field: 'ProjectId', title: '项目ID', minWidth: 150 },
{ field: 'DeviceType', title: '设备类型', minWidth: 150 },
{ field: 'IoTDataType', title: 'IoT数据类型', minWidth: 150 },
{ field: 'DeviceId', title: '设备ID', minWidth: 150 },
];
// - 使
@ -89,30 +86,18 @@ const formOptions: VbenFormProps = {
FocusAddress: FocusAddress as string,
DeviceType: DeviceType ? Number(DeviceType) : undefined,
DeviceId: DeviceId as string,
SystemName: SystemName as string,
},
// 使
submitOnChange: false,
//
handleValuesChange: async (values, changedFields) => {
//
const relevantFields = new Set([
'DeviceId',
'DeviceType',
'FocusAddress',
'IoTDataType',
'SystemName',
]);
const hasRelevantChange = changedFields.some((field) =>
relevantFields.has(field),
);
const relevantFields = ['SystemName', 'DeviceType', 'IoTDataType', 'DeviceId', 'FocusAddress'];
const hasRelevantChange = changedFields.some(field => relevantFields.includes(field));
if (hasRelevantChange) {
console.log('表单字段变化:', { values, changedFields });
console.log(
'相关字段变化:',
changedFields.filter((field) => relevantFields.has(field)),
);
console.log('相关字段变化:', changedFields.filter(field => relevantFields.includes(field)));
// 使 setTimeout
setTimeout(async () => {
@ -162,45 +147,62 @@ const gridOptions: VxeGridProps<any> = {
console.log('=== API调用开始 ===');
// DeviceTypeIoTDataType
const deviceTypeValue = formValues.DeviceType || DeviceType;
const deviceTypeNumber = deviceTypeValue
? Number(deviceTypeValue)
: undefined;
const deviceTypeNumber = deviceTypeValue ? Number(deviceTypeValue) : undefined;
const ioTDataTypeValue = formValues.IoTDataType;
console.log('=== API调用开始 ===2', ioTDataTypeValue);
const ioTDataTypeNumber = ioTDataTypeValue ? Number(ioTDataTypeValue) : undefined;
// DeviceId(10)使focusId
let finalDeviceId = formValues.DeviceId || DeviceId;
if (formValues.DeviceId) {
if (deviceTypeNumber === 10 && formValues.DeviceId) {
const deviceInfo = getDeviceInfoById(formValues.DeviceId);
if (deviceInfo) {
if (deviceTypeNumber === 10) {
// 使focusId
if (deviceInfo.focusId) {
finalDeviceId = deviceInfo.focusId;
console.log('设备类型为集中器使用focusId:', {
originalDeviceId: formValues.DeviceId,
focusId: deviceInfo.focusId,
deviceInfo: deviceInfo,
});
}
} else {
// 使meterId
if (deviceInfo.meterId) {
finalDeviceId = deviceInfo.meterId;
console.log('设备类型为非集中器使用meterId:', {
originalDeviceId: formValues.DeviceId,
meterId: deviceInfo.meterId,
deviceInfo: deviceInfo,
});
}
}
if (deviceInfo && deviceInfo.focusId) {
finalDeviceId = deviceInfo.focusId;
console.log('设备类型为集中器使用focusId:', {
originalDeviceId: formValues.DeviceId,
focusId: deviceInfo.focusId,
deviceInfo: deviceInfo,
});
}
}
console.log('请求参数:', {
page,
formValues,
routeParams: { DeviceType, DeviceId, FocusAddress },
typeConversions: {
deviceType: {
originalValue: deviceTypeValue,
convertedValue: deviceTypeNumber,
type: typeof deviceTypeNumber,
},
ioTDataType: {
originalValue: ioTDataTypeValue,
convertedValue: ioTDataTypeNumber,
type: typeof ioTDataTypeNumber,
},
deviceId: {
originalValue: formValues.DeviceId || DeviceId,
finalValue: finalDeviceId,
isFocusId: deviceTypeNumber === 10 && formValues.DeviceId && getDeviceInfoById(formValues.DeviceId)?.focusId,
},
},
finalParams: {
...formValues,
pageIndex: page.currentPage,
pageSize: page.pageSize,
DeviceType: deviceTypeNumber,
DeviceId: finalDeviceId,
FocusAddress: formValues.FocusAddress || FocusAddress,
SystemName: formValues.SystemName,
IoTDataType: ioTDataTypeNumber,
},
});
try {
const { data } = await postTreeModelDeviceDataInfoPage({
body: {
...formValues,
pageIndex: page.currentPage,
pageSize: page.pageSize,
// 使使
@ -208,8 +210,8 @@ const gridOptions: VxeGridProps<any> = {
DeviceId: finalDeviceId,
FocusAddress: formValues.FocusAddress || FocusAddress,
//
SystemName: formValues.SystemName || SystemName,
IoTDataType: ioTDataTypeValue,
SystemName: formValues.SystemName,
IoTDataType: ioTDataTypeNumber,
},
});
@ -263,19 +265,14 @@ const gridOptions: VxeGridProps<any> = {
items: data.items || [],
totalCount: data.totalCount || 0,
};
console.log('返回给表格的数据:', result);
console.log(
'总数:',
result.totalCount,
'当前页数据量:',
result.items.length,
);
console.log('总数:', result.totalCount, '当前页数据量:', result.items.length);
console.log('分页信息:', {
currentPage: page.currentPage,
pageSize: page.pageSize,
});
return result;
}
@ -314,40 +311,6 @@ watch(
}
},
);
//
watch(
() => [DeviceType, DeviceId, FocusAddress, SystemName],
async (newValues, oldValues) => {
console.log('路由参数变化:', { newValues, oldValues });
//
if (newValues.some(val => val) && gridApi) {
//
await fetchDeviceOptions();
//
setTimeout(() => {
console.log('自动触发查询,路由参数:', { DeviceType, DeviceId, FocusAddress, SystemName });
gridApi.reload();
}, 100);
}
},
{ immediate: true }
);
//
onMounted(async () => {
console.log('页面挂载完成,检查路由参数:', { DeviceType, DeviceId, FocusAddress, SystemName });
//
if (DeviceType || DeviceId || FocusAddress || SystemName) {
//
await fetchDeviceOptions();
//
setTimeout(() => {
console.log('页面初始化时自动触发查询');
gridApi.reload();
}, 200);
}
});
</script>
<template>

View File

@ -50,8 +50,8 @@ export const querySchema = computed(() => [
TypeName: 'MeterTypeEnum',
},
},
labelField: 'value',
valueField: 'key',
labelField: 'secondValue',
valueField: 'value',
optionsPropName: 'options',
immediate: true,
afterFetch: (res: any) => {

View File

@ -123,9 +123,9 @@ async function submit() {
const formValues = await formApi.getValues();
const fetchParams: any = isEdit
? {
id: editRow.value.id,
...formValues,
}
id: editRow.value.id,
...formValues,
}
: formValues;
try {
@ -171,12 +171,11 @@ function onDel(row: any) {
const toStatusData = (row: Record<string, any>) => {
// 使
router.push({
path: '/iotdb/deviceData',
path: '/iotdb/status',
query: {
DeviceType: 10,
DeviceId: row.focusId,
FocusAddress: row.focusAddress,
SystemName: row.businessSystemName,
},
});
};
@ -203,46 +202,59 @@ const openAddModal = async () => {
<Page auto-content-height>
<Grid>
<template #toolbar-actions>
<TableAction :actions="[
{
label: $t('common.add'),
type: 'primary',
icon: 'ant-design:plus-outlined',
onClick: openAddModal.bind(null),
auth: ['AbpIdentity.Users.Create'],
},
]" />
<TableAction
:actions="[
{
label: $t('common.add'),
type: 'primary',
icon: 'ant-design:plus-outlined',
onClick: openAddModal.bind(null),
auth: ['AbpIdentity.Users.Create'],
},
]"
/>
</template>
<template #isSelfDevelop="{ row }">
<component :is="h(Tag, { color: row.selfDevelop ? 'green' : 'red' }, () =>
row.selfDevelop ? $t('common.yes') : $t('common.no'),
)
" />
<component
:is="
h(Tag, { color: row.selfDevelop ? 'green' : 'red' }, () =>
row.selfDevelop ? $t('common.yes') : $t('common.no'),
)
"
/>
</template>
<template #isStatus="{ row }">
<component :is="h(Tag, { color: row.status ? 'green' : 'red' }, () =>
row.status ? $t('common.yes') : $t('common.no'),
)
" />
<component
:is="
h(Tag, { color: row.status ? 'green' : 'red' }, () =>
row.status ? $t('common.yes') : $t('common.no'),
)
"
/>
</template>
<template #isEnable="{ row }">
<component :is="h(Tag, { color: row.enabled ? 'green' : 'red' }, () =>
row.enabled ? $t('common.yes') : $t('common.no'),
)
" />
<component
:is="
h(Tag, { color: row.enabled ? 'green' : 'red' }, () =>
row.enabled ? $t('common.yes') : $t('common.no'),
)
"
/>
</template>
<template #action="{ row }">
<TableAction :actions="[
{
label: $t('common.edit'),
type: 'link',
size: 'small',
auth: ['AbpIdentity.Users.Update'],
onClick: onEdit.bind(null, row),
},
]" :drop-down-actions="[
<TableAction
:actions="[
{
label: $t('common.edit'),
type: 'link',
size: 'small',
auth: ['AbpIdentity.Users.Update'],
onClick: onEdit.bind(null, row),
},
]"
:drop-down-actions="[
{
label: row.enabled ? $t('common.disabled') : $t('common.enabled'),
icon: `ant-design:${row.enabled ? 'close' : 'check'}-outlined`,
@ -268,11 +280,15 @@ const openAddModal = async () => {
auth: ['AbpIdentity.Users.Delete'],
onClick: toStatusData.bind(null, row),
},
]" />
]"
/>
</template>
</Grid>
<UserModal :title="editRow.id ? $t('common.edit') : $t('common.add')" class="w-[800px]">
<UserModal
:title="editRow.id ? $t('common.edit') : $t('common.add')"
class="w-[800px]"
>
<component :is="editRow.id ? EditForm : AddForm" />
</UserModal>
</Page>

View File

@ -127,14 +127,14 @@ async function submit() {
const formValues = await formApi.getValues();
const fetchParams: any = isEdit
? {
id: editRow.value.id,
...formValues,
password: formValues.password || '000000',
}
id: editRow.value.id,
...formValues,
password: formValues.password || '000000',
}
: {
...formValues,
password: formValues.password || '000000',
};
...formValues,
password: formValues.password || '000000',
};
try {
userModalApi.setState({ loading: true, confirmLoading: true });
@ -178,12 +178,11 @@ function onDel(row: any) {
const toStatusData = (row: Record<string, any>) => {
// 使
router.push({
path: '/iotdb/deviceData',
path: '/iotdb/point',
query: {
DeviceType: row.meterType,
DeviceId: row.meterId,
FocusAddress: row.focusAddress,
SystemName: row.businessSystemName,
},
});
};
@ -213,22 +212,24 @@ const openAddModal = async () => {
<Page auto-content-height>
<Grid>
<template #toolbar-actions>
<TableAction :actions="[
{
label: $t('common.add'),
type: 'primary',
icon: 'ant-design:plus-outlined',
onClick: openAddModal.bind(null),
auth: ['AbpIdentity.Users.Create'],
},
]" />
<TableAction
:actions="[
{
label: $t('common.add'),
type: 'primary',
icon: 'ant-design:plus-outlined',
onClick: openAddModal.bind(null),
auth: ['AbpIdentity.Users.Create'],
},
]"
/>
</template>
<template #isMeterType="{ row }">
{{ meterTypeOptions[row.meterType - 1]?.label }}
</template>
<template #isSingleRate="{ row }">
{{rateOptions.find((item) => item.value === row.singleRate)?.label}}
{{ rateOptions.find((item) => item.value === row.singleRate)?.label }}
</template>
<template #isArchiveStatus="{ row }">
{{
@ -239,40 +240,54 @@ const openAddModal = async () => {
{{ row.tripState ? $t('common.SwitchOff') : $t('common.Closing') }}
</template>
<template #isHaveValve="{ row }">
<component :is="h(Tag, { color: row.haveValve ? 'green' : 'red' }, () =>
row.haveValve ? $t('common.yes') : $t('common.no'),
)
" />
<component
:is="
h(Tag, { color: row.haveValve ? 'green' : 'red' }, () =>
row.haveValve ? $t('common.yes') : $t('common.no'),
)
"
/>
</template>
<template #isSelfDevelop="{ row }">
<component :is="h(Tag, { color: row.selfDevelop ? 'green' : 'red' }, () =>
row.selfDevelop ? $t('common.yes') : $t('common.no'),
)
" />
<component
:is="
h(Tag, { color: row.selfDevelop ? 'green' : 'red' }, () =>
row.selfDevelop ? $t('common.yes') : $t('common.no'),
)
"
/>
</template>
<template #isDynamicPassword="{ row }">
<component :is="h(Tag, { color: row.dynamicPassword ? 'green' : 'red' }, () =>
row.dynamicPassword ? $t('common.yes') : $t('common.no'),
)
" />
<component
:is="
h(Tag, { color: row.dynamicPassword ? 'green' : 'red' }, () =>
row.dynamicPassword ? $t('common.yes') : $t('common.no'),
)
"
/>
</template>
<template #isEnable="{ row }">
<component :is="h(Tag, { color: row.enabled ? 'green' : 'red' }, () =>
row.enabled ? $t('common.yes') : $t('common.no'),
)
" />
<component
:is="
h(Tag, { color: row.enabled ? 'green' : 'red' }, () =>
row.enabled ? $t('common.yes') : $t('common.no'),
)
"
/>
</template>
<template #action="{ row }">
<TableAction :actions="[
{
label: $t('common.edit'),
type: 'link',
size: 'small',
auth: ['AbpIdentity.Users.Update'],
onClick: onEdit.bind(null, row),
},
]" :drop-down-actions="[
<TableAction
:actions="[
{
label: $t('common.edit'),
type: 'link',
size: 'small',
auth: ['AbpIdentity.Users.Update'],
onClick: onEdit.bind(null, row),
},
]"
:drop-down-actions="[
{
label: $t('common.delete'),
icon: 'ant-design:delete-outlined',
@ -297,10 +312,14 @@ const openAddModal = async () => {
auth: ['AbpIdentity.Users.Delete'],
onClick: archivesIssued.bind(null, row),
},
]" />
]"
/>
</template>
</Grid>
<UserModal :title="editRow.id ? $t('common.edit') : $t('common.add')" class="w-[800px]">
<UserModal
:title="editRow.id ? $t('common.edit') : $t('common.add')"
class="w-[800px]"
>
<component :is="editRow.id ? EditForm : AddForm" />
</UserModal>
</Page>