| | |
| | | <div style="height: 600px;"> |
| | | <div style="display: flex; flex-direction: row; align-items: center; margin-top: 20px;"> |
| | | <span style="margin-left: 10px;" class="demonstration">{{ $t('reportmanage.productiontime') }}</span> |
| | | <el-date-picker style="margin-left: 10px;" v-model="timeRange" type="daterange" format="YYYY/MM/DD" |
| | | <!-- <el-date-picker style="margin-left: 10px;" v-model="timeRange" type="daterange" format="YYYY/MM/DD" |
| | | value-format="YYYY-MM-DD" :start-placeholder="$t('reportmanage.starttime')" |
| | | :end-placeholder="$t('reportmanage.endtime')" :default-time="defaultTime" /> |
| | | :end-placeholder="$t('reportmanage.endtime')" :default-time="defaultTime" /> --> |
| | | <el-date-picker v-model="timeRange" type="datetimerange" range-separator="至" :start-placeholder="$t('reportmanage.starttime')" |
| | | style="margin-left: 15px;" value-format = "YYYY-MM-DD hh:mm:ss" |
| | | :end-placeholder="$t('reportmanage.endtime')"> |
| | | </el-date-picker> |
| | | <el-select v-model="report.type" :placeholder="$t('reportmanage.ctype')" style="margin-left: 10px;"> |
| | | <!-- <el-option :label="$t('reportmanage.all')" value="0"></el-option> --> |
| | | <!-- <el-option :label="$t('reportmanage.completed')" value="1"></el-option> --> |
| | |
| | | import { WebSocketHost, host } from '@/utils/constants' |
| | | import { initializeWebSocket, closeWebSocket } from '@/utils/WebSocketService'; |
| | | import { useI18n } from 'vue-i18n' |
| | | import { inject } from 'vue'; |
| | | const globalDate = inject('globalDate'); |
| | | const timeRange = ref([]) |
| | | const { t } = useI18n() |
| | | const report = ref({ |
| | | type: '8', |
| | |
| | | workingProcedure: '0', |
| | | }); |
| | | const reportData = ref([]) |
| | | const endDate = new Date(); |
| | | const startDate = new Date(); |
| | | startDate.setDate(endDate.getDate() - 7); // 获取一个星期前的时间 |
| | | // 格式化为 "YYYY-MM-DD" 格式 |
| | | const formatDate = (date) => { |
| | | function formatTimestamp(timestamp) { |
| | | const date = new Date(timestamp); |
| | | const year = date.getFullYear(); |
| | | const month = String(date.getMonth() + 1).padStart(2, '0'); |
| | | const day = String(date.getDate()).padStart(2, '0'); |
| | | return `${year}-${month}-${day}`; |
| | | }; |
| | | |
| | | const timeRange = ref([formatDate(startDate), formatDate(endDate)]); |
| | | 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'); // 补零(如果需要显示时间) |
| | | return `${year}-${month}-${day} ${hours}:${minutes}:${seconds}`; |
| | | } |
| | | // 格式化后端时间并计算一周前的时间 |
| | | 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)) |
| | | } |
| | | // const timeRange = ref([formatTimestamp(startDate), formatTimestamp(globalDate)]); |
| | | const selectOptionsa = ref([]); |
| | | const selectOptionsb = ref([]); |
| | | const selectOptionsc = ref([]); |
| | |
| | | // 查询数据 |
| | | const selectReportData = async () => { |
| | | const response = await request.post("/cacheVerticalGlass/damage/selectDamage", { |
| | | startTime: timeRange.value[0], |
| | | endTime: timeRange.value[1]+" 23:59:59", |
| | | startTime: (timeRange.value && timeRange.value[0]) || '', |
| | | endTime: (timeRange.value && timeRange.value[1]) || '', |
| | | type: report.value.type, |
| | | status: report.value.status, |
| | | workingProcedure: report.value.workingProcedure |
| | |
| | | // })); |
| | | // }; |
| | | // let socket; |
| | | onMounted(() => { |
| | | // socket = new WebSocket(socketUrl); |
| | | // socket.onmessage = (event) => { |
| | | // const data = JSON.parse(event.data); |
| | | |
| | | // // updateCharts(); |
| | | // }; |
| | | // }; |
| | | }); |
| | | onUnmounted(() => { |
| | | socket.close(); |
| | | }); |
| | | onMounted(() => { |
| | | fetchTableData(); |
| | | parseAndSetTime(); |
| | | // socket = initializeWebSocket(socketUrl, handleMessage); |
| | | }); |
| | | onUnmounted(() => { |