admin
2024-08-08 682919cdb4229973a4917bdb3cb876ec6d5b574a
提交 | 用户 | 时间
e57a89 1 <template>
2   <div class="app-container">
3    <el-row :gutter="5">
c2944a 4      <el-col :span="7">
e57a89 5        <el-card shadow="never">
6          <span class="head-font">工位编号 : {{headContent.processesCode}}</span>
7        </el-card>
8      </el-col>
c2944a 9      <el-col :span="7">
e57a89 10        <el-card shadow="never">
11          <span class="head-font">工位名称 : {{headContent.processesName}}</span>
12        </el-card>
13      </el-col>
c2944a 14      <el-col :span="10">
e57a89 15        <el-card shadow="never">
b64ed2 16          <span class="head-font">产品序列号 : {{headContent.sfcCode}}</span>
c2944a 17 <!--         <el-input v-model="content" style="float: right;width: 150px;" placeholder="请输入内容"></el-input>-->
18 <!--         <el-button @click="scanCompleted" style="float: right" type="primary">扫码完成</el-button>-->
19          <el-button type="primary" style="float: right" icon="el-icon-search" size="mini" @click="serialLink">串口连接</el-button>
20          <el-button @click="clearClick" style="float: right" type="danger" size="mini">清除</el-button>
e57a89 21        </el-card>
22      </el-col>
23
24    </el-row>
25    <el-row :gutter="5" style="margin-top: 5px">
c2944a 26      <el-col :span="7" >
e57a89 27        <el-card class="bottom-card">
28          <div slot="header" class="clearfix">
29            <i class="el-icon-tickets"></i>
30            <span style="font-weight: bold">当前工件信息</span>
31          </div>
c2944a 32          <el-descriptions :column="1" border :content-style="{'min-width': '140px'}">
33 <!--         <el-descriptions :column="1" :label-style="{'font-size': '15px'}" border :content-style="{'min-width': '150px'}">-->
e57a89 34            <el-descriptions-item label="工单编号">
b64ed2 35                <span>{{workpieceInformation.workOrderNo}}</span>
e57a89 36            </el-descriptions-item>
768498 37            <el-descriptions-item label="产品型号">
e57a89 38              <span>{{workpieceInformation.productCode}}</span>
39            </el-descriptions-item>
768498 40            <el-descriptions-item label="小车码">
A 41              <span>{{headContent.cardCode}}</span>
e57a89 42            </el-descriptions-item>
768498 43            <el-descriptions-item label="开始时间">
A 44              <span>{{workpieceInformation.inboundTime}}</span>
45            </el-descriptions-item>
e57a89 46          </el-descriptions>
47          <el-divider></el-divider>
48          <el-row>
49            <el-col :span="12">
50              <el-button class="circle-button" :class="cakeLamp.plcState ? 'circle-green-animate':'circle-red'" circle></el-button>
51              <span style="display: none">{{cakeLamp.plcState}}</span>
52              <span>&nbsp;PLC状态</span>
53            </el-col>
54            <el-col :span="12">
55              <el-button class="circle-button" :class="cakeLamp.scannerState ? 'circle-green-animate':'circle-red'" circle></el-button>
56              <span style="display: none">{{cakeLamp.scannerState}}</span>
57              <span>&nbsp;扫码枪状态</span>
58            </el-col>
59          </el-row>
60          <el-row style="margin-top: 20px">
61            <el-col :span="12">
62              <el-button class="circle-button" :class="cakeLamp.InPlace ? 'circle-green':'circle-red'" circle></el-button>
63              <span style="display: none">{{cakeLamp.InPlace}}</span>
64              <span>&nbsp;工件到位</span>
65            </el-col>
66            <el-col :span="12">
67              <el-button class="circle-button" :class="cakeLamp.scanFinish ? 'circle-green':'circle-red'" circle></el-button>
68              <span style="display: none">{{cakeLamp.scanFinish}}</span>
69              <span>&nbsp;扫码完成</span>
70            </el-col>
71          </el-row>
72          <el-row style="margin-top: 20px">
73            <el-col :span="12">
74              <el-button class="circle-button" :class="cakeLamp.startWork ? 'circle-green':'circle-red'" circle></el-button>
75              <span style="display: none">{{cakeLamp.startWork}}</span>
76              <span>&nbsp;开始作业</span>
77            </el-col>
78            <el-col :span="12">
79              <el-button class="circle-button" :class="cakeLamp.release ? 'circle-green':'circle-red'" circle></el-button>
80              <span style="display: none">{{cakeLamp.release}}</span>
81              <span>&nbsp;允许放行</span>
82            </el-col>
83
84          </el-row>
a75d86 85
9f636f 86          <el-row v-show="goOnlineFlag" style="margin-top: 20px">
A 87            <el-button @click="getWorkOrders" type="primary">接收工单</el-button>
88
89            <div style="display: none">
90              <div id="getWorkOrdersPrintPrintMe" style="width: 500px;">
91                <div ref="canvasWrapper" id="canvasWrapper3" style="display: flex;justify-content: center;"></div>
92                <p style="font-size: 10px;word-break: break-all;display: flex;justify-content: center;">{{packCode}}</p>
93              </div>
391c41 94 <!--             <el-button @click="print">打印</el-button>-->
9f636f 95              <el-button @click="test1">生成二维码</el-button>
A 96            </div>
97          </el-row>
98
99          <el-row v-show="offlineFlag" style="margin-top: 20px">
391c41 100            <el-button id="print" v-print="'#printMe'" type="primary">打印三联码</el-button>
9f636f 101            <el-button style="display: none" @click="test1">生成二维码</el-button>
391c41 102            <el-button style="display: none" @click="test2">生成
A 103              <span style="font-size: 10px;margin-left: 52px">MADE IN CHINA</span><br>
104              <br>
105              <br>二维码</el-button>
106            <div style="display: none">
107              <div  id="printMe">
9f636f 108                <br>
391c41 109                <p style="margin-left: 53px">{{printInfoData.partNumber}}</p>
A 110                <p style="margin-left: 53px">{{printInfoData.hardwareVersion}}</p>
111                <p style="margin-left: 53px">{{printInfoData.softwareVersion}}</p>
9f636f 112                <br>
A 113                <br>
391c41 114                <br>
A 115                <br>
116                <img style="width: 140px;height: 20px;margin-left: 30px" :src="require('@/assets/images/a8963a24920640508e96150a053fc41.png')"/>
117                <span style="margin-left: 72px">{{printInfoData.printModel}}</span><br>
682919 118                <span style="margin-left: 73px">{{printInfoData.supplierCode}}</span><br>
A 119                <span style="margin-left: 55px">{{printInfoData.partNumber}}</span><br>
120                <span style="font-size: 10px;margin-left: 28px;">{{headContent.sfcCode}}</span><br>
121                <span style="font-size: 10px;margin-left: 60px">MADE IN CHINA</span><br>
122
9f636f 123                <br>
A 124                <br>
125                <br>
126                <div ref="canvasWrapper" id="canvasWrapper1" style="display: flex;justify-content: center;margin-top: -27px;"></div>
682919 127                <span style="font-size: 10px;word-break: break-all;display: flex;justify-content: center;width: 155px;margin-left: 20px;margin-top: 3px">P{{printInfoData.partNumber}}#T{{headContent.sfcCode}}#V{{printInfoData.supplierCode}}#S{{printInfoData.softwareVersion}}#H{{printInfoData.hardwareVersion}}#NBMS#</span>
9f636f 128                <br>
A 129                <br>
130                <div ref="canvasWrapper" id="canvasWrapper2" style="display: flex;justify-content: center;margin-top: -27px"></div>
682919 131                <span style="font-size: 10px;word-break: break-all;display: flex;justify-content: center;width: 155px;margin-left: 20px;margin-top: 3px">P{{printInfoData.partNumber}}#T{{headContent.sfcCode}}#V{{printInfoData.supplierCode}}#S{{printInfoData.softwareVersion}}#H{{printInfoData.hardwareVersion}}#NBMS#</span>
9f636f 132              </div>
391c41 133            </div>
9f636f 134          </el-row>
e57a89 135        </el-card>
136
137      </el-col>
c2944a 138      <el-col :span="17">
e57a89 139        <el-tabs type="border-card"  style="height: 600px" v-model="activeName" @tab-click="changeMenu">
140          <el-tab-pane name="first">
141            <span slot="label"> <a class="el-icon-date"></a>首页</span>
b77c7b 142            <el-col :span="24">
0caf87 143              <el-table height="500" :cell-style="rowStyle" :data="formulaChildList">
768498 144                <el-table-column label="拧紧步号" width="80" align="center" prop="stepSort">
e57a89 145                </el-table-column>
8cfe20 146                <el-table-column label="操作内容" align="center" prop="operationSteps">
e57a89 147                </el-table-column>
768498 148                <el-table-column label="产品编号" width="80" align="center" prop="productCode">
b77c7b 149                </el-table-column>
4e83fa 150                <el-table-column label="物料编码" width="140" align="center" prop="materialCode">
5316c5 151                </el-table-column>
b77303 152                <el-table-column label="采集值" align="center" prop="collectData">
b77c7b 153                </el-table-column>
768498 154                <el-table-column label="结果" width="60" align="center" prop="results">
b77c7b 155                </el-table-column>
8cfe20 156
e57a89 157              </el-table>
158            </el-col>
159          </el-tab-pane>
160        </el-tabs>
161      </el-col>
162    </el-row>
c2944a 163     <el-dialog v-dialogpop-up :title="title" :visible.sync="open1" width="1000" append-to-body>
164       <el-row
165         type="flex"
166         class="row-bg"
167         justify="center"
168         v-show="portsList.length === 0"
169       >
170         <el-col :span="7">
171           <div style="margin-top: 400px">
172           <span style="display: block">
173             仅支持Chrome 89+或者Edge 89+浏览器(安全上下文(HTTPS)中可用)
174           </span>
175             <el-button type="primary" @click="obtainAuthorization">授权</el-button>
176           </div>
177         </el-col>
178       </el-row>
179       <el-form
180         v-show="portsList.length > 0"
181         ref="form1"
182         :model="form1"
183         label-width="100px">
184         <el-row>
185           <el-col :span="24"
186           ><div>
187             <el-form-item label="串口">
188               <el-select
189                 v-model="form1.port"
190                 filterable
191                 placeholder="请选择串口"
192                 :disabled="isDisable"
193               >
194                 <el-option
195                   v-for="item in portsList"
196                   :key="item.value"
197                   :label="item.label"
198                   :value="item.value"
199                 >
200                 </el-option>
201               </el-select>
202             </el-form-item>
203             <el-form-item label="波特率">
204               <el-autocomplete
205                 popper-class="my-autocomplete"
206                 v-model="form1.baudRate"
207                 :fetch-suggestions="querySearch"
208                 placeholder="请输入波特率"
209                 :disabled="isDisable"
210               >
211                 <i class="el-icon-edit el-input__icon" slot="suffix"> </i>
212                 <template slot-scope="{ item }">
213                   <div class="name">{{ item.value }}</div>
214                   <span class="addr">{{ item.address }}</span>
215                 </template>
216               </el-autocomplete>
217             </el-form-item>
218             <el-form-item label="数据位">
219               <el-select
220                 v-model="form1.dataBits"
221                 placeholder="请选择数据位"
222                 :disabled="isDisable"
223               >
224                 <el-option label="7" value="7"></el-option>
225                 <el-option label="8" value="8"></el-option>
226               </el-select>
227             </el-form-item>
228             <el-form-item label="停止位">
229               <el-select
230                 v-model="form1.stopBits"
231                 placeholder="请选择停止位"
232                 :disabled="isDisable"
233               >
234                 <el-option label="1" value="1"></el-option>
235                 <el-option label="2" value="2"></el-option>
236               </el-select>
237             </el-form-item>
238
239             <el-form-item label="校验位">
240               <el-select
241                 v-model="form1.parity"
242                 placeholder="请选择校验位"
243                 :disabled="isDisable"
244               >
245                 <el-option label="None" value="none"></el-option>
246                 <el-option label="Even" value="even"></el-option>
247                 <el-option label="Odd" value="odd"></el-option>
248               </el-select>
249             </el-form-item>
250
251             <el-form-item label="流控制">
252               <el-select
253                 v-model="form1.flowControl"
254                 placeholder="请选择流控制"
255                 :disabled="isDisable"
256               >
257                 <el-option label="None" value="none"></el-option>
258                 <el-option label="HardWare" value="hardware"></el-option>
259               </el-select>
260             </el-form-item>
261             <el-form-item label="显示历史">
262               <el-switch
263                 v-model="form1.isShowHistory"
264                 @change="loadHistory"
265               ></el-switch>
266               <el-button
267                 type="danger"
268                 icon="el-icon-delete"
269                 circle
270                 title="清空历史"
271                 @click="clearHistory"
272               ></el-button>
273             </el-form-item>
274             <el-form-item label="发送区设置" v-show="isShowSendArea">
275               <el-form-item label="发送格式">
276                 <el-radio-group v-model="form1.type">
277                   <el-radio label="1">ASCII</el-radio>
278                   <el-radio label="2">HEX</el-radio>
279                 </el-radio-group>
280               </el-form-item>
281               <el-form-item label="发送信息">
282                 <el-input type="textarea" v-model="form1.sendMsg"></el-input>
283               </el-form-item>
284               <el-button type="primary" @click="sendCommon">发送</el-button>
285             </el-form-item>
286
287             <el-form-item>
288               <el-button :type="btnType" @click="connectBtn">{{
289                   btnText
290                 }}</el-button>
291               <el-button type="info" @click="obtainAuthorization"
292               >新增授权</el-button
293               >
294             </el-form-item>
295           </div>
296           </el-col>
297         </el-row>
298       </el-form>
299     </el-dialog>
e57a89 300   </div>
301 </template>
302 <script>
303 import {listWorkReport} from "@/api/main/om/workReport/workReport";
304 import {listStationConf,getIpv4} from "@/api/main/sc/stationConf";
b77303 305 import {
8cfe20 306   clearWorkpieceRelease,
273d64 307   fistSetpNumber, inPlaceInspection,
A 308   listFormulaChild, manualNgOffline,
0caf87 309   noPageListFormulaChild,
273d64 310   releaseCheck, unfinishedProcess,
b77303 311   updateResults,
312   updateTighteningFormula,
313   workpieceRelease
314 } from "@/api/main/bs/formulaChild/formulaChild";
c2944a 315 import MySerialPort from "@/utils/MySerialPort";
316 import USBDevice from "@/utils/usb.json";
a75d86 317 import {
237733 318   bindYzSfcFlag,
A 319   checkCarCode, checkYzSfcCode,
a75d86 320   findBytrolleyYardGetOne,
A 321   listProductionOrde,
322   receivingWorkOrders,
323   trolleyYardBinDing
324 } from "@/api/main/om/productionOrde/productionOrde";
b64ed2 325 import {addPassingStationCollection} from "@/api/main/da/passingStationCollection/passingStationCollection";
49c784 326 import {
327   addBasicParameters,
328   addParamCollection,
32483a 329   addTighteningParameters,
ddb300 330   saveCampaignTimeParameters,
0aaaba 331   replaceAssemblyCode, checkRecordDataDone, enterWeighing,
49c784 332 } from "@/api/main/da/paramCollection/paramCollection";
9f636f 333 import QRCode from "qrcodejs2";
391c41 334 import {listEquipmentArchives} from "@/api/main/em/equipmentArchives/equipmentArchives";
e57a89 335
336 export default {
337   name: "stationTerminal",
338   data() {
339     return {
9f636f 340       printInfoData: {
A 341         softwareVersion: 'SW001.001', //软件版本号
342         hardwareVersion: 'HW001.001', //硬件版本号
343         printModel: 'H2155D', //型号
344         partNumber: '9900200136', //零部件号
345         supplierCode: '993983', //供应商编码
346       },
a75d86 347       carCode: '',
9f636f 348       goOnlineFlag: false,
A 349       offlineFlag: false,
350
a75d86 351
e57a89 352       serialPortContent: '',
353       // 查询参数
354       formulaChildParams: {
355         pageNum: 1,
356         pageSize: 10,
357         productCode: null,
358         processesCode: null,
0aaaba 359         artificialNgFlag: null,
A 360         sfcBarcode: null,
e57a89 361       },
362       // 配方配置子信息表格数据
363       formulaChildList: [],
364       ipAddress: '',
365       imgSrc: '',
366       headContent: {
367         processesCode: 'OP1010',
368         processesName: '贴标机-贴码',
49c784 369         sfcCode: '',
ddb300 370         yzSfcCode: '',
a75d86 371         cardCode: '',
e57a89 372       },
373       workpieceInformation: {
b64ed2 374         workOrderNo: null,
e57a89 375         productCode: null,
376         productModel: null,
377         productName: null,
768498 378         inboundTime: null,
e57a89 379       },
380       // 查询参数
381       queryParams: {
382         pageNum: 1,
383         pageSize: 10,
384         sfcCode: null,
385       },
386       // 查询参数
387       StationConfQueryParams: {
388         pageNum: 1,
389         pageSize: 10,
390         ipAddress: null,
391       },
392       cakeLamp: {
393         plcState: 1, //plc
394         scannerState: 1, //扫码枪
395         InPlace: 0, //工件到位
396         scanFinish: 0,
397         startWork: 0,
398         release: 0 //允许放行
399       },
400       content: '',
401       activeName: 'first',
4e83fa 402       // url: "ws://192.168.2.248:8080/websocket/message/",
682919 403       // url: "ws://10.103.210.248:8080/websocket/message/",
A 404       url: "ws://192.168.2.76:8080/websocket/message/",
e57a89 405       message: "",
406       text_content: "",
407       ws: null,
c2944a 408       inputValue: '9',
409
410       open1: false,
411       input: "",
412       keepReading: true,
413       form1: {
b5fcd8 414         baudRate: "115200",
c2944a 415         dataBits: "8",
416         stopBits: "1",
417         parity: "none",
418         flowControl: "none",
419         desc: "",
420         type: "1",
421         isShowHistory: false,
422       },
423       btnType: "primary",
424       btnText: "连接串口",
425       restaurants: [],
426       portsList: [],
427       isShowSendArea: false,
428       readType: 1,
429       title: "",
b64ed2 430
431       passingStationForm: {},
49c784 432       originalArray: [],
237733 433       yzSfcFlag: 1,
768498 434       endYz: false,
391c41 435       packCode: 'test111'
e57a89 436     }
437   },
438   beforeDestroy() {
439     this.exit();
440   },
441   created() {
442     this.initStation();
443     // this.getStationConfList();
444     // setTimeout(() => {
445     //   this.connectWebsocket();
446     // }, 3000);
447   },
448   mounted() {
c2944a 449     if ("serial" in navigator) {
450       this.myserialport = new MySerialPort();
451       this.getPorts();
452       navigator.serial.addEventListener("connect", (e) => {
453         this.$message.success("设备已连接");
454         this.getPorts();
455       });
456       navigator.serial.addEventListener("disconnect", (e) => {
457         this.$message.error("设备已断开");
458       });
459       this.restaurants = this.loadAll();
460     } else {
461       this.$message.error(
462         "当前为HTTP模式或者浏览器版本过低,不支持网页连接串口"
463       );
464     }
465   },
466   computed: {
467     isDisable() {
468       return this.btnType === "danger";
391c41 469     }
e57a89 470   },
471   methods: {
9f636f 472
A 473     //接收工单-------开始
474     getWorkOrdersPrint() {
475       let newStr = document.getElementById('getWorkOrdersPrintPrintMe').innerHTML;
476       const printFrame = document.createElement('iframe');
477       printFrame.style.display = 'none';
478       document.body.appendChild(printFrame);
479       const content = document.getElementById('getWorkOrdersPrintPrintMe').innerHTML;
480       printFrame.contentDocument.write(content);
481       printFrame.contentWindow.print();
482       document.body.removeChild(printFrame);
483       return false;
484     },
485     async getWorkOrders(){
486       await receivingWorkOrders().then(response => {
487         this.packCode = response.msg;
488         this.getWorkOrdersTest1()
489       });
490       setTimeout(() => {
491         this.getWorkOrdersPrint()
492       },50)
493     },
494     getWorkOrdersTest1(){
495       document.getElementById('canvasWrapper3').innerHTML = ''
496       this.$nextTick(() => {
497         let qrCode = new QRCode('canvasWrapper3',{
498           width: 80,
499           height: 80,
500           padding: 0,
501           margin: 0,
502           text: this.packCode,
503           colorDark: '#000',
504           colorLight: '#fff'
505         })
506       })
507     },
508     //接收工单-------结束
509
510     //下线打印-------开始
391c41 511     initializePrintInfoData(){
A 512       listEquipmentArchives().then(response => {
513         this.printInfoData.softwareVersion = response.rows[0].equipmentCode
514         this.printInfoData.hardwareVersion = response.rows[0].equipmentName
515         this.printInfoData.supplierCode = response.rows[0].equipmentSpec
516         this.printInfoData.printModel = response.rows[0].equipmentBrand
517         this.printInfoData.partNumber = response.rows[0].equipmentTypeName
518         console.log(response.rows[0])
519       });
520     },
9f636f 521     test1(){
A 522       document.getElementById('canvasWrapper1').innerHTML = '';
523       this.$nextTick(() => {
524           let qrCode = new QRCode('canvasWrapper1',{
525             width: 120,
526             height: 120,
527             text: 'P'+this.printInfoData.partNumber+'#T'+ this.headContent.sfcCode +'#V'+this.printInfoData.supplierCode+'#S'+this.printInfoData.softwareVersion+'#H'+this.printInfoData.hardwareVersion+'#NBMS#',
528             colorDark: '#000',
529             colorLight: '#fff'
530           })
531         }
532       )
533     },
534     test2(){
535       document.getElementById('canvasWrapper2').innerHTML = '';
536       this.$nextTick(() => {
537           let qrCode = new QRCode('canvasWrapper2',{
538             width: 120,
539             height: 120,
540             text: 'P'+this.printInfoData.partNumber+'#T'+ this.headContent.sfcCode +'#V'+this.printInfoData.supplierCode+'#S'+this.printInfoData.softwareVersion+'#H'+this.printInfoData.hardwareVersion+'#NBMS#',
541             colorDark: '#000',
542             colorLight: '#fff'
543           })
544         }
545       )
546     },
547     print1() {
391c41 548       // 使用插件打印方式
A 549       // this.$print(this.$refs.printMe)
550       // this.initializePrintInfoData()
551       // if(this.headContent.sfcCode){
552       //   //新页面打印
553       //   // let newStr = document.getElementById('printMe').innerHTML;
554       //   // let newWin = window.open('', '_blank',st);
555       //   // newWin.document.body.innerHTML = newStr;
556       //   // newWin.print();
557       //   // 本页面打印
558       //   let newStr = document.getElementById('printMe').innerHTML;
559       //   const printFrame = document.createElement('iframe');
560       //   printFrame.style.display = 'none';
561       //   document.body.appendChild(printFrame);
562       //   const content = document.getElementById('printMe').innerHTML;
563       //   printFrame.contentDocument.write(content);
564       //   printFrame.contentWindow.print();
565       //   console.log(printFrame)
566       //   // document.body.removeChild(printFrame);
567       //   console.log(printFrame)
568       //   return false;
569       // }else {
570       //   this.$message.error('未扫描总成码禁止打印!');
571       // }
9f636f 572     },
A 573     //下线打印-------截止
768498 574     bindcardCode(scanValue){
A 575       // this.$message('绑定成功!');
a75d86 576       let param = {
A 577         productNum: this.headContent.sfcCode,
768498 578         trolleyYard: scanValue,
a75d86 579       }
A 580       trolleyYardBinDing(param).then(response => {
581       });
582
583     },
c2944a 584     serialLink() {
585       this.open1 = true
ddb300 586     },
A 587     bindYzSfc(){
588       if(this.headContent.sfcCode!==""&&this.headContent.yzSfcCode!==""){
589         let param = {
590           sfcCode: this.headContent.sfcCode,
591           locationCode: this.headContent.processesCode,
592           yzSfcCode: this.headContent.yzSfcCode
593         }
237733 594         const orderParam = {
A 595           productNum: this.headContent.sfcCode,
596         }
ddb300 597         replaceAssemblyCode(param).then(response => {
68f0c8 598           this.$message('绑定成功!');
237733 599           bindYzSfcFlag(orderParam).then(response => {
A 600             this.yzSfcFlag = 1
601           });
ddb300 602         });
A 603       }
c2944a 604     },
e57a89 605     Release(){
93feb8 606       // this.$message('portsList!'+this.portsList.length);
607       if(this.btnType === "danger"){
608         this.$message('连接了!');
609
610       }else {
611         this.$message('mei连接了!');
612
e57a89 613       }
614     },
c2944a 615     serialPortMethod(value){
b77303 616       let formulaChildParams = {
617         scanBarcode: value,
618         sfcBarcode: this.headContent.sfcCode,
619         workOrderNo: this.workpieceInformation.workOrderNo,
620         productCode: this.workpieceInformation.productCode,
621         locationCode: this.headContent.processesCode,
622         collectionTime: new Date()
623       }
624       updateResults(formulaChildParams).then(response => {
c5e9c5 625         console.log(response)
626         if(response.msg === "3"){
627           this.cakeLamp.release= 1 //允许放行
2fbce7 628         }else if(response.msg === "2"){
A 629           this.$message.error('扫码重复请重新扫码!');
c5e9c5 630         }
b77303 631         this.getListFormulaChild()
632       });
e57a89 633     },
634     rowStyle({ row }) {
635       if (row.results === 'OK') {
636         return 'background-color: PaleGreen';
637       } else if (row.results === 'NG') {
638         return 'background-color: LightSalmon';
639       }
640       return '';
641     },
642     /** 查询配方配置子信息列表 */
643     getListFormulaChild() {
11cc36 644       // this.formulaChildList = []
e57a89 645       this.formulaChildParams.productCode = this.workpieceInformation.productCode
646       this.formulaChildParams.processesCode = this.headContent.processesCode
6e3e50 647       if(this.formulaChildParams.artificialNgFlag !== null){
0aaaba 648         this.formulaChildParams.sfcBarcode = this.headContent.sfcCode
A 649       }
6e3e50 650       console.log("getListFormulaChild"+this.formulaChildParams.artificialNgFlag)
0caf87 651       noPageListFormulaChild(this.formulaChildParams).then(response => {
e57a89 652         this.formulaChildList = response.rows;
6a462f 653         if (this.formulaChildList.length >0){
W 654           let pos = 0
655           const tempArr = this.formulaChildList.filter(x=> 'OK' === x.results)
656           if (tempArr.length>0){
657             pos = tempArr.length
658             this.$nextTick(() => {
659               let temp33 = document.getElementsByClassName('el-table__row')
660               console.log('temp33',temp33)
661               console.log('len',temp33.item(pos))
662               if (temp33.length > 0){
663                 console.log('1111111111111111')
664                 let arr = temp33[pos-1]
665                 console.log('srr',arr)
666                 arr.scrollIntoView({ block: 'center' })
667               }
668             })
669           }
670
671         }
672
e57a89 673       });
674     },
1df825 675     endClear(){
676       this.cakeLamp.InPlace= 0 //工件到位
677       this.cakeLamp.scanFinish= 0
678       this.cakeLamp.startWork= 0
679       this.cakeLamp.release= 0 //允许放行
b77c7b 680
1df825 681       this.formulaChildList = []
c5e9c5 682       this.workpieceInformation.productCode = null;
683       this.workpieceInformation.workOrderNo = null;
684       this.workpieceInformation.productModel = null;
685       this.workpieceInformation.productName = null;
768498 686       this.workpieceInformation.inboundTime = null;
5316c5 687       this.headContent.sfcCode = '';
288790 688       this.headContent.yzSfcCode = '';
A 689       this.headContent.cardCode = '';
0aaaba 690       this.formulaChildParams.artificialNgFlag = null
A 691       this.formulaChildParams.sfcBarcode = null
1df825 692     },
e57a89 693     changeMenu(tab, event) {
694       console.log(tab, event);
695     },
696     clearClick(){
8cfe20 697       const param = {
A 698         workOrderNo: this.workpieceInformation.workOrderNo,
699         productCode: this.workpieceInformation.productCode,
700         locationCode: this.headContent.processesCode,
701         productBarcode: this.headContent.sfcCode,
702       }
703       this.endClear()
704       clearWorkpieceRelease(param).then(response => {});
705       this.headContent.sfcCode = ''
bdb404 706       this.$message('清除成功!');
e57a89 707     },
708     scanCompleted(){
709       this.$message('扫码完成'+this.content);
710       this.headContent.sfcCode = this.content
711       this.queryParams.sfcCode = this.content
712       this.getList()
713       this.getListFormulaChild()
714       this.cakeLamp.scanFinish = 1
715       this.cakeLamp.startWork = 1
716
717     },
b64ed2 718     /** 查询工单列表 */
e57a89 719     async getList() {
391c41 720       this.initializePrintInfoData()
b64ed2 721       await listProductionOrde(this.queryParams).then(response => {
e57a89 722         let rowsData = response.rows[0];
723         console.log(rowsData)
b64ed2 724         this.workpieceInformation.workOrderNo = rowsData.workOrderNo;
e57a89 725         this.workpieceInformation.productCode = rowsData.productCode;
726         this.workpieceInformation.productModel = rowsData.productModel;
727         this.workpieceInformation.productName = rowsData.productName;
768498 728         this.headContent.cardCode = rowsData.trolleyYard;
6e3e50 729         this.formulaChildParams.artificialNgFlag = rowsData.artificialNgFlag;
e57a89 730       });
9f636f 731       if(this.headContent.processesCode === 'POP430'){
A 732         this.test1()
733         this.test2()
734       }
e57a89 735       this.getListFormulaChild()
768498 736       // this.addOverStationCollection()
A 737       this.workpieceInformation.inboundTime = this.getCurrentTime()
bdb404 738       const param = {
A 739         processesCode: this.headContent.processesCode,
6e3e50 740         productCode: this.workpieceInformation.productCode
bdb404 741       }
A 742       fistSetpNumber(param).then(response => {
743         console.log("fistSetpNumber------"+response.msg)
744       });
b64ed2 745     },
746
768498 747     getCurrentTime() {
A 748       const now = new Date();
749       const year = now.getFullYear();
750       const month = this.padTimeUnit(now.getMonth() + 1); // 月份是从0开始的
751       const day = this.padTimeUnit(now.getDate());
752       const hours = this.padTimeUnit(now.getHours());
753       const minutes = this.padTimeUnit(now.getMinutes());
754       const seconds = this.padTimeUnit(now.getSeconds());
755       return `${year}-${month}-${day} ${hours}:${minutes}:${seconds}`;
756     },
757     padTimeUnit(value) {
758       return value.toString().padStart(2, '0');
759     },
8cfe20 760     addBaseData(){
A 761       addBasicParameters(this.passingStationForm).then(response => {});
762     },
763
b64ed2 764     /** 入站增加过站采集记录 **/
765     addOverStationCollection(){
766       this.passingStationForm = {
767         id: null,
768         workOrderNo: this.workpieceInformation.workOrderNo,
769         productCode: this.workpieceInformation.productCode,
770         locationCode: this.headContent.processesCode,
771         model: this.workpieceInformation.productModel,
772         productBarcode: this.headContent.sfcCode,
32483a 773         sfcCode: this.headContent.sfcCode,
b64ed2 774         inboundTime: new Date()
775       }
b77c7b 776       addPassingStationCollection(this.passingStationForm).then(response => {});
4a5f2a 777       // addBasicParameters(this.passingStationForm).then(response => {});
e57a89 778     },
779     exit() {
780       if (this.ws) {
781         this.ws.close();
782         this.ws = null;
783       }
784     },
785     send() {
786       if (this.ws) {
787         this.ws.send(this.message);
788       } else {
789         alert("未连接到服务器");
790       }
791     },
1df825 792
49c784 793     initStation: async function () {
e57a89 794       await getIpv4().then(response => {
795         this.StationConfQueryParams.ipAddress = response.msg
49c784 796         console.log('查询到本工位IP为' + this.StationConfQueryParams.ipAddress)
e57a89 797       });
798       await listStationConf(this.StationConfQueryParams).then(response => {
799         let rows = response.rows[0]
49c784 800         if (response.rows.length === 0) {
e57a89 801           this.$message('该工位没有配置IP,请联系管理员配置IP');
802           return
803         }
804         this.headContent.processesName = rows.processesName
805         this.headContent.processesCode = rows.processesCode
a75d86 806         console.log('设置工位编码' + this.headContent.processesCode)
273d64 807         inPlaceInspection({processesCode: this.headContent.processesCode}).then(response => {
A 808           console.log(response)
809           this.cakeLamp.InPlace = response.data
810         });
a320dc 811
9f636f 812         if(this.headContent.processesCode === 'POP230'){
A 813           this.goOnlineFlag = true
814         }
815         if(this.headContent.processesCode === 'POP430'){
816           this.offlineFlag = true
817         }
818
e57a89 819       });
f17d8c 820       this.conCom()
49c784 821       console.log('websocket连接工位为' + this.headContent.processesCode)
e57a89 822       const wsuri = this.url + this.headContent.processesCode;
823       this.ws = new WebSocket(wsuri);
824       const self = this;
825       this.ws.onopen = function (event) {
391c41 826         self.$message('websocket连接成功!');
a320dc 827
e57a89 828       };
829       this.ws.onmessage = function (event) {
391c41 830         if (event.data === "print") {
A 831           self.$message('postman调用打印方法打印!');
832           // self.print1()
833           document.getElementById('print').click();
834         }else if (event.data === "IN") {
49c784 835           self.cakeLamp.InPlace = 1;
273d64 836         } else if (event.data === "NG") {
A 837           //给plc发下线信号
838           //清除数据
0aaaba 839           self.$confirm('拧紧三次NG,请确认下线!!!', '消息', {
273d64 840             confirmButtonText: '确定',
0aaaba 841             cancelButtonText: '取消',
A 842             showCancelButton: false,
273d64 843             type: 'warning'
A 844           }).then(() => {
845             self.ngFunction();
0aaaba 846             this.$message({
A 847               type: 'success',
848               message: '确认成功!'
849             });
850           });
273d64 851
49c784 852         } else if (event.data === "OUT") {
853           self.cakeLamp.release = 1;
32483a 854         } else if (event.data === "END") {
768498 855
A 856           const formulaChildIndex = self.formulaChildList.length-1
237733 857
16714e 858           if(self.headContent.sfcCode=== ''||self.headContent.sfcCode=== null){
273d64 859             unfinishedProcess({processesCode: self.headContent.processesCode,recordDataDone: 26}).then(response => {});
2fbce7 860             self.$message('总成码为空,请扫码!')
768498 861             return;
16714e 862           }
A 863
768498 864           if(self.formulaChildList[formulaChildIndex].results !== 'OK'){
A 865             self.$message('未做完工序禁止放行');
273d64 866             unfinishedProcess({processesCode: self.headContent.processesCode,recordDataDone: 25}).then(response => {});
768498 867             return;
A 868           }
869
870           const param = {
871             workOrderNo: self.workpieceInformation.workOrderNo,
872             productCode: self.workpieceInformation.productCode,
873             locationCode: self.headContent.processesCode,
874             productBarcode: self.headContent.sfcCode,
875             inboundTime: self.workpieceInformation.inboundTime,
876             formulaChildEntity: self.formulaChildList[formulaChildIndex]
877           }
0aaaba 878
768498 879           console.log("进入最终方法")
A 880           self.endSaveData(param)
49c784 881         } else if (event.data.includes("[")) {
b77c7b 882           let formulaChilds = "";
3c2299 883           self.formulaChildList.sort((a, b) => a.stepSort - b.stepSort);
884           self.formulaChildList
885             .filter((formulaChild) => formulaChild.operationType === '1');
886           for (let i = 0; i < self.formulaChildList.length; i++) {
887             let formulaChild = self.formulaChildList[i];
b77c7b 888             let results = formulaChild.results;
2fbce7 889
3c2299 890             if (results === '' || results === null || results === 'NG') {
b77303 891               formulaChilds = formulaChild;
3c2299 892               break;
b77c7b 893             }
3c2299 894           }
2fbce7 895            if(formulaChilds === ""){
A 896              self.$message.error('本工位已工作完成!');
897              return;
898            }
49c784 899           const param = {
2fbce7 900             id: formulaChilds.id,
49c784 901             tightenTheArray: event.data,
b77c7b 902             paramCode: formulaChilds.paramCode,
49c784 903             workOrderNo: self.workpieceInformation.workOrderNo,
904             productCode: self.workpieceInformation.productCode,
905             locationCode: self.headContent.processesCode,
906             productBarcode: self.headContent.sfcCode,
2fbce7 907             spareField1: formulaChilds.spareField1,
A 908             spareField2: formulaChilds.spareField2,
909             spareField3: formulaChilds.spareField3,
910             spareField4: formulaChilds.spareField4,
273d64 911             stepSort: formulaChilds.stepSort,
A 912             ngTimes: formulaChilds.ngTimes,
49c784 913           }
16714e 914           if(formulaChilds.paramCode === null||formulaChilds.paramCode ===''){
A 915             self.$message('未找到参数码,请检查参数码是否正确');
916             return;
917           }
6e3e50 918           self.formulaChildParams.artificialNgFlag = null
A 919           console.log("self.formulaChildParams.artificialNgFlag"+self.formulaChildParams.artificialNgFlag)
16714e 920           if(self.headContent.sfcCode!==null||self.headContent.sfcCode!==''){
A 921             updateTighteningFormula(param).then(response => {
2fbce7 922               //addTighteningParameters(param).then(response => {});
16714e 923               self.getListFormulaChild()
A 924             }).catch(error =>{
925               self.getListFormulaChild()
926             });
927           }
e57a89 928         }
929       };
930     },
c2944a 931
768498 932     endSaveData(param){
A 933       saveCampaignTimeParameters(param).then(response => {
934       this.cakeLamp.release = 1;
935       this.endClear()
936       workpieceRelease(param).then(response => {});
937       });
938     },
1df825 939
273d64 940     ngFunction(){
A 941       const param = {
942         locationCode: this.headContent.processesCode,
943         sfcBarcode: this.headContent.sfcCode,
944         productCode: this.workpieceInformation.productCode,
945       }
946       manualNgOffline(param).then(response => {});
947       clearWorkpieceRelease(param).then(releaseCheck =>{});
948       this.endClear()
949     },
950
c2944a 951     //接受数据的回调
952     callBack(value) {
953       if (this.form1.isShowHistory) this.form1.desc = this.readLi().join("");
954       else {
955         const scanValue = this.myserialport.hex2atostr(value).replace(/[\r\n]/g, '');
11cc36 956         console.log("串口收到数据-------------------"+scanValue)
2fbce7 957         console.log("sfc=--"+this.headContent.sfcCode+"--")
bdb404 958         if(this.headContent.sfcCode !== '' && this.headContent.sfcCode !== null
A 959           && this.headContent.sfcCode !== undefined){
273d64 960           if(scanValue.includes("0RSP1TE") && this.headContent.processesCode === 'POP230'){
a75d86 961             this.headContent.cardCode = scanValue
768498 962             this.bindcardCode(scanValue);
A 963             this.serialPortMethod(scanValue)
ddb300 964           }else {
a52d08 965             this.$message('工位终端扫描物料编码'+scanValue);
3c2299 966             console.log(scanValue)
967             this.serialPortMethod(scanValue)
968           }
ddb300 969         } else {
273d64 970           if(this.headContent.processesCode === 'POP230'){
a75d86 971             this.headContent.sfcCode = scanValue;
A 972             this.queryParams.productNum = scanValue;
4a5f2a 973             this.getList()
A 974             this.cakeLamp.scanFinish = 1
975             this.cakeLamp.startWork = 1
a75d86 976           }else {
A 977             let param = {
978               trolleyYard: scanValue
979             }
980             findBytrolleyYardGetOne(param).then(response => {
4a5f2a 981               if(response.msg !== '2'){
A 982                 this.headContent.sfcCode = response.msg;
983                 this.queryParams.productNum = response.msg;
984                 this.$message('扫码识别产品序列号'+scanValue);
985                 // this.headContent.sfcCode = scanValue;
986                 // this.queryParams.productNum = scanValue;
987                 this.getList()
988                 this.cakeLamp.scanFinish = 1
989                 this.cakeLamp.startWork = 1
990               }else {
991                 this.$message('没有序列号'+scanValue);
992                 return
993               }
a75d86 994             });
A 995           }
4a5f2a 996
ddb300 997         }
A 998
e57a89 999       }
c2944a 1000     },
1001     clearHistory() {
1002       this.form1.desc = "";
1003       this.myserialport.state.readValue = [];
1004     },
1005     loadHistory() {
1006       if (this.form1.isShowHistory) this.form1.desc = this.readLi().join("");
1007       else {
1008         let temp = this.readLi();
1009         if (temp.length > 0) this.form1.desc = temp[temp.length - 1].join("");
1010       }
1011     },
1012     readLi() {
1013       let readType = this.readType;
1014       return this.myserialport.state.readValue.map((items, index) => {
1015         const item = items.value;
1016         const type = items.type; // 1接收,2发送
1017         let body = [];
1018         if (item !== undefined) {
1019           let strArr = [];
1020           for (let hex of Array.from(item)) {
1021             strArr.push(hex.toString(16).toLocaleUpperCase());
1022           }
1023           if (strArr.includes("D") && strArr.includes("A")) {
1024             if (strArr.indexOf("A") - strArr.indexOf("D") === 1) {
1025               strArr.splice(strArr.indexOf("D"), 1);
1026               strArr.splice(strArr.indexOf("A"), 1, <br key={0} />);
1027             }
1028           }
1029           strArr = strArr.map((item) => {
1030             if (typeof item === "string") {
1031               if (readType === 1) {
1032                 return this.myserialport.hex2a(parseInt(item, 16));
1033               } else if (readType === 2) {
1034                 return item + " ";
1035               }
1036             }
1037             return item;
1038           });
1039           if (typeof strArr[strArr.length - 1] === "string") {
1040             strArr.push("\r\n");
1041           }
1042           body.push(strArr.join(""));
1043         }
1044         return body;
1045       });
1046     },
640ff8 1047     conCom(){
1048       try {
1049         this.myserialport.state.baudRate = this.form1.baudRate;
1050         this.myserialport.state.dataBits = this.form1.dataBits;
1051         this.myserialport.state.stopBits = this.form1.stopBits;
1052         this.myserialport.state.parity = this.form1.parity;
1053         this.myserialport.state.flowControl = this.form1.flowControl;
1054         this.myserialport.openPort(0, true, this.callBack);
1055         console.log(this.form1.port)
1056       } catch (error) {
1057         this.$message.error("串口连接失败!请检查串口是否已被占用");
1058       }
1059       if (this.myserialport.state.isOpen) {
1060         this.$message.success("串口连接成功");
1061       }
1062     },
c2944a 1063     //连接
1064     async connectBtn() {
1065       if (this.btnType === "primary") {
1066         try {
1067           this.myserialport.state.baudRate = this.form1.baudRate;
1068           this.myserialport.state.dataBits = this.form1.dataBits;
1069           this.myserialport.state.stopBits = this.form1.stopBits;
1070           this.myserialport.state.parity = this.form1.parity;
1071           this.myserialport.state.flowControl = this.form1.flowControl;
1072           await this.myserialport.openPort(this.form1.port, true, this.callBack);
11cc36 1073           console.log(this.form1.port)
c2944a 1074         } catch (error) {
1075           this.$message.error("串口连接失败!请检查串口是否已被占用");
1076         }
1077         if (this.myserialport.state.isOpen) {
1078           this.$message.success("串口连接成功");
1079           this.open1 = false
1080           this.btnType = "danger";
1081           this.btnText = "关闭串口";
1082         }
1083       } else {
1084         this.myserialport.openPort(this.form1.port, false, this.callBack);
1085         this.$message.success("串口关闭成功");
1086         this.btnType = "primary";
1087         this.btnText = "连接串口";
1088       }
1089     },
1090     //授权
1091     async obtainAuthorization() {
1092       if ("serial" in navigator) {
1093         console.log("The Web Serial API is supported.");
1094         if (!this.myserialport) this.myserialport = new MySerialPort();
1095         try {
1096           await this.myserialport.handleRequestPort();
1097           this.$message.success("串口授权成功");
1098           this.getPortInfo(this.myserialport.state.ports);
1099         } catch (error) {
1100           this.$message.warning("未选择新串口授权!");
1101         }
1102       } else {
1103         this.$message.error(
1104           "当前为HTTP模式或者浏览器版本过低,不支持网页连接串口"
1105         );
1106       }
1107     },
1108     //串口列表初始化
1109     getPortInfo(portList) {
1110       this.portsList = [];
1111       portList.map((port, index) => {
1112         const { usbProductId, usbVendorId } = port.getInfo();
1113         if (usbProductId === undefined || usbVendorId === undefined) {
1114           this.portsList.push({ label: "未知设备" + index, value: index });
1115         } else {
1116           const usbVendor = USBDevice.filter(
1117             (item) => parseInt(item.vendor, 16) === usbVendorId
1118           );
1119           let usbProduct = [];
1120           if (usbVendor.length === 1) {
1121             usbProduct = usbVendor[0].devices.filter(
1122               (item) => parseInt(item.devid, 16) === usbProductId
1123             );
1124           }
1125           this.portsList.push({ label: usbProduct[0].devname, value: index });
1126         }
1127       });
1128     },
1129     // 发送
1130     async sendCommon() {
1131       if (this.myserialport.state.isOpen) {
1132         if (this.form1.sendMsg.length !== 0) {
1133           const writeType = this.form1.type;
1134           let value = this.form1.sendMsg;
1135           let arr = [];
1136           if (writeType === 1) {
1137             // ASCII
1138             for (let i = 0; i < value.length; i++) {
1139               arr.push(this.myserialport.a2hex(value[i]));
1140             }
1141           } else if (writeType === 2) {
1142             // HEX
1143             if (/^[0-9A-Fa-f]+$/.test(value) && value.length % 2 === 0) {
1144               for (let i = 0; i < value.length; i = i + 2) {
1145                 arr.push(parseInt(value.substring(i, i + 2), 16));
1146               }
1147             } else {
1148               this.$message.error("格式错误");
1149               return;
1150             }
1151           }
1152           this.myserialport.writeText(arr);
1153         } else {
1154           this.$message.warning("请输入发送的信息");
1155         }
1156       } else {
1157         this.$message.warning("串口处于关闭状态,请连接串口");
1158       }
1159     },
1160     async getPorts() {
1161       await this.myserialport.getPorts();
1162       this.getPortInfo(this.myserialport.state.ports);
1163     },
1164     querySearch(queryString, cb) {
1165       var restaurants = this.restaurants;
1166       var results = queryString
1167         ? restaurants.filter(this.createFilter(queryString))
1168         : restaurants;
1169       // 调用 callback 返回建议列表的数据
1170       cb(results);
1171     },
1172     createFilter(queryString) {
1173       return (restaurant) => {
1174         return (
1175           restaurant.value.toLowerCase().indexOf(queryString.toLowerCase()) ===
1176           0
1177         );
1178       };
1179     },
1180     loadAll() {
1181       return [
1182         { value: "110" },
1183         { value: "300" },
1184         { value: "600" },
1185         { value: "1200" },
1186         { value: "2400" },
1187         { value: "4800" },
1188         { value: "7200" },
1189         { value: "9600" },
1190         { value: "14400" },
1191         { value: "19200" },
1192         { value: "28800" },
1193         { value: "38400" },
1194         { value: "56000" },
1195         { value: "57600" },
1196         { value: "76800" },
1197         { value: "115200" },
1198         { value: "230400" },
1199         { value: "460800" },
1200       ];
1201     },
e57a89 1202   }
1203 }
1204
1205 </script>
1206 <style scoped>
1207 .bottom-card{
1208   height: 600px;
1209 }
1210 .circle-button{
1211   height: 30px;
1212   width: 30px;
1213 }
1214 .circle-red {
1215   background-color: #e01a4f;
1216 }
1217 .circle-green {
1218   background-color: green;
1219 }
1220 .circle-green-animate {
1221   background-color: green;
1222   animation: circle-green-animate 2s infinite;
1223 }
1224   @keyframes circle-green-animate {
1225     50% {
1226       opacity: 0.6;
1227     }
1228     0% {
1229       opacity: 0.2;
1230     }
1231   }
1232 .head-font{
c2944a 1233   /*font-weight: bold;*/
1234   /*font-size: 25px;*/
e57a89 1235 }
1236 span{
1237   font-size: 15px;
1238 }
1239 .el-table .warning-row {
1240   background: oldlace;
1241 }
1242
1243 .el-table .success-row {
1244   background: #f0f9eb;
1245 }
1246 </style>
1247