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