helongyang
2 天以前 cb25acc46bf41863e068b6f968f1592b7a14d1c9
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
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
<template>
  <div id="title">
    <div id="bkuang" style="border-top: none">
      <div class="skuang">
        <div class="zhuname">油墨仓堆垛机</div>
        <div class="zhankuang">
          <div class="xname">堆垛机状态:</div>
          <div class="xzhi" :title="data.R_YM_Status">{{ data.R_YM_Status }}</div>
        </div>
        <div class="zhankuang">
          <div class="xname">堆垛机手自动状态:</div>
          <div class="xzhi" :title="data.R_YM_AutoStatus">{{ data.R_YM_AutoStatus }}</div>
        </div>
        <div class="zhankuang">
          <div class="xname">正在执行的任务号:</div>
          <div class="xzhi" :title="data.R_YM_TaskNum">{{ data.R_YM_TaskNum }}</div>
        </div>
        <div class="zhankuang">
          <div class="xname">堆垛机工作状态:</div>
          <div class="xzhi" :title="data.R_YM_WorkStatus">{{ data.R_YM_WorkStatus }}</div>
        </div>
        <div class="zhankuang">
          <div class="xname">作业类型:</div>
          <div class="xzhi" :title="data.R_YM_WorkType">{{ data.R_YM_WorkType }}</div>
        </div>
        <div class="zhankuang">
          <div class="xname">托盘类型:</div>
          <div class="xzhi" :title="data.R_YM_TrayType">{{ data.R_YM_TrayType }}</div>
        </div>
      </div>
      <div class="skuang">
        <div class="zhuname">出入库9001站台</div>
        <div class="zhankuang">
          <div class="xname">有货(读):</div>
          <div class="xzhi" :title="data.R_YM_Tray1">{{ data.R_YM_Tray1 }}</div>
        </div>
        <div class="zhankuang">
          <div class="xname">入库执行中(读):</div>
          <div class="xzhi" :title="data.R_YM_Inbounding1">{{ data.R_YM_Inbounding1 }}</div>
        </div>
        <div class="zhankuang">
          <div class="xname">提升机空闲(读):</div>
          <div class="xzhi" :title="data.R_YM_Leisure1">{{ data.R_YM_Leisure1 }}</div>
        </div>
        <div class="zhankuang">
          <div class="xname">出库执行中(读):</div>
          <div class="xzhi" :title="data.R_YM_Outbounding1">{{ data.R_YM_Outbounding1 }}</div>
        </div>
        <div class="zhankuang">
          <div class="xname">申请入库(写):</div>
          <div class="xzhi" :title="data.W_YM_RequestIn1">{{ data.W_YM_RequestIn1 }}</div>
        </div>
        <div class="zhankuang">
          <div class="xname">申请出库(写):</div>
          <div class="xzhi" :title="data.W_YM_RequestOut1">{{ data.W_YM_RequestOut1 }}</div>
        </div> 
      </div>
      
      <div class="skuang">
        <div class="zhuname">出入库9002站台</div>
        <div class="zhankuang">
          <div class="xname">有货(读):</div>
          <div class="xzhi" :title="data.R_YM_Tray2">{{ data.R_YM_Tray2 }}</div>
        </div>
        <div class="zhankuang">
          <div class="xname">入库执行中(读):</div>
          <div class="xzhi" :title="data.R_YM_Inbounding2">{{ data.R_YM_Inbounding2 }}</div>
        </div>
        <div class="zhankuang">
          <div class="xname">提升机空闲(读):</div>
          <div class="xzhi" :title="data.R_YM_Leisure2">{{ data.R_YM_Leisure2 }}</div>
        </div>
        <div class="zhankuang">
          <div class="xname">出库执行中(读):</div>
          <div class="xzhi" :title="data.R_YM_Outbounding2">{{ data.R_YM_Outbounding2 }}</div>
        </div>
        <div class="zhankuang">
          <div class="xname">申请入库(写):</div>
          <div class="xzhi" :title="data.W_YM_RequestIn2">{{ data.W_YM_RequestIn2 }}</div>
        </div>
        <div class="zhankuang">
          <div class="xname">申请出库(写):</div>
          <div class="xzhi" :title="data.W_YM_RequestOut2">{{ data.W_YM_RequestOut2 }}</div>
        </div>
      </div>
    </div>
    
  </div>
</template>
 
<script>
import { ref, nextTick } from "vue";
import { useStore } from "vuex";
import { onMounted } from "vue";
 
