1
z8018
2025-05-05 b6837f097e9cdb2645368aed4ddb03f580c331e4
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
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
<template>
  <div class="bigdata-container" ref="bigdataContainer">
    <div
      class="bigdata"
      v-for="item in contentData"
      :key="item.stationCode"
      :id="item.stationCode"
      @click="handleClick"
    >
      <h1>{{ item.stationCode }}--{{ item.orderData.length > 0 ?item.orderData[0].orderCode +"-"+ item.orderData[0].cusName + "-" +item.orderData[0].orderName : '暂无订单'}}</h1>
      <!-- <h1></h1> -->
      <div class="bigdata-content">
        <div class="content-item" :data-value="item.stationSortedNum">工位数</div>
        <div class="content-item" :data-value="item.sortedNum">已分拣</div>
        <div class="content-item" :data-value="item.unsortedNum">未分拣</div>
        <div class="content-item" :data-value="item.orderTotalNum">订单数</div>
      </div>
      <div class="bigdata-table">
        <table>
          <thead>
            <tr>
              <th>订单号</th>
              <th>客户名</th>
              <th>订单名</th>
              <th>批次</th>
              <th>工件名</th>
            </tr>
          </thead>
          <tbody>
            <tr v-for="(order,index) in item.orderData" :key="index">
              <td>{{ order.orderCode }}</td>
              <td>{{ order.cusName }}</td>
              <td>{{ order.orderName }}</td>
              <td>{{ order.batch }}</td>
              <td>{{ order.productName }}</td>
            </tr>
          </tbody>
        </table>
      </div>
      <div :id="item.stationCode + '-modal'" class="modal-overlay">
        <div class="modal-content">请放行</div>
      </div>
    </div>
  </div>
