yangfeng
2023-12-04 bb7f2e3ecbd47edfde477d742990bcbad3d601e1
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
<template>
  <BackgroundBoardLayout>
    <template #leftBlock1>
      <StatisticalBox :all-list="allList"></StatisticalBox>
    </template>
    <template #leftBlock2>
      <MachineStartupRate></MachineStartupRate>
    </template>
    <template #leftBlock3>
      <CountView :total-object="totalObject"></CountView>
    </template>
    <template #leftBlock4>
      <OrderCompleteRadio></OrderCompleteRadio>
    </template>
    <template #leftBlock5>
      <WorkOrderProgress></WorkOrderProgress>
    </template>
    <template #leftBlock6>
      <PerSonnelProductivity></PerSonnelProductivity>
    </template>
    <template #rightBlock1>
      <DeviceChart></DeviceChart>
    </template>
    <template #rightBlock2>
      <MaterialChart></MaterialChart>
    </template>
    <template #rightBlock3>
      <BarChart></BarChart>
    </template>
  </BackgroundBoardLayout>
</template>
 
<script>
import StatisticalBox from "@/views/cockpitPage/components/StatisticalBox";
import MachineStartupRate from "@/views/cockpitPage/components/MachineStartupRate";
import CountView from "@/views/cockpitPage/components/CountView";
import BackgroundBoardLayout from "@/components/cockpitPage/BackgroundBoardLayout.vue";
import PerSonnelProductivity from "@/views/cockpitPage/components/PerSonnelProductivity.vue";
import DeviceChart from "@/views/cockpitPage/components/DeviceChart.vue";
import MaterialChart from "@/views/cockpitPage/components/MaterialChart.vue";
import BarChart from "@/views/cockpitPage/components/BarChart.vue";
import OrderCompleteRadio from "@/views/cockpitPage/components/OrderCompleteRadio";
import WorkOrderProgress from "@/views/cockpitPage/components/WorkOrderProgress";
import { getDashboard } from "@/api/cockpitPage/index";
export default {
  components: {
    StatisticalBox,
    BackgroundBoardLayout,
    PerSonnelProductivity,
    DeviceChart,
    MaterialChart,
    BarChart,
    MachineStartupRate,
    CountView,
    OrderCompleteRadio,
    WorkOrderProgress,
  },
  props: {},
  data() {
    return {
      allList: [
        { value: 0, label: "开机台数" },
        { value: 0, label: "总产量" },
        { value: 0, label: "生产工单数" },
        { value: 0, label: "延期交付" },
        { value: 0, label: "物料不足" },
        { value: 0, label: "计划达成率" },
      ],
      totalObject: {},
    };
  },
  mounted() {
    this.getDashboard();
    setInterval(() => {
      this.getDashboard();
    }, 300000);
  },
  watch: {},
  methods: {
    async getDashboard() {
      await getDashboard().then((res) => {
        console.log(res);
        // 左上数值统计数据
        this.setLeftBlock1(res.data);
        //  左中数据统计值
        this.setLeftBlock3(res.data);
      });
    },
    // 处理左上数据
    setLeftBlock1(data) {
      this.allList.map((item) => {
        if (item.label === "开机台数") {
          item.value = data?.DeviceRunningAmount ?? 0;
        } else if (item.label === "总产量") {
          item.value = data?.TotalProductionAmount ?? 0;
        } else if (item.label === "生产工单数") {
          item.value = data?.WorkOrderAmount ?? 0;
        } else if (item.label === "延期交付") {
          item.value = data?.DelayWorkOrderAmount ?? 0;
        } else if (item.label === "物料不足") {
          item.value = data?.MaterialMissWorkOrderAmount ?? 0;
        } else if (item.label === "计划达成率") {
          item.value =
            typeof data?.PlanOrderFinishRate === "string"
              ? parseFloat(
                  data?.PlanOrderFinishRate.length > 0
                    ? data?.PlanOrderFinishRate
                    : "0"
                )
              : data?.PlanOrderFinishRate ?? 0;
        }
      });
    },
    // 左中数据统计值
    setLeftBlock3(data) {
      this.totalObject = {
        InternalDeviceRunningAmount: data?.InternalDeviceRunningAmount ?? 0,
        ExternalDeviceRunningAmount: data?.ExternalDeviceRunningAmount ?? 0,
        OutPlanProductionAmount: data?.OutPlanProductionAmount ?? 0,
        PlanProductionAmount: data?.PlanProductionAmount ?? 0,
        RealExternalProductionAmount: data?.RealExternalProductionAmount ?? 0,
        RealProductionAmount: data?.RealProductionAmount ?? 0,
      };
    },
  },
};
</script>
 
<style scoped lang="scss"></style>