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