huangxiaoqiang
2025-06-03 975ea3c28b1661b3b6eabee5277cc98d853736d3
CodeManagement/BigScreenVue/src/views/indexs/center-bottom.vue
@@ -11,7 +11,7 @@
<script>
// import { currentGET } from "api/modules";
import { graphic } from "echarts";
import {Productions} from "@/api/http.js"
import {Getproductionvolume} from "@/api/http.js"
import axios from 'axios'
export default {
  data() {
@@ -35,7 +35,7 @@
                    "产量" +
                    " : " +
                    item.value +
                    "PCS</br>";
                    "托</br>";
              } else {
                result += item.marker + " " + item.seriesName + " :  - </br>";
              }
@@ -44,7 +44,7 @@
          },
        },
        legend: {
          data: ["单位:PCS"],
          data: ["单位:托"],
          textStyle: {
            color: "#B4B4B4",
          },
@@ -57,14 +57,14 @@
          top: "20px",
        },
        xAxis: {
          data: ['8/12','8/13','8/14','8/15','8/16','8/17','8/18'],
          data: [],
          axisLine: {
            lineStyle: {
              color: "#B4B4B4",
            },
          },
          axisTick: {
            show: false,
            show: true,
          },
        },
        yAxis: [
@@ -82,7 +82,7 @@
        ],
        series: [
          {
            name: "单位:PCS",
            name: "单位:托",
            type: "bar",
            barWidth: 20,
            itemStyle: {
@@ -106,8 +106,8 @@
          },
        ],
      },
    };
  },
      xAxisDates: [],
    };},
  props: {},
  mounted() {
    this.getData();
@@ -129,21 +129,30 @@
      }, 3000);
    },
    async getData() {
      // this.numberData.forEach((item, index) => {
      //   item.number.number[0] += ++index
      //   item.number = { ...item.number }
      // })
      var rep = await Productions();
      console.log(rep);
      //获取rep中对象的的today值整合成数组
      var todays= rep.map((item) => {
        return item.today;
      });
      //获取rep中对象的的pcsCounts值整合成数组
      var pcsCounts= rep.map((item) => {
        return item.pcsCounts;
      });
      console.log(todays);
      const rep = await Getproductionvolume();
      console.log(rep)
        var rep1=rep.filter(it=>it.taskType==100&&it.roadway.includes("CW"))
    // 分组并排序
    const groupedData = rep1.reduce((acc, item) => {
      const dateKey = item.createDate.split(' ')[0];
      acc[dateKey] = acc[dateKey] || { date: dateKey, tasks: [] };
      acc[dateKey].tasks.push(item);
      return acc;
    }, {});
    const sortedGroups = Object.values(groupedData).sort(
      (a, b) => new Date(b.date) - new Date(a.date)
    );
    // 提取日期(7/2 格式)
    this.xAxisDates= sortedGroups.map(group => {
      const date = new Date(group.date);
      return `${date.getMonth() + 1}/${date.getDate()}`;
    });
    const pcsCounts = sortedGroups.map(group => group.tasks.length);
      this.options = {
        tooltip: {
          trigger: "axis",
@@ -163,7 +172,7 @@
                    "产量" +
                    " : " +
                    item.value +
                    "PCS</br>";
                    "托</br>";
              } else {
                result += item.marker + " " + item.seriesName + " :  - </br>";
              }
@@ -172,7 +181,7 @@
          },
        },
        legend: {
          data: ["单位:PCS"],
          data: ["单位:托"],
          textStyle: {
            color: "#B4B4B4",
          },
@@ -185,14 +194,14 @@
          top: "20px",
        },
        xAxis: {
          data: todays.reverse(),
          data:this.xAxisDates.reverse(),
          axisLine: {
            lineStyle: {
              color: "#B4B4B4",
            },
          },
          axisTick: {
            show: false,
            show: true,
          },
        },
        yAxis: [
@@ -210,7 +219,7 @@
        ],
        series: [
          {
            name: "单位:PCS",
            name: "单位:托",
            type: "bar",
            barWidth: 20,
            itemStyle: {
@@ -239,115 +248,9 @@
        this.$store.state.setting.echartsAutoTime
      );
    },
    // async getData() {
    //   this.pageflag = true;
    //   let rep = await Timefault((a)=>{
    //       console.log(a);
    //     });
    //    this.init(rep);
    //   currentGET("big6", { companyName: this.companyName }).then((res) => {
    //     console.log("故障时长统计", res);
    //     // if (res.success) {
    //     //   this.init(res.data);
    //     //   console.log("测试2",res.data);
    //     // } else {
    //     //   this.pageflag = false;
    //     //   this.$Message({
    //     //     text: res.msg,
    //     //     type: "warning",
    //     //   });
    //     // }
    //   });
    // },
    // init(val) {
    //   console.log(val);
    //   this.options = {
    //     tooltip: {
    //       trigger: "axis",
    //       backgroundColor: "rgba(0,0,0,.6)",
    //       borderColor: "rgba(147, 235, 248, .8)",
    //       textStyle: {
    //         color: "#FFF",
    //       },
    //       formatter: function (params) {
    //         // 添加单位
    //         var result = params[0].name + "<br>";
    //         params.forEach(function (item) {
    //           if (item.value) {
    //               result +=
    //                 item.marker +
    //                 " " +
    //                 "合格产量" +
    //                 " : " +
    //                 item.value +
    //                 "箱</br>";
    //           } else {
    //             result += item.marker + " " + item.seriesName + " :  - </br>";
    //           }
    //         });
    //         return result;
    //       },
    //     },
    //     legend: {
    //       data: ["单位:箱"],
    //       textStyle: {
    //         color: "#B4B4B4",
    //       },
    //       top: "-5",
    //     },
    //     grid: {
    //       left: "50px",
    //       right: "40px",
    //       bottom: "30px",
    //       top: "20px",
    //     },
    //     xAxis: {
    //       data: [val[6].datetime,val[5].datetime,val[4].datetime,val[3].datetime,
    //             val[2].datetime,val[1].datetime,val[0].datetime],
    //       axisLine: {
    //         lineStyle: {
    //           color: "#B4B4B4",
    //         },
    //       },
    //       axisTick: {
    //         show: false,
    //       },
    //     },
    //     yAxis: [
    //       {
    //         splitLine: { show: true },
    //         axisLine: {
    //           lineStyle: {
    //             color: "#B4B4B4",
    //           },
    //         },
    //         axisLabel: {
    //           formatter: "{value}",
    //         },
    //       }
    //     ],
    //     series: [
    //       {
    //         name: "单位:箱",
    //         type: "bar",
    //         barWidth: 20,
    //         itemStyle: {
    //           borderRadius: 5,
    //           color: new graphic.LinearGradient(0, 0, 0, 1, [
    //             { offset: 0, color: "#956FD4" },
    //             { offset: 1, color: "#3EACE5" },
    //           ]),
    //         },
    //         data: [val[6].qty,val[5].qty,val[4].qty,val[3].qty,
    //               val[2].qty,val[1].qty,val[0].qty],
    //       },
    //     ],
    //   };
    // },
  },
  }
};
</script>
<style lang="scss" scoped>