| | |
| | | <template> |
| | | <div class="home-contianer"> |
| | | |
| | | <div class="chart_left"> |
| | | <div class="titles"> |
| | | <el-icon class="icons" :size="24" color="#409EFF"> |
| | | <Checked /> |
| | | </el-icon> |
| | | ä»»å¡è¿è¡ä¸ |
| | | </div> |
| | | <div style="margin-top: 60px;"></div> |
| | | <div class="item_center"> |
| | | <Task-List :data="chartData" :options="chartOptions" /> |
| | | </div> |
| | | </div> |
| | | </template> |
| | | <script> |
| | | import { ref, onMounted, onUnmounted } from 'vue'; |
| | | export default { |
| | | components: {}, |
| | | data() { |
| | | return { |
| | | |
| | | n: 90, |
| | | value1: '1', |
| | | }; |
| | | }, |
| | | setup() { |
| | | let open = (item) => { |
| | | window.open(item.url, '_blank'); |
| | | }; |
| | | let interval; |
| | | onMounted(() => { |
| | | <script setup> |
| | | import TaskList from '../components/index/TaskList.vue'; |
| | | import http from '../api/http.js'; |
| | | import { ref, onMounted, onUnmounted, watch } from 'vue'; |
| | | |
| | | // interval = setInterval(() => { |
| | | // chart2.xAxis[0].data.splice(0, 1); |
| | | // let lastYear = |
| | | // chart2.xAxis[0].data[chart2.xAxis[0].data.length - 1] * 1 + 1; |
| | | // chart2.xAxis[0].data.push(lastYear); |
| | | // ç¤ºä¾æ°æ® |
| | | const chartData = ref([ |
| | | { value: 103, name: '已忶', itemStyle: { color: '#FF6B6B' } }, |
| | | { value: 735, name: '已宿', itemStyle: { color: '#4ECDC4' } }, |
| | | ]); |
| | | |
| | | // chart2.series[0].data.splice(0, 1); |
| | | // chart2.series[0].data.push(~~(Math.random() * 1000)); |
| | | const fetchData = async () => { |
| | | try { |
| | | const response = await http.post("api/Task/GetTaskData", {}); |
| | | |
| | | // chart2.series[1].data.splice(0, 1); |
| | | // chart2.series[1].data.push(~~(Math.random() * 1000)); |
| | | // $chart2.setOption(chart2); |
| | | // }, 2000); |
| | | }); |
| | | onUnmounted(() => { |
| | | |
| | | }); |
| | | return { open }; |
| | | }, |
| | | destroyed() { |
| | | console.log(response); |
| | | chartData.value = response.data; // æ´æ°ååºå¼æ°æ® |
| | | console.log('æ°æ®æ´æ°æå:', chartData.value); |
| | | } catch (error) { |
| | | console.error('API请æ±å¤±è´¥:', error); |
| | | } |
| | | }; |
| | | // window.addEventListener("resize", function () { |
| | | // $chart2.setOption(chart2); |
| | | // }); |
| | | const startPolling = () => { |
| | | fetchData(); // åå§å è½½ |
| | | intervalId = setInterval(fetchData, 5 * 60 * 1000); // 5åé |
| | | }; |
| | | |
| | | // æ¸
ç宿¶å¨ |
| | | const stopPolling = () => { |
| | | if (intervalId) { |
| | | clearInterval(intervalId); |
| | | console.log('å·²åæ¢æ°æ®è½®è¯¢'); |
| | | } |
| | | }; |
| | | onMounted(() => { |
| | | startPolling(); |
| | | }); |
| | | onUnmounted(() => { |
| | | stopPolling(); |
| | | }); |
| | | const chartOptions = ref({ |
| | | tooltip: { |
| | | formatter: '{b}: {c} ({d}%)' |
| | | }, |
| | | legend: { |
| | | itemWidth: 14, |
| | | itemHeight: 14, |
| | | textStyle: { fontSize: 12 } |
| | | } |
| | | }); |
| | | </script> |
| | | <style lang="less" scoped> |
| | | .home-contianer { |
| | | padding: 6px; |
| | | background: #eee; |
| | | <style scoped> |
| | | .dashboard { |
| | | width: 100%; |
| | | height: 100vh; |
| | | padding: 20px; |
| | | box-sizing: border-box; |
| | | } |
| | | |
| | | .m-charts { |
| | | display: grid; |
| | | margin: 10px; |
| | | grid-template-columns: 33% 33% 95%; |
| | | justify-content: space-between; |
| | | } |
| | | |
| | | .labelContent { |
| | | padding-top: 3vh; |
| | | } |
| | | |
| | | .chart_left, |
| | | .chart_center, |
| | | .chart_right { |
| | | position: relative; |
| | | border-radius: 10px; |
| | | background-color: white; |
| | | box-shadow: 0px 0px 10px 0px #ccc; |
| | | height: 100%; |
| | | // max-width: 800px; |
| | | // position: absolute; |
| | | top: 0; |
| | | right: 0; |
| | | left: 0; |
| | | margin: 0 auto; |
| | | |
| | | .h-top { |
| | | display: flex; |
| | | .h-top-left { |
| | | height: 100%; |
| | | width: 300px; |
| | | background: white; |
| | | } |
| | | height: 300px; |
| | | } |
| | | .h-top > div { |
| | | border: 1px solid #e8e7e7; |
| | | border-radius: 5px; |
| | | // margin: 6px; |
| | | } |
| | | .h-top-center { |
| | | height: 100%; |
| | | background: white; |
| | | margin: 0 6px; |
| | | display: flex; |
| | | flex-direction: column; |
| | | flex: 1; |
| | | .item1 .num { |
| | | padding-top: 28px; |
| | | } |
| | | .item2 .num { |
| | | padding-bottom: 20px; |
| | | } |
| | | |
| | | .n-item { |
| | | width: 100%; |
| | | height: 100%; |
| | | text-align: center; |
| | | cursor: pointer; |
| | | // display: flex; |
| | | .item { |
| | | border-right: 1px solid #e5e5e5; |
| | | width: 33.3333333%; |
| | | float: left; |
| | | height: 50%; |
| | | border-bottom: 1px solid #e5e5e5; |
| | | padding: 47px 0; |
| | | font-size: 13px; |
| | | } |
| | | .item:hover { |
| | | background: #f9f9f9; |
| | | cursor: pointer; |
| | | } |
| | | .item:last-child { |
| | | border-right: 0; |
| | | } |
| | | .item3, |
| | | .item6 { |
| | | border-right: 0; |
| | | } |
| | | .num { |
| | | word-break: break-all; |
| | | color: #282727; |
| | | font-size: 30px; |
| | | transition: transform 0.8s; |
| | | } |
| | | .num:hover { |
| | | color: #55ce80; |
| | | transform: scale(1.2); |
| | | } |
| | | .text { |
| | | font-size: 13px; |
| | | color: #777; |
| | | } |
| | | } |
| | | } |
| | | .h-top-right { |
| | | // flex: 1; |
| | | |
| | | width: 400px; |
| | | height: 100%; |
| | | background: white; |
| | | } |
| | | .h3 { |
| | | padding: 7px 15px; |
| | | font-weight: 500; |
| | | background: #fff; |
| | | border-bottom: 1px dotted #d4d4d4; |
| | | } |
| | | width: 550px; |
| | | } |
| | | .task-table { |
| | | table { |
| | | width: 100%; |
| | | .thead { |
| | | font-weight: bold; |
| | | } |
| | | tr { |
| | | cursor: pointer; |
| | | td { |
| | | border-bottom: 1px solid #f3f3f3; |
| | | padding: 9px 8px; |
| | | font-size: 12px; |
| | | } |
| | | } |
| | | tr:hover { |
| | | background: #eee; |
| | | } |
| | | } |
| | | |
| | | .icons { |
| | | margin-right: 5px; |
| | | } |
| | | .h-chart { |
| | | height: 340px; |
| | | margin: 6px 0px; |
| | | |
| | | .indexModel .item_center { |
| | | height: 68vh; |
| | | width: 98%; |
| | | margin: 0vh 1%; |
| | | |
| | | } |
| | | |
| | | .titles { |
| | | width: 200px; |
| | | height: 5vh; |
| | | display: flex; |
| | | .h-left-grid { |
| | | width: 300px; |
| | | height: 100%; |
| | | background: white; |
| | | display: inline-block; |
| | | .name { |
| | | margin-left: 7px; |
| | | } |
| | | .item:hover { |
| | | background: #f9f9f9; |
| | | cursor: pointer; |
| | | } |
| | | .item { |
| | | padding: 22px 14px; |
| | | float: left; |
| | | width: 50%; |
| | | height: 33.33333%; |
| | | border-bottom: 1px solid #eee; |
| | | border-right: 1px solid #eee; |
| | | i { |
| | | font-size: 30px; |
| | | } |
| | | .desc { |
| | | font-size: 12px; |
| | | color: #c3c3c3; |
| | | padding: 5px 0 0 4px; |
| | | line-height: 1.5; |
| | | } |
| | | } |
| | | } |
| | | } |
| | | #h-chart2 { |
| | | border-radius: 3px; |
| | | background: white; |
| | | padding-top: 10px; |
| | | height: 100%; |
| | | width: 0; |
| | | flex: 1; |
| | | margin: 0 7px; |
| | | } |
| | | #h-chart3 { |
| | | border-radius: 3px; |
| | | padding: 10px 10px 0 10px; |
| | | background: white; |
| | | // padding-top: 10px; |
| | | height: 100%; |
| | | |
| | | width: 400px; |
| | | } |
| | | </style> |
| | | align-items: center; |
| | | font-size: 1.5rem; |
| | | font-weight: 600; |
| | | position: absolute; |
| | | top: 0px; |
| | | left: 15px; |
| | | }</style> |