cl
2024-08-03 d5a7019a83a88564d266fe4fa50782052c38c7a4
提交 | 用户 | 时间
b78728 1 <template>
A 2   <div class="app-container">
3    <el-row :gutter="5">
bf111f 4      <el-col :span="7">
A 5        <el-card style="height: 71px;padding-top: 6px" shadow="never">
6           <span class="head-font">工位编号 : {{headContent.processesCode}}</span>
b78728 7        </el-card>
A 8      </el-col>
dd5d35 9      <el-col :span="17">
b78728 10        <el-card shadow="never">
dd5d35 11          <span class="head-font">物料编码 : </span>
d5a701 12          <el-input style="width: 50%" ref="inputData" v-model="materialCode" @change="handleEnter" @keyup="handleEnter" placeholder="请扫描物料编码"></el-input>
dd5d35 13          <el-button type="primary" style="float: right" icon="el-icon-search"  @click="serialLink">串口连接</el-button>
A 14          <el-button @click="clearClick" style="float: right" type="danger" >清除</el-button>
b78728 15        </el-card>
A 16      </el-col>
17
18    </el-row>
19    <el-row :gutter="5" style="margin-top: 5px">
20      <el-col :span="7" >
21        <el-card class="bottom-card">
22          <div slot="header" class="clearfix">
23            <i class="el-icon-tickets"></i>
24            <span style="font-weight: bold">当前工件信息</span>
25          </div>
26          <el-descriptions :column="1" border :content-style="{'min-width': '140px'}">
dd5d35 27            <el-descriptions-item label="产品序列号">
A 28              <span>{{headContent.sfcCode}}</span>
29            </el-descriptions-item>
b78728 30            <el-descriptions-item label="工单编号">
A 31                <span>{{workpieceInformation.workOrderNo}}</span>
32            </el-descriptions-item>
33            <el-descriptions-item label="物料编码">
34              <span>{{workpieceInformation.materialCode}}</span>
35            </el-descriptions-item>
36            <el-descriptions-item label="计划数量">
37              <span>{{workpieceInformation.planQty}}</span>
38            </el-descriptions-item>
39            <el-descriptions-item label="开始时间">
40              <span>{{workpieceInformation.inboundTime}}</span>
41            </el-descriptions-item>
42          </el-descriptions>
43          <el-divider></el-divider>
44          <el-row>
45            <el-col :span="12">
46              <el-button class="circle-button" :class="cakeLamp.plcState ? 'circle-green-animate':'circle-red'" circle></el-button>
47              <span style="display: none">{{cakeLamp.plcState}}</span>
48              <span>&nbsp;PLC状态</span>
49            </el-col>
50            <el-col :span="12">
51              <el-button class="circle-button" :class="cakeLamp.scannerState ? 'circle-green-animate':'circle-red'" circle></el-button>
52              <span style="display: none">{{cakeLamp.scannerState}}</span>
53              <span>&nbsp;扫码枪状态</span>
54            </el-col>
55          </el-row>
56          <el-row style="margin-top: 20px">
57            <el-col :span="12">
58              <el-button class="circle-button" :class="cakeLamp.InPlace ? 'circle-green':'circle-red'" circle></el-button>
59              <span style="display: none">{{cakeLamp.InPlace}}</span>
60              <span>&nbsp;工件到位</span>
61            </el-col>
62            <el-col :span="12">
63              <el-button class="circle-button" :class="cakeLamp.scanFinish ? 'circle-green':'circle-red'" circle></el-button>
64              <span style="display: none">{{cakeLamp.scanFinish}}</span>
65              <span>&nbsp;扫码完成</span>
66            </el-col>
67          </el-row>
68          <el-row style="margin-top: 20px">
69            <el-col :span="12">
70              <el-button class="circle-button" :class="cakeLamp.startWork ? 'circle-green':'circle-red'" circle></el-button>
71              <span style="display: none">{{cakeLamp.startWork}}</span>
72              <span>&nbsp;开始作业</span>
73            </el-col>
74            <el-col :span="12">
75              <el-button class="circle-button" :class="cakeLamp.release ? 'circle-green':'circle-red'" circle></el-button>
76              <span style="display: none">{{cakeLamp.release}}</span>
77              <span>&nbsp;允许放行</span>
78            </el-col>
79          </el-row>
80          <el-row v-show="orderFlag" style="margin-top: 20px">
81            <el-button @click="getWorkOrders" type="warning" size="mini">接收工单</el-button>
82          </el-row>
83        </el-card>
84
85      </el-col>
86      <el-col :span="17">
777422 87        <el-tabs type="border-card"  style="height: 600px" v-model="activeName">
b78728 88          <el-tab-pane name="first">
A 89            <span slot="label"> <a class="el-icon-date"></a>首页</span>
90            <el-col :span="24">
91              <el-table height="500" :cell-style="rowStyle" :data="formulaChildList">
92                <el-table-column label="拧紧步号" width="80" align="center" prop="stepSort">
93                </el-table-column>
94                <el-table-column label="操作内容" align="center" prop="operationSteps">
95                </el-table-column>
96                <el-table-column label="产品编号" width="80" align="center" prop="productCode">
97                </el-table-column>
98                <el-table-column label="物料编码" width="110" align="center" prop="materialCode">
99                </el-table-column>
100                <el-table-column label="采集值" align="center" prop="collectData">
101                </el-table-column>
102                <el-table-column label="结果" width="60" align="center" prop="results">
103                </el-table-column>
104
105              </el-table>
106            </el-col>
107          </el-tab-pane>
108        </el-tabs>
109      </el-col>
110    </el-row>
111   </div>
112 </template>
113 <script>
114 import {listWorkReport} from "@/api/main/om/workReport/workReport";
115 import {listStationConf,getIpv4} from "@/api/main/sc/stationConf";
116 import {
117   clearWorkpieceRelease,
118   fistSetpNumber, initializedData,
119   listFormulaChild,
120   noPageListFormulaChild,
121   releaseCheck, unfinishedProcess,
122   updateResults,
123   updateTighteningFormula,
124   workpieceRelease
125 } from "@/api/main/bs/formulaChild/formulaChild";
126 import MySerialPort from "@/utils/MySerialPort";
127 import USBDevice from "@/utils/usb.json";
128 import {
129   bindYzSfcFlag,
130   checkCarCode, checkYzSfcCode,
131   findBytrolleyYardGetOne,
132   listProductionOrde, mozuReceivingWorkOrders,
133   receivingWorkOrders,
134   trolleyYardBinDing
135 } from "@/api/main/om/productionOrde/productionOrde";
136 import {addPassingStationCollection} from "@/api/main/da/passingStationCollection/passingStationCollection";
137 import {
138   addBasicParameters,
139   addParamCollection,
140   addTighteningParameters,
141   saveCampaignTimeParameters,
142   replaceAssemblyCode, checkRecordDataDone,
143 } from "@/api/main/da/paramCollection/paramCollection";
144 import {addFormula} from "@/api/main/bs/formula/formula";
145
146 export default {
147   name: "stationTerminal",
148   data() {
149     return {
dd5d35 150       materialCode: '', // 物料编码
b78728 151       carCode: '',
A 152       showInput: false,
153       onLineBinDing: false,
154
155       serialPortContent: '',
156       // 查询参数
157       formulaChildParams: {
158         pageNum: 1,
159         pageSize: 10,
160         productCode: null,
161         processesCode: null,
162       },
163       // 配方配置子信息表格数据
164       formulaChildList: [],
165       ipAddress: '',
166       imgSrc: '',
167       headContent: {
168         processesCode: 'OP1010',
169         processesName: '贴标机-贴码',
170         sfcCode: '',
171         yzSfcCode: '',
172         cardCode: '',
173       },
174       workpieceInformation: {
175         workOrderNo: null,
176         productCode: null,
177         productModel: null,
178         productName: null,
179         inboundTime: null,
180         materialCode: null,
181         planQty: null,
182       },
183       // 查询参数
184       queryParams: {
185         pageNum: 1,
186         pageSize: 10,
187         sfcCode: null,
188       },
189       // 查询参数
190       StationConfQueryParams: {
191         pageNum: 1,
192         pageSize: 10,
193         ipAddress: null,
194       },
195       cakeLamp: {
196         plcState: 1, //plc
197         scannerState: 1, //扫码枪
198         InPlace: 0, //工件到位
199         scanFinish: 0,
200         startWork: 0,
201         release: 0 //允许放行
202       },
203       content: '',
d5a701 204       url: "ws://192.168.20.250:8080/websocket/message/",
b78728 205
A 206       passingStationForm: {},
207       originalArray: [],
777422 208       orderFlag: true,
A 209       activeName: 'first',
210
b78728 211     }
d5a701 212   },
C 213   mounted() {
214     this.setFocus()
b78728 215   },
A 216   beforeDestroy() {
217     this.exit();
218   },
219   created() {
220     this.initStation();
221   },
222   computed: {
223     isDisable() {
224       return this.btnType === "danger";
225     },
226   },
227   methods: {
d5a701 228     setFocus(){
C 229       this.$nextTick(()=>{
230         this.$refs.inputData.focus()
231       })
232     },
777422 233     changeMenu(tab, event) {
A 234       console.log(tab, event);
235     },
dd5d35 236     handleEnter() {
A 237       this.serialPortMethod(this.materialCode)
238       this.$message("扫描物料编码"+this.materialCode);
239     },
b78728 240     getWorkOrders(){
A 241       if(this.headContent.sfcCode === '' || this.headContent.sfcCode === null){
242         //接收工单
243         const param = {
244           lineCode: this.headContent.processesCode
245         }
246         mozuReceivingWorkOrders(param).then(response => {
247           this.headContent.sfcCode = response.msg;
248           this.queryParams.productNum = response.msg;
249           this.getList()
250           this.cakeLamp.scanFinish = 1
251           this.cakeLamp.startWork = 1
252           this.cakeLamp.InPlace = 1
253         });
254       }else {
255         this.$message.error("已经有工单了,不能接收!");
256       }
257     },
258     serialLink() {
259       this.open1 = true
260     },
261     serialPortMethod(value){
262       let formulaChildParams = {
263         scanBarcode: value,
264         sfcBarcode: this.headContent.sfcCode,
265         workOrderNo: this.workpieceInformation.workOrderNo,
266         productCode: this.workpieceInformation.productCode,
267         locationCode: this.headContent.processesCode,
268         collectionTime: new Date()
269       }
270       updateResults(formulaChildParams).then(response => {
271         console.log(response)
272         if(response.msg === "3"){
273           this.cakeLamp.release= 1 //允许放行
274         }else if(response.msg === "2"){
275           this.$message.error('扫码重复请重新扫码!');
276         }
277         this.getListFormulaChild()
278       });
279     },
280     rowStyle({ row }) {
281       if (row.results === 'OK') {
282         return 'background-color: PaleGreen';
283       } else if (row.results === 'NG') {
284         return 'background-color: LightSalmon';
285       }
286       return '';
287     },
288     /** 查询配方配置子信息列表 */
289     getListFormulaChild() {
290       // this.formulaChildList = []
291       this.formulaChildParams.productCode = this.workpieceInformation.productCode
292       this.formulaChildParams.processesCode = this.headContent.processesCode
293       console.log(this.formulaChildParams)
294       noPageListFormulaChild(this.formulaChildParams).then(response => {
295         this.formulaChildList = response.rows;
296         if (this.formulaChildList.length >0){
297           let pos = 0
298           const tempArr = this.formulaChildList.filter(x=> 'OK' === x.results)
299           if (tempArr.length>0){
300             pos = tempArr.length
301             this.$nextTick(() => {
302               let temp33 = document.getElementsByClassName('el-table__row')
303               console.log('temp33',temp33)
304               console.log('len',temp33.item(pos))
305               if (temp33.length > 0){
306                 console.log('1111111111111111')
307                 let arr = temp33[pos-1]
308                 console.log('srr',arr)
309                 arr.scrollIntoView({ block: 'center' })
310               }
311             })
312           }
313
314         }
315
316       });
317     },
318     endClear(){
319       this.cakeLamp.InPlace= 0 //工件到位
320       this.cakeLamp.scanFinish= 0
321       this.cakeLamp.startWork= 0
322       this.cakeLamp.release= 0 //允许放行
323
324       this.formulaChildList = []
325       this.workpieceInformation.productCode = null;
326       this.workpieceInformation.workOrderNo = null;
327       this.workpieceInformation.productModel = null;
328       this.workpieceInformation.productName = null;
329       this.workpieceInformation.inboundTime = null;
330       this.headContent.sfcCode = '';
331       this.headContent.yzSfcCode = '';
332       this.headContent.cardCode = '';
777422 333       this.workpieceInformation.planQty = ''
b78728 334     },
A 335     clearClick(){
336       const param = {
337         workOrderNo: this.workpieceInformation.workOrderNo,
338         productCode: this.workpieceInformation.productCode,
339         locationCode: this.headContent.processesCode,
340         productBarcode: this.headContent.sfcCode,
341       }
342       this.endClear()
343       clearWorkpieceRelease(param).then(response => {});
344       this.headContent.sfcCode = ''
345       this.$message('清除成功!');
346     },
347     /** 查询工单列表 */
348     async getList() {
349       await listProductionOrde(this.queryParams).then(response => {
350         let rowsData = response.rows[0];
351         console.log(rowsData)
352         this.workpieceInformation.workOrderNo = rowsData.workOrderNo;
353         this.workpieceInformation.productCode = rowsData.productCode;
354         this.workpieceInformation.materialCode = rowsData.materialCode;
355         this.workpieceInformation.planQty = rowsData.planQty;
356         this.headContent.cardCode = rowsData.trolleyYard;
357       });
358       this.getListFormulaChild()
359       this.workpieceInformation.inboundTime = this.getCurrentTime()
360     },
361
362     initializedData(){
363       const param = {
364         locationCode: this.headContent.processesCode,
365       }
366       initializedData(param).then(response => {
367         if(response.msg !== ''){
368           this.headContent.sfcCode = response.msg;
369           this.queryParams.productNum = response.msg;
370           this.getList()
371           this.cakeLamp.scanFinish = 1
372           this.cakeLamp.startWork = 1
373           this.cakeLamp.InPlace = 1
374         }
375       });
376     },
377
378     getCurrentTime() {
379       const now = new Date();
380       const year = now.getFullYear();
381       const month = this.padTimeUnit(now.getMonth() + 1); // 月份是从0开始的
382       const day = this.padTimeUnit(now.getDate());
383       const hours = this.padTimeUnit(now.getHours());
384       const minutes = this.padTimeUnit(now.getMinutes());
385       const seconds = this.padTimeUnit(now.getSeconds());
386       return `${year}-${month}-${day} ${hours}:${minutes}:${seconds}`;
387     },
388     padTimeUnit(value) {
389       return value.toString().padStart(2, '0');
390     },
391
392     exit() {
393       if (this.ws) {
394         this.ws.close();
395         this.ws = null;
396       }
397     },
398     send() {
399       if (this.ws) {
400         this.ws.send(this.message);
401       } else {
402         alert("未连接到服务器");
403       }
404     },
405
406     initStation: async function () {
407       await getIpv4().then(response => {
408         this.StationConfQueryParams.ipAddress = response.msg
409         console.log('查询到本工位IP为' + this.StationConfQueryParams.ipAddress)
410       });
411       await listStationConf(this.StationConfQueryParams).then(response => {
412         let rows = response.rows[0]
413         if (response.rows.length === 0) {
414           this.$message('该工位没有配置IP,请联系管理员配置IP');
415           return
416         }
417         this.headContent.processesName = rows.processesName
418         this.headContent.processesCode = rows.processesCode
419         this.initializedData()
420
421       });
422       console.log('websocket连接工位为' + this.headContent.processesCode)
423       const wsuri = this.url + this.headContent.processesCode;
424       this.ws = new WebSocket(wsuri);
425       const self = this;
426       this.ws.onopen = function (event) {
dd5d35 427         self.$message('websocket连接成功!');
b78728 428       };
A 429
430
431       //socket从后台向前台推送数据
432       this.ws.onmessage = function (event) {
433         if (event.data === "IN") {
434           self.cakeLamp.InPlace = 1;
435         } else if (event.data === "OUT") {
436           self.cakeLamp.release = 1;
437         } else if (event.data === "END") {
438
439           const formulaChildIndex = self.formulaChildList.length-1
440
441           const orderParam = {
442             productNum: self.headContent.sfcCode,
443           }
444
445           if(self.headContent.sfcCode=== ''||self.headContent.sfcCode=== null){
446             self.$message('总成码为空,请扫码!')
447             unfinishedProcess({processesCode: self.headContent.processesCode,recordDataDone: 26}).then(response => {});
448             return;
449           }
450
451           if(self.formulaChildList[formulaChildIndex].results !== 'OK'){
452             self.$message('未做完工序禁止放行');
453             unfinishedProcess({processesCode: self.headContent.processesCode,recordDataDone: 25}).then(response => {});
454             return;
455           }
456
457
458           const param = {
459             workOrderNo: self.workpieceInformation.workOrderNo,
460             productCode: self.workpieceInformation.productCode,
461             locationCode: self.headContent.processesCode,
462             productBarcode: self.headContent.sfcCode,
463             inboundTime: self.workpieceInformation.inboundTime,
464             formulaChildEntity: self.formulaChildList[formulaChildIndex]
465           }
466
467           console.log("进入最终方法")
468           self.endSaveData(param)
469
777422 470         } else if(event.data.includes("productNum")){
b78728 471           let productNum = event.data.split(',')[1];
A 472           self.headContent.sfcCode = productNum;
473           self.queryParams.productNum = productNum;
474           self.getList()
475           self.cakeLamp.scanFinish = 1
476           self.cakeLamp.startWork = 1
477           self.cakeLamp.InPlace = 1
478
479         }
480       };
481     },
482
483     endSaveData(param){
484       saveCampaignTimeParameters(param).then(response => {
485       this.cakeLamp.release = 1;
486       this.endClear()
487       workpieceRelease(param).then(response => {});
488       });
489     },
490   }
491 }
492
493 </script>
494 <style scoped>
495 .bottom-card{
496   height: 600px;
497 }
498 .circle-button{
499   height: 30px;
500   width: 30px;
501 }
502 .circle-red {
503   background-color: #e01a4f;
504 }
505 .circle-green {
506   background-color: green;
507 }
508 .circle-green-animate {
509   background-color: green;
510   animation: circle-green-animate 2s infinite;
511 }
512   @keyframes circle-green-animate {
513     50% {
514       opacity: 0.6;
515     }
516     0% {
517       opacity: 0.2;
518     }
519   }
520 .head-font{
521   /*font-weight: bold;*/
522   /*font-size: 25px;*/
523 }
524 span{
525   font-size: 15px;
526 }
527 .el-table .warning-row {
528   background: oldlace;
529 }
530
531 .el-table .success-row {
532   background: #f0f9eb;
533 }
534 </style>
535