</template>
<script>
import { useRoute } from "vue-router";
export default {
  name: "bigdata",
  data() {
    return {
      client: null, // WebSocket客户端对象
      deviceCode: "",
      contentData: [
        // {
        //   stationCode: "C011",
        //   orderTotalNum: 9999,
        //   sortedNum: 1111,
        //   unsortedNum: 8888,
        //   orderData: [
        //     {
        //       orderCode: "A00001",
        //       cusName: "客户A",
        //       orderName: "订单A",
        //       batch: "批次A",
        //       productName: "产品A"
        //     }
        //   ]
        // },
        // {
        //   stationCode: "C012",
        //   orderTotalNum: 9999,
        //   sortedNum: 1111,
        //   unsortedNum: 8888,
        //   orderData: [
        //     {
        //       orderCode: "A00001",
        //       cusName: "客户A",
        //       orderName: "订单A",
        //       batch: "批次A",
        //       productName: "产品A"
        //     }
        //   ]
        // },
        // {
        //   stationCode: "C013",
        //   orderTotalNum: 9999,
        //   sortedNum: 1111,
        //   unsortedNum: 8888,
        //   orderData: [
        //     {
        //       orderCode: "A00001",
        //       cusName: "客户A",
        //       orderName: "订单A",
        //       batch: "批次A",
        //       productName: "产品A"
        //     }
        //   ]
        // },
        // {
        //   stationCode: "C014",
        //   orderTotalNum: 9999,
        //   sortedNum: 1111,
        //   unsortedNum: 8888,
        //   orderData: [
        //     {
        //       orderCode: "A00001",
        //       cusName: "客户A",
        //       orderName: "订单A",
        //       batch: "批次A",
        //       productName: "产品A"
        //     }
        //   ]
        // },
        // {
        //   stationCode: "C015",
        //   orderTotalNum: 9999,
        //   sortedNum: 1111,
        //   unsortedNum: 8888,
        //   orderData: [
        //     {
        //       orderCode: "A00001",
        //       cusName: "客户A",
        //       orderName: "订单A",
        //       batch: "批次A",
        //       productName: "产品A"
        //     }
        //   ]
        // },
        // {
        //   stationCode: "C016",
        //   orderTotalNum: 9999,
        //   sortedNum: 1111,
        //   unsortedNum: 8888,
        //   orderData: [
        //     {
        //       orderCode: "A00001",
        //       cusName: "客户A",
        //       orderName: "订单A",
        //       batch: "批次A",
        //       productName: "产品A"
        //     }
        //   ]
        // }
      ]
    };
  },
  created() {
    const route = useRoute();
    const deviceCode = route.query.deviceCode;
    this.deviceCode = deviceCode;
    this.createSocket(window.webConfig.webSocketUrl + deviceCode);
 
    this.getStations(deviceCode);
  },
  methods: {
    modalOverlay(stationCode, show) {
      const modal = document.getElementById(stationCode + "-modal");
      if (modal) {
        if (show) {
          const element = document.getElementById(stationCode); // 获取元素
          modal.style.display = "flex"; // 显示遮罩层
          modal.style.left = element.offsetLeft + "px"; // 设置遮罩层位置
          modal.style.top = element.offsetTop + "px"; // 设置遮罩层位置
          modal.style.width = element.offsetWidth + "px"; // 设置遮罩层宽度
          modal.style.height = element.offsetHeight + "px"; // 设置遮罩层高度
        } else {
          modal.style.display = "none"; // 隐藏遮罩层
        }
        // modal.classList.add("modal-blink"); // 添加闪烁效果
      }
    },
    handleClick() {
      const parent = event.target.closest(".bigdata");
      parent.classList.remove("flash-bg");
      void parent.offsetWidth; // 强制DOM重绘
      parent.classList.add("flash-bg");
 
      const stationCode = parent.id;
      this.modalOverlay(stationCode, true); // 显示遮罩层
 
      setTimeout(() => {
        this.modalOverlay(stationCode, false); // 隐藏遮罩层
      }, 10000); // 2秒后隐藏遮罩层
    },
    handleBackgroundColor(stationCode) {
      const element = document.getElementById(stationCode);
      if (element) {
        element.classList.remove("flash-bg");
        void element.offsetWidth; // 强制DOM重绘
        element.classList.add("flash-bg");
      }
    },
    clearStationContent(stationCode) {
      this.contentData.find(
        item => item.stationCode === stationCode
      ).orderTotalNum = 0;
      this.contentData.find(
        item => item.stationCode === stationCode
      ).sortedNum = 0;
      this.contentData.find(
        item => item.stationCode === stationCode
      ).unsortedNum = 0;
      this.contentData.find(
        item => item.stationCode === stationCode
      ).stationSortedNum = 0;
      his.contentData.find(
        item => item.stationCode === stationCode
      ).orderData = [];
    },
    createSocket(url) {
      // 创建WebSocket连接
      //"ws://127.0.0.1:9295/admin"
      this.client = new WebSocket(url);
      var _this = this; // 保存this的引用
      this.client.onopen = function() {
        _this.client.onmessage = _this.handleMessage;
        console.log("WebSocket 连接成功");
      };
 
      this.client.onclose = function() {
        console.log("WebSocket 连接关闭");
        setTimeout(_this.createSocket(url), 10000);
      };
 
      this.client.onerror = function() {};
    },
    handleMessage(event) {
      const data = JSON.parse(event.data);
      console.log("收到消息:", event.data);
      if (data.release == 1) {
        this.clearStationContent(data.stationCode);
        this.modalOverlay(data.stationCode, true); // 显示遮罩层
        for (let i = 0; i < this.contentData.length; i++) {
          if (this.contentData[i].orderId === data.data.orderId) {
            this.clearStationContent(this.contentData[i].stationCode);
            this.modalOverlay(this.contentData[i].stationCode, true); // 显示遮罩层
          }
        }
      } else if (data.release == 2) {
        this.clearStationContent(data.stationCode);
        this.modalOverlay(data.stationCode, false); // 隐藏遮罩层
        for (let i = 0; i < this.contentData.length; i++) {
          if (this.contentData[i].orderId === data.data.orderId) {
            this.clearStationContent(this.contentData[i].stationCode);
            this.modalOverlay(this.contentData[i].stationCode, false); // 隐藏遮罩层
          }
        }
      } else {
        this.contentData
          .find(item => item.stationCode === data.stationCode)
          .orderData.push(data.data.orderData);
        this.contentData.find(
          item => item.stationCode === data.stationCode
        ).orderTotalNum = data.data.orderTotalNum;
        this.contentData.find(
          item => item.stationCode === data.stationCode
        ).sortedNum = data.data.sortedNum;
        this.contentData.find(
          item => item.stationCode === data.stationCode
        ).unsortedNum = data.data.unsortedNum;
        this.contentData.find(
          item => item.stationCode === data.stationCode
        ).stationSortedNum = data.data.stationSortedNum;
 
        for (let i = 0; i < this.contentData.length; i++) {
          if (this.contentData[i].orderId === data.data.orderId) {
            this.contentData[i].sortedNum = data.data.sortedNum;
            this.contentData[i].unsortedNum = data.data.unsortedNum;
          }
        }
        this.handleBackgroundColor(data.stationCode);
      }
    },
    getStations(deviceCode) {
      this.http
        .post(
          "/api/Container/GetPutStations?deviceCode=" + deviceCode,
          {},
          true
        )
        .then(x => {
          if (!x.status) return this.$message.error(x.message);
          this.contentData = x.data;
        });
    }
  }
};
</script>
 
