| | |
| | | import dayjs from 'dayjs'; |
| | | import request from "@/utils/request" |
| | | import {closeWebSocket, initializeWebSocket} from '@/utils/WebSocketService'; |
| | | import { inject } from 'vue'; |
| | | const router = useRouter() |
| | | const tableDataa = ref([]) |
| | | const tableDatab = ref([]) |
| | |
| | | const leftingStation = ref(''); |
| | | const loadingline = ref(''); |
| | | let webSocket: WebSocket | null = null; |
| | | const globalDate = inject('globalDate'); |
| | | const value = ref('') |
| | | const options = [ |
| | | { |
| | |
| | | taskState: '', |
| | | }); |
| | | let startTime = window.localStorage.getItem('startTime') |
| | | let endTime = window.localStorage.getItem('endTime') |
| | | request.post("/glassStorage/rawGlassStorageTask/setRawGlassTaskRequest",{ |
| | | beginDate: startTime, |
| | | endDate: endTime, |
| | | endDate: globalDate, |
| | | }).then((response) => { |
| | | if (response.code == 200) { |
| | | tableDataa.value = response.data |
| | | console.log(tableDataa.value); |
| | | } else { |
| | | ElMessage.warning(response.msg) |
| | | |
| | | } |
| | | }); |
| | | // 格式化后端时间并计算一周前的时间 |
| | | const defaultTime = ref<[Date, Date]>([new Date(), new Date()]); |
| | | function parseAndSetTime() { |
| | | const backendTime = new Date(globalDate); |
| | | const oneWeekAgo = new Date(backendTime.getTime() - 7 * 24 * 60 * 60 * 1000); // 减去7天 |
| | | console.log(formatTimestamp(oneWeekAgo)); |
| | | console.log(oneWeekAgo); |
| | | timeRange.value = [formatTimestamp(oneWeekAgo), formatTimestamp(backendTime)]; |
| | | window.localStorage.setItem('startTime', formatTimestamp(oneWeekAgo)) |
| | | } |
| | | onMounted(() => { |
| | | socket = initializeWebSocket(socketUrl, handleMessage); |
| | | const endTime = dayjs().startOf('minute'); // 当前时间,精确到分钟 |
| | | const startTime = endTime.subtract(7, 'day').startOf('minute'); // 当前时间的前一天,精确到分钟 |
| | | // 设置时间范围为 [开始时间, 结束时间] |
| | | timeRange.value = [startTime.format('YYYY-MM-DD HH:mm:ss'), endTime.format('YYYY-MM-DD HH:mm:ss')]; |
| | | window.localStorage.setItem('startTime', startTime.format('YYYY-MM-DD HH:mm:ss')) |
| | | window.localStorage.setItem('endTime', endTime.format('YYYY-MM-DD HH:mm:ss')) |
| | | parseAndSetTime(); |
| | | }); |
| | | let socket = null; |
| | | const socketUrl = `ws://${WebSocketHost}:${host}/api/glassStorage/api/talk/rawGlass`; |
| | |
| | | } |
| | | }; |
| | | // 格式化时间戳为年月日时间字符串的函数 |
| | | function formatTimestamp(timestamp) { |
| | | function formatTimestamp(timestamp: number | Date): string { |
| | | const date = new Date(timestamp); |
| | | const year = date.getFullYear(); |
| | | const month = String(date.getMonth() + 1).padStart(2, '0'); // 月份从0开始,需要加1,并补零 |
| | | const day = String(date.getDate()).padStart(2, '0'); // 补零 |
| | | const hours = String(date.getHours()).padStart(2, '0'); // 补零(如果需要显示时间) |
| | | const minutes = String(date.getMinutes()).padStart(2, '0'); // 补零(如果需要显示时间) |
| | | const seconds = String(date.getSeconds()).padStart(2, '0'); // 补零(如果需要显示时间) |
| | | const month = String(date.getMonth() + 1).padStart(2, '0'); |
| | | const day = String(date.getDate()).padStart(2, '0'); |
| | | const hours = String(date.getHours()).padStart(2, '0'); |
| | | const minutes = String(date.getMinutes()).padStart(2, '0'); |
| | | const seconds = String(date.getSeconds()).padStart(2, '0'); |
| | | return `${year}-${month}-${day} ${hours}:${minutes}:${seconds}`; |
| | | } |
| | | function getStatusType1(taskType) { |