dengjunjie
2025-04-03 1e12c140c041c0cb52306a0db9ff0ba18354d0d8
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
<template>
  <div>
    <!-- height:40px -->
    <div class="title">库位平面图</div>
 
    <!-- <div>只显示一个区域的一个堆垛机对应的状态</div> -->
    <div class="main" :style="{ height: mian_height }">
      <!-- 平面图显示区域 -->
      <div class="right">
        <div v-for="layer in locationData" :key="layer.index">
          <div class="row_tip">第{{ layer.index }}层</div>
          <div class="row" v-for="row in layer.rows" :key="row.index">
            <el-tooltip
              v-for="col in row.cols"
              :key="col.column"
              effect="dark"
              :content="getTooltipContent(col)"
              placement="top"
              :show-after="200"
              :hide-after="0"
              ><div
                class="item"
                :style="{ 'background-color': GetBgColor(col) }"
              >
                {{ row.index }}-{{ col.column }}-{{ layer.index }}
              </div>
            </el-tooltip>
          </div>
        </div>
      </div>
 
      <!-- 选择提示区域 -->
      <div class="left">
        <!-- <div>区域:</div>
        <el-select
          size="mini"
          filterable
          v-model="Area.shelf_code"
          placeholder="请选择"
        >
          <el-option
            v-for="item in slectData"
            :value="item.shelf_code"
            :label="item.house_name"
            :key="item.house_name"
          ></el-option>
        </el-select> -->
        <!-- <div class="tipText">堆垛机:</div>
        <el-select
          size="mini"
          clearable
          filterable
          @change="SCChange"
          v-model="Area.tunnel"
          placeholder="请选择"
        >
          <el-option
            v-for="item in scList"
            :value="item"
            :label="item"
            :key="item"
          ></el-option>
        </el-select> -->
        <!-- <div class="tipText">层:</div>
        <el-select
          size="mini"
          clearable
          filterable
          @change="SCChange"
          v-model="Area.layer"
          placeholder="请选择"
        >
          <el-option
            v-for="item in layers"
            :value="item"
            :label="item"
            :key="item"
          ></el-option>
        </el-select> -->
        <br />
        <ElButton type="success" class="btn" @click="GetViewData"
          >刷新</ElButton
        >
 
        <div style="margin-top: 80px">
          <div>说明</div>
          <div v-for="item in infoMsg" :key="item.bgcolor">
            <div class="infoMsg" :style="{ 'background-color': item.bgcolor }">
              {{ item.msg }}
            </div>
          </div>
        </div>
      </div>
    </div>
  </div>
</template>
 
<script>
import { ElButton } from "element-plus";
 
