提交 | 用户 | 时间
|
b78728
|
1 |
<template> |
A |
2 |
<div class="app-container"> |
|
3 |
<el-row :gutter="5"> |
|
4 |
<el-col :span="7"> |
140592
|
5 |
<el-card style="height: 72px;padding-top: 9px" shadow="never"> |
b78728
|
6 |
<span class="head-font">工位编号 : {{headContent.processesCode}}</span> |
A |
7 |
<span hidden>{{headContent.inboundTime}}</span> |
|
8 |
</el-card> |
|
9 |
</el-col> |
|
10 |
<el-col :span="7"> |
|
11 |
<el-card shadow="never"> |
140592
|
12 |
<span class="head-font">物料编码 : </span> |
A |
13 |
<el-input style="width: 70%" ref="inputData" v-model="materialCode" @change="materialCodeHandleEnter" placeholder="请扫描总成序列号"></el-input> |
b78728
|
14 |
</el-card> |
A |
15 |
</el-col> |
|
16 |
<el-col :span="10"> |
140592
|
17 |
<el-card style="height: 72px;padding-top: 9px" shadow="never"> |
b78728
|
18 |
<span class="head-font">产品序列号 : {{headContent.sfcCode}}</span> |
A |
19 |
<el-button @click="clearClick" style="float: right" type="danger" size="mini">清除</el-button> |
|
20 |
</el-card> |
|
21 |
</el-col> |
|
22 |
|
|
23 |
</el-row> |
|
24 |
<el-row :gutter="5" style="margin-top: 5px"> |
|
25 |
<el-col :span="24"> |
|
26 |
<el-tabs type="border-card" style="height: 600px" v-model="activeName" @tab-click="changeMenu"> |
|
27 |
<el-tab-pane name="first"> |
|
28 |
<span slot="label"> <a class="el-icon-date"></a>首页</span> |
|
29 |
<el-col :span="24"> |
|
30 |
<el-table height="500" :cell-style="rowStyle" :data="formulaChildList"> |
|
31 |
<el-table-column label="排序" width="60" align="center" type="index"> |
|
32 |
</el-table-column> |
|
33 |
<el-table-column label="操作内容" :show-overflow-tooltip='true' align="center" prop="operationSteps"> |
|
34 |
</el-table-column> |
|
35 |
<el-table-column label="产品编号" align="center" prop="productCode"> |
|
36 |
</el-table-column> |
|
37 |
<el-table-column label="物料编码" align="center" prop="materialCode"> |
|
38 |
</el-table-column> |
|
39 |
<el-table-column label="采集值" align="center" prop="collectData"> |
|
40 |
</el-table-column> |
|
41 |
<el-table-column label="结果" align="center" prop="results"> |
|
42 |
</el-table-column> |
|
43 |
</el-table> |
|
44 |
</el-col> |
|
45 |
</el-tab-pane> |
|
46 |
</el-tabs> |
|
47 |
</el-col> |
|
48 |
</el-row> |
|
49 |
</div> |
|
50 |
</template> |
|
51 |
<script> |
|
52 |
import {getIpv4, listStationConf} from "@/api/main/sc/stationConf"; |
|
53 |
import { |
|
54 |
checkMaterialCode, |
|
55 |
clearWorkpieceRelease, |
|
56 |
fistSetpNumber, |
|
57 |
noPageListFormulaChild, |
|
58 |
workpieceRelease, |
|
59 |
yzUpdateResults, |
|
60 |
yzUpdateTighteningFormula |
|
61 |
} from "@/api/main/bs/formulaChild/formulaChild"; |
|
62 |
import MySerialPort from "@/utils/MySerialPort"; |
|
63 |
import USBDevice from "@/utils/usb.json"; |
|
64 |
import {addPassingStationCollection} from "@/api/main/da/passingStationCollection/passingStationCollection"; |
|
65 |
import { |
|
66 |
addTighteningParameters, preInstallOut, |
|
67 |
replaceAssemblyCode, |
|
68 |
saveCampaignTimeParameters, |
|
69 |
yzAddBasicParameters, |
|
70 |
} from "@/api/main/da/paramCollection/paramCollection"; |
|
71 |
|
|
72 |
export default { |
|
73 |
name: "stationTerminal", |
|
74 |
data() { |
|
75 |
return { |
|
76 |
showInput: true, |
|
77 |
serialPortContent: '', |
|
78 |
// 查询参数 |
|
79 |
formulaChildParams: { |
|
80 |
pageNum: 1, |
|
81 |
pageSize: 10, |
|
82 |
productCode: null, |
|
83 |
processesCode: null, |
|
84 |
}, |
|
85 |
// 配方配置子信息表格数据 |
|
86 |
formulaChildList: [], |
|
87 |
ipAddress: '', |
|
88 |
imgSrc: '', |
|
89 |
headContent: { |
|
90 |
processesCode: 'OP1010', |
|
91 |
processesName: '贴标机-贴码', |
|
92 |
sfcCode: '', |
|
93 |
yzSfcCode: '', |
|
94 |
inboundTime: '', |
|
95 |
}, |
|
96 |
workpieceInformation: { |
|
97 |
workOrderNo: null, |
|
98 |
productCode: null, |
|
99 |
productModel: null, |
|
100 |
productName: null, |
|
101 |
beat: null, |
|
102 |
}, |
|
103 |
// 查询参数 |
|
104 |
queryParams: { |
|
105 |
pageNum: 1, |
|
106 |
pageSize: 10, |
|
107 |
sfcCode: null, |
|
108 |
}, |
|
109 |
// 查询参数 |
|
110 |
StationConfQueryParams: { |
|
111 |
pageNum: 1, |
|
112 |
pageSize: 10, |
|
113 |
ipAddress: null, |
|
114 |
}, |
|
115 |
cakeLamp: { |
|
116 |
plcState: 1, //plc |
|
117 |
scannerState: 1, //扫码枪 |
|
118 |
InPlace: 0, //工件到位 |
|
119 |
scanFinish: 0, |
|
120 |
startWork: 0, |
|
121 |
release: 0 //允许放行 |
|
122 |
}, |
|
123 |
content: '', |
|
124 |
activeName: 'first', |
|
125 |
// url: "ws://10.103.210.248:8080/websocket/message/", |
2b9842
|
126 |
url: "ws://192.168.20.250:8080/websocket/message/", |
b78728
|
127 |
message: "", |
A |
128 |
text_content: "", |
|
129 |
ws: null, |
|
130 |
inputValue: '9', |
|
131 |
|
|
132 |
open1: false, |
|
133 |
input: "", |
|
134 |
keepReading: true, |
|
135 |
form1: { |
|
136 |
baudRate: "115200", |
|
137 |
dataBits: "8", |
|
138 |
stopBits: "1", |
|
139 |
parity: "none", |
|
140 |
flowControl: "none", |
|
141 |
desc: "", |
|
142 |
type: "1", |
|
143 |
isShowHistory: false, |
|
144 |
}, |
|
145 |
btnType: "primary", |
|
146 |
btnText: "连接串口", |
|
147 |
restaurants: [], |
|
148 |
portsList: [], |
|
149 |
isShowSendArea: false, |
|
150 |
readType: 1, |
|
151 |
title: "", |
|
152 |
|
|
153 |
passingStationForm: {}, |
|
154 |
originalArray: [], |
140592
|
155 |
materialCode: '', |
b78728
|
156 |
} |
A |
157 |
}, |
|
158 |
created() { |
140592
|
159 |
this.setFocus() |
A |
160 |
this.initStation() |
b78728
|
161 |
}, |
A |
162 |
methods: { |
140592
|
163 |
|
A |
164 |
materialCodeHandleEnter() { |
|
165 |
if(!this.headContent.sfcCode){ |
|
166 |
this.headContent.sfcCode = this.materialCode |
|
167 |
this.headContent.inboundTime = this.getCurrentTime(); |
|
168 |
this.getList() |
|
169 |
}else { |
|
170 |
this.serialPortMethod(this.materialCode); |
|
171 |
this.$message("扫描物料编码"+this.materialCode); |
|
172 |
this.setFocus(); |
|
173 |
this.materialCode = ''; |
|
174 |
} |
|
175 |
}, |
|
176 |
setFocus(){ |
|
177 |
this.$nextTick(()=>{ |
|
178 |
this.$refs.inputData.focus() |
|
179 |
}) |
|
180 |
}, |
b78728
|
181 |
serialLink() { |
A |
182 |
this.open1 = true |
|
183 |
}, |
|
184 |
Release(){ |
|
185 |
// this.$message('portsList!'+this.portsList.length); |
|
186 |
if(this.btnType === "danger"){ |
|
187 |
this.$message('连接了!'); |
|
188 |
|
|
189 |
}else { |
|
190 |
this.$message('mei连接了!'); |
|
191 |
|
|
192 |
} |
|
193 |
|
|
194 |
}, |
|
195 |
|
|
196 |
getCurrentTime() { |
|
197 |
const now = new Date(); |
|
198 |
const year = now.getFullYear(); |
|
199 |
const month = this.padTimeUnit(now.getMonth() + 1); // 月份是从0开始的 |
|
200 |
const day = this.padTimeUnit(now.getDate()); |
|
201 |
const hours = this.padTimeUnit(now.getHours()); |
|
202 |
const minutes = this.padTimeUnit(now.getMinutes()); |
|
203 |
const seconds = this.padTimeUnit(now.getSeconds()); |
|
204 |
return `${year}-${month}-${day} ${hours}:${minutes}:${seconds}`; |
|
205 |
}, |
|
206 |
padTimeUnit(value) { |
|
207 |
return value.toString().padStart(2, '0'); |
|
208 |
}, |
|
209 |
serialPortMethod(value){ |
|
210 |
let formulaChildParams = { |
|
211 |
scanBarcode: value, |
|
212 |
sfcBarcode: this.headContent.sfcCode, |
140592
|
213 |
workOrderNo: '-', |
A |
214 |
productCode: "9900200461", |
b78728
|
215 |
locationCode: this.headContent.processesCode, |
A |
216 |
collectionTime: new Date() |
|
217 |
} |
|
218 |
yzUpdateResults(formulaChildParams).then(response => { |
|
219 |
this.getListFormulaChild() |
|
220 |
}); |
|
221 |
}, |
|
222 |
rowStyle({ row }) { |
|
223 |
if (row.results === 'OK') { |
|
224 |
return 'background-color: PaleGreen'; |
|
225 |
} else if (row.results === 'NG') { |
|
226 |
return 'background-color: LightSalmon'; |
|
227 |
} |
|
228 |
return ''; |
|
229 |
}, |
|
230 |
/** 查询配方配置子信息列表 */ |
|
231 |
getListFormulaChild() { |
140592
|
232 |
this.formulaChildParams.productCode = "9900200461" |
b78728
|
233 |
this.formulaChildParams.processesCode = this.headContent.processesCode |
A |
234 |
console.log(this.formulaChildParams) |
|
235 |
noPageListFormulaChild(this.formulaChildParams).then(response => { |
|
236 |
this.formulaChildList = response.rows; |
|
237 |
if (this.formulaChildList.length >0){ |
|
238 |
let pos = 0 |
|
239 |
const tempArr = this.formulaChildList.filter(x=> 'OK' === x.results) |
|
240 |
if (tempArr.length>0){ |
|
241 |
pos = tempArr.length |
|
242 |
this.$nextTick(() => { |
|
243 |
let temp33 = document.getElementsByClassName('el-table__row') |
|
244 |
console.log('temp33',temp33) |
|
245 |
console.log('len',temp33.item(pos)) |
|
246 |
if (temp33.length > 0){ |
|
247 |
console.log('1111111111111111') |
|
248 |
let arr = temp33[pos-1] |
|
249 |
console.log('srr',arr) |
|
250 |
arr.scrollIntoView({ block: 'center' }) |
|
251 |
} |
|
252 |
}) |
|
253 |
} |
|
254 |
|
|
255 |
} |
|
256 |
}); |
|
257 |
}, |
|
258 |
endClear(){ |
|
259 |
|
|
260 |
}, |
|
261 |
changeMenu(tab, event) { |
|
262 |
console.log(tab, event); |
|
263 |
}, |
|
264 |
clearClick(){ |
|
265 |
const param = { |
|
266 |
productCode: '1P102S', |
|
267 |
locationCode: this.headContent.processesCode, |
|
268 |
} |
|
269 |
clearWorkpieceRelease(param).then(response => {}); |
99b2ae
|
270 |
|
A |
271 |
|
b78728
|
272 |
this.headContent.sfcCode = '' |
99b2ae
|
273 |
// this.formulaChildList = []; |
140592
|
274 |
this.materialCode = '' |
b78728
|
275 |
this.$message('清除成功!'); |
140592
|
276 |
this.setFocus() |
99b2ae
|
277 |
setTimeout(() => { |
A |
278 |
// 这里是你想要延时后执行的逻辑 |
|
279 |
this.getList() |
|
280 |
}, 500); // 500毫秒 = 0.5秒 |
b78728
|
281 |
}, |
A |
282 |
scanCompleted(){ |
|
283 |
this.$message('扫码完成'+this.content); |
|
284 |
this.headContent.sfcCode = this.content |
|
285 |
this.queryParams.sfcCode = this.content |
|
286 |
this.getList() |
|
287 |
this.getListFormulaChild() |
|
288 |
this.cakeLamp.scanFinish = 1 |
|
289 |
this.cakeLamp.startWork = 1 |
|
290 |
|
|
291 |
}, |
|
292 |
/** 查询工单列表 */ |
|
293 |
async getList() { |
|
294 |
const param = { |
|
295 |
processesCode: this.headContent.processesCode, |
|
296 |
} |
99b2ae
|
297 |
fistSetpNumber(param).then(response => {}); |
b78728
|
298 |
this.getListFormulaChild() |
A |
299 |
// this.addOverStationCollection() |
|
300 |
}, |
|
301 |
|
|
302 |
/** 入站增加过站采集记录 **/ |
|
303 |
addOverStationCollection(){ |
|
304 |
this.passingStationForm = { |
|
305 |
id: null, |
|
306 |
// workOrderNo: this.workpieceInformation.workOrderNo, |
|
307 |
productCode: "1P102S", |
|
308 |
locationCode: this.headContent.processesCode, |
|
309 |
// model: this.workpieceInformation.productModel, |
|
310 |
productBarcode: this.headContent.sfcCode, |
|
311 |
sfcCode: this.headContent.sfcCode, |
|
312 |
inboundTime: new Date() |
|
313 |
} |
|
314 |
addPassingStationCollection(this.passingStationForm).then(response => {}); |
|
315 |
yzAddBasicParameters(this.passingStationForm).then(response => {}); |
|
316 |
}, |
|
317 |
exit() { |
|
318 |
if (this.ws) { |
|
319 |
this.ws.close(); |
|
320 |
this.ws = null; |
|
321 |
} |
|
322 |
}, |
|
323 |
send() { |
|
324 |
if (this.ws) { |
|
325 |
this.ws.send(this.message); |
|
326 |
} else { |
|
327 |
alert("未连接到服务器"); |
|
328 |
} |
|
329 |
}, |
|
330 |
|
|
331 |
initStation: async function () { |
|
332 |
await getIpv4().then(response => { |
|
333 |
this.StationConfQueryParams.ipAddress = response.msg |
|
334 |
console.log('查询到本工位IP为' + this.StationConfQueryParams.ipAddress) |
|
335 |
}); |
|
336 |
await listStationConf(this.StationConfQueryParams).then(response => { |
|
337 |
let rows = response.rows[0] |
|
338 |
if (response.rows.length === 0) { |
|
339 |
this.$message('该工位没有配置IP,请联系管理员配置IP'); |
|
340 |
return |
|
341 |
} |
|
342 |
this.headContent.processesName = rows.processesName |
|
343 |
this.headContent.processesCode = rows.processesCode |
|
344 |
console.log('设置工位编码' + this.headContent.processesCode) |
|
345 |
|
|
346 |
}); |
|
347 |
console.log('websocket连接工位为' + this.headContent.processesCode) |
|
348 |
const wsuri = this.url + this.headContent.processesCode; |
|
349 |
this.ws = new WebSocket(wsuri); |
|
350 |
const self = this; |
|
351 |
this.ws.onopen = function (event) { |
140592
|
352 |
self.$message('websocket连接成功!'); |
b78728
|
353 |
}; |
A |
354 |
this.ws.onmessage = function (event) { |
|
355 |
if(event.data.includes("[")) { |
|
356 |
let formulaChilds = ""; |
|
357 |
self.formulaChildList.sort((a, b) => a.stepSort - b.stepSort); |
|
358 |
self.formulaChildList |
|
359 |
.filter((formulaChild) => formulaChild.operationType === '1'); |
|
360 |
for (let i = 0; i < self.formulaChildList.length; i++) { |
|
361 |
let formulaChild = self.formulaChildList[i]; |
|
362 |
let results = formulaChild.results; |
|
363 |
if (results === '' || results === null || results === 'NG') { |
|
364 |
formulaChilds = formulaChild; |
|
365 |
break; |
|
366 |
} |
|
367 |
} |
|
368 |
const param = { |
|
369 |
tightenTheArray: event.data, |
|
370 |
paramCode: formulaChilds.paramCode, |
140592
|
371 |
workOrderNo: '-', |
A |
372 |
productCode: "9900200461", |
b78728
|
373 |
locationCode: self.headContent.processesCode, |
A |
374 |
productBarcode: self.headContent.sfcCode, |
|
375 |
spareField2: formulaChilds.spareField2, |
|
376 |
spareField3: formulaChilds.spareField3, |
|
377 |
spareField4: formulaChilds.spareField4, |
|
378 |
stepSort: formulaChilds.stepSort |
|
379 |
} |
|
380 |
if(self.headContent.sfcCode === null||self.headContent.sfcCode ===''){ |
|
381 |
self.$message('未找到总成码,请先扫码!'); |
|
382 |
return; |
|
383 |
} |
|
384 |
if(formulaChilds.paramCode === null||formulaChilds.paramCode ===''){ |
|
385 |
self.$message('未找到参数码,请检查参数码是否正确'); |
|
386 |
return; |
|
387 |
} |
|
388 |
|
|
389 |
checkMaterialCode(param).then(response => { |
|
390 |
if(response.msg === "2"){ |
|
391 |
self.$message('未扫描物料码完毕!'); |
|
392 |
}else { |
|
393 |
yzUpdateTighteningFormula(param).then(response => { |
|
394 |
console.log(response) |
|
395 |
if(response.msg === "1" || response.msg === "3"){ |
|
396 |
self.getListFormulaChild() |
|
397 |
}else { |
|
398 |
const param = { |
|
399 |
locationCode: self.headContent.processesCode, |
|
400 |
productBarcode: self.headContent.sfcCode, |
|
401 |
inboundTime: self.headContent.inboundTime |
|
402 |
} |
|
403 |
preInstallOut(param).then(response => {}); |
|
404 |
workpieceRelease(param).then(response => {}); |
|
405 |
self.formulaChildList = []; |
|
406 |
self.headContent.sfcCode = ''; |
|
407 |
} |
|
408 |
}); |
|
409 |
addTighteningParameters(param).then(response => {}); |
|
410 |
} |
|
411 |
}); |
|
412 |
} |
|
413 |
}; |
|
414 |
}, |
|
415 |
//接受数据的回调 |
|
416 |
callBack(value) { |
|
417 |
if (this.form1.isShowHistory) this.form1.desc = this.readLi().join(""); |
|
418 |
else { |
|
419 |
const scanValue = this.myserialport.hex2atostr(value).replace(/[\r\n]/g, ''); |
|
420 |
console.log("串口收到数据-------------------"+scanValue) |
|
421 |
|
|
422 |
if(this.headContent.sfcCode !== ''){ |
|
423 |
this.$message('预装工位扫描物料编码'+scanValue); |
|
424 |
console.log(scanValue) |
|
425 |
this.serialPortMethod(scanValue) |
|
426 |
} else { |
|
427 |
this.headContent.sfcCode = scanValue; |
|
428 |
this.headContent.inboundTime = this.getCurrentTime(); |
|
429 |
this.getList() |
|
430 |
} |
|
431 |
} |
|
432 |
}, |
|
433 |
} |
|
434 |
} |
|
435 |
|
|
436 |
</script> |
|
437 |
<style scoped> |
|
438 |
.bottom-card{ |
|
439 |
height: 600px; |
|
440 |
} |
|
441 |
.circle-button{ |
|
442 |
height: 30px; |
|
443 |
width: 30px; |
|
444 |
} |
|
445 |
.circle-red { |
|
446 |
background-color: #e01a4f; |
|
447 |
} |
|
448 |
.circle-green { |
|
449 |
background-color: green; |
|
450 |
} |
|
451 |
.circle-green-animate { |
|
452 |
background-color: green; |
|
453 |
animation: circle-green-animate 2s infinite; |
|
454 |
} |
|
455 |
@keyframes circle-green-animate { |
|
456 |
50% { |
|
457 |
opacity: 0.6; |
|
458 |
} |
|
459 |
0% { |
|
460 |
opacity: 0.2; |
|
461 |
} |
|
462 |
} |
|
463 |
.head-font{ |
|
464 |
/*font-weight: bold;*/ |
|
465 |
/*font-size: 25px;*/ |
|
466 |
} |
|
467 |
span{ |
|
468 |
font-size: 15px; |
|
469 |
} |
|
470 |
.el-table .warning-row { |
|
471 |
background: oldlace; |
|
472 |
} |
|
473 |
|
|
474 |
.el-table .success-row { |
|
475 |
background: #f0f9eb; |
|
476 |
} |
|
477 |
</style> |
|
478 |
|