export default {
  data() {
    return {
      xuan: 0
    };
  },
  methods: {
  },
  setup() {
    const store = useStore();
    const data = ref({});
 
    // 1. 定义普通字段的映射规则
    const statusMap = {
      R_YM_Status: {
        1: "正常",
        2: "故障",
        3: "急停",
      },
      R_YM_AutoStatus: {
        0: "维修",
        1: "手动",
        2: "半自动",
        3: "自动",
      },
      R_YM_WorkStatus: {
        0: "待机",
        1: "取货中",
        2: "取货完成",
        4: "放货中",
        5: "放货完成",
        6: "任务完成",
      },
      R_YM_WorkType: {
        0: "无作业任务(0)",
        1: "取放货作业(1)",
        2: "只取货作业(2)",
        3: "只放货作业(3)",
        4: "移动到指定位置"
      },
      R_YM_TrayType: {
        "-1": "空箱(-1)",
        1: "小托盘(1)",
        2: "中托盘(2)",
        3: "大托盘(3)",
        4: "特大托盘(4)",
      }
    };
 
    // 2. 定义需要共用映射规则的字段列表和对应的映射规则
    const booleanFields = [
      "R_YM_Tray1", "R_YM_Inbounding1",
      "R_YM_Leisure1", "R_YM_Outbounding1",
      "W_YM_RequestIn1", "W_YM_RequestOut1",
      "R_YM_Tray2", "R_YM_Inbounding2",
      "R_YM_Leisure2", "R_YM_Outbounding2",
      "W_YM_RequestIn2", "W_YM_RequestOut2",
    ];
    const booleanMap = {
      true: "是",
      false: "否"
    };
 
    // 处理数据,先处理普通映射,再批量处理共用映射的字段
    const processData = (rawData) => {
      if (!rawData) return {};
      const processed = { ...rawData };
 
      // 处理普通字段映射
      Object.keys(statusMap).forEach(key => {
        if (processed.hasOwnProperty(key)) {
          const map = statusMap[key];
          processed[key] = map[processed[key]] || processed[key];
        }
      });
 
      // 批量处理共用映射规则的字段
      booleanFields.forEach(key => {
        if (processed.hasOwnProperty(key)) {
          processed[key] = booleanMap[processed[key]] || processed[key];
        }
      });
 
      return processed;
    };
 
    onMounted(() => {
      nextTick(() => {
        setInterval(() => {
          const rawData = store.state.homedata;
          data.value = processData(rawData);
          const xian = document.getElementsByClassName("xzhi");
          for (let i = 0; i < xian.length; i++) {
            if (xian[i].innerHTML === "是") {
              xian[i].style.color = "yellow";
            } else if (xian[i].innerHTML === "否") {
              xian[i].style.color = "red";
            }
          }
        });
      });
    });
 
    return {
      data,
    };
  }
};
</script>
 
<style scoped>
.ding {
  float: left;
  width: 20px;
  height: 20px;
  margin-top: 7px;
}
.yan {
  color: white;
  float: left;
  font-size: 25px;
}
.dakuang {
  width: 250px;
  height: 50px;
  position: absolute;
  top: 150px;
  left: 200px;
}
#xiugai {
  width: 100px;
  height: 30px;
  float: left;
  border-radius: 5px;
  text-align: center;
  line-height: 30px;
  cursor: pointer;
  border: 1px solid white;
  color: white;
  background: rgba(255, 255, 255, 0.5);
  font-size: 25px;
  position: absolute;
  top: 150px;
  left: 450px;
}
#xiugai:hover {
  background: #f60;
}
#shu1,
#shu2 {
  width: 200px;
  height: 30px;
  float: left;
  margin-top: 0px;
  margin-right: 0px;
  border-radius: 5px;
  border: 1px solid white;
}
#guan {
  width: 40px;
  height: 40px;
  float: left;
  font-size: 1.1cqw;
  text-align: center;
  line-height: 40px;
  cursor: pointer;
  margin-left: 560px;
  color: white;
  position: absolute;
}
#ti {
  width: 600px;
  height: 300px;
  position: relative;
  background: rgba(255, 255, 255, 1);
  border-radius: 10px;
  top: 230px;
  left: 35%;
  display: none;
  background-image: url("../../img/1.png");
  background-repeat: no-repeat;
  background-size: 170%;
  background-position: -220px 0px;
}
.zhuname {
  width: 100%;
  height: 5vh;
  float: left;
  text-align: center;
  line-height: 50px;
  font-weight: 700;
  font-size: 1.1cqw;
  color: white;
}
.xname {
  width: 70%;
  height: 80px;
  float: left;
  line-height: 7vh;
  font-size: 1.1cqw;
  color: white;
}
.xzhi {
  width: 30%;
  height: 7vh;
  float: left;
  line-height: 50px;
  font-size: 1.1cqw;
  color: rgb(242, 242, 50);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.zhankuang {
  width: 45%;
  height: 3vh;
  margin-top: 10px;
  margin-left: 5%;
  float: left;
}
#title {
  float: left;
  width: 95%;
  height: 88vh;
  margin-top: 40px;
  margin-left: 3%;
  background-image: url("../../img/1.png");
  background-repeat: no-repeat;
  background-size: 100%;
  container-type: inline-size;
}
#bkuang {
  width: 100%;
  height: 55vh;
  float: left;
}
.skuang {
  width: 31%;
  height: 55vh;
  float: left;
  border-top: none;
  border-left: none;
  border-bottom: none;
  background: rgba(255, 255, 255, 0.2);
  margin-left: 1.7%;
  border-radius: 10px;
}
</style>