| | |
| | | <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> |
| | | <el-button type="primary" @click="showchart=!showchart" style="margin-left: 10px;">{{ $t('large.switch') }}</el-button> |
| | | </div> |
| | | <el-table ref="table" style="margin-top: 20px;height: 580px;width: 1770px;" :data="tableDatax" |
| | | <el-table v-show="!showchart" 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="hollowTotalAreaOutTwo" align="center" :label="$t('large.hollowTotalAreaOutTwo')" |
| | | min-width="40" /> |
| | | </el-table> |
| | | <div style="margin-top: 20px;margin-left: 40%;"> |
| | | <div v-show="!showchart" 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 v-show="showchart" id="ss" style="width: 100%; display: flex; justify-content: center;"> |
| | | <div ref="chartRef" style="width: 1770px; height: 320px;"></div> |
| | | </div> |
| | | <div v-show="showchart" id="ss" style="width: 100%; display: flex; justify-content: center;"> |
| | | <div ref="chartRef2" style="width: 1770px; height: 320px;"></div> |
| | | </div> |
| | | </div> |
| | | </template> |
| | |
| | | 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 { onBeforeUnmount, onMounted, onUnmounted, reactive, ref , nextTick} from "vue"; |
| | | import { closeWebSocket, initializeWebSocket } from '@/utils/WebSocketService'; |
| | | import { ElMessage, ElMessageBox } from 'element-plus' |
| | | import * as echarts from 'echarts'; |
| | | const { t } = useI18n() |
| | | let language = ref(localStorage.getItem('lang') || 'zh') |
| | | import { inject } from 'vue'; |
| | |
| | | })); |
| | | // tableDatax.value = response.data.records; |
| | | tableDatax.value = formattedData; |
| | | createchart(tableDatax); |
| | | totalRecords.value = response.data.total / 2 || 0 |
| | | } else { |
| | | ElMessage.error(response.message); |
| | |
| | | })); |
| | | // tableDatax.value = response.data.records; |
| | | tableDatax.value = formattedData; |
| | | createchart(tableDatax); |
| | | totalRecords.value = response.data.total / 2 || 0 |
| | | } else { |
| | | ElMessage.error(response.message); |
| | |
| | | })); |
| | | // tableDatax.value = response.data.records; |
| | | tableDatax.value = formattedData; |
| | | createchart(tableDatax); |
| | | totalRecords.value = response.data.total / 2 || 0 |
| | | } else { |
| | | ElMessage.error(response.message); |
| | |
| | | // 导出为文件 |
| | | const excelBuffer = XLSX.write(workbook, { bookType: 'xlsx', type: 'array' }); |
| | | const blob = new Blob([excelBuffer], { type: 'application/octet-stream' }); |
| | | saveAs(blob, '生产情况导出.xlsx'); |
| | | saveAs(blob, t('large.Productionsituation')); |
| | | }; |
| | | let categories = ref([]); // 获取日期作为 x 轴 |
| | | let totalAreaOutOne = ref([]); |
| | | let countIn = ref([]); |
| | | let totalAreaOutTwo = ref([]); |
| | | let totalAreaOut = ref([]); |
| | | let countOut = ref([]); |
| | | let hollowTotalAreaOutTwo = ref([]); |
| | | let hollowCountOutOne = ref([]); |
| | | let countOutTwo = ref([]); |
| | | let hollowCountOutTwo = ref([]); |
| | | let hollowTotalAreaOutOne = ref([]); |
| | | let totalAreaIn = ref([]); |
| | | let countOutOne = ref([]); |
| | | let myChart = null; |
| | | let myChart2 = null; |
| | | const chartRef = ref(null) |
| | | const chartRef2 = ref(null) |
| | | const showchart = ref(false) |
| | | const createchart = (productionVO) => { |
| | | categories = productionVO.value.map(item => item.date); // 获取日期作为 x 轴 |
| | | totalAreaOutOne = productionVO.value.map(item => item.totalAreaOutOne); |
| | | countIn = productionVO.value.map(item => item.countIn); |
| | | totalAreaOutTwo = productionVO.value.map(item => item.totalAreaOutTwo); |
| | | totalAreaOut = productionVO.value.map(item => item.totalAreaOut); |
| | | countOut = productionVO.value.map(item => item.countOut); |
| | | hollowTotalAreaOutTwo = productionVO.value.map(item => item.hollowTotalAreaOutTwo); |
| | | hollowCountOutOne = productionVO.value.map(item => item.hollowCountOutOne); |
| | | countOutTwo = productionVO.value.map(item => item.countOutTwo); |
| | | hollowCountOutTwo = productionVO.value.map(item => item.hollowCountOutTwo); |
| | | hollowTotalAreaOutOne = productionVO.value.map(item => item.hollowTotalAreaOutOne); |
| | | totalAreaIn = productionVO.value.map(item => item.totalAreaIn); |
| | | countOutOne = productionVO.value.map(item => item.countOutOne); |
| | | //图表 |
| | | nextTick() // 确保 DOM 加载完成 |
| | | const chartDom = chartRef.value; |
| | | if (!chartDom) { |
| | | console.error('图表容器未找到'); |
| | | return; |
| | | } |
| | | if (!myChart) { |
| | | myChart = echarts.init(chartDom); |
| | | } |
| | | |
| | | const option = { |
| | | title: { text: '' }, |
| | | tooltip: { trigger: 'axis' }, |
| | | legend: { |
| | | data: [ |
| | | t('large.countOutOne'), |
| | | t('large.totalAreaOutOne'), |
| | | t('large.countOutTwo'), |
| | | t('large.totalAreaOutTwo'), |
| | | t('large.countIn'), |
| | | t('large.totalAreaIn') |
| | | ] |
| | | }, |
| | | grid: { left: '3%', right: '4%', bottom: '3%', containLabel: true }, |
| | | toolbox: { feature: { saveAsImage: {} } }, |
| | | xAxis: { |
| | | type: 'category', |
| | | boundaryGap: false, |
| | | data: categories // 这是日期数据 |
| | | }, |
| | | yAxis: { type: 'value' }, |
| | | series: [ |
| | | { name: t('large.countOutOne'), type: 'bar', data: countOutOne }, |
| | | { name: t('large.totalAreaOutOne'), type: 'bar', data: totalAreaOutOne }, |
| | | { name: t('large.countOutTwo'), type: 'bar', data: countOutTwo }, |
| | | { name: t('large.totalAreaOutTwo'), type: 'bar', data: totalAreaOutTwo }, |
| | | { name: t('large.countIn'), type: 'bar', data: countIn }, |
| | | { name: t('large.totalAreaIn'), type: 'bar', data: totalAreaIn } |
| | | ] |
| | | }; |
| | | |
| | | myChart.setOption(option); |
| | | |
| | | |
| | | const chartDom2 = chartRef2.value; |
| | | if (!chartDom2) { |
| | | console.error('图表容器未找到'); |
| | | return; |
| | | } |
| | | // myChart2 = echarts.init(chartDom2); |
| | | if (!myChart2) { |
| | | myChart2 = echarts.init(chartDom2); |
| | | } |
| | | // else { |
| | | // myChart2.clear(); |
| | | // } |
| | | const option2 = { |
| | | title: { text: '' }, |
| | | tooltip: { trigger: 'axis' }, |
| | | legend: { |
| | | data: [ |
| | | t('large.totalAreaOut'), |
| | | t('large.countOut'), |
| | | t('large.hollowTotalAreaOutOne'), |
| | | t('large.hollowCountOutOne'), |
| | | t('large.hollowCountOutTwo'), |
| | | t('large.hollowTotalAreaOutTwo') |
| | | ] |
| | | }, |
| | | grid: { left: '3%', right: '4%', bottom: '3%', containLabel: true }, |
| | | toolbox: { feature: { saveAsImage: {} } }, |
| | | xAxis: { |
| | | type: 'category', |
| | | boundaryGap: false, |
| | | data: categories // 这是日期数据 |
| | | }, |
| | | yAxis: { type: 'value' }, |
| | | series: [ |
| | | { name: t('large.totalAreaOut'), type: 'bar', data: totalAreaOut }, |
| | | { name: t('large.countOut'), type: 'bar', data: countOut }, |
| | | { name: t('large.hollowTotalAreaOutOne'), type: 'bar', data: hollowTotalAreaOutOne }, |
| | | { name: t('large.hollowCountOutOne'), type: 'bar', data: hollowCountOutOne }, |
| | | { name: t('large.hollowCountOutTwo'), type: 'bar', data: hollowCountOutTwo }, |
| | | { name: t('large.hollowTotalAreaOutTwo'), type: 'bar', data: hollowTotalAreaOutTwo } |
| | | ] |
| | | }; |
| | | |
| | | myChart2.setOption(option2); |
| | | } |
| | | |
| | | |
| | | |
| | | </script> |
| | | <style scoped></style> |