<style scoped>
.modal-overlay {
  display: none; /* 默认不显示 */
  position: fixed; /* 全屏定位 */
  background-color: rgba(0, 0, 0, 0.5); /* 半透明黑色遮罩 */
  z-index: 5; /* 确保遮罩在内容之下 */
  opacity: 1; /* 初始完全不透明 */
  animation: modal-overlay 1.5s infinite; /* 1秒闪烁一次,无限次重复 */
}
 
@keyframes modal-overlay {
  0%,
  100% {
    opacity: 1;
  }
  50% {
    opacity: 0;
  }
}
 
.modal-content {
  position: absolute; /* 相对定位 */
  top: 50%; /* 垂直居中 */
  left: 50%; /* 水平居中 */
  transform: translate(-50%, -50%); /* 精确居中 */
  padding: 20px; /* 内边距 */
  border-radius: 10px; /* 圆角 */
  font-size: 20px; /* 字体大小 */
  animation: modal-content 1.5s infinite; /* 1秒闪烁一次,无限次重复 */
  font-family: "Microsoft YaHei", sans-serif; /* 字体样式 */
  color: #f0f0f0; /* 字体颜色 */
}
 
@keyframes modal-content {
  0%,
  100% {
    font-size: 40px;
    color: #f0f0f0;
  }
  50% {
    font-size: 20px;
    color: #000000;
  }
}
 
.bigdata-container {
  width: 100%;
  height: 100%;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  grid-template-rows: repeat(2, 1fr);
  gap: 5px;
  padding: 5px;
  background: #f8f9fa;
}
 
.bigdata {
  background: #ffffff;
  border-radius: 12px;
  box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
  padding: 5px;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  border: 1px solid #e9ecef;
  overflow: hidden; /* 外层容器隐藏溢出 */
  position: relative;
}
 
.flash-bg {
  animation: bg-flash 1s ease-in-out;
  position: relative;
}
 
/* 新增动画保护层 */
.flash-bg::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  border-radius: 5px;
  animation: bg-flash 1s ease-in-out;
  z-index: 1;
}
 
@keyframes bg-flash {
  0%,
  100% {
    background-color: rgba(102, 232, 132, 0);
    z-index: 1;
  }
  50% {
    background-color: rgba(102, 232, 132, 0.4);
    z-index: 2;
  }
}
 
/* 保证内容始终可见 */
.bigdata-content,
.bigdata-table {
  position: relative;
  z-index: 3;
}
 
/* 修复表格容器样式 */
.bigdata-table {
  margin-top: 5px;
  padding-top: 5px;
  border-top: 1px solid #eee;
  flex: 1;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}
 
.bigdata h1 {
  font-size: 14px;
  color: #2d8cf0;
  font-weight: 700;
  margin-bottom: 5px;
  text-shadow: 1px 1px 2px rgba(45, 140, 240, 0.15);
  letter-spacing: 0.5px;
  font-family: "Microsoft YaHei", sans-serif;
}
 
.bigdata-content {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 5px;
  margin: 5px 0;
}
 
