Blame view

HHECS.Web/src/views/main/components/DeviceMonitor.vue 6.67 KB
王硕 authored
1
<template>
胡菁 authored
2
  <el-container class="device-monitor">
胡菁 authored
3
    <el-aside width="225px">
胡菁 authored
4
5
6
7
8
      <el-card class="box-card">
        <div slot="header" class="clearfix">
          <span>概览</span>
        </div>
        <div class="container">
胡菁 authored
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
          <div
            v-for="(item, index) in overyviewsList"
            :key="item.code"
            class="text item"
          >
            <div
              :style="
                index == 0
                  ? 'background-color:#1E9FFF'
                  : index == 1
                  ? 'background-color:#009688'
                  : index == 2
                  ? 'background-color:#FFB800'
                  : 'background-color:#1E9FFF'
              "
            >
胡菁 authored
25
26
              <el-row>
                <el-col :span="14">
胡菁 authored
27
                  {{ item.name }}
胡菁 authored
28
29
30
                </el-col>
                <el-col :span="10">
                  <!-- <br/> -->
胡菁 authored
31
                  <span>{{ item.description }}</span>
胡菁 authored
32
33
                </el-col>
              </el-row>
胡菁 authored
34
35
36
37
            </div>
          </div>
        </div>
      </el-card>
胡菁 authored
38
      <el-card class="box-card device-info">
胡菁 authored
39
40
41
        <div slot="header" class="clearfix">
          <span>设备概览</span>
        </div>
胡菁 authored
42
43
44
45
46
47
        <el-divider
          v-if="srmList.length > 0"
          content-position="center"
          style="width: 100vw"
          >堆垛机</el-divider
        >
胡菁 authored
48
49
50
        <el-tag
          v-for="item in srmList"
          :key="item.name"
胡菁 authored
51
          :type="getTagType(item)"
胡菁 authored
52
          effect="dark"
胡菁 authored
53
54
          class="tag-item"
        >
胡菁 authored
55
56
          {{ item.name }}
        </el-tag>
胡菁 authored
57
58
59
        <el-divider v-if="stationList.length > 0" content-position="center"
          >站台</el-divider
        >
胡菁 authored
60
61
62
        <el-tag
          v-for="item in stationList"
          :key="item.name"
胡菁 authored
63
          :type="getTagTypePort(item)"
胡菁 authored
64
          effect="dark"
胡菁 authored
65
66
          class="tag-item"
        >
胡菁 authored
67
68
          {{ item.name }}
        </el-tag>
胡菁 authored
69
70
71
        <el-divider v-if="rgvList.length > 0" content-position="center"
          >RGV</el-divider
        >
胡菁 authored
72
73
74
        <el-tag
          v-for="item in rgvList"
          :key="item.name"
胡菁 authored
75
          :type="getTagType(item)"
胡菁 authored
76
          effect="dark"
胡菁 authored
77
78
          class="tag-item"
        >
胡菁 authored
79
80
          {{ item.name }}
        </el-tag>
胡菁 authored
81
82
83
        <el-divider v-if="crgvList.length > 0" content-position="center"
          >CRGV</el-divider
        >
胡菁 authored
84
85
86
        <el-tag
          v-for="item in crgvList"
          :key="item.name"
胡菁 authored
87
          :type="getTagTypePort(item)"
胡菁 authored
88
          effect="dark"
胡菁 authored
89
90
          class="tag-item"
        >
胡菁 authored
91
92
          {{ item.name }}
        </el-tag>
胡菁 authored
93
94
      </el-card>
    </el-aside>
胡菁 authored
95
    <el-main>
胡菁 authored
96
      <map-module ref="map" />
胡菁 authored
97
    </el-main>
胡菁 authored
98
  </el-container>
王硕 authored
99
100
101
</template>

