1
huangxiaoqiang
昨天 af5847927931d3f491d7be5e0178cff3c37ac6f9
ÏîÄ¿´úÂë/WMS/WIDESEA_WMSClient/src/views/Home.vue
@@ -1,12 +1,24 @@
<template>
  <div class="chart_left">
  <div class="chart_left" style="margin-left: 20px;">
    <div class="titles">
      <el-icon class="icons" :size="24" color="#409EFF">
        <Checked />
      </el-icon>
      ä»»åŠ¡è¿›è¡Œä¸­
    </div>
    <div style="margin-top: 60px;"></div>
    <div style="margin-top: 20px;"></div>
    <div class="item_center">
      <Task-List :data="chartData" :options="chartOptions" />
    </div>
  </div>
  <div class="chart_left" style="margin-left: 20px;">
    <div class="titles">
      <el-icon class="icons" :size="24" color="#409EFF">
        <Checked />
      </el-icon>
      ä»»åŠ¡è¿›è¡Œä¸­
    </div>
    <div style="margin-top: 20px;"></div>
    <div class="item_center">
      <Task-List :data="chartData" :options="chartOptions" />
    </div>
@@ -16,33 +28,33 @@
import TaskList from '../components/index/TaskList.vue';
import http from '../api/http.js';
import { ref, onMounted, onUnmounted, watch } from 'vue'; 
const taskListRef = ref(null);
// ç¤ºä¾‹æ•°æ®
const chartData = ref([
  { value: 103, name: '已取消', itemStyle: { color: '#FF6B6B' } },
  { value: 735, name: '已完成', itemStyle: { color: '#4ECDC4' } },
  // { value: 103, name: '已取消', itemStyle: { color: '#FF6B6B' } },
  // { value: 735, name: '已完成', itemStyle: { color: '#4ECDC4' } },
]);
const fetchData = async () => {
  try {
    const response = await http.post("api/Task/GetTaskData", {});
    chartData.value = response.data;
    console.log(response);
    chartData.value = response.data; // æ›´æ–°å“åº”式数据
    console.log('数据更新成功:', chartData.value);
    if (taskListRef.value) taskListRef.value.initChart();
  } catch (error) {
    console.error('API请求失败:', error);
  }
};
const intervalId = ref(null)
const startPolling = () => {
  fetchData(); // åˆå§‹åŠ è½½
  intervalId = setInterval(fetchData, 5 * 60 * 1000); // 5分钟
  intervalId.value = setInterval(fetchData, 5 * 60 * 1000); // 5分钟
};
// æ¸…理定时器
const stopPolling = () => {
  if (intervalId) {
    clearInterval(intervalId);
  if (intervalId.value) {
    clearInterval(intervalId.value);
    console.log('已停止数据轮询');
  }
};
@@ -82,9 +94,7 @@
  padding-top: 3vh;
}
.chart_left,
.chart_center,
.chart_right {
.chart_left {
  position: relative;
  border-radius: 10px;
  background-color: white;
@@ -98,10 +108,9 @@
}
.indexModel .item_center {
  height: 68vh;
  height: 90vh;
  width: 98%;
  margin: 0vh 1%;
  margin: 0vh 20%;
}
.titles {