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