admin
2024-06-15 8cfe20288690f2ba46c804f41f39e8aa48c2dea0
提交 | 用户 | 时间
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>
49c784 37            <el-descriptions-item label="产品编号">
e57a89 38              <span>{{workpieceInformation.productCode}}</span>
39            </el-descriptions-item>
40            <el-descriptions-item label="产品型号">
41              <span>{{workpieceInformation.productModel}}</span>
42            </el-descriptions-item>
43            <el-descriptions-item label="产品名称">
44              <span>{{workpieceInformation.productName}}</span>
45            </el-descriptions-item>
b64ed2 46 <!--           <el-descriptions-item label="节拍">-->
47 <!--             <span>{{workpieceInformation.beat}}</span>-->
48 <!--           </el-descriptions-item>-->
e57a89 49          </el-descriptions>
50          <el-divider></el-divider>
51          <el-row>
52            <el-col :span="12">
53              <el-button class="circle-button" :class="cakeLamp.plcState ? 'circle-green-animate':'circle-red'" circle></el-button>
54              <span style="display: none">{{cakeLamp.plcState}}</span>
55              <span>&nbsp;PLC状态</span>
56            </el-col>
57            <el-col :span="12">
58              <el-button class="circle-button" :class="cakeLamp.scannerState ? 'circle-green-animate':'circle-red'" circle></el-button>
59              <span style="display: none">{{cakeLamp.scannerState}}</span>
60              <span>&nbsp;扫码枪状态</span>
61            </el-col>
62          </el-row>
63          <el-row style="margin-top: 20px">
64            <el-col :span="12">
65              <el-button class="circle-button" :class="cakeLamp.InPlace ? 'circle-green':'circle-red'" circle></el-button>
66              <span style="display: none">{{cakeLamp.InPlace}}</span>
67              <span>&nbsp;工件到位</span>
68            </el-col>
69            <el-col :span="12">
70              <el-button class="circle-button" :class="cakeLamp.scanFinish ? 'circle-green':'circle-red'" circle></el-button>
71              <span style="display: none">{{cakeLamp.scanFinish}}</span>
72              <span>&nbsp;扫码完成</span>
73            </el-col>
74          </el-row>
75          <el-row style="margin-top: 20px">
76            <el-col :span="12">
77              <el-button class="circle-button" :class="cakeLamp.startWork ? 'circle-green':'circle-red'" circle></el-button>
78              <span style="display: none">{{cakeLamp.startWork}}</span>
79              <span>&nbsp;开始作业</span>
80            </el-col>
81            <el-col :span="12">
82              <el-button class="circle-button" :class="cakeLamp.release ? 'circle-green':'circle-red'" circle></el-button>
83              <span style="display: none">{{cakeLamp.release}}</span>
84              <span>&nbsp;允许放行</span>
85            </el-col>
86
87          </el-row>
70cc26 88          <el-row v-show="showInput" style="margin-top: 20px">
ddb300 89            <el-col></el-col>
A 90              <span style="width: 130px;" class="head-font">预装总成号 : {{headContent.yzSfcCode}}</span>
91          </el-row>
68f0c8 92 <!--         <el-row v-show="showInput" style="margin-top: 20px">-->
A 93 <!--           <el-button @click="bindYzSfc" type="primary">绑定</el-button>-->
94 <!--         </el-row>-->
a75d86 95
A 96          <el-row v-show="onLineBinDing" style="margin-top: 20px">
97            <el-col></el-col>
98            <span style="width: 130px;" class="head-font">小车码 : {{headContent.cardCode}}</span>
99          </el-row>
68f0c8 100 <!--         <el-row v-show="onLineBinDing" style="margin-top: 20px">-->
A 101 <!--           <el-button @click="bindcardCode" type="primary">绑定</el-button>-->
102 <!--         </el-row>-->
e57a89 103        </el-card>
104
105      </el-col>
c2944a 106      <el-col :span="17">
e57a89 107        <el-tabs type="border-card"  style="height: 600px" v-model="activeName" @tab-click="changeMenu">
108          <el-tab-pane name="first">
109            <span slot="label"> <a class="el-icon-date"></a>首页</span>
b77c7b 110            <el-col :span="24">
0caf87 111              <el-table height="500" :cell-style="rowStyle" :data="formulaChildList">
8cfe20 112 <!--               <el-table-column label="排序" width="60" align="center" type="index">-->
A 113 <!--               </el-table-column>-->
114                <el-table-column label="拧紧步号" align="center" prop="stepSort">
e57a89 115                </el-table-column>
8cfe20 116 <!--               <el-table-column label="操作内容" :show-overflow-tooltip='true' align="center" prop="operationSteps">-->
A 117                <el-table-column label="操作内容" align="center" prop="operationSteps">
e57a89 118                </el-table-column>
b77303 119                <el-table-column label="产品编号" align="center" prop="productCode">
b77c7b 120                </el-table-column>
5316c5 121                <el-table-column label="物料编码" align="center" prop="materialCode">
A 122                </el-table-column>
b77303 123                <el-table-column label="采集值" align="center" prop="collectData">
b77c7b 124                </el-table-column>
b77303 125                <el-table-column label="结果" align="center" prop="results">
b77c7b 126                </el-table-column>
8cfe20 127
e57a89 128              </el-table>
129            </el-col>
b77c7b 130 <!--           <el-col :span="14">-->
131 <!--             <el-image style="height: 520px;width: 100%" :src="imgSrc"></el-image>-->
132 <!--           </el-col>-->
e57a89 133          </el-tab-pane>
b77c7b 134 <!--         <el-tab-pane name="second">-->
135 <!--           <span slot="label"> <b class="el-icon-date"></b>物料BOM</span>-->
136 <!--           <el-empty>-->
137 <!--             <span slot="description">暂无数据</span>-->
138 <!--           </el-empty>-->
139 <!--         </el-tab-pane>-->
140 <!--         <el-tab-pane name="third">-->
141 <!--           <span slot="label"> <b class="el-icon-date"></b>采集清单</span>-->
142 <!--           <el-empty>-->
143 <!--             <span slot="description">暂无数据</span>-->
144 <!--           </el-empty>-->
145 <!--         </el-tab-pane>-->
146 <!--         <el-tab-pane name="fourth">-->
147 <!--           <span slot="label"> <b class="el-icon-date"></b>安灯状态</span>-->
148 <!--           <el-empty>-->
149 <!--             <span slot="description">暂无数据</span>-->
150 <!--           </el-empty>-->
151 <!--         </el-tab-pane>-->
152 <!--         <el-tab-pane name="fifth">-->
153 <!--           <span slot="label"> <b class="el-icon-date"></b>工艺配方</span>-->
154 <!--           <el-empty>-->
155 <!--             <span slot="description">暂无数据</span>-->
156 <!--           </el-empty>-->
157 <!--         </el-tab-pane>-->
e57a89 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,
a320dc 305   fistSetpNumber,
b77303 306   listFormulaChild,
0caf87 307   noPageListFormulaChild,
b77303 308   releaseCheck,
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,
237733 329   replaceAssemblyCode, checkRecordDataDone,
49c784 330 } from "@/api/main/da/paramCollection/paramCollection";
e57a89 331
332 export default {
333   name: "stationTerminal",
334   data() {
335     return {
a75d86 336       carCode: '',
A 337       showInput: false,
338       onLineBinDing: false,
339
e57a89 340       serialPortContent: '',
341       // 查询参数
342       formulaChildParams: {
343         pageNum: 1,
344         pageSize: 10,
345         productCode: null,
346         processesCode: null,
347       },
348       // 配方配置子信息表格数据
349       formulaChildList: [],
350       ipAddress: '',
351       imgSrc: '',
352       headContent: {
353         processesCode: 'OP1010',
354         processesName: '贴标机-贴码',
49c784 355         sfcCode: '',
ddb300 356         yzSfcCode: '',
a75d86 357         cardCode: '',
e57a89 358       },
359       workpieceInformation: {
b64ed2 360         workOrderNo: null,
e57a89 361         productCode: null,
362         productModel: null,
363         productName: null,
364         beat: null,
365       },
366       // 查询参数
367       queryParams: {
368         pageNum: 1,
369         pageSize: 10,
370         sfcCode: null,
371       },
372       // 查询参数
373       StationConfQueryParams: {
374         pageNum: 1,
375         pageSize: 10,
376         ipAddress: null,
377       },
378       cakeLamp: {
379         plcState: 1, //plc
380         scannerState: 1, //扫码枪
381         InPlace: 0, //工件到位
382         scanFinish: 0,
383         startWork: 0,
384         release: 0 //允许放行
385       },
386       content: '',
387       activeName: 'first',
3581b1 388       url: "ws://192.168.2.76:8080/websocket/message/",
e57a89 389       message: "",
390       text_content: "",
391       ws: null,
c2944a 392       inputValue: '9',
393
394       open1: false,
395       input: "",
396       keepReading: true,
397       form1: {
b5fcd8 398         baudRate: "115200",
c2944a 399         dataBits: "8",
400         stopBits: "1",
401         parity: "none",
402         flowControl: "none",
403         desc: "",
404         type: "1",
405         isShowHistory: false,
406       },
407       btnType: "primary",
408       btnText: "连接串口",
409       restaurants: [],
410       portsList: [],
411       isShowSendArea: false,
412       readType: 1,
413       title: "",
b64ed2 414
415       passingStationForm: {},
49c784 416       originalArray: [],
237733 417       yzSfcFlag: 1,
e57a89 418     }
419   },
420   beforeDestroy() {
421     this.exit();
422   },
423   created() {
424     this.initStation();
425     // this.getStationConfList();
426     // setTimeout(() => {
427     //   this.connectWebsocket();
428     // }, 3000);
429   },
430   mounted() {
c2944a 431     if ("serial" in navigator) {
432       this.myserialport = new MySerialPort();
433       this.getPorts();
434       navigator.serial.addEventListener("connect", (e) => {
435         this.$message.success("设备已连接");
436         this.getPorts();
437       });
438       navigator.serial.addEventListener("disconnect", (e) => {
439         this.$message.error("设备已断开");
440       });
441       this.restaurants = this.loadAll();
442     } else {
443       this.$message.error(
444         "当前为HTTP模式或者浏览器版本过低,不支持网页连接串口"
445       );
446     }
447   },
448   computed: {
449     isDisable() {
450       return this.btnType === "danger";
451     },
e57a89 452   },
453   methods: {
a75d86 454     bindcardCode(){
68f0c8 455       this.$message('绑定成功!');
a75d86 456       let param = {
A 457         productNum: this.headContent.sfcCode,
458         trolleyYard: this.headContent.cardCode,
459       }
460       trolleyYardBinDing(param).then(response => {
461       });
462
463     },
c2944a 464     serialLink() {
465       this.open1 = true
ddb300 466     },
A 467     bindYzSfc(){
468       if(this.headContent.sfcCode!==""&&this.headContent.yzSfcCode!==""){
469         let param = {
470           sfcCode: this.headContent.sfcCode,
471           locationCode: this.headContent.processesCode,
472           yzSfcCode: this.headContent.yzSfcCode
473         }
237733 474         const orderParam = {
A 475           productNum: this.headContent.sfcCode,
476         }
ddb300 477         replaceAssemblyCode(param).then(response => {
68f0c8 478           this.$message('绑定成功!');
237733 479           bindYzSfcFlag(orderParam).then(response => {
A 480             this.yzSfcFlag = 1
481           });
ddb300 482         });
A 483       }
c2944a 484     },
e57a89 485     Release(){
93feb8 486       // this.$message('portsList!'+this.portsList.length);
487       if(this.btnType === "danger"){
488         this.$message('连接了!');
489
490       }else {
491         this.$message('mei连接了!');
492
e57a89 493       }
494     },
c2944a 495     serialPortMethod(value){
b77303 496       let formulaChildParams = {
497         scanBarcode: value,
498         sfcBarcode: this.headContent.sfcCode,
499         workOrderNo: this.workpieceInformation.workOrderNo,
500         productCode: this.workpieceInformation.productCode,
501         locationCode: this.headContent.processesCode,
502         collectionTime: new Date()
503       }
504       updateResults(formulaChildParams).then(response => {
c5e9c5 505         console.log(response)
506         if(response.msg === "3"){
507           this.cakeLamp.release= 1 //允许放行
508         }
b77303 509         this.getListFormulaChild()
510       });
e57a89 511     },
512     rowStyle({ row }) {
513       if (row.results === 'OK') {
514         return 'background-color: PaleGreen';
515       } else if (row.results === 'NG') {
516         return 'background-color: LightSalmon';
517       }
518       return '';
519     },
520     /** 查询配方配置子信息列表 */
521     getListFormulaChild() {
11cc36 522       // this.formulaChildList = []
e57a89 523       this.formulaChildParams.productCode = this.workpieceInformation.productCode
524       this.formulaChildParams.processesCode = this.headContent.processesCode
054a69 525       console.log(this.formulaChildParams)
0caf87 526       noPageListFormulaChild(this.formulaChildParams).then(response => {
e57a89 527         this.formulaChildList = response.rows;
6a462f 528         if (this.formulaChildList.length >0){
W 529           let pos = 0
530           const tempArr = this.formulaChildList.filter(x=> 'OK' === x.results)
531           if (tempArr.length>0){
532             pos = tempArr.length
533             this.$nextTick(() => {
534               let temp33 = document.getElementsByClassName('el-table__row')
535               console.log('temp33',temp33)
536               console.log('len',temp33.item(pos))
537               if (temp33.length > 0){
538                 console.log('1111111111111111')
539                 let arr = temp33[pos-1]
540                 console.log('srr',arr)
541                 arr.scrollIntoView({ block: 'center' })
542               }
543             })
544           }
545
546         }
547
e57a89 548       });
549     },
1df825 550     endClear(){
551       this.cakeLamp.InPlace= 0 //工件到位
552       this.cakeLamp.scanFinish= 0
553       this.cakeLamp.startWork= 0
554       this.cakeLamp.release= 0 //允许放行
b77c7b 555
1df825 556       this.formulaChildList = []
c5e9c5 557       this.workpieceInformation.productCode = null;
558       this.workpieceInformation.workOrderNo = null;
559       this.workpieceInformation.productModel = null;
560       this.workpieceInformation.productName = null;
5316c5 561       this.headContent.sfcCode = '';
288790 562       this.headContent.yzSfcCode = '';
A 563       this.headContent.cardCode = '';
1df825 564     },
e57a89 565     changeMenu(tab, event) {
566       console.log(tab, event);
567     },
568     clearClick(){
8cfe20 569       const param = {
A 570         workOrderNo: this.workpieceInformation.workOrderNo,
571         productCode: this.workpieceInformation.productCode,
572         locationCode: this.headContent.processesCode,
573         productBarcode: this.headContent.sfcCode,
574       }
575       this.endClear()
576       clearWorkpieceRelease(param).then(response => {});
577       this.headContent.sfcCode = ''
578       this.$message('清楚成功!');
e57a89 579     },
580     scanCompleted(){
581       this.$message('扫码完成'+this.content);
582       this.headContent.sfcCode = this.content
583       this.queryParams.sfcCode = this.content
584       this.getList()
585       this.getListFormulaChild()
586       this.cakeLamp.scanFinish = 1
587       this.cakeLamp.startWork = 1
588
589     },
b64ed2 590     /** 查询工单列表 */
e57a89 591     async getList() {
b64ed2 592       await listProductionOrde(this.queryParams).then(response => {
e57a89 593         let rowsData = response.rows[0];
594         console.log(rowsData)
b64ed2 595         this.workpieceInformation.workOrderNo = rowsData.workOrderNo;
e57a89 596         this.workpieceInformation.productCode = rowsData.productCode;
597         this.workpieceInformation.productModel = rowsData.productModel;
598         this.workpieceInformation.productName = rowsData.productName;
a320dc 599         // this.timer = setInterval(() => {
A 600         //   this.workpieceInformation.beat++;
601         // }, 1000);
e57a89 602       });
603       this.getListFormulaChild()
b64ed2 604       this.addOverStationCollection()
605     },
606
8cfe20 607     addBaseData(){
A 608       addBasicParameters(this.passingStationForm).then(response => {});
609     },
610
b64ed2 611     /** 入站增加过站采集记录 **/
612     addOverStationCollection(){
613       this.passingStationForm = {
614         id: null,
615         workOrderNo: this.workpieceInformation.workOrderNo,
616         productCode: this.workpieceInformation.productCode,
617         locationCode: this.headContent.processesCode,
618         model: this.workpieceInformation.productModel,
619         productBarcode: this.headContent.sfcCode,
32483a 620         sfcCode: this.headContent.sfcCode,
b64ed2 621         inboundTime: new Date()
622       }
b77c7b 623       addPassingStationCollection(this.passingStationForm).then(response => {});
4a5f2a 624       // addBasicParameters(this.passingStationForm).then(response => {});
e57a89 625     },
626     exit() {
627       if (this.ws) {
628         this.ws.close();
629         this.ws = null;
630       }
631     },
632     send() {
633       if (this.ws) {
634         this.ws.send(this.message);
635       } else {
636         alert("未连接到服务器");
637       }
638     },
1df825 639
49c784 640     initStation: async function () {
e57a89 641       await getIpv4().then(response => {
642         this.StationConfQueryParams.ipAddress = response.msg
49c784 643         console.log('查询到本工位IP为' + this.StationConfQueryParams.ipAddress)
e57a89 644       });
645       await listStationConf(this.StationConfQueryParams).then(response => {
646         let rows = response.rows[0]
49c784 647         if (response.rows.length === 0) {
e57a89 648           this.$message('该工位没有配置IP,请联系管理员配置IP');
649           return
650         }
651         this.headContent.processesName = rows.processesName
652         this.headContent.processesCode = rows.processesCode
a75d86 653         if(this.headContent.processesCode === 'OP240'){
A 654           this.onLineBinDing = true
655         }
4a5f2a 656         if(this.headContent.processesCode === 'OP260'){
a75d86 657           this.showInput = true
A 658         }
e57a89 659
a75d86 660         console.log('设置工位编码' + this.headContent.processesCode)
a320dc 661
e57a89 662       });
f17d8c 663       this.conCom()
49c784 664       console.log('websocket连接工位为' + this.headContent.processesCode)
e57a89 665       const wsuri = this.url + this.headContent.processesCode;
666       this.ws = new WebSocket(wsuri);
667       const self = this;
668       this.ws.onopen = function (event) {
669         this.$message('websocket连接成功!');
a320dc 670
e57a89 671       };
672       this.ws.onmessage = function (event) {
49c784 673         if (event.data === "IN") {
674           self.cakeLamp.InPlace = 1;
a320dc 675           console.log(self.headContent.processesCode);
A 676           const param = {
677             processesCode: self.headContent.processesCode,
678           }
679           fistSetpNumber(param).then(response => {});
49c784 680         } else if (event.data === "IN0") {
681           self.cakeLamp.InPlace = 0;
682         } else if (event.data === "OUT") {
683           self.cakeLamp.release = 1;
32483a 684         } else if (event.data === "END") {
685           const param = {
686             workOrderNo: self.workpieceInformation.workOrderNo,
687             productCode: self.workpieceInformation.productCode,
688             locationCode: self.headContent.processesCode,
689             productBarcode: self.headContent.sfcCode,
690           }
237733 691
A 692           const orderParam = {
693             productNum: self.headContent.sfcCode,
694           }
16714e 695
A 696           if(self.headContent.sfcCode=== ''||self.headContent.sfcCode=== null){
697             self.$message('总成码为空,请检查!')
698             return
699           }
700
237733 701           checkCarCode(orderParam).then(response => {
A 702             console.log(response.data)
703             if(response.data === 1){
704               if(self.headContent.processesCode === "OP260"){
705                 checkYzSfcCode(orderParam).then(response => {
706                   if(response.data === 1){
707                     saveCampaignTimeParameters(param).then(response => {
708                       checkRecordDataDone(param).then(response => {
709                         if(response.msg === "21"){
710                           self.cakeLamp.release = 1;
711                           self.endClear()
712                           workpieceRelease(param).then(response => {});
713                         }else {
714                           self.$message('未做完工序禁止放行');
715                         }
716                       });
717                     });
718                   }else {
719                     self.$message('请先绑定预装总成');
720                   }
721                 });
722               }else {
723                 saveCampaignTimeParameters(param).then(response => {
724                   checkRecordDataDone(param).then(response => {
725                     if(response.msg === "21"){
726                       self.cakeLamp.release = 1;
727                       self.endClear()
728                       workpieceRelease(param).then(response => {});
729                     }else {
730                       self.$message('未做完工序禁止放行');
731                     }
732                   });
733                 });
734               }
735             }else {
736               self.$message('未绑定小车码禁止放行');
737             }
738           });
49c784 739         } else if (event.data.includes("[")) {
b77c7b 740           let formulaChilds = "";
3c2299 741           self.formulaChildList.sort((a, b) => a.stepSort - b.stepSort);
742           self.formulaChildList
743             .filter((formulaChild) => formulaChild.operationType === '1');
744           for (let i = 0; i < self.formulaChildList.length; i++) {
745             let formulaChild = self.formulaChildList[i];
b77c7b 746             let results = formulaChild.results;
3c2299 747             if (results === '' || results === null || results === 'NG') {
b77303 748               formulaChilds = formulaChild;
3c2299 749               break;
b77c7b 750             }
3c2299 751           }
49c784 752           const param = {
753             tightenTheArray: event.data,
b77c7b 754             paramCode: formulaChilds.paramCode,
49c784 755             workOrderNo: self.workpieceInformation.workOrderNo,
756             productCode: self.workpieceInformation.productCode,
757             locationCode: self.headContent.processesCode,
758             productBarcode: self.headContent.sfcCode,
759           }
16714e 760           if(formulaChilds.paramCode === null||formulaChilds.paramCode ===''){
A 761             self.$message('未找到参数码,请检查参数码是否正确');
762             return;
763           }
764           if(self.headContent.sfcCode!==null||self.headContent.sfcCode!==''){
765             addTighteningParameters(param).then(response => {});
766             updateTighteningFormula(param).then(response => {
767               self.getListFormulaChild()
768             }).catch(error =>{
769               self.getListFormulaChild()
770             });
771           }
e57a89 772         }
773       };
774     },
c2944a 775
1df825 776
777
c2944a 778     //接受数据的回调
779     callBack(value) {
780       if (this.form1.isShowHistory) this.form1.desc = this.readLi().join("");
781       else {
782         const scanValue = this.myserialport.hex2atostr(value).replace(/[\r\n]/g, '');
11cc36 783         console.log("串口收到数据-------------------"+scanValue)
ddb300 784
A 785         if(this.headContent.sfcCode !== ''){
4a5f2a 786           if(scanValue.includes("P9900173252")){
ddb300 787             this.headContent.yzSfcCode = scanValue
68f0c8 788             this.bindYzSfc();
A 789           }else if(scanValue.includes("0RSP1TE")){
a75d86 790             this.headContent.cardCode = scanValue
68f0c8 791             this.bindcardCode();
ddb300 792           }else {
a52d08 793             this.$message('工位终端扫描物料编码'+scanValue);
3c2299 794             console.log(scanValue)
795             this.serialPortMethod(scanValue)
796           }
ddb300 797         } else {
a75d86 798           if(this.headContent.processesCode === 'OP240'){
A 799             this.headContent.sfcCode = scanValue;
800             this.queryParams.productNum = scanValue;
4a5f2a 801             this.getList()
A 802             this.cakeLamp.scanFinish = 1
803             this.cakeLamp.startWork = 1
a75d86 804           }else {
A 805             let param = {
806               trolleyYard: scanValue
807             }
808             findBytrolleyYardGetOne(param).then(response => {
4a5f2a 809               if(response.msg !== '2'){
A 810                 this.headContent.sfcCode = response.msg;
811                 this.queryParams.productNum = response.msg;
812                 this.$message('扫码识别产品序列号'+scanValue);
813                 // this.headContent.sfcCode = scanValue;
814                 // this.queryParams.productNum = scanValue;
815                 this.getList()
816                 this.cakeLamp.scanFinish = 1
817                 this.cakeLamp.startWork = 1
818               }else {
819                 this.$message('没有序列号'+scanValue);
820                 return
821               }
a75d86 822             });
A 823           }
4a5f2a 824
ddb300 825         }
A 826
e57a89 827       }
c2944a 828     },
829     clearHistory() {
830       this.form1.desc = "";
831       this.myserialport.state.readValue = [];
832     },
833     loadHistory() {
834       if (this.form1.isShowHistory) this.form1.desc = this.readLi().join("");
835       else {
836         let temp = this.readLi();
837         if (temp.length > 0) this.form1.desc = temp[temp.length - 1].join("");
838       }
839     },
840     readLi() {
841       let readType = this.readType;
842       return this.myserialport.state.readValue.map((items, index) => {
843         const item = items.value;
844         const type = items.type; // 1接收,2发送
845         let body = [];
846         if (item !== undefined) {
847           let strArr = [];
848           for (let hex of Array.from(item)) {
849             strArr.push(hex.toString(16).toLocaleUpperCase());
850           }
851           if (strArr.includes("D") && strArr.includes("A")) {
852             if (strArr.indexOf("A") - strArr.indexOf("D") === 1) {
853               strArr.splice(strArr.indexOf("D"), 1);
854               strArr.splice(strArr.indexOf("A"), 1, <br key={0} />);
855             }
856           }
857           strArr = strArr.map((item) => {
858             if (typeof item === "string") {
859               if (readType === 1) {
860                 return this.myserialport.hex2a(parseInt(item, 16));
861               } else if (readType === 2) {
862                 return item + " ";
863               }
864             }
865             return item;
866           });
867           if (typeof strArr[strArr.length - 1] === "string") {
868             strArr.push("\r\n");
869           }
870           body.push(strArr.join(""));
871         }
872         return body;
873       });
874     },
640ff8 875     conCom(){
876       try {
877         this.myserialport.state.baudRate = this.form1.baudRate;
878         this.myserialport.state.dataBits = this.form1.dataBits;
879         this.myserialport.state.stopBits = this.form1.stopBits;
880         this.myserialport.state.parity = this.form1.parity;
881         this.myserialport.state.flowControl = this.form1.flowControl;
882         this.myserialport.openPort(0, true, this.callBack);
883         console.log(this.form1.port)
884       } catch (error) {
885         this.$message.error("串口连接失败!请检查串口是否已被占用");
886       }
887       if (this.myserialport.state.isOpen) {
888         this.$message.success("串口连接成功");
889       }
890     },
c2944a 891     //连接
892     async connectBtn() {
893       if (this.btnType === "primary") {
894         try {
895           this.myserialport.state.baudRate = this.form1.baudRate;
896           this.myserialport.state.dataBits = this.form1.dataBits;
897           this.myserialport.state.stopBits = this.form1.stopBits;
898           this.myserialport.state.parity = this.form1.parity;
899           this.myserialport.state.flowControl = this.form1.flowControl;
900           await this.myserialport.openPort(this.form1.port, true, this.callBack);
11cc36 901           console.log(this.form1.port)
c2944a 902         } catch (error) {
903           this.$message.error("串口连接失败!请检查串口是否已被占用");
904         }
905         if (this.myserialport.state.isOpen) {
906           this.$message.success("串口连接成功");
907           this.open1 = false
908           this.btnType = "danger";
909           this.btnText = "关闭串口";
910         }
911       } else {
912         this.myserialport.openPort(this.form1.port, false, this.callBack);
913         this.$message.success("串口关闭成功");
914         this.btnType = "primary";
915         this.btnText = "连接串口";
916       }
917     },
918     //授权
919     async obtainAuthorization() {
920       if ("serial" in navigator) {
921         console.log("The Web Serial API is supported.");
922         if (!this.myserialport) this.myserialport = new MySerialPort();
923         try {
924           await this.myserialport.handleRequestPort();
925           this.$message.success("串口授权成功");
926           this.getPortInfo(this.myserialport.state.ports);
927         } catch (error) {
928           this.$message.warning("未选择新串口授权!");
929         }
930       } else {
931         this.$message.error(
932           "当前为HTTP模式或者浏览器版本过低,不支持网页连接串口"
933         );
934       }
935     },
936     //串口列表初始化
937     getPortInfo(portList) {
938       this.portsList = [];
939       portList.map((port, index) => {
940         const { usbProductId, usbVendorId } = port.getInfo();
941         if (usbProductId === undefined || usbVendorId === undefined) {
942           this.portsList.push({ label: "未知设备" + index, value: index });
943         } else {
944           const usbVendor = USBDevice.filter(
945             (item) => parseInt(item.vendor, 16) === usbVendorId
946           );
947           let usbProduct = [];
948           if (usbVendor.length === 1) {
949             usbProduct = usbVendor[0].devices.filter(
950               (item) => parseInt(item.devid, 16) === usbProductId
951             );
952           }
953           this.portsList.push({ label: usbProduct[0].devname, value: index });
954         }
955       });
956     },
957     // 发送
958     async sendCommon() {
959       if (this.myserialport.state.isOpen) {
960         if (this.form1.sendMsg.length !== 0) {
961           const writeType = this.form1.type;
962           let value = this.form1.sendMsg;
963           let arr = [];
964           if (writeType === 1) {
965             // ASCII
966             for (let i = 0; i < value.length; i++) {
967               arr.push(this.myserialport.a2hex(value[i]));
968             }
969           } else if (writeType === 2) {
970             // HEX
971             if (/^[0-9A-Fa-f]+$/.test(value) && value.length % 2 === 0) {
972               for (let i = 0; i < value.length; i = i + 2) {
973                 arr.push(parseInt(value.substring(i, i + 2), 16));
974               }
975             } else {
976               this.$message.error("格式错误");
977               return;
978             }
979           }
980           this.myserialport.writeText(arr);
981         } else {
982           this.$message.warning("请输入发送的信息");
983         }
984       } else {
985         this.$message.warning("串口处于关闭状态,请连接串口");
986       }
987     },
988     async getPorts() {
989       await this.myserialport.getPorts();
990       this.getPortInfo(this.myserialport.state.ports);
991     },
992     querySearch(queryString, cb) {
993       var restaurants = this.restaurants;
994       var results = queryString
995         ? restaurants.filter(this.createFilter(queryString))
996         : restaurants;
997       // 调用 callback 返回建议列表的数据
998       cb(results);
999     },
1000     createFilter(queryString) {
1001       return (restaurant) => {
1002         return (
1003           restaurant.value.toLowerCase().indexOf(queryString.toLowerCase()) ===
1004           0
1005         );
1006       };
1007     },
1008     loadAll() {
1009       return [
1010         { value: "110" },
1011         { value: "300" },
1012         { value: "600" },
1013         { value: "1200" },
1014         { value: "2400" },
1015         { value: "4800" },
1016         { value: "7200" },
1017         { value: "9600" },
1018         { value: "14400" },
1019         { value: "19200" },
1020         { value: "28800" },
1021         { value: "38400" },
1022         { value: "56000" },
1023         { value: "57600" },
1024         { value: "76800" },
1025         { value: "115200" },
1026         { value: "230400" },
1027         { value: "460800" },
1028       ];
1029     },
e57a89 1030   }
1031 }
1032
1033 </script>
1034 <style scoped>
1035 .bottom-card{
1036   height: 600px;
1037 }
1038 .circle-button{
1039   height: 30px;
1040   width: 30px;
1041 }
1042 .circle-red {
1043   background-color: #e01a4f;
1044 }
1045 .circle-green {
1046   background-color: green;
1047 }
1048 .circle-green-animate {
1049   background-color: green;
1050   animation: circle-green-animate 2s infinite;
1051 }
1052   @keyframes circle-green-animate {
1053     50% {
1054       opacity: 0.6;
1055     }
1056     0% {
1057       opacity: 0.2;
1058     }
1059   }
1060 .head-font{
c2944a 1061   /*font-weight: bold;*/
1062   /*font-size: 25px;*/
e57a89 1063 }
1064 span{
1065   font-size: 15px;
1066 }
1067 .el-table .warning-row {
1068   background: oldlace;
1069 }
1070
1071 .el-table .success-row {
1072   background: #f0f9eb;
1073 }
1074 </style>
1075