提交 | 用户 | 时间
|
06713a
|
1 |
<template> |
A |
2 |
<div class="app-container"> |
|
3 |
<el-row :gutter="5"> |
|
4 |
<el-col :span="7"> |
|
5 |
<el-card shadow="never"> |
|
6 |
<span class="head-font">工位编号 : {{headContent.processesCode}}</span> |
|
7 |
</el-card> |
|
8 |
</el-col> |
1c84ae
|
9 |
<el-col :span="17"> |
06713a
|
10 |
<el-card shadow="never"> |
A |
11 |
<span class="head-font">工位名称 : {{headContent.processesName}}</span> |
|
12 |
<el-button type="primary" style="float: right" icon="el-icon-search" size="mini" @click="serialLink">串口连接</el-button> |
|
13 |
<el-button @click="clearClick" style="float: right" type="danger" size="mini">清除</el-button> |
|
14 |
</el-card> |
|
15 |
</el-col> |
1c84ae
|
16 |
<!-- <el-col :span="10">--> |
A |
17 |
<!-- <el-card shadow="never">--> |
|
18 |
<!-- <span class="head-font">产品序列号 : {{headContent.sfcCode}}</span>--> |
|
19 |
<!--<!– <el-input v-model="content" style="float: right;width: 150px;" placeholder="请输入内容"></el-input>–>--> |
|
20 |
<!--<!– <el-button @click="scanCompleted" style="float: right" type="primary">扫码完成</el-button>–>--> |
|
21 |
<!-- <el-button type="primary" style="float: right" icon="el-icon-search" size="mini" @click="serialLink">串口连接</el-button>--> |
|
22 |
<!-- <el-button @click="clearClick" style="float: right" type="danger" size="mini">清除</el-button>--> |
|
23 |
<!-- </el-card>--> |
|
24 |
<!-- </el-col>--> |
06713a
|
25 |
|
A |
26 |
</el-row> |
|
27 |
<el-row :gutter="5" style="margin-top: 5px"> |
|
28 |
<el-col :span="7" > |
|
29 |
<el-card class="bottom-card"> |
|
30 |
<div slot="header" class="clearfix"> |
|
31 |
<i class="el-icon-tickets"></i> |
|
32 |
<span style="font-weight: bold">当前工位信息</span> |
|
33 |
</div> |
|
34 |
<el-row> |
|
35 |
<el-col :span="12"> |
|
36 |
<el-button class="circle-button" :class="cakeLamp.plcState ? 'circle-green-animate':'circle-red'" circle></el-button> |
|
37 |
<span style="display: none">{{cakeLamp.plcState}}</span> |
|
38 |
<span> PLC状态</span> |
|
39 |
</el-col> |
|
40 |
<el-col :span="12"> |
|
41 |
<el-button class="circle-button" :class="cakeLamp.scannerState ? 'circle-green-animate':'circle-red'" circle></el-button> |
|
42 |
<span style="display: none">{{cakeLamp.scannerState}}</span> |
|
43 |
<span> 扫码枪状态</span> |
|
44 |
</el-col> |
|
45 |
</el-row> |
|
46 |
<el-row style="margin-top: 20px"> |
|
47 |
<el-col :span="12"> |
|
48 |
<el-button class="circle-button" :class="cakeLamp.InPlace ? 'circle-green':'circle-red'" circle></el-button> |
|
49 |
<span style="display: none">{{cakeLamp.InPlace}}</span> |
|
50 |
<span> 工件到位</span> |
|
51 |
</el-col> |
|
52 |
<el-col :span="12"> |
|
53 |
<el-button class="circle-button" :class="cakeLamp.scanFinish ? 'circle-green':'circle-red'" circle></el-button> |
|
54 |
<span style="display: none">{{cakeLamp.scanFinish}}</span> |
|
55 |
<span> 扫码完成</span> |
|
56 |
</el-col> |
|
57 |
</el-row> |
|
58 |
<el-row style="margin-top: 20px"> |
|
59 |
<el-col :span="12"> |
|
60 |
<el-button class="circle-button" :class="cakeLamp.startWork ? 'circle-green':'circle-red'" circle></el-button> |
|
61 |
<span style="display: none">{{cakeLamp.startWork}}</span> |
|
62 |
<span> 开始作业</span> |
|
63 |
</el-col> |
|
64 |
<el-col :span="12"> |
|
65 |
<el-button class="circle-button" :class="cakeLamp.release ? 'circle-green':'circle-red'" circle></el-button> |
|
66 |
<span style="display: none">{{cakeLamp.release}}</span> |
|
67 |
<span> 允许放行</span> |
|
68 |
</el-col> |
|
69 |
|
|
70 |
</el-row> |
|
71 |
<el-divider></el-divider> |
|
72 |
<el-row style="margin-top: 20px"> |
|
73 |
<span style="width: 130px;" class="head-font">模组码A : {{headContent.moduleA}}</span> |
|
74 |
</el-row> |
|
75 |
<el-row style="margin-top: 20px"> |
|
76 |
<span style="width: 130px;" class="head-font">模组码B : {{headContent.moduleB}}</span> |
|
77 |
</el-row> |
|
78 |
</el-card> |
|
79 |
|
|
80 |
</el-col> |
|
81 |
<el-col :span="17"> |
|
82 |
<el-tabs type="border-card" style="height: 600px" v-model="activeName" @tab-click="changeMenu"> |
|
83 |
<el-tab-pane name="first"> |
|
84 |
<span slot="label"> <a class="el-icon-date"></a>首页</span> |
|
85 |
<el-col :span="24"> |
|
86 |
<el-table height="500" :cell-style="rowStyle" :data="formulaChildList"> |
|
87 |
<el-table-column label="排序" width="60" align="center" type="index"> |
|
88 |
</el-table-column> |
|
89 |
<el-table-column label="操作内容" :show-overflow-tooltip='true' align="center" prop="operationSteps"> |
|
90 |
</el-table-column> |
|
91 |
<el-table-column label="产品编号" align="center" prop="productCode"> |
|
92 |
</el-table-column> |
|
93 |
<el-table-column label="物料编码" align="center" prop="materialCode"> |
|
94 |
</el-table-column> |
|
95 |
<el-table-column label="采集值" align="center" prop="collectData"> |
|
96 |
</el-table-column> |
|
97 |
<el-table-column label="结果" align="center" prop="results"> |
|
98 |
</el-table-column> |
|
99 |
</el-table> |
|
100 |
</el-col> |
|
101 |
</el-tab-pane> |
|
102 |
</el-tabs> |
|
103 |
</el-col> |
|
104 |
</el-row> |
|
105 |
<el-dialog v-dialogpop-up :title="title" :visible.sync="open1" width="1000" append-to-body> |
|
106 |
<el-row |
|
107 |
type="flex" |
|
108 |
class="row-bg" |
|
109 |
justify="center" |
|
110 |
v-show="portsList.length === 0" |
|
111 |
> |
|
112 |
<el-col :span="7"> |
|
113 |
<div style="margin-top: 400px"> |
|
114 |
<span style="display: block"> |
|
115 |
仅支持Chrome 89+或者Edge 89+浏览器(安全上下文(HTTPS)中可用) |
|
116 |
</span> |
|
117 |
<el-button type="primary" @click="obtainAuthorization">授权</el-button> |
|
118 |
</div> |
|
119 |
</el-col> |
|
120 |
</el-row> |
|
121 |
<el-form |
|
122 |
v-show="portsList.length > 0" |
|
123 |
ref="form1" |
|
124 |
:model="form1" |
|
125 |
label-width="100px"> |
|
126 |
<el-row> |
|
127 |
<el-col :span="24" |
|
128 |
><div> |
|
129 |
<el-form-item label="串口"> |
|
130 |
<el-select |
|
131 |
v-model="form1.port" |
|
132 |
filterable |
|
133 |
placeholder="请选择串口" |
|
134 |
:disabled="isDisable" |
|
135 |
> |
|
136 |
<el-option |
|
137 |
v-for="item in portsList" |
|
138 |
:key="item.value" |
|
139 |
:label="item.label" |
|
140 |
:value="item.value" |
|
141 |
> |
|
142 |
</el-option> |
|
143 |
</el-select> |
|
144 |
</el-form-item> |
|
145 |
<el-form-item label="波特率"> |
|
146 |
<el-autocomplete |
|
147 |
popper-class="my-autocomplete" |
|
148 |
v-model="form1.baudRate" |
|
149 |
:fetch-suggestions="querySearch" |
|
150 |
placeholder="请输入波特率" |
|
151 |
:disabled="isDisable" |
|
152 |
> |
|
153 |
<i class="el-icon-edit el-input__icon" slot="suffix"> </i> |
|
154 |
<template slot-scope="{ item }"> |
|
155 |
<div class="name">{{ item.value }}</div> |
|
156 |
<span class="addr">{{ item.address }}</span> |
|
157 |
</template> |
|
158 |
</el-autocomplete> |
|
159 |
</el-form-item> |
|
160 |
<el-form-item label="数据位"> |
|
161 |
<el-select |
|
162 |
v-model="form1.dataBits" |
|
163 |
placeholder="请选择数据位" |
|
164 |
:disabled="isDisable" |
|
165 |
> |
|
166 |
<el-option label="7" value="7"></el-option> |
|
167 |
<el-option label="8" value="8"></el-option> |
|
168 |
</el-select> |
|
169 |
</el-form-item> |
|
170 |
<el-form-item label="停止位"> |
|
171 |
<el-select |
|
172 |
v-model="form1.stopBits" |
|
173 |
placeholder="请选择停止位" |
|
174 |
:disabled="isDisable" |
|
175 |
> |
|
176 |
<el-option label="1" value="1"></el-option> |
|
177 |
<el-option label="2" value="2"></el-option> |
|
178 |
</el-select> |
|
179 |
</el-form-item> |
|
180 |
|
|
181 |
<el-form-item label="校验位"> |
|
182 |
<el-select |
|
183 |
v-model="form1.parity" |
|
184 |
placeholder="请选择校验位" |
|
185 |
:disabled="isDisable" |
|
186 |
> |
|
187 |
<el-option label="None" value="none"></el-option> |
|
188 |
<el-option label="Even" value="even"></el-option> |
|
189 |
<el-option label="Odd" value="odd"></el-option> |
|
190 |
</el-select> |
|
191 |
</el-form-item> |
|
192 |
|
|
193 |
<el-form-item label="流控制"> |
|
194 |
<el-select |
|
195 |
v-model="form1.flowControl" |
|
196 |
placeholder="请选择流控制" |
|
197 |
:disabled="isDisable" |
|
198 |
> |
|
199 |
<el-option label="None" value="none"></el-option> |
|
200 |
<el-option label="HardWare" value="hardware"></el-option> |
|
201 |
</el-select> |
|
202 |
</el-form-item> |
|
203 |
<el-form-item label="显示历史"> |
|
204 |
<el-switch |
|
205 |
v-model="form1.isShowHistory" |
|
206 |
@change="loadHistory" |
|
207 |
></el-switch> |
|
208 |
<el-button |
|
209 |
type="danger" |
|
210 |
icon="el-icon-delete" |
|
211 |
circle |
|
212 |
title="清空历史" |
|
213 |
@click="clearHistory" |
|
214 |
></el-button> |
|
215 |
</el-form-item> |
|
216 |
<el-form-item label="发送区设置" v-show="isShowSendArea"> |
|
217 |
<el-form-item label="发送格式"> |
|
218 |
<el-radio-group v-model="form1.type"> |
|
219 |
<el-radio label="1">ASCII</el-radio> |
|
220 |
<el-radio label="2">HEX</el-radio> |
|
221 |
</el-radio-group> |
|
222 |
</el-form-item> |
|
223 |
<el-form-item label="发送信息"> |
|
224 |
<el-input type="textarea" v-model="form1.sendMsg"></el-input> |
|
225 |
</el-form-item> |
|
226 |
<el-button type="primary" @click="sendCommon">发送</el-button> |
|
227 |
</el-form-item> |
|
228 |
|
|
229 |
<el-form-item> |
|
230 |
<el-button :type="btnType" @click="connectBtn">{{ |
|
231 |
btnText |
|
232 |
}}</el-button> |
|
233 |
<el-button type="info" @click="obtainAuthorization" |
|
234 |
>新增授权</el-button |
|
235 |
> |
|
236 |
</el-form-item> |
|
237 |
</div> |
|
238 |
</el-col> |
|
239 |
</el-row> |
|
240 |
</el-form> |
|
241 |
</el-dialog> |
|
242 |
</div> |
|
243 |
</template> |
|
244 |
<script> |
|
245 |
import {listWorkReport} from "@/api/main/om/workReport/workReport"; |
|
246 |
import {listStationConf,getIpv4} from "@/api/main/sc/stationConf"; |
|
247 |
import { |
|
248 |
jrmUpdateResults, |
|
249 |
listFormulaChild, |
|
250 |
noPageListFormulaChild, |
|
251 |
releaseCheck, |
|
252 |
updateResults, |
|
253 |
updateTighteningFormula, |
|
254 |
workpieceRelease |
|
255 |
} from "@/api/main/bs/formulaChild/formulaChild"; |
|
256 |
import MySerialPort from "@/utils/MySerialPort"; |
|
257 |
import USBDevice from "@/utils/usb.json"; |
|
258 |
import { |
|
259 |
findBytrolleyYardGetOne, |
|
260 |
listProductionOrde, |
|
261 |
receivingWorkOrders, |
|
262 |
trolleyYardBinDing |
|
263 |
} from "@/api/main/om/productionOrde/productionOrde"; |
|
264 |
import { |
|
265 |
addPassingStationCollection, |
|
266 |
jrmAddPassingStationCollection |
|
267 |
} from "@/api/main/da/passingStationCollection/passingStationCollection"; |
|
268 |
import { |
|
269 |
addBasicParameters, |
|
270 |
addParamCollection, |
|
271 |
addTighteningParameters, |
|
272 |
saveCampaignTimeParameters, |
1c84ae
|
273 |
replaceAssemblyCode, jrmSaveCampaignTimeParameters, |
06713a
|
274 |
} from "@/api/main/da/paramCollection/paramCollection"; |
A |
275 |
|
|
276 |
export default { |
|
277 |
name: "stationTerminal", |
|
278 |
data() { |
|
279 |
return { |
|
280 |
carCode: '', |
|
281 |
showInput: false, |
|
282 |
onLineBinDing: false, |
|
283 |
|
|
284 |
serialPortContent: '', |
|
285 |
// 查询参数 |
|
286 |
formulaChildParams: { |
|
287 |
pageNum: 1, |
|
288 |
pageSize: 10, |
|
289 |
productCode: null, |
|
290 |
processesCode: null, |
|
291 |
}, |
|
292 |
// 配方配置子信息表格数据 |
|
293 |
formulaChildList: [], |
|
294 |
ipAddress: '', |
|
295 |
imgSrc: '', |
|
296 |
headContent: { |
|
297 |
processesCode: 'OP1010', |
|
298 |
processesName: '贴标机-贴码', |
|
299 |
sfcCode: '', |
|
300 |
yzSfcCode: '', |
|
301 |
cardCode: '', |
|
302 |
moduleA: '', |
|
303 |
moduleB: '', |
|
304 |
}, |
|
305 |
workpieceInformation: { |
|
306 |
workOrderNo: null, |
|
307 |
productCode: null, |
|
308 |
productModel: null, |
|
309 |
productName: null, |
|
310 |
beat: null, |
|
311 |
}, |
|
312 |
// 查询参数 |
|
313 |
queryParams: { |
|
314 |
pageNum: 1, |
|
315 |
pageSize: 10, |
|
316 |
sfcCode: null, |
|
317 |
}, |
|
318 |
// 查询参数 |
|
319 |
StationConfQueryParams: { |
|
320 |
pageNum: 1, |
|
321 |
pageSize: 10, |
|
322 |
ipAddress: null, |
|
323 |
}, |
|
324 |
cakeLamp: { |
|
325 |
plcState: 1, //plc |
|
326 |
scannerState: 1, //扫码枪 |
|
327 |
InPlace: 0, //工件到位 |
|
328 |
scanFinish: 0, |
|
329 |
startWork: 0, |
|
330 |
release: 0 //允许放行 |
|
331 |
}, |
|
332 |
content: '', |
|
333 |
activeName: 'first', |
|
334 |
url: "ws://192.168.2.76:8080/websocket/message/", |
|
335 |
message: "", |
|
336 |
text_content: "", |
|
337 |
ws: null, |
|
338 |
inputValue: '9', |
|
339 |
|
|
340 |
open1: false, |
|
341 |
input: "", |
|
342 |
keepReading: true, |
|
343 |
form1: { |
|
344 |
baudRate: "115200", |
|
345 |
dataBits: "8", |
|
346 |
stopBits: "1", |
|
347 |
parity: "none", |
|
348 |
flowControl: "none", |
|
349 |
desc: "", |
|
350 |
type: "1", |
|
351 |
isShowHistory: false, |
|
352 |
}, |
|
353 |
btnType: "primary", |
|
354 |
btnText: "连接串口", |
|
355 |
restaurants: [], |
|
356 |
portsList: [], |
|
357 |
isShowSendArea: false, |
|
358 |
readType: 1, |
|
359 |
title: "", |
|
360 |
|
|
361 |
passingStationForm: {}, |
|
362 |
originalArray: [], |
|
363 |
} |
|
364 |
}, |
|
365 |
beforeDestroy() { |
|
366 |
this.exit(); |
|
367 |
}, |
|
368 |
created() { |
|
369 |
this.initStation(); |
|
370 |
// this.getStationConfList(); |
|
371 |
// setTimeout(() => { |
|
372 |
// this.connectWebsocket(); |
|
373 |
// }, 3000); |
|
374 |
}, |
|
375 |
mounted() { |
|
376 |
if ("serial" in navigator) { |
|
377 |
this.myserialport = new MySerialPort(); |
|
378 |
this.getPorts(); |
|
379 |
navigator.serial.addEventListener("connect", (e) => { |
|
380 |
this.$message.success("设备已连接"); |
|
381 |
this.getPorts(); |
|
382 |
}); |
|
383 |
navigator.serial.addEventListener("disconnect", (e) => { |
|
384 |
this.$message.error("设备已断开"); |
|
385 |
}); |
|
386 |
this.restaurants = this.loadAll(); |
|
387 |
} else { |
|
388 |
this.$message.error( |
|
389 |
"当前为HTTP模式或者浏览器版本过低,不支持网页连接串口" |
|
390 |
); |
|
391 |
} |
|
392 |
}, |
|
393 |
computed: { |
|
394 |
isDisable() { |
|
395 |
return this.btnType === "danger"; |
|
396 |
}, |
|
397 |
}, |
|
398 |
methods: { |
|
399 |
bindcardCode(){ |
|
400 |
this.$message('可以绑定!'); |
|
401 |
let param = { |
|
402 |
productNum: this.headContent.sfcCode, |
|
403 |
trolleyYard: this.headContent.cardCode, |
|
404 |
} |
|
405 |
trolleyYardBinDing(param).then(response => { |
|
406 |
}); |
|
407 |
|
|
408 |
}, |
|
409 |
serialLink() { |
|
410 |
this.open1 = true |
|
411 |
}, |
|
412 |
bindYzSfc(){ |
|
413 |
if(this.headContent.sfcCode!==""&&this.headContent.yzSfcCode!==""){ |
|
414 |
let param = { |
|
415 |
sfcCode: this.headContent.sfcCode, |
|
416 |
locationCode: this.headContent.processesCode, |
|
417 |
yzSfcCode: this.headContent.yzSfcCode |
|
418 |
} |
|
419 |
this.$message('可以绑定!'); |
|
420 |
replaceAssemblyCode(param).then(response => { |
|
421 |
|
|
422 |
}); |
|
423 |
} |
|
424 |
}, |
|
425 |
Release(){ |
|
426 |
// this.$message('portsList!'+this.portsList.length); |
|
427 |
if(this.btnType === "danger"){ |
|
428 |
this.$message('连接了!'); |
|
429 |
|
|
430 |
}else { |
|
431 |
this.$message('mei连接了!'); |
|
432 |
|
|
433 |
} |
|
434 |
}, |
|
435 |
serialPortMethod(value){ |
|
436 |
let formulaChildParams = { |
|
437 |
scanBarcode: value, |
|
438 |
sfcBarcode: this.headContent.moduleA+','+this.headContent.moduleB, |
|
439 |
// workOrderNo: this.workpieceInformation.workOrderNo, |
|
440 |
productCode: '1P102S', |
|
441 |
locationCode: this.headContent.processesCode, |
|
442 |
collectionTime: new Date() |
|
443 |
} |
|
444 |
jrmUpdateResults(formulaChildParams).then(response => { |
|
445 |
console.log(response) |
|
446 |
if(response.msg === "3"){ |
|
447 |
this.cakeLamp.release= 1 //允许放行 |
|
448 |
} |
|
449 |
this.getListFormulaChild() |
|
450 |
}); |
|
451 |
}, |
|
452 |
rowStyle({ row }) { |
|
453 |
if (row.results === 'OK') { |
|
454 |
return 'background-color: PaleGreen'; |
|
455 |
} else if (row.results === 'NG') { |
|
456 |
return 'background-color: LightSalmon'; |
|
457 |
} |
|
458 |
return ''; |
|
459 |
}, |
|
460 |
/** 查询配方配置子信息列表 */ |
|
461 |
getListFormulaChild() { |
1c84ae
|
462 |
console.log('getListFormulaChild') |
06713a
|
463 |
// this.formulaChildList = [] |
A |
464 |
this.formulaChildParams.productCode = '1P102S' |
|
465 |
this.formulaChildParams.processesCode = this.headContent.processesCode |
|
466 |
console.log(this.formulaChildParams) |
|
467 |
noPageListFormulaChild(this.formulaChildParams).then(response => { |
|
468 |
this.formulaChildList = response.rows; |
|
469 |
}); |
1c84ae
|
470 |
console.log('success_getListFormulaChild') |
06713a
|
471 |
}, |
A |
472 |
endClear(){ |
|
473 |
this.cakeLamp.InPlace= 0 //工件到位 |
|
474 |
this.cakeLamp.scanFinish= 0 |
|
475 |
this.cakeLamp.startWork= 0 |
|
476 |
this.cakeLamp.release= 0 //允许放行 |
|
477 |
|
|
478 |
this.formulaChildList = [] |
|
479 |
this.workpieceInformation.productCode = null; |
|
480 |
this.workpieceInformation.workOrderNo = null; |
|
481 |
this.workpieceInformation.productModel = null; |
|
482 |
this.workpieceInformation.productName = null; |
|
483 |
this.headContent.sfcCode = ''; |
|
484 |
}, |
|
485 |
changeMenu(tab, event) { |
|
486 |
console.log(tab, event); |
|
487 |
}, |
|
488 |
clearClick(){ |
|
489 |
this.$message('这是一条清除消息提示'); |
|
490 |
this.headContent.sfcCode = null |
|
491 |
}, |
|
492 |
scanCompleted(){ |
|
493 |
this.$message('扫码完成'+this.content); |
|
494 |
this.headContent.sfcCode = this.content |
|
495 |
this.queryParams.sfcCode = this.content |
|
496 |
this.getList() |
|
497 |
this.getListFormulaChild() |
|
498 |
this.cakeLamp.scanFinish = 1 |
|
499 |
this.cakeLamp.startWork = 1 |
|
500 |
|
|
501 |
}, |
|
502 |
/** 查询工单列表 */ |
|
503 |
async getList() { |
|
504 |
this.getListFormulaChild() |
|
505 |
this.addOverStationCollection() |
|
506 |
}, |
|
507 |
|
|
508 |
/** 入站增加过站采集记录 **/ |
|
509 |
addOverStationCollection(){ |
1c84ae
|
510 |
console.log('addOverStationCollection') |
06713a
|
511 |
this.passingStationForm = { |
A |
512 |
id: null, |
|
513 |
// workOrderNo: this.workpieceInformation.workOrderNo, |
|
514 |
productCode: '1P102S', |
|
515 |
locationCode: this.headContent.processesCode, |
|
516 |
// model: this.workpieceInformation.productModel, |
|
517 |
// productBarcode: this.headContent.sfcCode, |
|
518 |
sfcCode: this.headContent.moduleA+','+this.headContent.moduleB, |
|
519 |
inboundTime: new Date() |
|
520 |
} |
|
521 |
jrmAddPassingStationCollection(this.passingStationForm).then(response => {}); |
|
522 |
// addBasicParameters(this.passingStationForm).then(response => {}); |
|
523 |
}, |
|
524 |
exit() { |
|
525 |
if (this.ws) { |
|
526 |
this.ws.close(); |
|
527 |
this.ws = null; |
|
528 |
} |
|
529 |
}, |
|
530 |
send() { |
|
531 |
if (this.ws) { |
|
532 |
this.ws.send(this.message); |
|
533 |
} else { |
|
534 |
alert("未连接到服务器"); |
|
535 |
} |
|
536 |
}, |
|
537 |
|
|
538 |
initStation: async function () { |
|
539 |
await getIpv4().then(response => { |
|
540 |
this.StationConfQueryParams.ipAddress = response.msg |
|
541 |
console.log('查询到本工位IP为' + this.StationConfQueryParams.ipAddress) |
|
542 |
}); |
|
543 |
await listStationConf(this.StationConfQueryParams).then(response => { |
|
544 |
let rows = response.rows[0] |
|
545 |
if (response.rows.length === 0) { |
|
546 |
this.$message('该工位没有配置IP,请联系管理员配置IP'); |
|
547 |
return |
|
548 |
} |
|
549 |
this.headContent.processesName = rows.processesName |
|
550 |
this.headContent.processesCode = rows.processesCode |
|
551 |
if(this.headContent.processesCode === 'OP240'){ |
|
552 |
this.onLineBinDing = true |
|
553 |
} |
|
554 |
if(this.headContent.processesCode === 'OP260'){ |
|
555 |
this.showInput = true |
|
556 |
} |
|
557 |
|
|
558 |
console.log('设置工位编码' + this.headContent.processesCode) |
|
559 |
}); |
|
560 |
this.conCom() |
|
561 |
console.log('websocket连接工位为' + this.headContent.processesCode) |
|
562 |
const wsuri = this.url + this.headContent.processesCode; |
|
563 |
this.ws = new WebSocket(wsuri); |
|
564 |
const self = this; |
|
565 |
this.ws.onopen = function (event) { |
|
566 |
this.$message('websocket连接成功!'); |
|
567 |
}; |
|
568 |
this.ws.onmessage = function (event) { |
|
569 |
if (event.data === "IN") { |
|
570 |
self.cakeLamp.InPlace = 1; |
|
571 |
} else if (event.data === "IN0") { |
|
572 |
self.cakeLamp.InPlace = 0; |
|
573 |
} else if (event.data === "OUT") { |
|
574 |
self.cakeLamp.release = 1; |
|
575 |
} else if (event.data === "END") { |
|
576 |
const param = { |
|
577 |
workOrderNo: self.workpieceInformation.workOrderNo, |
|
578 |
productCode: self.workpieceInformation.productCode, |
|
579 |
locationCode: self.headContent.processesCode, |
|
580 |
productBarcode: self.headContent.sfcCode, |
|
581 |
} |
1c84ae
|
582 |
jrmSaveCampaignTimeParameters(param).then(response => {}); |
06713a
|
583 |
self.cakeLamp.release = 1; |
A |
584 |
self.endClear() |
|
585 |
workpieceRelease(param).then(response => {}); |
|
586 |
} else if (event.data.includes("[")) { |
|
587 |
let formulaChilds = ""; |
|
588 |
self.formulaChildList.sort((a, b) => a.stepSort - b.stepSort); |
|
589 |
self.formulaChildList |
|
590 |
.filter((formulaChild) => formulaChild.operationType === '1'); |
|
591 |
for (let i = 0; i < self.formulaChildList.length; i++) { |
|
592 |
let formulaChild = self.formulaChildList[i]; |
|
593 |
let results = formulaChild.results; |
|
594 |
if (results === '' || results === null || results === 'NG') { |
|
595 |
formulaChilds = formulaChild; |
|
596 |
break; |
|
597 |
} |
|
598 |
} |
|
599 |
const param = { |
|
600 |
tightenTheArray: event.data, |
|
601 |
paramCode: formulaChilds.paramCode, |
1c84ae
|
602 |
// workOrderNo: self.workpieceInformation.workOrderNo, |
A |
603 |
productCode: '1P102S', |
06713a
|
604 |
locationCode: self.headContent.processesCode, |
A |
605 |
productBarcode: self.headContent.sfcCode, |
|
606 |
} |
|
607 |
addTighteningParameters(param).then(response => {}); |
|
608 |
updateTighteningFormula(param).then(response => { |
|
609 |
self.getListFormulaChild() |
|
610 |
}).catch(error =>{ |
|
611 |
self.getListFormulaChild() |
|
612 |
}); |
|
613 |
} |
|
614 |
}; |
|
615 |
}, |
|
616 |
|
|
617 |
|
|
618 |
|
|
619 |
//接受数据的回调 |
|
620 |
callBack(value) { |
|
621 |
if (this.form1.isShowHistory) this.form1.desc = this.readLi().join(""); |
|
622 |
else { |
|
623 |
const scanValue = this.myserialport.hex2atostr(value).replace(/[\r\n]/g, ''); |
|
624 |
console.log("串口收到数据-------------------"+scanValue) |
|
625 |
|
|
626 |
if(this.headContent.moduleA !== '' && this.headContent.moduleB !== '' ){ |
|
627 |
this.serialPortMethod(scanValue) |
|
628 |
} else { |
|
629 |
if(scanValue.includes("9900168135")){ |
|
630 |
this.headContent.moduleA = scanValue; |
|
631 |
} |
|
632 |
if(scanValue.includes("9900168136")){ |
|
633 |
this.headContent.moduleB = scanValue; |
|
634 |
this.$message('扫码识别产品序列号'+scanValue); |
|
635 |
this.getList() |
|
636 |
this.cakeLamp.InPlace = 1 |
|
637 |
this.cakeLamp.scanFinish = 1 |
|
638 |
this.cakeLamp.startWork = 1 |
|
639 |
} |
|
640 |
} |
|
641 |
} |
|
642 |
}, |
|
643 |
clearHistory() { |
|
644 |
this.form1.desc = ""; |
|
645 |
this.myserialport.state.readValue = []; |
|
646 |
}, |
|
647 |
loadHistory() { |
|
648 |
if (this.form1.isShowHistory) this.form1.desc = this.readLi().join(""); |
|
649 |
else { |
|
650 |
let temp = this.readLi(); |
|
651 |
if (temp.length > 0) this.form1.desc = temp[temp.length - 1].join(""); |
|
652 |
} |
|
653 |
}, |
|
654 |
readLi() { |
|
655 |
let readType = this.readType; |
|
656 |
return this.myserialport.state.readValue.map((items, index) => { |
|
657 |
const item = items.value; |
|
658 |
const type = items.type; // 1接收,2发送 |
|
659 |
let body = []; |
|
660 |
if (item !== undefined) { |
|
661 |
let strArr = []; |
|
662 |
for (let hex of Array.from(item)) { |
|
663 |
strArr.push(hex.toString(16).toLocaleUpperCase()); |
|
664 |
} |
|
665 |
if (strArr.includes("D") && strArr.includes("A")) { |
|
666 |
if (strArr.indexOf("A") - strArr.indexOf("D") === 1) { |
|
667 |
strArr.splice(strArr.indexOf("D"), 1); |
|
668 |
strArr.splice(strArr.indexOf("A"), 1, <br key={0} />); |
|
669 |
} |
|
670 |
} |
|
671 |
strArr = strArr.map((item) => { |
|
672 |
if (typeof item === "string") { |
|
673 |
if (readType === 1) { |
|
674 |
return this.myserialport.hex2a(parseInt(item, 16)); |
|
675 |
} else if (readType === 2) { |
|
676 |
return item + " "; |
|
677 |
} |
|
678 |
} |
|
679 |
return item; |
|
680 |
}); |
|
681 |
if (typeof strArr[strArr.length - 1] === "string") { |
|
682 |
strArr.push("\r\n"); |
|
683 |
} |
|
684 |
body.push(strArr.join("")); |
|
685 |
} |
|
686 |
return body; |
|
687 |
}); |
|
688 |
}, |
|
689 |
conCom(){ |
|
690 |
try { |
|
691 |
this.myserialport.state.baudRate = this.form1.baudRate; |
|
692 |
this.myserialport.state.dataBits = this.form1.dataBits; |
|
693 |
this.myserialport.state.stopBits = this.form1.stopBits; |
|
694 |
this.myserialport.state.parity = this.form1.parity; |
|
695 |
this.myserialport.state.flowControl = this.form1.flowControl; |
|
696 |
this.myserialport.openPort(0, true, this.callBack); |
|
697 |
console.log(this.form1.port) |
|
698 |
} catch (error) { |
|
699 |
this.$message.error("串口连接失败!请检查串口是否已被占用"); |
|
700 |
} |
|
701 |
if (this.myserialport.state.isOpen) { |
|
702 |
this.$message.success("串口连接成功"); |
|
703 |
} |
|
704 |
}, |
|
705 |
//连接 |
|
706 |
async connectBtn() { |
|
707 |
if (this.btnType === "primary") { |
|
708 |
try { |
|
709 |
this.myserialport.state.baudRate = this.form1.baudRate; |
|
710 |
this.myserialport.state.dataBits = this.form1.dataBits; |
|
711 |
this.myserialport.state.stopBits = this.form1.stopBits; |
|
712 |
this.myserialport.state.parity = this.form1.parity; |
|
713 |
this.myserialport.state.flowControl = this.form1.flowControl; |
|
714 |
await this.myserialport.openPort(this.form1.port, true, this.callBack); |
|
715 |
console.log(this.form1.port) |
|
716 |
} catch (error) { |
|
717 |
this.$message.error("串口连接失败!请检查串口是否已被占用"); |
|
718 |
} |
|
719 |
if (this.myserialport.state.isOpen) { |
|
720 |
this.$message.success("串口连接成功"); |
|
721 |
this.open1 = false |
|
722 |
this.btnType = "danger"; |
|
723 |
this.btnText = "关闭串口"; |
|
724 |
} |
|
725 |
} else { |
|
726 |
this.myserialport.openPort(this.form1.port, false, this.callBack); |
|
727 |
this.$message.success("串口关闭成功"); |
|
728 |
this.btnType = "primary"; |
|
729 |
this.btnText = "连接串口"; |
|
730 |
} |
|
731 |
}, |
|
732 |
//授权 |
|
733 |
async obtainAuthorization() { |
|
734 |
if ("serial" in navigator) { |
|
735 |
console.log("The Web Serial API is supported."); |
|
736 |
if (!this.myserialport) this.myserialport = new MySerialPort(); |
|
737 |
try { |
|
738 |
await this.myserialport.handleRequestPort(); |
|
739 |
this.$message.success("串口授权成功"); |
|
740 |
this.getPortInfo(this.myserialport.state.ports); |
|
741 |
} catch (error) { |
|
742 |
this.$message.warning("未选择新串口授权!"); |
|
743 |
} |
|
744 |
} else { |
|
745 |
this.$message.error( |
|
746 |
"当前为HTTP模式或者浏览器版本过低,不支持网页连接串口" |
|
747 |
); |
|
748 |
} |
|
749 |
}, |
|
750 |
//串口列表初始化 |
|
751 |
getPortInfo(portList) { |
|
752 |
this.portsList = []; |
|
753 |
portList.map((port, index) => { |
|
754 |
const { usbProductId, usbVendorId } = port.getInfo(); |
|
755 |
if (usbProductId === undefined || usbVendorId === undefined) { |
|
756 |
this.portsList.push({ label: "未知设备" + index, value: index }); |
|
757 |
} else { |
|
758 |
const usbVendor = USBDevice.filter( |
|
759 |
(item) => parseInt(item.vendor, 16) === usbVendorId |
|
760 |
); |
|
761 |
let usbProduct = []; |
|
762 |
if (usbVendor.length === 1) { |
|
763 |
usbProduct = usbVendor[0].devices.filter( |
|
764 |
(item) => parseInt(item.devid, 16) === usbProductId |
|
765 |
); |
|
766 |
} |
|
767 |
this.portsList.push({ label: usbProduct[0].devname, value: index }); |
|
768 |
} |
|
769 |
}); |
|
770 |
}, |
|
771 |
// 发送 |
|
772 |
async sendCommon() { |
|
773 |
if (this.myserialport.state.isOpen) { |
|
774 |
if (this.form1.sendMsg.length !== 0) { |
|
775 |
const writeType = this.form1.type; |
|
776 |
let value = this.form1.sendMsg; |
|
777 |
let arr = []; |
|
778 |
if (writeType === 1) { |
|
779 |
// ASCII |
|
780 |
for (let i = 0; i < value.length; i++) { |
|
781 |
arr.push(this.myserialport.a2hex(value[i])); |
|
782 |
} |
|
783 |
} else if (writeType === 2) { |
|
784 |
// HEX |
|
785 |
if (/^[0-9A-Fa-f]+$/.test(value) && value.length % 2 === 0) { |
|
786 |
for (let i = 0; i < value.length; i = i + 2) { |
|
787 |
arr.push(parseInt(value.substring(i, i + 2), 16)); |
|
788 |
} |
|
789 |
} else { |
|
790 |
this.$message.error("格式错误"); |
|
791 |
return; |
|
792 |
} |
|
793 |
} |
|
794 |
this.myserialport.writeText(arr); |
|
795 |
} else { |
|
796 |
this.$message.warning("请输入发送的信息"); |
|
797 |
} |
|
798 |
} else { |
|
799 |
this.$message.warning("串口处于关闭状态,请连接串口"); |
|
800 |
} |
|
801 |
}, |
|
802 |
async getPorts() { |
|
803 |
await this.myserialport.getPorts(); |
|
804 |
this.getPortInfo(this.myserialport.state.ports); |
|
805 |
}, |
|
806 |
querySearch(queryString, cb) { |
|
807 |
var restaurants = this.restaurants; |
|
808 |
var results = queryString |
|
809 |
? restaurants.filter(this.createFilter(queryString)) |
|
810 |
: restaurants; |
|
811 |
// 调用 callback 返回建议列表的数据 |
|
812 |
cb(results); |
|
813 |
}, |
|
814 |
createFilter(queryString) { |
|
815 |
return (restaurant) => { |
|
816 |
return ( |
|
817 |
restaurant.value.toLowerCase().indexOf(queryString.toLowerCase()) === |
|
818 |
0 |
|
819 |
); |
|
820 |
}; |
|
821 |
}, |
|
822 |
loadAll() { |
|
823 |
return [ |
|
824 |
{ value: "110" }, |
|
825 |
{ value: "300" }, |
|
826 |
{ value: "600" }, |
|
827 |
{ value: "1200" }, |
|
828 |
{ value: "2400" }, |
|
829 |
{ value: "4800" }, |
|
830 |
{ value: "7200" }, |
|
831 |
{ value: "9600" }, |
|
832 |
{ value: "14400" }, |
|
833 |
{ value: "19200" }, |
|
834 |
{ value: "28800" }, |
|
835 |
{ value: "38400" }, |
|
836 |
{ value: "56000" }, |
|
837 |
{ value: "57600" }, |
|
838 |
{ value: "76800" }, |
|
839 |
{ value: "115200" }, |
|
840 |
{ value: "230400" }, |
|
841 |
{ value: "460800" }, |
|
842 |
]; |
|
843 |
}, |
|
844 |
} |
|
845 |
} |
|
846 |
|
|
847 |
</script> |
|
848 |
<style scoped> |
|
849 |
.bottom-card{ |
|
850 |
height: 600px; |
|
851 |
} |
|
852 |
.circle-button{ |
|
853 |
height: 30px; |
|
854 |
width: 30px; |
|
855 |
} |
|
856 |
.circle-red { |
|
857 |
background-color: #e01a4f; |
|
858 |
} |
|
859 |
.circle-green { |
|
860 |
background-color: green; |
|
861 |
} |
|
862 |
.circle-green-animate { |
|
863 |
background-color: green; |
|
864 |
animation: circle-green-animate 2s infinite; |
|
865 |
} |
|
866 |
@keyframes circle-green-animate { |
|
867 |
50% { |
|
868 |
opacity: 0.6; |
|
869 |
} |
|
870 |
0% { |
|
871 |
opacity: 0.2; |
|
872 |
} |
|
873 |
} |
|
874 |
.head-font{ |
|
875 |
/*font-weight: bold;*/ |
|
876 |
/*font-size: 25px;*/ |
|
877 |
} |
|
878 |
span{ |
|
879 |
font-size: 15px; |
|
880 |
} |
|
881 |
.el-table .warning-row { |
|
882 |
background: oldlace; |
|
883 |
} |
|
884 |
|
|
885 |
.el-table .success-row { |
|
886 |
background: #f0f9eb; |
|
887 |
} |
|
888 |
</style> |
|
889 |
|