1
huanghongfeng
2025-09-12 a1a0c91857b670152ec7d4afa7bc4140953a5e98
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
<template>
  <div style="width: 100%;height: 425px;background-color: #fff;">
 
    <div class="grid-container">
      <div v-for="(item, index) in gridItems.slice(104, 212)" :key="index" class="grid-item" :style="{ 'background-color': GetBgColor(item) }">
      </div>
    </div>
 
 
    <div style="border: 1px solid #fff;width: 100%;height: 85px;background-color: #000;">
      <div :style="{
        background: plcData ? '#228B22' : '#00ffff',
        transition: 'background 3s ease-in-out',
        width: '10%',
        height: '70px',
        marginTop: '7px',
        transition: 'margin-left 10s ease',  // 添加动画效果,平滑过渡
        marginLeft: plcData ? '85%' : '1%',  // 计算margin-left,根据ddjSC值控制位置
        display: 'flex',
        justifyContent: 'center',
        alignItems: 'center',
        borderRadius: '10px'
      }"
      :class="{ 'moving': plcData }">
        <img src="../assets/ddj.png" style="height: 55px;" />
      </div>
    </div>
 
 
    <div class="grid-container">
      <div v-for="(item, index) in gridItems.slice(0, 104)" :key="index" class="grid-item" :style="{ 'background-color': GetBgColor(item) }">
 
      </div>
      
    </div>
  </div>
</template>
 
<script>
import drawMixin from "../utils/drawMixin";
import axios from 'axios';
 
export default {
  mixins: [drawMixin],
  data() {
    return {
      gridItems: [],  // 初始化为空数组
      plcData:false,
      infoMsg: [
        { bgcolor: "", msg: "空货位", state: "0" },
        { bgcolor: "#ff0", msg: "出入库锁定", state: "1" },
        { bgcolor: "orange", msg: "有货", state: "2" },
        { bgcolor: "#4C6E91", msg: "空托锁定", state: "98" },
        { bgcolor: "#76D7C4", msg: "空托盘", state: "99" },
        { bgcolor: "#FF0000", msg: "禁用", state: "100" }
      ],
    }
  },
  computed: {
        
    },
  mounted() {
    this.loadLocalData(); 
    //this.loadLocalSC();
    this.interval2 = setInterval(() => {
      this.loadLocalData();
      
    }, 2000);
    // this.interval = setInterval(() => {
    //   this.loadLocalSC();
    // }, 20000);
    
  },
  beforeDestroy() {
  clearInterval(this.interval2);
  clearInterval(this.interval);
},
  methods: {
    GetBgColor(col) {
      let bgColor = "#b7ba6b";
      // 优先显示禁用状态
      if (col.location_lock) {
        this.infoMsg.forEach((el) => {
          if (el.state == "100") {
            bgColor = el.bgcolor;
          }
        });
      } else {
        this.infoMsg.forEach((el) => {
          if (el.state == col.location_state) {
            bgColor = el.bgcolor;
          }
        });
      }
      return bgColor;
    },
    loadLocalData() {
      axios.post("http://127.0.0.1:9290/api/LocationInfo/GetLocationStatu2").then((x) => {
        this.gridItems = x.data;
      })
    },
    loadLocalSC() {
      axios.post("http://127.0.0.1:9291/api/Task/EquipmentInformationsc").then((res) => {
        this.plcData = res.data;
      })
    }
  }
}
</script>
 
<style lang="scss">
@import '../assets/scss/index.scss';
 
/* 添加渐现动画 */
@keyframes move {
  0% {
    margin-left: 1%;
  }
  50% {
    margin-left: 86%;
  }
  100% {
    margin-left: 1%;
  }
}
 
.moving {
  animation: move 14s infinite ease-in-out;
}
 
.scroll-container {
  width: 85%;
  height: 95px;
  margin: 5px auto;
  border: 1px solid #fff;
  overflow-y: auto;
  /* 添加垂直滚动条 */
  display: flex;
  flex-direction: column;
  /* 垂直排列子元素 */
}
 
.scroll-item {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 95px;
  border-bottom: 1px solid #ddd;
  background-color: aqua;
}
 
.scroll-item img {
  height: 70%;
  margin-right: 10px;
}
 
.scroll-item p {
  margin: 0;
}
</style>