修复日期格式异常的问题
This commit is contained in:
parent
dafeaf3075
commit
27a71e1d5f
@ -49,6 +49,22 @@ const getDeviceInfoById = (deviceId: string) => {
|
|||||||
return deviceOptions.value.find((device) => device.id === deviceId);
|
return deviceOptions.value.find((device) => device.id === deviceId);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// 格式化日期为 yyyy-MM-dd HH:mm:ss 格式
|
||||||
|
const formatDate = (date: Date | string) => {
|
||||||
|
if (!date) return undefined;
|
||||||
|
|
||||||
|
const d = new Date(date);
|
||||||
|
if (isNaN(d.getTime())) return undefined;
|
||||||
|
|
||||||
|
const year = d.getFullYear();
|
||||||
|
const month = String(d.getMonth() +1).padStart(2, '0');
|
||||||
|
const day = String(d.getDate()).padStart(2, '0');
|
||||||
|
const hours = String(d.getHours()).padStart(2, '0');
|
||||||
|
const minutes = String(d.getMinutes()).padStart(2, '0');
|
||||||
|
const seconds = String(d.getSeconds()).padStart(2, '0');
|
||||||
|
|
||||||
|
return `${year}-${month}-${day} ${hours}:${minutes}:${seconds}`;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
const route = useRoute();
|
const route = useRoute();
|
||||||
@ -232,8 +248,8 @@ const gridOptions: VxeGridProps<any> = {
|
|||||||
const ioTDataTypeValue = currentFormValues.IoTDataType;
|
const ioTDataTypeValue = currentFormValues.IoTDataType;
|
||||||
|
|
||||||
// 处理日期范围参数
|
// 处理日期范围参数
|
||||||
const startCreationTime = currentFormValues.StartCreationTime;
|
const startCreationTime = currentFormValues.StartCreationTime ? formatDate(currentFormValues.StartCreationTime) : undefined;
|
||||||
const endCreationTime = currentFormValues.EndCreationTime;
|
const endCreationTime = currentFormValues.EndCreationTime ? formatDate(currentFormValues.EndCreationTime) : undefined;
|
||||||
|
|
||||||
// 处理DeviceId,当设备类型为集中器(10)时,使用focusId
|
// 处理DeviceId,当设备类型为集中器(10)时,使用focusId
|
||||||
let finalDeviceId = currentFormValues.DeviceId || DeviceId || '';
|
let finalDeviceId = currentFormValues.DeviceId || DeviceId || '';
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user