export default {
  data() {
    return {
      slectData: [],
      scList: [],
      layers: [],
      Area: { house_name: "", tunnel: "", shelf_code: "" },
      mian_height: "",
      infoMsg: [
        { bgcolor: "lightgreen", msg: "空货位", state: 0 },
        { bgcolor: "orange", msg: "有货", state: "Stored" },
        { bgcolor: "#2BB3D5", msg: "执行中", state: "InAssigned" },
        { bgcolor: "#ccc", msg: "禁用", state: "Lock" },
        { bgcolor: "red", msg: "异常", state: "error" },
        { bgcolor: "#b7ba6b", msg: "空托", state: 99 },
      ],
      locationData: [],
    };
  },
  computed: {
    GetBgColor() {
      return (col) => {
        var bgColor = "#b7ba6b";
        //优先显示禁用状态
        if (col.enalbeStatus == 3) {
          this.infoMsg.forEach((el) => {
            if (el.state == "Lock") {
              bgColor = el.bgcolor;
            }
          });
        } else {
          this.infoMsg.forEach((el) => {
            if (
              col.locationStatus == 4 ||
              col.locationStatus == 6 ||
              col.locationStatus == 7
            ) {
              if (el.state == "InAssigned") {
                bgColor = el.bgcolor;
              }
            } else if (col.locationStatus == 2 || col.locationStatus == 3) {
              if (el.state == "Stored") {
                bgColor = el.bgcolor;
              }
            } else if (el.state == col.locationStatus) {
              bgColor = el.bgcolor;
            }
          });
        }
        return bgColor;
      };
    },
  },
  watch: {
    //切换库区
    "Area.shelf_code"(newValue, oldValue) {
      this.scList = [];
      this.layers = [];
      this.slectData.forEach((e) => {
        if (e.areaName == newValue) {
          this.Area.tunnel = e.tunnel[0];
          this.scList = e.tunnel;
          this.Area.layer = "第" + e.layers[0] + "层";
          this.layers = e.layers;
        }
      });
      this.GetViewData();
    },
  },
  methods: {
    getTooltipContent(col) {
      return [
      `状态: ${this.getStatusText(col.locationStatus)}`,
      `启用状态: ${this.getEnableStatusText(col.enalbeStatus)}`,
      `托盘号: ${col.palletNo || "无"}`
    ].join('\n');
      // return `状态: ${this.getStatusText(col.locationStatus)}
      //         启用状态: ${this.getEnableStatusText(col.enalbeStatus)}
      //         托盘号: ${col.palletNo || "无"}`;
    },
    getStatusText(status) {
      const statusMap = {
        0: "空货位",
        2: "有货",
        3: "有货",
        4: "执行中",
        6: "执行中",
        7: "执行中",
        99: "空托",
      };
      return statusMap[status] || "未知状态";
    },
    getEnableStatusText(status) {
      const enableMap = {
        1: "正常",
        3: "禁用",
      };
      return enableMap[status] || "未知";
    },
    GetViewData() {
      var _this = this;
      this.http
        .post("/api/StockView/GetLocationStockView", {}, "查询中")
        .then((x) => {
          _this.locationData = x.data;
          // console.log("后端返回:", x.data);
          // console.log("返回数据:", _this.locationData);
        });
    },
    // 切换堆垛机
    SCChange() {
      this.GetViewData();
    },
  },
  mounted() {
    var mainHeight = document.getElementById("vol-main");
    this.mian_height = mainHeight.offsetHeight - 40 + "px";
    var _this = this;
    //加载下拉选项
    this.http
      .get("/api/LocationInfo/GetLocationLayer", {}, "查询中")
      .then((x) => {
        _this.slectData = x;
        //加载第一个区域,第一个堆垛机
        _this.Area.shelf_code = _this.slectData[0].areaName;
        _this.scList = _this.slectData[0].tunnel;
        _this.layers = _this.slectData[0].layers;
      });
      this.GetViewData();
  },
  components: { ElButton },
};
</script>
 
<style scoped>
.left {
  height: 100%;
  float: left;
  width: 18%;
  /* background: lightblue; */
  padding-top: 20px;
  padding-left: 20px;
}
 
.right {
  padding: 9px;
  height: 98%;
  overflow-y: auto;
  overflow-x: auto;
  float: left;
  width: 82%;
  padding-top: 5px;
}
 
.title {
  text-align: center;
  padding: 5px 0px;
  font-size: 20px;
  font-weight: bold;
  width: 82%;
}
 
.row_tip {
  font-size: 16px;
  padding-left: 5px;
}
 
.row {
  overflow: auto;
  margin-bottom: 11px;
}
 
.item {
  float: left;
  width: 66px;
  height: 38px;
  margin: 3px;
  background-color: lightblue;
  text-align: center;
  font-size: 14px;
  border-radius: 3px;
  line-height: 38px;
}
 
.tipText {
  margin-top: 10px;
}
 
.btn {
  margin-top: 15px;
}
 
.infoMsg {
  float: left;
  width: 63px;
  height: 35px;
  margin: 3px;
  text-align: center;
  font-size: 14px;
  border-radius: 3px;
  line-height: 38px;
}
</style>
 
<style>
.el-input {
  width: 180px;
}
</style>