New file |
| | |
| | | <template> |
| | | <div> |
| | | <div style="display: flex;width: 2000px;"> |
| | | <el-date-picker v-model="timeRange" type="daterange" range-separator="至" |
| | | :start-placeholder="$t('reportmanage.starttime')" :end-placeholder="$t('reportmanage.endtime')" |
| | | value-format="YYYY-MM-DD" style="margin-left: 15px;"> |
| | | </el-date-picker> |
| | | <el-button type="primary" style="margin-left: 10px;margin-bottom: 10px;" @click="sethistorical()">{{ |
| | | $t('reportmanage.inquire') }}</el-button> |
| | | <el-button type="primary" @click="exportToExcel">{{ $t('large.ExporttoExcel') }}</el-button> |
| | | </div> |
| | | <el-table ref="table" style="margin-top: 20px;height: 580px;width: 2000px;" :data="tableDatax" |
| | | :header-cell-style="{ background: '#F2F3F5 ', color: '#1D2129' }"> |
| | | <el-table-column prop="productDate" align="center" :label="$t('large.date')" min-width="70" /> |
| | | <el-table-column prop="edgBeginTime" align="center" :label="$t('large.loadstart')" min-width="120" /> |
| | | <el-table-column prop="edgEndTime" align="center" :label="$t('large.loadend')" min-width="120" /> |
| | | <el-table-column prop="edgTimeTotal" align="center" :label="$t('large.loadtotal')" min-width="50" /> |
| | | <el-table-column prop="edgTimeFree" align="center" :label="$t('large.loadfree')" min-width="50" /> |
| | | <el-table-column prop="edgTimeDiff" align="center" :label="$t('large.loaddiff')" min-width="50" /> |
| | | <el-table-column prop="countOut" align="center" :label="$t('large.loadnumber')" min-width="50" /> |
| | | <el-table-column prop="totalAreaOut" align="center" :label="$t('large.loadarea')" min-width="50" /> |
| | | <el-table-column prop="bigBeginTime" align="center" :label="$t('large.tempstart')" min-width="120" /> |
| | | <el-table-column prop="bigEndTime" align="center" :label="$t('large.tempend')" min-width="120" /> |
| | | <el-table-column prop="bigTimeTotal" align="center" :label="$t('large.temptotal')" |
| | | min-width="40" /> |
| | | <el-table-column prop="bigTimeFree" align="center" :label="$t('large.tempfree')" min-width="50" /> |
| | | <el-table-column prop="bigTimeDiff" align="center" :label="$t('large.tempdiff')" |
| | | min-width="40" /> |
| | | |
| | | <el-table-column prop="temperingLayoutCount" align="center" :label="$t('large.tempstove')" min-width="50" /> |
| | | <el-table-column prop="temperingGlassCount" align="center" :label="$t('large.tempnumber')" min-width="50" /> |
| | | <el-table-column prop="temperingArea" align="center" :label="$t('large.temparea')" min-width="50" /> |
| | | <el-table-column prop="hollowBeginTime" align="center" :label="$t('large.hollowstart')" min-width="120" /> |
| | | <el-table-column prop="hollowEndTime" align="center" :label="$t('large.hollowend')" min-width="120" /> |
| | | <el-table-column prop="hollowTimeTotal" align="center" :label="$t('large.hollowtotal')" min-width="50" /> |
| | | <el-table-column prop="hollowTimeFree" align="center" :label="$t('large.hollowfree')" min-width="50" /> |
| | | <el-table-column prop="hollowTimeDiff" align="center" :label="$t('large.hollowdiff')" min-width="50" /> |
| | | |
| | | <el-table-column prop="hollowGlassCount" align="center" :label="$t('large.hollownumber')" min-width="50" /> |
| | | <el-table-column prop="hollowArea" align="center" :label="$t('large.hollowarea')" min-width="50" /> |
| | | <!-- <el-table-column prop="engineerId" align="center" :label="$t('large.engineerId')" min-width="40" /> |
| | | <el-table-column prop="glassTotal" align="center" :label="$t('large.totalnumber')" min-width="40" /> |
| | | <el-table-column prop="glassTotalArea" align="center" :label="$t('large.tatalarea')" min-width="40" /> --> |
| | | </el-table> |
| | | <!-- <div style="margin-top: 20px;margin-left: 40%;"> |
| | | <el-pagination v-model:current-page="currentPage2" :page-size="pageSize" :size="large" :disabled="disabled" |
| | | layout="prev, pager, next, jumper" :total="totalRecords" @current-change="handlePageChange2" |
| | | style="margin-top: 10px;" /> |
| | | </div> --> |
| | | </div> |
| | | </template> |
| | | <script lang="ts" setup> |
| | | import { useI18n } from 'vue-i18n' |
| | | import { useRouter } from "vue-router" |
| | | import request from "@/utils/request" |
| | | import { host, WebSocketHost } from '@/utils/constants' |
| | | import { onBeforeUnmount, onMounted, onUnmounted, reactive, ref } from "vue"; |
| | | import { closeWebSocket, initializeWebSocket } from '@/utils/WebSocketService'; |
| | | import { ElMessage, ElMessageBox } from 'element-plus' |
| | | const { t } = useI18n() |
| | | let language = ref(localStorage.getItem('lang') || 'zh') |
| | | import { inject } from 'vue'; |
| | | const globalDate = inject('globalDate'); |
| | | const router = useRouter() |
| | | const timeRange = ref([]) |
| | | const selectValuesa = reactive([]); |
| | | const tableDatax = ref([]) |
| | | const currentPage2 = ref(1) |
| | | const totalRecords = ref(0) |
| | | const rawGlassHeight = ref(''); |
| | | const rawGlassThickness = ref(''); |
| | | const rawGlassWidth = ref(''); |
| | | const rawGlassfilmsId = ref(''); |
| | | const slot = ref(''); |
| | | let getglobalDate = window.localStorage.getItem('getglobalDate') |
| | | const historical = async () => { |
| | | try { |
| | | let startTime = window.localStorage.getItem('startTime') |
| | | const response = await request.post("/loadGlass/largenScreen/queryProduction", { |
| | | pageNo: 1, |
| | | pageSize: 20, |
| | | beginDate: startTime, |
| | | endDate: getglobalDate |
| | | }) |
| | | if (response.code == 200) { |
| | | ElMessage.success(response.message); |
| | | // const formattedData = response.data.records.map(record => ({ |
| | | // ...record, |
| | | // formattedCreateTime: formatTimestamp(record.createTime), |
| | | // formattedUpdateTime: formatTimestamp(record.updateTime), |
| | | // })); |
| | | // tableDatax.value = response.data.records; |
| | | tableDatax.value = response.data; |
| | | totalRecords.value = response.data.total / 2 || 0 |
| | | } else { |
| | | ElMessage.error(response.message); |
| | | } |
| | | } |
| | | catch (error) { |
| | | console.error(error); |
| | | } |
| | | } |
| | | const handlePageChange2 = (newPage) => { |
| | | currentPage2.value = newPage; |
| | | window.localStorage.setItem('pagenumber', currentPage2.value) |
| | | historicala(currentPage2.value); |
| | | }; |
| | | const historicala = async (page) => { |
| | | try { |
| | | let pslot = '' |
| | | let celllist = [] |
| | | if (selectValuesa[0] != null && selectValuesa[0] != 'undefined') { |
| | | if (selectValuesa[0] != "") { |
| | | celllist = [selectValuesa[0]]; |
| | | } |
| | | } |
| | | if (slot.value != "") { |
| | | pslot = slot.value |
| | | } else { |
| | | pslot = '0' |
| | | } |
| | | let page = window.localStorage.getItem('pagenumber') |
| | | let startTime = window.localStorage.getItem('startTime') |
| | | const response = await request.post("/loadGlass/largenScreen/queryProduction", { |
| | | pageNo: page, |
| | | pageSize: 20, |
| | | beginDate: (timeRange.value && timeRange.value[0]) || '', |
| | | endDate: (timeRange.value && timeRange.value[1]) || '', |
| | | }) |
| | | if (response.code == 200) { |
| | | ElMessage.success(response.message); |
| | | // const formattedData = response.data.records.map(record => ({ |
| | | // ...record, |
| | | // formattedCreateTime: formatTimestamp(record.createTime), |
| | | // formattedUpdateTime: formatTimestamp(record.updateTime), |
| | | // })); |
| | | // tableDatax.value = response.data.records; |
| | | tableDatax.value = response.data; |
| | | totalRecords.value = response.data.total / 2 || 0 |
| | | } else { |
| | | ElMessage.error(response.message); |
| | | } |
| | | } |
| | | catch (error) { |
| | | console.error(error); |
| | | } |
| | | } |
| | | // 历史查询点击 |
| | | const sethistorical = async () => { |
| | | try { |
| | | let pslot = '' |
| | | let celllist = [] |
| | | if (selectValuesa[0] != null && selectValuesa[0] != 'undefined') { |
| | | if (selectValuesa[0] != "") { |
| | | celllist = [selectValuesa[0]]; |
| | | } |
| | | } |
| | | if (slot.value != "") { |
| | | pslot = slot.value |
| | | } else { |
| | | pslot = '0' |
| | | } |
| | | let startTime = window.localStorage.getItem('startTime') |
| | | let page = window.localStorage.getItem('pagenumber') |
| | | const response = await request.post("/loadGlass/largenScreen/queryProduction", { |
| | | pageNo: 1, |
| | | pageSize: 20, |
| | | beginDate: (timeRange.value && timeRange.value[0]) || '', |
| | | endDate: (timeRange.value && timeRange.value[1]) || '', |
| | | }) |
| | | if (response.code == 200) { |
| | | currentPage2.value = 1 |
| | | ElMessage.success(response.message); |
| | | // const formattedData = response.data.records.map(record => ({ |
| | | // ...record, |
| | | // formattedCreateTime: formatTimestamp(record.createTime), |
| | | // formattedUpdateTime: formatTimestamp(record.updateTime), |
| | | // })); |
| | | // tableDatax.value = response.data.records; |
| | | tableDatax.value = response.data; |
| | | totalRecords.value = response.data.total / 2 || 0 |
| | | } else { |
| | | ElMessage.error(response.message); |
| | | } |
| | | } |
| | | catch (error) { |
| | | console.error(error); |
| | | } |
| | | } |
| | | // 格式化时间戳为年月日时间字符串的函数 |
| | | function formatTimestamp(timestamp) { |
| | | 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'); // 补零(如果需要显示时间) |
| | | return `${year}-${month}-${day} ${hours}:${minutes}:${seconds}`; |
| | | } |
| | | // 格式化后端时间并计算一周前的时间 |
| | | const defaultTime = ref<[Date, Date]>([new Date(), new Date()]); |
| | | function parseAndSetTime() { |
| | | const backendTime = new Date(getglobalDate); |
| | | const oneWeekAgo = new Date(backendTime.getTime() - 7 * 24 * 60 * 60 * 1000); // 减去7天 |
| | | oneWeekAgo.setHours(0, 0, 0, 0); |
| | | timeRange.value = [formatTimestamp(oneWeekAgo), formatTimestamp(backendTime)]; |
| | | window.localStorage.setItem('startTime', formatTimestamp(oneWeekAgo)) |
| | | } |
| | | function getStatusTypeb(taskState: number) { |
| | | switch (taskState) { |
| | | case 0: |
| | | return 'primary'; |
| | | case 1: |
| | | return 'success'; |
| | | case 2: |
| | | return 'info'; |
| | | } |
| | | } |
| | | function getStatusTextb(taskState: number) { |
| | | switch (taskState) { |
| | | case 0: |
| | | return t('searchOrder.empty'); |
| | | case 1: |
| | | return t('film.execution'); |
| | | case 2: |
| | | return t('searchOrder.endtask'); |
| | | } |
| | | } |
| | | function getStatusTypea(taskRunning: number) { |
| | | switch (taskRunning) { |
| | | case 0: |
| | | return 'primary'; |
| | | case 1: |
| | | return 'success'; |
| | | } |
| | | } |
| | | onMounted(() => { |
| | | parseAndSetTime(); |
| | | historical(); |
| | | }); |
| | | |
| | | import * as XLSX from 'xlsx'; |
| | | import { saveAs } from 'file-saver'; |
| | | |
| | | const exportToExcel = () => { |
| | | // 表格数据(深拷贝防止污染) |
| | | const data = JSON.parse(JSON.stringify(tableDatax.value)); |
| | | |
| | | // 表头转换为中文或国际化文本 |
| | | const headerMap = { |
| | | productDate: t('large.date'), |
| | | edgBeginTime: t('large.loadstart'), |
| | | edgEndTime: t('large.loadend'), |
| | | edgTimeTotal: t('large.loadtotal'), |
| | | edgTimeFree: t('large.loadfree'), |
| | | edgTimeDiff: t('large.loaddiff'), |
| | | countOut: t('large.loadnumber'), |
| | | totalAreaOut: t('large.loadarea'), |
| | | bigBeginTime: t('large.tempstart'), |
| | | bigEndTime: t('large.tempend'), |
| | | bigTimeTotal: t('large.temptotal'), |
| | | bigTimeFree: t('large.tempfree'), |
| | | bigTimeDiff: t('large.tempdiff'), |
| | | temperingLayoutCount: t('large.tempstove'), |
| | | temperingGlassCount: t('large.tempnumber'), |
| | | temperingArea: t('large.temparea'), |
| | | hollowBeginTime: t('large.hollowstart'), |
| | | hollowEndTime: t('large.hollowend'), |
| | | hollowTimeTotal: t('large.hollowtotal'), |
| | | hollowTimeFree: t('large.hollowfree'), |
| | | hollowTimeDiff: t('large.hollowdiff'), |
| | | hollowGlassCount: t('large.hollownumber'), |
| | | hollowArea: t('large.hollowarea'), |
| | | }; |
| | | |
| | | // 将数据中的 key 替换为中文表头 |
| | | const exportData = data.map(row => { |
| | | const newRow = {}; |
| | | for (const key in headerMap) { |
| | | newRow[headerMap[key]] = row[key]; |
| | | } |
| | | return newRow; |
| | | }); |
| | | |
| | | // 转换为工作表 |
| | | const worksheet = XLSX.utils.json_to_sheet(exportData); |
| | | const workbook = XLSX.utils.book_new(); |
| | | XLSX.utils.book_append_sheet(workbook, worksheet, 'Sheet1'); |
| | | |
| | | // 导出为文件 |
| | | const excelBuffer = XLSX.write(workbook, { bookType: 'xlsx', type: 'array' }); |
| | | const blob = new Blob([excelBuffer], { type: 'application/octet-stream' }); |
| | | saveAs(blob, '生产统计导出.xlsx'); |
| | | }; |
| | | |
| | | </script> |
| | | <style scoped></style> |