children.vue
9.23 KB
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
<template>
<div class="children-body">
<div class="children-top-container" id="scrollBox">
<!-- WMS 模块 → 满足条件后 禁用!-->
<div class="children-item">
<div class="children-title">WMS</div>
<div class="square-box">
<!-- <button @mousedown="handleDown" @mouseup="handleUp" @mouseleave="handleUp" :class="{ disabled: isDeviceTaskReceived }">更改优先级</button>
<button @mousedown="handleDown" @mouseup="handleUp" @mouseleave="handleUp" :class="{ disabled: isDeviceTaskReceived }">下发任务</button> -->
<button @mousedown="handleDown" @mouseup="handleUp" @mouseleave="handleUp" :class="{ disabled: isDeviceTaskReceived }">取消任务</button>
</div>
</div>
<!-- WCS 模块 → 永远不禁用!正常使用!-->
<div class="children-item" v-if="isWcsTaskReceived">
<div class="children-title">WCS</div>
<div class="square-box">
<button @mousedown="handleDown" @mouseup="handleUp" @mouseleave="handleUp">复位</button>
</div>
</div>
<!-- 执行设备 模块 → 根据接口获取权限!-->
<div class="children-item" v-if="isequipment">
<div class="children-title">{{ titleEquipment }}</div>
<div class="square-box">
<button v-for="(item, index) in equipmentData" :key="index" @mousedown="handleDown" @mouseup="handleUp" @mouseleave="handleUp">{{ item.buttonName }}</button>
</div>
</div>
<!-- 开始库位 模块 → 根据接口获取权限!-->
<div class="children-item" v-if="isendLocationt">
<div class="children-title">{{ titlestartLocationt }}</div>
<div class="square-box">
<button v-for="(item, index) in startLocationtData" :key="index" @mousedown="handleDown" @mouseup="handleUp" @mouseleave="handleUp">{{ item.buttonName }}</button>
</div>
</div>
<!-- 结束库位 模块 → 根据接口获取权限!-->
<div class="children-item" v-if="isstartLocationt">
<div class="children-title">{{ titleendLocationt }}</div>
<div class="square-box">
<button v-for="(item, index) in endLocationtData" :key="index" @mousedown="handleDown" @mouseup="handleUp" @mouseleave="handleUp">{{ item.buttonName }}</button>
</div>
</div>
</div>
</div>
</template>
<script>
export default {
props: {
qustData: {
type: Array,
default: () => [],
},
},
data() {
return {
baseUrlOffOne: 'http://127.0.0.1:6002/api/BulletinBoard/Mes/V1/ReadData1',
baseUrlOnLineOne: window.appConfig.baseUrlintTotalConversion,
sysData: {},
isLongPress: false,
pressTimer: null,
equipmentData: [],
startLocationtData: [],
endLocationtData: [],
titleEquipment: '', //执行设备
titlestartLocationt: '', //开始库位
titleendLocationt: '', //结束库位
isDeviceTaskReceived: false,
isWcsTaskReceived: false,
isequipment: false,
isendLocationt: false,
isstartLocationt: false,
lastExecutionEquipmentId: null,
}
},
watch: {
qustData: {
immediate: true,
deep: true,
handler(newVal) {
//控制WMS,WCS
this.permission(newVal)
//控制设备模块
this.equipment(newVal)
//控制开始模块
// this.startLocation(newVal)
//控制结束模块
// this.endLocation(newVal)
},
},
},
mounted() {
const scrollBox = document.getElementById('scrollBox')
scrollBox.addEventListener('wheel', (e) => {
e.preventDefault()
scrollBox.scrollLeft += e.deltaY * 1.5
})
},
methods: {
permission(newVal) {
// 设备接收任务 → 只控制 WMS 按钮禁用
const deviceTaskItem = newVal.find((item) => item.key === '设备接收任务')
this.isDeviceTaskReceived = !!(deviceTaskItem && (deviceTaskItem.value ?? '').trim() !== '')
// WCS 接收任务 → 控制显示隐藏
const wcsTaskItem = newVal.find((item) => item.key === 'WCS接收任务')
this.isWcsTaskReceived = !!(wcsTaskItem && (wcsTaskItem.value ?? '').trim() !== '')
},
equipment(newVal) {
// 1. 先判断newVal是否有值,避免数组越界
// if (!newVal || newVal.length === 0) {
// this.isequipment = false
// this.lastExecutionEquipmentId = null // 重置缓存
// return
// }
// // 2. 获取当前的executionEquipmentId
// const currentId = newVal[0].executionEquipmentId
// // 3. 对比当前值与上一次缓存值:无变化则直接返回
// if (currentId === this.lastExecutionEquipmentId) {
// return
// }
// // 4. 有变化时更新缓存值
// this.lastExecutionEquipmentId = currentId
if (newVal[0].executionEquipmentId == null) {
this.isequipment = false
} else {
this.titleEquipment = newVal[0].executionEquipmentId
const opt = {
urlSuffix: window.baseOnLineOrOff ? this.baseUrlOnLineOne : this.baseUrlOffTwo,
logTitle: '执行设备',
isUrlALL: true,
headers: window.baseOnLineOrOff,
header: window.baseOnLineOrOff,
type: 'post',
data: {
requestMethod: 'post',
requestUrl: '/api/Button/GetEquipmentButtonByEquipmentIDs',
requestService: 'WCS',
requestBody: [newVal[0].executionEquipmentId],
},
}
const callBackFn = (res) => {
const realList = Object.values(res.data.data)[0] || []
if (realList.length != 0) {
this.equipmentData = realList
this.isequipment = true
}
}
''.ajax(this, opt, callBackFn)
}
},
startLocation(newVal) {
if (newVal[0].fromLocation == null) {
this.isendLocationt = false
} else {
this.titlestartLocationt = newVal[0].fromLocation
const opt = {
urlSuffix: window.baseOnLineOrOff ? this.baseUrlOnLineOne : this.baseUrlOffTwo,
logTitle: '开始库位',
isUrlALL: true,
headers: window.baseOnLineOrOff,
header: window.baseOnLineOrOff,
type: 'post',
data: {
requestMethod: 'post',
requestUrl: '/api/Button/GetEquipmentButtonByEquipmentIDs',
requestService: 'WCS',
requestBody: [newVal[0].fromLocation],
},
}
const callBackFn = (res) => {
const realList = Object.values(res.data.data)[0] || []
if (realList.length != 0) {
this.startLocationtData = realList
this.isendLocationt = true
}
}
''.ajax(this, opt, callBackFn)
}
},
endLocation(newVal) {
if (newVal[0].toLocation == null) {
this.isstartLocationt = false
} else {
this.titleendLocationt = newVal[0].toLocation
const opt = {
urlSuffix: window.baseOnLineOrOff ? this.baseUrlOnLineOne : this.baseUrlOffTwo,
logTitle: '目标库位',
isUrlALL: true,
headers: window.baseOnLineOrOff,
header: window.baseOnLineOrOff,
type: 'post',
data: {
requestMethod: 'post',
requestUrl: '/api/Button/GetEquipmentButtonByEquipmentIDs',
requestService: 'WCS',
requestBody: [newVal[0].toLocation],
},
}
const callBackFn = (res) => {
const realList = Object.values(res.data.data)[0] || []
if (realList.length != 0) {
this.endLocationtData = realList
this.isstartLocationt = true
}
}
''.ajax(this, opt, callBackFn)
}
},
// ajaxSuccessDataBefore(res, title) {
// const dynamicData = Object.values(res.data)[0] || []
// console.log(dynamicData, '123')
// if (!res.data || res.data.result == null || res.data.result.length === 0) {
// this.sysData = []
// ''.Log(`${title}无数据`, 'getData')
// return false
// }
// return true
// },
// 长按
handleDown() {
this.isLongPress = false
clearTimeout(this.pressTimer)
this.pressTimer = setTimeout(() => {
this.isLongPress = true
this.apiLongPress()
}, 500)
},
// 松开
handleUp() {
clearTimeout(this.pressTimer)
if (this.isLongPress) {
this.apiRelease()
}
this.isLongPress = false
},
apiLongPress() {
console.log('长按触发')
},
apiRelease() {
console.log('松开触发')
},
},
}
</script>
<style scoped>
.children-body {
width: 100%;
height: 100%;
color: #f0f0f5;
font-size: 1vw;
display: flex;
flex-direction: column;
padding: 0;
box-sizing: border-box;
overflow: hidden;
}
.children-top-container {
width: 100%;
height: 100%;
display: flex;
gap: 0.6vw;
overflow-x: auto;
overflow-y: hidden;
-webkit-overflow-scrolling: touch;
scrollbar-width: none;
-ms-overflow-style: none;
}
.children-top-container::-webkit-scrollbar {
display: none;
}
.children-item {
flex: 0 0 auto;
width: 17.2vw;
height: 100%;
background-color: #3f5675;
border-radius: 0.3vw;
box-shadow: 0 0 1.2vw rgba(0, 0, 0, 0.2);
display: flex;
flex-direction: column;
overflow: hidden;
}
.children-title {
height: 1vw;
color: #ffffff;
font-size: 1vw;
font-weight: 600;
display: flex;
align-items: center;
padding: 0.5vw 0 0.4vw 0.65vw;
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
}
.square-box {
flex: 1;
background-color: #3f5675;
padding: 0vw 0.4vw;
box-sizing: border-box;
display: flex;
flex-wrap: wrap;
column-gap: 0.4vw;
row-gap: 0.4vw;
align-items: flex-start;
justify-content: flex-start;
align-content: flex-start;
}
.square-box button {
width: 8vw;
height: 3vw;
font-size: 0.9vw;
border: none;
border-radius: 0.3vw;
background: #fff;
color: #000;
cursor: pointer;
}
/* 禁用样式 */
.square-box button.disabled {
background: #999 !important;
color: #ccc !important;
cursor: not-allowed !important;
}
.square-box button:active {
background-color: #5a98e6;
}
</style>