Compare commits

..

No commits in common. "b50155261601fcd701bfa2f831a2f862de3b2ce1" and "fa8a4c9cc7338b83401a57904e54e4dcaf16dc55" have entirely different histories.

10 changed files with 93 additions and 281 deletions

View File

@ -97,8 +97,7 @@
"receivedMessageHexString": "Received Message (Hex)", "receivedMessageHexString": "Received Message (Hex)",
"receivedTime": "Received Time", "receivedTime": "Received Time",
"isReceived": "Received Status", "isReceived": "Received Status",
"receivedRemark": "Report Parsing Remarks", "receivedRemark": "Report Parsing Remarks"
"title": "Title"
}, },
"message": { "message": {
"title": "Title", "title": "Title",

View File

@ -97,8 +97,7 @@
"receivedMessageHexString": "消息上报内容", "receivedMessageHexString": "消息上报内容",
"receivedTime": "消息上报时间", "receivedTime": "消息上报时间",
"isReceived": "是否已上报", "isReceived": "是否已上报",
"receivedRemark": "上报报文解析备注", "receivedRemark": "上报报文解析备注"
"title": "日志"
}, },
"message": { "message": {
"title": "标题", "title": "标题",

View File

@ -197,12 +197,12 @@ async function submit() {
const fetchParams: any = isEdit const fetchParams: any = isEdit
? { ? {
id: editRow.value.id, id: editRow.value.id,
...formValues, ...formValues,
} }
: { : {
...formValues, ...formValues,
}; };
try { try {
const resp = await api({ body: fetchParams }); const resp = await api({ body: fetchParams });
@ -311,20 +311,20 @@ async function onStatusChange(record: any) {
<Grid> <Grid>
<template #toolbar-actions> <template #toolbar-actions>
<TableAction :actions="[ <TableAction :actions="[
{ {
label: $t('common.add'), label: $t('common.add'),
type: 'primary', type: 'primary',
icon: 'ant-design:plus-outlined', icon: 'ant-design:plus-outlined',
onClick: openAddModal.bind(null), onClick: openAddModal.bind(null),
auth: ['AbpIdentity.Users.Create'], auth: ['AbpIdentity.Users.Create'],
}, },
]" /> ]" />
</template> </template>
<template #isEnable="{ row }"> <template #isEnable="{ row }">
<component :is="h(Tag, { color: row.isEnabled ? 'green' : 'red' }, () => <component :is="h(Tag, { color: row.isEnabled ? 'green' : 'red' }, () =>
row.isEnabled ? $t('common.yes') : $t('common.no'), row.isEnabled ? $t('common.yes') : $t('common.no'),
) )
" /> " />
</template> </template>
@ -338,13 +338,13 @@ async function onStatusChange(record: any) {
<template #action="{ row }"> <template #action="{ row }">
<TableAction :actions="[ <TableAction :actions="[
{ {
label: $t('common.edit'), label: $t('common.edit'),
type: 'link', type: 'link',
size: 'small', size: 'small',
auth: ['AbpIdentity.Users.Update'], auth: ['AbpIdentity.Users.Update'],
onClick: onEdit.bind(null, row), onClick: onEdit.bind(null, row),
}, },
{ {
label: row.isEnabled ? '禁用' : '启用', label: row.isEnabled ? '禁用' : '启用',
type: 'link', type: 'link',

View File

@ -229,36 +229,18 @@ function onDel(row: any) {
}, },
}); });
} }
const toDeviceInfoData = (row: Record<string, any>) => { const toStatusData = (row: Record<string, any>) => {
// 使 // 使
router.push({ router.push({
path: '/iotdbdatamanagement/deviceData', path: '/iotdb/deviceData',
query: { query: {
DeviceAddress: row.deviceAddress, DeviceType: row.ioTPlatform,
DeviceId: row.deviceAddress,
FocusAddress: row.ioTPlatformDeviceOpenInfo,
DataBaseName: row.deviceName,
}, },
}); });
}; };
const toDeviceLog = (row: Record<string, any>) => {
//
if (row.ioTPlatform === 1 || row.ioTPlatform === '1') {
// CTWing
router.push({
path: '/iotdbdatamanagement/ctwingLog',
query: {
DeviceAddress: row.deviceAddress,
},
});
} else if (row.ioTPlatform === 2 || row.ioTPlatform === '2') {
// OneNET
router.push({
path: '/iotdbdatamanagement/onenetLog',
query: {
DeviceAddress: row.deviceAddress,
},
});
}
};
const openAddModal = async () => { const openAddModal = async () => {
editRow.value = {}; editRow.value = {};
userModalApi.open(); userModalApi.open();
@ -377,14 +359,7 @@ const toolbarActions = computed(() => [
type: 'link', type: 'link',
size: 'small', size: 'small',
auth: ['AbpIdentity.Users.Update'], auth: ['AbpIdentity.Users.Update'],
onClick: toDeviceInfoData.bind(null, row), onClick: toStatusData.bind(null, row),
},
{
label: $t('abp.log.title'),
type: 'link',
size: 'small',
auth: ['AbpIdentity.Users.Update'],
onClick: toDeviceLog.bind(null, row),
}, },
]" :drop-down-actions="[ ]" :drop-down-actions="[
{ {

View File

@ -83,7 +83,7 @@ export const tableSchema: any = computed((): VxeGridProps['columns'] => [
title: $t('common.action'), title: $t('common.action'),
field: 'action', field: 'action',
fixed: 'right', fixed: 'right',
width: '165', width: '150',
slots: { default: 'action' }, slots: { default: 'action' },
}, },
]); ]);
@ -105,8 +105,7 @@ export const addDeviceFormSchema: any = computed(() => [
optionsPropName: 'options', optionsPropName: 'options',
immediate: true, immediate: true,
allowClear: true, allowClear: true,
placeholder: placeholder: $t('common.pleaseSelect') + $t('abp.deviceInfos.ioTPlatform'),
$t('common.pleaseSelect') + $t('abp.deviceInfos.ioTPlatform'),
afterFetch: (res: any) => { afterFetch: (res: any) => {
// 确保返回的是数组格式 // 确保返回的是数组格式
if (Array.isArray(res)) { if (Array.isArray(res)) {

View File

@ -19,10 +19,7 @@ defineOptions({
}); });
const route = useRoute(); const route = useRoute();
const { DeviceAddress } = route.query; const { DeviceType, DeviceId, FocusAddress } = route.query;
//
const isInitializing = ref(false);
// //
const deviceSelectRef = ref(); const deviceSelectRef = ref();
@ -51,13 +48,13 @@ const fetchDeviceOptions = async () => {
} }
}; };
// // ID
const getDeviceInfoByAddress = (deviceAddress: string) => { const getDeviceInfoById = (deviceId: string) => {
if (!deviceAddress || !deviceOptions.value || deviceOptions.value.length === 0) { if (!deviceId || !deviceOptions.value || deviceOptions.value.length === 0) {
return null; return null;
} }
const device = deviceOptions.value.find((device) => device.deviceAddress === deviceAddress); const device = deviceOptions.value.find((device) => device.id === deviceId);
return device; return device;
}; };
@ -83,27 +80,19 @@ const getDeviceInfoFromRef = async () => {
const formOptions: VbenFormProps = { const formOptions: VbenFormProps = {
schema: querySchema.value, schema: querySchema.value,
initialValues: {
DeviceAddress: DeviceAddress as string,
},
// 使 // 使
submitOnChange: false, submitOnChange: false,
// //
handleValuesChange: async (values, changedFields) => { handleValuesChange: async (values, changedFields) => {
// // DeviceId selectedDeviceInfo
if (isInitializing.value) { if (changedFields.includes('DeviceId')) {
return; const deviceId = values.DeviceId;
}
// DeviceAddress selectedDeviceInfo if (deviceId) {
if (changedFields.includes('DeviceAddress')) {
const deviceAddress = values.DeviceAddress;
if (deviceAddress) {
// deviceOptions // deviceOptions
let device = let device =
deviceOptions.value.length > 0 deviceOptions.value.length > 0
? deviceOptions.value.find((d) => d.deviceAddress === deviceAddress) ? deviceOptions.value.find((d) => d.id === deviceId)
: null; : null;
// DeviceSelect // DeviceSelect
@ -111,7 +100,7 @@ const formOptions: VbenFormProps = {
try { try {
// DeviceSelect // DeviceSelect
const deviceSelectRef = const deviceSelectRef =
gridApi.formApi.getFieldComponentRef('DeviceAddress'); gridApi.formApi.getFieldComponentRef('DeviceId');
if (deviceSelectRef && deviceSelectRef.getSelectedDevice) { if (deviceSelectRef && deviceSelectRef.getSelectedDevice) {
device = deviceSelectRef.getSelectedDevice(); device = deviceSelectRef.getSelectedDevice();
} }
@ -127,7 +116,7 @@ const formOptions: VbenFormProps = {
setTimeout(() => { setTimeout(() => {
try { try {
const deviceSelectRef = const deviceSelectRef =
gridApi.formApi.getFieldComponentRef('DeviceAddress'); gridApi.formApi.getFieldComponentRef('DeviceId');
if (deviceSelectRef && deviceSelectRef.getSelectedDevice) { if (deviceSelectRef && deviceSelectRef.getSelectedDevice) {
const delayedDevice = deviceSelectRef.getSelectedDevice(); const delayedDevice = deviceSelectRef.getSelectedDevice();
if (delayedDevice) { if (delayedDevice) {
@ -146,7 +135,7 @@ const formOptions: VbenFormProps = {
// //
const relevantFields = new Set([ const relevantFields = new Set([
'DeviceAddress', 'DeviceId',
'EndCreationTime', 'EndCreationTime',
'IoTDataType', 'IoTDataType',
'StartCreationTime', 'StartCreationTime',
@ -191,19 +180,14 @@ const gridOptions: VxeGridProps<any> = {
// API // API
const currentFormValues = gridApi?.formApi ? await gridApi.formApi.getValues() : {}; const currentFormValues = gridApi?.formApi ? await gridApi.formApi.getValues() : {};
// DeviceAddress使
if (!currentFormValues.DeviceAddress && DeviceAddress) {
currentFormValues.DeviceAddress = DeviceAddress as string;
}
// //
let deviceAddress = currentFormValues.DeviceAddress || ''; let deviceAddress = currentFormValues.DeviceId || '';
// 使 // 使
const deviceInfo = const deviceInfo =
selectedDeviceInfo.value || selectedDeviceInfo.value ||
(deviceAddress && deviceOptions.value.length > 0 (currentFormValues.DeviceId && deviceOptions.value.length > 0
? getDeviceInfoByAddress(deviceAddress) ? getDeviceInfoById(currentFormValues.DeviceId)
: null); : null);
if (deviceInfo) { if (deviceInfo) {
@ -215,11 +199,13 @@ const gridOptions: VxeGridProps<any> = {
pageSize: page.pageSize, pageSize: page.pageSize,
SearchKeyword: currentFormValues.SearchKeyword || '', SearchKeyword: currentFormValues.SearchKeyword || '',
IoTDataType: currentFormValues.IoTDataType || '', IoTDataType: currentFormValues.IoTDataType || '',
DeviceAddress: deviceAddress, // 使 DeviceId: deviceAddress, // 使
StartCreationTime: formatDate(currentFormValues.StartCreationTime), StartCreationTime: formatDate(currentFormValues.StartCreationTime),
EndCreationTime: formatDate(currentFormValues.EndCreationTime), EndCreationTime: formatDate(currentFormValues.EndCreationTime),
}; };
if (DeviceType) queryParams.DeviceType = DeviceType;
if (DeviceId) queryParams.DeviceId = DeviceId;
const { data } = await postTableModelCtWingLogInfo({ const { data } = await postTableModelCtWingLogInfo({
body: queryParams, body: queryParams,
}); });
@ -235,52 +221,11 @@ const gridOptions: VxeGridProps<any> = {
const [Grid, gridApi] = useVbenVxeGrid({ formOptions, gridOptions }); const [Grid, gridApi] = useVbenVxeGrid({ formOptions, gridOptions });
//
const initializeGrid = async () => {
try {
//
isInitializing.value = true;
//
await fetchDeviceOptions();
//
if (DeviceAddress) {
//
setTimeout(async () => {
if (gridApi && gridApi.formApi) {
//
const currentValues = await gridApi.formApi.getValues();
if (!currentValues.DeviceAddress && DeviceAddress) {
await gridApi.formApi.setValues({
...currentValues,
DeviceAddress: DeviceAddress as string,
});
}
//
setTimeout(() => {
isInitializing.value = false;
gridApi.reload();
}, 200);
} else {
isInitializing.value = false;
}
}, 300);
} else {
//
isInitializing.value = false;
}
} catch (error) {
console.error('初始化表格失败:', error);
isInitializing.value = false;
}
};
// //
watch( watch(
() => gridApi?.pagerApi?.pageSize, () => gridApi?.pagerApi?.pageSize,
async (newSize, oldSize) => { async (newSize, oldSize) => {
if (newSize !== oldSize && oldSize && !isInitializing.value) { if (newSize !== oldSize && oldSize) {
// //
gridApi.pagerApi.currentPage = 1; gridApi.pagerApi.currentPage = 1;
// //
@ -294,7 +239,7 @@ watch(
watch( watch(
() => gridApi?.pagerApi?.currentPage, () => gridApi?.pagerApi?.currentPage,
async (newPage, oldPage) => { async (newPage, oldPage) => {
if (newPage !== oldPage && oldPage && !isInitializing.value) { if (newPage !== oldPage && oldPage) {
// //
const latestValues = await gridApi.formApi.getValues(); const latestValues = await gridApi.formApi.getValues();
gridApi.reload(latestValues); gridApi.reload(latestValues);
@ -302,19 +247,16 @@ watch(
}, },
); );
// //
onMounted(async () => { onMounted(async () => {
// VXE await fetchDeviceOptions();
setTimeout(async () => {
await initializeGrid();
}, 100);
}); });
</script> </script>
<template> <template>
<Page auto-content-height> <Page auto-content-height>
<Grid> <Grid>
<template #DeviceAddress="{ model, field }"> <template #DeviceId="{ model, field }">
<DeviceSelect ref="deviceSelectRef" v-model:value="model[field]" <DeviceSelect ref="deviceSelectRef" v-model:value="model[field]"
:placeholder="$t('common.pleaseSelect') + $t('abp.log.deviceInfo')" allow-clear /> :placeholder="$t('common.pleaseSelect') + $t('abp.log.deviceInfo')" allow-clear />
</template> </template>

View File

@ -16,7 +16,7 @@ export const querySchema = computed(() => [
api: getCommonGetSelectList, api: getCommonGetSelectList,
params: { params: {
query: { query: {
typeName: 'IoTDBDataTypeConst', typeName: 'IoTDBDataTypeConst',
}, },
}, },
labelField: 'value', labelField: 'value',
@ -45,7 +45,7 @@ export const querySchema = computed(() => [
}, },
{ {
component: 'DeviceSelect', component: 'DeviceSelect',
fieldName: 'DeviceAddress', fieldName: 'DeviceId',
label: $t('abp.log.deviceInfo'), label: $t('abp.log.deviceInfo'),
componentProps: { componentProps: {
placeholder: $t('common.pleaseSelect') + $t('abp.log.deviceInfo'), placeholder: $t('common.pleaseSelect') + $t('abp.log.deviceInfo'),

View File

@ -68,7 +68,7 @@ const formatDate = (date: Date | string) => {
}; };
const route = useRoute(); const route = useRoute();
const { DeviceType, DeviceAddress } = route.query; const { DeviceType, DeviceId } = route.query;
// //
const dynamicColumns = ref<any[]>([]); const dynamicColumns = ref<any[]>([]);
@ -146,8 +146,6 @@ const initDefaultColumns = () => {
// //
const isGridInitialized = ref(false); const isGridInitialized = ref(false);
//
const isInitializing = ref(false);
// //
initDefaultColumns(); initDefaultColumns();
@ -156,17 +154,12 @@ const formOptions: VbenFormProps = {
schema: querySchema.value, schema: querySchema.value,
initialValues: { initialValues: {
DeviceType: DeviceType ? Number(DeviceType) : undefined, DeviceType: DeviceType ? Number(DeviceType) : undefined,
DeviceAddress: DeviceAddress as string, // 使DeviceAddress DeviceAddress: DeviceId as string, // 使DeviceIdDeviceAddress
}, },
// 使 // 使
submitOnChange: false, submitOnChange: false,
// //
handleValuesChange: async (values, changedFields) => { handleValuesChange: async (values, changedFields) => {
//
if (isInitializing.value) {
return;
}
// //
const relevantFields = new Set([ const relevantFields = new Set([
'DeviceAddress', 'DeviceAddress',
@ -273,11 +266,6 @@ const gridOptions: VxeGridProps<any> = {
formValues || formValues ||
(gridApi?.formApi ? await gridApi.formApi.getValues() : {}) || (gridApi?.formApi ? await gridApi.formApi.getValues() : {}) ||
{}; {};
// DeviceAddress使
if (!currentFormValues.DeviceAddress && DeviceAddress) {
currentFormValues.DeviceAddress = DeviceAddress as string;
}
// DeviceTypeIoTDataType // DeviceTypeIoTDataType
const deviceTypeValue = currentFormValues.DeviceType; const deviceTypeValue = currentFormValues.DeviceType;
const deviceTypeNumber = deviceTypeValue const deviceTypeNumber = deviceTypeValue
@ -297,16 +285,11 @@ const gridOptions: VxeGridProps<any> = {
// //
let deviceAddress = currentFormValues.DeviceAddress || ''; let deviceAddress = currentFormValues.DeviceAddress || '';
// DeviceAddress使
if (!deviceAddress && DeviceAddress) {
deviceAddress = DeviceAddress as string;
}
// 使 // 使
const deviceInfo = const deviceInfo =
selectedDeviceInfo.value || selectedDeviceInfo.value ||
(deviceAddress && deviceOptions.value.length > 0 (currentFormValues.DeviceAddress && deviceOptions.value.length > 0
? getDeviceInfoByAddress(deviceAddress) ? getDeviceInfoByAddress(currentFormValues.DeviceAddress)
: null); : null);
if (deviceInfo) { if (deviceInfo) {
@ -382,7 +365,7 @@ const [Grid, gridApi] = useVbenVxeGrid({ formOptions, gridOptions });
watch( watch(
() => gridApi?.pagerApi?.pageSize, () => gridApi?.pagerApi?.pageSize,
(newSize, oldSize) => { (newSize, oldSize) => {
if (newSize !== oldSize && oldSize && !isInitializing.value) { if (newSize !== oldSize && oldSize) {
// //
gridApi.pagerApi.currentPage = 1; gridApi.pagerApi.currentPage = 1;
// //
@ -395,7 +378,7 @@ watch(
watch( watch(
() => gridApi?.pagerApi?.currentPage, () => gridApi?.pagerApi?.currentPage,
(newPage, oldPage) => { (newPage, oldPage) => {
if (newPage !== oldPage && oldPage && !isInitializing.value) { if (newPage !== oldPage && oldPage) {
// //
gridApi.reload(); gridApi.reload();
} }
@ -405,9 +388,6 @@ watch(
// //
const initializeGrid = async () => { const initializeGrid = async () => {
try { try {
//
isInitializing.value = true;
// //
await fetchDeviceOptions(); await fetchDeviceOptions();
@ -429,47 +409,23 @@ const initializeGrid = async () => {
} }
// //
if (DeviceType || DeviceAddress) { if (DeviceType || DeviceId) {
// //
setTimeout(async () => { setTimeout(() => {
if (gridApi && gridApi.formApi) { if (gridApi) {
// gridApi.reload();
const currentValues = await gridApi.formApi.getValues();
if (!currentValues.DeviceAddress && DeviceAddress) {
await gridApi.formApi.setValues({
...currentValues,
DeviceAddress: DeviceAddress as string,
});
}
//
setTimeout(() => {
isInitializing.value = false;
//
gridApi.reload();
}, 200);
} else {
isInitializing.value = false;
} }
}, 300); }, 300);
} else {
//
isInitializing.value = false;
} }
} catch (error) { } catch (error) {
console.error('初始化表格失败:', error); console.error('初始化表格失败:', error);
isInitializing.value = false;
} }
}; };
// //
watch( watch(
() => [DeviceType, DeviceAddress], () => [DeviceType, DeviceId],
async (newValues, oldValues) => { async (newValues, oldValues) => {
//
if (isInitializing.value) {
return;
}
// //
if (newValues.some(Boolean) && gridApi && isGridInitialized.value) { if (newValues.some(Boolean) && gridApi && isGridInitialized.value) {
// //

View File

@ -19,10 +19,7 @@ defineOptions({
}); });
const route = useRoute(); const route = useRoute();
const { DeviceAddress } = route.query; const { DeviceType, DeviceId, FocusAddress } = route.query;
//
const isInitializing = ref(false);
// //
const deviceSelectRef = ref(); const deviceSelectRef = ref();
@ -51,13 +48,13 @@ const fetchDeviceOptions = async () => {
} }
}; };
// // ID
const getDeviceInfoByAddress = (deviceAddress: string) => { const getDeviceInfoById = (deviceId: string) => {
if (!deviceAddress || !deviceOptions.value || deviceOptions.value.length === 0) { if (!deviceId || !deviceOptions.value || deviceOptions.value.length === 0) {
return null; return null;
} }
const device = deviceOptions.value.find((device) => device.deviceAddress === deviceAddress); const device = deviceOptions.value.find((device) => device.id === deviceId);
return device; return device;
}; };
@ -82,27 +79,19 @@ const getDeviceInfoFromRef = async () => {
const formOptions: VbenFormProps = { const formOptions: VbenFormProps = {
schema: querySchema.value, schema: querySchema.value,
initialValues: {
DeviceAddress: DeviceAddress as string,
},
// 使 // 使
submitOnChange: false, submitOnChange: false,
// //
handleValuesChange: async (values, changedFields) => { handleValuesChange: async (values, changedFields) => {
// // DeviceId selectedDeviceInfo
if (isInitializing.value) { if (changedFields.includes('DeviceId')) {
return; const deviceId = values.DeviceId;
}
// DeviceAddress selectedDeviceInfo if (deviceId) {
if (changedFields.includes('DeviceAddress')) {
const deviceAddress = values.DeviceAddress;
if (deviceAddress) {
// deviceOptions // deviceOptions
let device = let device =
deviceOptions.value.length > 0 deviceOptions.value.length > 0
? deviceOptions.value.find((d) => d.deviceAddress === deviceAddress) ? deviceOptions.value.find((d) => d.id === deviceId)
: null; : null;
// DeviceSelect // DeviceSelect
@ -110,7 +99,7 @@ const formOptions: VbenFormProps = {
try { try {
// DeviceSelect // DeviceSelect
const deviceSelectRef = const deviceSelectRef =
gridApi.formApi.getFieldComponentRef('DeviceAddress'); gridApi.formApi.getFieldComponentRef('DeviceId');
if (deviceSelectRef && deviceSelectRef.getSelectedDevice) { if (deviceSelectRef && deviceSelectRef.getSelectedDevice) {
device = deviceSelectRef.getSelectedDevice(); device = deviceSelectRef.getSelectedDevice();
} }
@ -126,7 +115,7 @@ const formOptions: VbenFormProps = {
setTimeout(() => { setTimeout(() => {
try { try {
const deviceSelectRef = const deviceSelectRef =
gridApi.formApi.getFieldComponentRef('DeviceAddress'); gridApi.formApi.getFieldComponentRef('DeviceId');
if (deviceSelectRef && deviceSelectRef.getSelectedDevice) { if (deviceSelectRef && deviceSelectRef.getSelectedDevice) {
const delayedDevice = deviceSelectRef.getSelectedDevice(); const delayedDevice = deviceSelectRef.getSelectedDevice();
if (delayedDevice) { if (delayedDevice) {
@ -145,7 +134,7 @@ const formOptions: VbenFormProps = {
// //
const relevantFields = new Set([ const relevantFields = new Set([
'DeviceAddress', 'DeviceId',
'EndCreationTime', 'EndCreationTime',
'IoTDataType', 'IoTDataType',
'StartCreationTime', 'StartCreationTime',
@ -189,19 +178,14 @@ const gridOptions: VxeGridProps<any> = {
// API // API
const currentFormValues = gridApi?.formApi ? await gridApi.formApi.getValues() : {}; const currentFormValues = gridApi?.formApi ? await gridApi.formApi.getValues() : {};
// DeviceAddress使
if (!currentFormValues.DeviceAddress && DeviceAddress) {
currentFormValues.DeviceAddress = DeviceAddress as string;
}
// //
let deviceAddress = currentFormValues.DeviceAddress || ''; let deviceAddress = currentFormValues.DeviceId || '';
// 使 // 使
const deviceInfo = const deviceInfo =
selectedDeviceInfo.value || selectedDeviceInfo.value ||
(deviceAddress && deviceOptions.value.length > 0 (currentFormValues.DeviceId && deviceOptions.value.length > 0
? getDeviceInfoByAddress(deviceAddress) ? getDeviceInfoById(currentFormValues.DeviceId)
: null); : null);
if (deviceInfo) { if (deviceInfo) {
@ -214,11 +198,13 @@ const gridOptions: VxeGridProps<any> = {
pageSize: page.pageSize, pageSize: page.pageSize,
SearchKeyword: currentFormValues.SearchKeyword || '', SearchKeyword: currentFormValues.SearchKeyword || '',
IoTDataType: currentFormValues.IoTDataType || '', IoTDataType: currentFormValues.IoTDataType || '',
DeviceAddress: deviceAddress, // 使 DeviceId: deviceAddress, // 使
StartCreationTime: formatDate(currentFormValues.StartCreationTime), StartCreationTime: formatDate(currentFormValues.StartCreationTime),
EndCreationTime: formatDate(currentFormValues.EndCreationTime), EndCreationTime: formatDate(currentFormValues.EndCreationTime),
}; };
if (DeviceType) queryParams.DeviceType = DeviceType;
if (DeviceId) queryParams.DeviceId = DeviceId;
const { data } = await postTableModelOneNetLogInfo({ const { data } = await postTableModelOneNetLogInfo({
body: queryParams, body: queryParams,
}); });
@ -234,52 +220,11 @@ const gridOptions: VxeGridProps<any> = {
const [Grid, gridApi] = useVbenVxeGrid({ formOptions, gridOptions }); const [Grid, gridApi] = useVbenVxeGrid({ formOptions, gridOptions });
//
const initializeGrid = async () => {
try {
//
isInitializing.value = true;
//
await fetchDeviceOptions();
//
if (DeviceAddress) {
//
setTimeout(async () => {
if (gridApi && gridApi.formApi) {
//
const currentValues = await gridApi.formApi.getValues();
if (!currentValues.DeviceAddress && DeviceAddress) {
await gridApi.formApi.setValues({
...currentValues,
DeviceAddress: DeviceAddress as string,
});
}
//
setTimeout(() => {
isInitializing.value = false;
gridApi.reload();
}, 200);
} else {
isInitializing.value = false;
}
}, 300);
} else {
//
isInitializing.value = false;
}
} catch (error) {
console.error('初始化表格失败:', error);
isInitializing.value = false;
}
};
// //
watch( watch(
() => gridApi?.pagerApi?.pageSize, () => gridApi?.pagerApi?.pageSize,
async (newSize, oldSize) => { async (newSize, oldSize) => {
if (newSize !== oldSize && oldSize && !isInitializing.value) { if (newSize !== oldSize && oldSize) {
// //
gridApi.pagerApi.currentPage = 1; gridApi.pagerApi.currentPage = 1;
// //
@ -293,7 +238,7 @@ watch(
watch( watch(
() => gridApi?.pagerApi?.currentPage, () => gridApi?.pagerApi?.currentPage,
async (newPage, oldPage) => { async (newPage, oldPage) => {
if (newPage !== oldPage && oldPage && !isInitializing.value) { if (newPage !== oldPage && oldPage) {
// //
const latestValues = await gridApi.formApi.getValues(); const latestValues = await gridApi.formApi.getValues();
gridApi.reload(latestValues); gridApi.reload(latestValues);
@ -301,19 +246,16 @@ watch(
}, },
); );
// //
onMounted(async () => { onMounted(async () => {
// VXE await fetchDeviceOptions();
setTimeout(async () => {
await initializeGrid();
}, 100);
}); });
</script> </script>
<template> <template>
<Page auto-content-height> <Page auto-content-height>
<Grid> <Grid>
<template #DeviceAddress="{ model, field }"> <template #DeviceId="{ model, field }">
<DeviceSelect ref="deviceSelectRef" v-model:value="model[field]" <DeviceSelect ref="deviceSelectRef" v-model:value="model[field]"
:placeholder="$t('common.pleaseSelect') + $t('abp.log.deviceInfo')" allow-clear /> :placeholder="$t('common.pleaseSelect') + $t('abp.log.deviceInfo')" allow-clear />
</template> </template>

View File

@ -45,7 +45,7 @@ export const querySchema = computed(() => [
}, },
{ {
component: 'DeviceSelect', component: 'DeviceSelect',
fieldName: 'DeviceAddress', fieldName: 'DeviceId',
label: $t('abp.log.deviceInfo'), label: $t('abp.log.deviceInfo'),
componentProps: { componentProps: {
placeholder: $t('common.pleaseSelect') + $t('abp.log.deviceInfo'), placeholder: $t('common.pleaseSelect') + $t('abp.log.deviceInfo'),