<script>
胡菁 authored
102
103
104
105
106
107
108
109
import {
  getCRGVInfo,
  getOverviews,
  getRGVInfo,
  getSRMInfo,
  getStationMonitorInfo,
} from "@/api/main";
import MapModule from "@/components/MapModule";
王硕 authored
110
111
export default {
  name: "DeviceMonitor",
胡菁 authored
112
  components: {
胡菁 authored
113
    MapModule,
胡菁 authored
114
  },
王硕 authored
115
  data() {
胡菁 authored
116
    return {
胡菁 authored
117
      //详情列表
胡菁 authored
118
      overyviewsList: [],
胡菁 authored
119
      //堆垛机列表
胡菁 authored
120
      srmList: [],
胡菁 authored
121
      //站台列表
胡菁 authored
122
      stationList: [],
胡菁 authored
123
      //rgv列表
胡菁 authored
124
      rgvList: [],
胡菁 authored
125
      //crgv列表
胡菁 authored
126
      crgvList: [],
胡菁 authored
127
      interval: null,
胡菁 authored
128
      isCurrentTab: false,
胡菁 authored
129
      isOpenServer: false,
胡菁 authored
130
131
    };
  },
胡菁 authored
132
133
134
135
136
137
138
139
140
141
  props: {
    // 定义接收的 startDeal 变量
    startDeal: {
      type: Boolean,
      default: false,
    },
  },
  watch: {
    // 监听 startDeal 变量的变化
    startDeal(newValue, oldValue) {
胡菁 authored
142
143
      // console.log('处理状态发生变化:', newValue);
      this.isOpenServer = newValue;
胡菁 authored
144
145
      if (this.isCurrentTab) {
        if (newValue) {
胡菁 authored
146
          this.start();
胡菁 authored
147
        } else {
胡菁 authored
148
149
150
          this.stop();
        }
      }
胡菁 authored
151
152
    },
  },
胡菁 authored
153
  beforeDestroy() {
胡菁 authored
154
    clearInterval(this.interval);
胡菁 authored
155
  },
胡菁 authored
156
  mounted() {
胡菁 authored
157
    // console.log(this.$dict);
胡菁 authored
158
159
160
  },
  methods: {
    //开始刷新数据
胡菁 authored
161
    start() {
胡菁 authored
162
      this.isCurrentTab = true;
胡菁 authored
163
      if (this.isOpenServer) {
胡菁 authored
164
165
166
167
168
        // this.srmList = window.srmData;
        // this.rgvList = window.rgvData;
        // this.stationList = window.stationData;
        // // console.log(this.srmList, this.rgvList, this.stationList)
        // this.$refs.map.updateData(this.srmList, this.rgvList, this.stationList);
胡菁 authored
169
胡菁 authored
170
        this.interval = setInterval(() => {
胡菁 authored
171
          getOverviews().then((response) => {
胡菁 authored
172
173
174
            // console.log(response);
            this.overyviewsList = response.data;
          });
胡菁 authored
175
          getSRMInfo().then((response) => {
胡菁 authored
176
177
            this.srmList = response.data;
          });
胡菁 authored
178
          getRGVInfo().then((response) => {
胡菁 authored
179
180
            this.rgvList = response.data;
          });
胡菁 authored
181
          getCRGVInfo().then((response) => {
胡菁 authored
182
183
            this.crgvList = response.data;
          });
胡菁 authored
184
          getStationMonitorInfo().then((response) => {
胡菁 authored
185
186
            this.stationList = response.data;
          });
胡菁 authored
187
188
189
190
191
192
193
          this.$refs.map.updateData(
            this.srmList,
            this.rgvList,
            this.stationList
          );
        }, 3000);
      }
胡菁 authored
194
195
    },
    //停止刷新数据
胡菁 authored
196
    stop() {
胡菁 authored
197
      this.isCurrentTab = false;
胡菁 authored
198
      clearInterval(this.interval);
胡菁 authored
199
200
201
202
203
    },

    getTagType(item) {
      if (item.operationModel == "5") {
        if (item.totalError == "True") {
胡菁 authored
204
          return "danger"; // 报警
胡菁 authored
205
        } else {
胡菁 authored
206
207
208
209
210
          if (
            item.fork1TaskExcuteStatus == "2" ||
            item.fork1TaskExcuteStatus == "3"
          ) {
            return ""; // 正常
胡菁 authored
211
          } else if (item.fork1TaskExcuteStatus == "1") {
胡菁 authored
212
            return "success"; // 待机
胡菁 authored
213
          } else {
胡菁 authored
214
            return "danger"; // 报警
胡菁 authored
215
216
217
          }
        }
      } else {
胡菁 authored
218
        return "warning"; // 非自动
胡菁 authored
219
220
221
222
223
224
      }
    },

    getTagTypePort(item) {
      if (item.stationMonitorAutomation == "1") {
        if (item.stationError == "1") {
胡菁 authored
225
          return "danger"; // 报警
胡菁 authored
226
227
        } else {
          if (item.stationMonitorOccupied == "1") {
胡菁 authored
228
            return ""; // 正常
胡菁 authored
229
          } else {
胡菁 authored
230
            return "success"; // 报警
胡菁 authored
231
232
233
          }
        }
      } else {
胡菁 authored
234
        return "warning"; // 非自动
胡菁 authored
235
      }
胡菁 authored
236
    },
王硕 authored
237
238
239
240
241
  },
};
</script>

<style lang="scss" scoped>
胡菁 authored
242
243
244
.container {
  width: 100%;
}
胡菁 authored
245
胡菁 authored
246
247
248
249
.text {
  font-size: 14px;
  color: white;
}
胡菁 authored
250
胡菁 authored
251
252
253
254
.text span {
  font-size: 16px;
  font-weight: bolder;
}
胡菁 authored
255
胡菁 authored
256
257
258
259
260
261
262
.item {
  border: 1px black solid;
  text-align: center;
  width: 100%;
  line-height: 3vh;
  margin-bottom: 5px;
}
胡菁 authored
263
胡菁 authored
264
265
266
267
268
.clearfix {
  height: 14px;
  font-size: 14px;
  color: #409eff;
}
胡菁 authored
269
胡菁 authored
270
271
272
.tag-item {
  margin: 0px 5px 5px 0px;
}
胡菁 authored
273
胡菁 authored
274
275
276
277
278
279
.device-info {
  display: flex;
  flex-wrap: wrap; // 允许元素换行
  max-height: 70vh; // 设置最大高度,超出显示滚动条
  overflow-y: auto; // 超出最大高度时显示纵向滚动条
}
王硕 authored
280
</style>
胡菁 authored
281
282
283

<style>
.device-monitor {
胡菁 authored
284
  .el-card__body {
胡菁 authored
285
286
287
288
    width: 225px;
  }
}
</style>