| | |
| | | <template> |
| | | <div> |
| | | <div style="display: flex;width: 1770px;"> |
| | | <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 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" 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: 1770px;" :data="tableDatax" |
| | | :header-cell-style="{ background: '#F2F3F5 ', color: '#1D2129' }"> |
| | | <el-table-column prop="date" align="center" :label="$t('large.date')" min-width="70" /> |
| | | <el-table-column prop="countOutOne" align="center" :label="$t('large.countOutOne')" min-width="40" /> |
| | | <el-table-column prop="totalAreaOutOne" align="center" :label="$t('large.totalAreaOutOne')" min-width="40" /> |
| | | <el-table-column prop="countOutTwo" align="center" :label="$t('large.countOutTwo')" min-width="50" /> |
| | | <el-table-column prop="totalAreaOutTwo" align="center" :label="$t('large.totalAreaOutTwo')" min-width="50" /> |
| | | <el-table-column prop="countIn" align="center" :label="$t('large.countIn')" min-width="50" /> |
| | | <el-table-column prop="totalAreaIn" align="center" :label="$t('large.totalAreaIn')" min-width="50" /> |
| | | <el-table-column prop="countOut" align="center" :label="$t('large.countOut')" min-width="40" /> |
| | | <el-table-column prop="totalAreaOut" align="center" :label="$t('large.totalAreaOut')" min-width="40" /> |
| | | <el-table-column prop="hollowCountOutOne" align="center" :label="$t('large.hollowCountOutOne')" min-width="40" /> |
| | | <el-table-column prop="hollowTotalAreaOutOne" align="center" :label="$t('large.hollowTotalAreaOutOne')" min-width="40" /> |
| | | <el-table-column prop="hollowCountOutTwo" align="center" :label="$t('large.hollowCountOutTwo')" min-width="40" /> |
| | | <el-table-column prop="hollowTotalAreaOutTwo" align="center" :label="$t('large.hollowTotalAreaOutTwo')" |
| | | min-width="40"/> |
| | | <el-table-column prop="countOutOne" align="center" :label="$t('large.countOutOne')" min-width="40" /> |
| | | <el-table-column prop="totalAreaOutOne" align="center" :label="$t('large.totalAreaOutOne')" min-width="40" /> |
| | | <el-table-column prop="countOutTwo" align="center" :label="$t('large.countOutTwo')" min-width="50" /> |
| | | <el-table-column prop="totalAreaOutTwo" align="center" :label="$t('large.totalAreaOutTwo')" min-width="50" /> |
| | | <el-table-column prop="countIn" align="center" :label="$t('large.countIn')" min-width="50" /> |
| | | <el-table-column prop="totalAreaIn" align="center" :label="$t('large.totalAreaIn')" min-width="50" /> |
| | | <el-table-column prop="countOut" align="center" :label="$t('large.countOut')" min-width="40" /> |
| | | <el-table-column prop="totalAreaOut" align="center" :label="$t('large.totalAreaOut')" min-width="40" /> |
| | | <el-table-column prop="hollowCountOutOne" align="center" :label="$t('large.hollowCountOutOne')" min-width="40" /> |
| | | <el-table-column prop="hollowTotalAreaOutOne" align="center" :label="$t('large.hollowTotalAreaOutOne')" |
| | | min-width="40" /> |
| | | <el-table-column prop="hollowCountOutTwo" align="center" :label="$t('large.hollowCountOutTwo')" min-width="40" /> |
| | | <el-table-column prop="hollowTotalAreaOutTwo" align="center" :label="$t('large.hollowTotalAreaOutTwo')" |
| | | 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" |
| | |
| | | })); |
| | | // tableDatax.value = response.data.records; |
| | | tableDatax.value = formattedData; |
| | | console.log(response.data.pages); |
| | | totalRecords.value = response.data.total / 2 || 0 |
| | | } else { |
| | | ElMessage.error(response.message); |
| | |
| | | } |
| | | const handlePageChange2 = (newPage) => { |
| | | currentPage2.value = newPage; |
| | | console.log(currentPage2.value); |
| | | window.localStorage.setItem('pagenumber', currentPage2.value) |
| | | historicala(currentPage2.value); |
| | | }; |
| | |
| | | } |
| | | let startTime = window.localStorage.getItem('startTime') |
| | | let page = window.localStorage.getItem('pagenumber') |
| | | console.log(page); |
| | | const response = await request.post("/loadGlass/largenScreen/queryDailyProduction", { |
| | | pageNo: 1, |
| | | pageSize: 20, |
| | |
| | | const backendTime = new Date(getglobalDate); |
| | | const oneWeekAgo = new Date(backendTime.getTime() - 7 * 24 * 60 * 60 * 1000); // 减去7天 |
| | | oneWeekAgo.setHours(0, 0, 0, 0); |
| | | console.log(formatTimestamp(oneWeekAgo)); |
| | | console.log(oneWeekAgo); |
| | | timeRange.value = [formatTimestamp(oneWeekAgo), formatTimestamp(backendTime)]; |
| | | window.localStorage.setItem('startTime', formatTimestamp(oneWeekAgo)) |
| | | } |
| | |
| | | return 'success'; |
| | | } |
| | | } |
| | | function getStatusTexta(taskRunning: number) { |
| | | switch (taskRunning) { |
| | | case 0: |
| | | return t('basicData.untask'); |
| | | case 1: |
| | | return t('basicData.up'); |
| | | } |
| | | } |
| | | 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 = { |
| | | date: t('large.date'), |
| | | countOutOne: t('large.countOutOne'), |
| | | totalAreaOutOne: t('large.totalAreaOutOne'), |
| | | countOutTwo: t('large.countOutTwo'), |
| | | totalAreaOutTwo: t('large.totalAreaOutTwo'), |
| | | countIn: t('large.countIn'), |
| | | totalAreaIn: t('large.totalAreaIn'), |
| | | countOut: t('large.countOut'), |
| | | totalAreaOut: t('large.totalAreaOut'), |
| | | hollowCountOutOne: t('large.hollowCountOutOne'), |
| | | hollowTotalAreaOutOne: t('large.hollowTotalAreaOutOne'), |
| | | hollowCountOutTwo: t('large.hollowCountOutTwo'), |
| | | hollowTotalAreaOutTwo: t('large.hollowTotalAreaOutTwo') |
| | | }; |
| | | |
| | | // 将数据中的 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> |