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