.content-item {
  position: relative;
  background: linear-gradient(145deg, #f8f9fa 0%, #e9ecef 100%);
  border-radius: 5px;
  padding: 5px 5px;
  color: #343a40;
  font-size: 20px;
  font-weight: 600;
  display: flex;
  flex-direction: column;
  align-items: center;
  letter-spacing: 0.8px;
  text-shadow: 0 1px 1px rgba(255, 255, 255, 0.9);
  transition: all 0.25s ease;
}
 
.content-item::after {
  content: attr(data-value);
  color: #2d8cf0;
  font-size: 30px;
  font-weight: 800;
  margin-top: 12px;
  text-shadow: 0 2px 4px rgba(45, 140, 240, 0.15);
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}
 
.content-item:hover {
  transform: translateY(-2px);
  box-shadow: 0 3px 8px rgba(0, 0, 0, 0.1);
  color: #2d8cf0;
  text-shadow: 0 2px 4px rgba(45, 140, 240, 0.2);
}
 
.content-item:hover::after {
  transform: scale(1.08);
  text-shadow: 0 4px 8px rgba(45, 140, 240, 0.25);
}
 
.bigdata:hover {
  transform: translateY(-5px) scale(1.02);
  box-shadow: 0 12px 24px rgba(45, 140, 240, 0.15);
  background: linear-gradient(45deg, #f4f9ff 0%, #e6f3ff 100%);
  border-color: #2d8cf0;
}
 
/* 表格整体样式 */
.bigdata-table table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  background: linear-gradient(145deg, #f8f9fa 0%, #e9ecef 100%);
  border-radius: 10px;
  overflow: hidden;
  box-shadow: 0 3px 8px rgba(0, 0, 0, 0.1);
  margin-top: 5px;
  max-height: 290px; /* 根据实际需要调整 */
  display: block;
  overflow-y: hidden; /* 隐藏滚动条 */
}
 
/* 固定表头 */
.bigdata-table thead {
  position: sticky;
  top: 0;
  z-index: 2;
  background: linear-gradient(145deg, #e6f3ff 0%, #d4e7ff 100%);
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
  opacity: 1;
}
 
/* 调整tbody显示高度 */
.bigdata-table tbody {
  max-height: calc(100% - 40px); /* 减去表头高度 */
  display: block;
  overflow-y: hidden;
  width: 100%;
}
 
/* 主内容区 */
.bigdata-table tbody:first-child {
  position: relative;
}
 
/* 克隆数据区 */
.bigdata-table tbody:last-child {
  top: 100%;
  transform: translateY(-45px); /* 初始位置补偿 */
}
 
/* 鼠标悬停暂停 */
.bigdata-table:hover tbody {
  animation-play-state: paused;
}
 
/* 修正表格布局 */
.bigdata-table tr {
  display: table;
  width: 100%;
  table-layout: fixed;
}
 
/* 表头样式 */
.bigdata-table th {
  background: linear-gradient(145deg, #e6f3ff 0%, #d4e7ff 100%);
  color: #2d8cf0;
  font-weight: 600;
  padding: 5px 12px;
  border-bottom: 2px solid #2d8cf0;
  letter-spacing: 0.5px;
  font-size: 12px;
}
 
/* 表格单元格 */
.bigdata-table td {
  padding: 12px;
  border-bottom: 1px solid rgba(233, 236, 239, 0.8);
  color: #495057;
  font-size: 12px;
  transition: all 0.25s ease;
}
 
/* 行悬停效果 */
.bigdata-table tr:hover td {
  background-color: rgba(45, 140, 240, 0.05);
  transform: translateX(4px);
}
 
/* 首列加粗 */
/* .bigdata-table td:first-child {
  font-weight: 500;
  color: #2d8cf0;
} */
 
/* 最后一行去底线 */
.bigdata-table tr:last-child td {
  border-bottom: none;
}
 
/* 滚动条美化 */
.bigdata-table::-webkit-scrollbar {
  width: 6px;
  height: 6px;
  background-color: #f8f9fa;
}
 
.bigdata-table th,
.bigdata-table td {
  text-align: center;
  vertical-align: middle;
}
 
/* 表头样式增加过渡效果 */
.bigdata-table th {
  transition: all 0.3s ease;
}
 
/* 调整首列样式 */
.bigdata-table td:first-child {
  font-weight: 500;
  color: #2d8cf0;
  text-align: left; /* 首列保持左对齐 */
  padding-left: 5px; /* 增加左侧间距 */
}
 
/* 最后单元格右对齐 */
.bigdata-table td:last-child {
  text-align: right;
  padding-right: 5px;
}
 
@keyframes scroll {
  0% {
    transform: translateY(0);
  }
  100% {
    transform: translateY(calc(-100% + 45px)); /* 最后一行高度补偿 */
  }
}
 
tbody {
  animation: scroll 30s linear infinite;
}
</style>