懒羊羊
2024-01-29 a36b834b2957440a755652ff17d067b18f4e9250
提交 | 用户 | 时间
b0742c 1 <template>
C 2   <div class="app-container">
589dc7 3    <el-row :gutter="5">
4      <el-col :span="6">
49ac5c 5        <el-card shadow="never">
6          <span class="head-font">工位编号 : {{headContent.processesCode}}</span>
589dc7 7        </el-card>
8      </el-col>
9      <el-col :span="6">
49ac5c 10        <el-card shadow="never">
11          <span class="head-font">工位名称 : {{headContent.processesName}}</span>
589dc7 12        </el-card>
13      </el-col>
8586e1 14      <el-col :span="12">
49ac5c 15        <el-card shadow="never">
16          <span class="head-font">总成编码 : {{headContent.sfcCode}}</span>
5a6d6b 17          <el-input v-model="content" style="float: right;width: 150px;" placeholder="请输入内容"></el-input>
49ac5c 18          <el-button @click="scanCompleted" style="float: right" type="primary">扫码完成</el-button>
19          <el-button @click="clearClick" style="float: right" type="danger">清除</el-button>
589dc7 20        </el-card>
21      </el-col>
8586e1 22
589dc7 23    </el-row>
24    <el-row :gutter="5" style="margin-top: 5px">
25      <el-col :span="6" >
26        <el-card class="bottom-card">
27          <div slot="header" class="clearfix">
49ac5c 28            <i class="el-icon-tickets"></i>
29            <span style="font-weight: bold">当前工件信息</span>
589dc7 30          </div>
49ac5c 31          <el-descriptions :column="1" :label-style="{'font-size': '15px'}" border :content-style="{'min-width': '150px'}">
32            <el-descriptions-item label="工单编号">
33                <span>{{workpieceInformation.workOrderCode}}</span>
589dc7 34            </el-descriptions-item>
49ac5c 35            <el-descriptions-item label="产品编号">
36              <span>{{workpieceInformation.productCode}}</span>
589dc7 37            </el-descriptions-item>
49ac5c 38            <el-descriptions-item label="产品型号">
39              <span>{{workpieceInformation.productModel}}</span>
589dc7 40            </el-descriptions-item>
49ac5c 41            <el-descriptions-item label="产品名称">
42              <span>{{workpieceInformation.productName}}</span>
589dc7 43            </el-descriptions-item>
49ac5c 44            <el-descriptions-item label="节拍">
45              <span>{{workpieceInformation.beat}}</span>
589dc7 46            </el-descriptions-item>
47          </el-descriptions>
48          <el-divider></el-divider>
49          <el-row>
50            <el-col :span="12">
49ac5c 51              <el-button class="circle-button" :class="cakeLamp.plcState ? 'circle-green-animate':'circle-red'" circle></el-button>
52              <span style="display: none">{{cakeLamp.plcState}}</span>
8586e1 53              <span>&nbsp;PLC状态</span>
589dc7 54            </el-col>
55            <el-col :span="12">
49ac5c 56              <el-button class="circle-button" :class="cakeLamp.scannerState ? 'circle-green-animate':'circle-red'" circle></el-button>
57              <span style="display: none">{{cakeLamp.scannerState}}</span>
8586e1 58              <span>&nbsp;扫码枪状态</span>
589dc7 59            </el-col>
60          </el-row>
61          <el-row style="margin-top: 20px">
62            <el-col :span="12">
49ac5c 63              <el-button class="circle-button" :class="cakeLamp.InPlace ? 'circle-green':'circle-red'" circle></el-button>
64              <span style="display: none">{{cakeLamp.InPlace}}</span>
8586e1 65              <span>&nbsp;工件到位</span>
589dc7 66            </el-col>
67            <el-col :span="12">
49ac5c 68              <el-button class="circle-button" :class="cakeLamp.scanFinish ? 'circle-green':'circle-red'" circle></el-button>
69              <span style="display: none">{{cakeLamp.scanFinish}}</span>
8586e1 70              <span>&nbsp;扫码完成</span>
589dc7 71            </el-col>
72          </el-row>
73          <el-row style="margin-top: 20px">
74            <el-col :span="12">
49ac5c 75              <el-button class="circle-button" :class="cakeLamp.startWork ? 'circle-green':'circle-red'" circle></el-button>
76              <span style="display: none">{{cakeLamp.startWork}}</span>
8586e1 77              <span>&nbsp;开始作业</span>
589dc7 78            </el-col>
79            <el-col :span="12">
49ac5c 80              <el-button class="circle-button" :class="cakeLamp.release ? 'circle-green':'circle-red'" circle></el-button>
81              <span style="display: none">{{cakeLamp.release}}</span>
8586e1 82              <span>&nbsp;允许放行</span>
589dc7 83            </el-col>
49138a 84
85          </el-row>
86          <el-row style="margin-top: 20px">
87            <el-col :span="12">
88              <el-input v-model="serialPortContent" style="width: 150px;" placeholder="请输入内容"></el-input>
89
90            </el-col>
91            <el-col :span="12">
92              <el-button @click="serialPortMethod" type="primary">串口获取数据</el-button>
93
94            </el-col>
589dc7 95          </el-row>
a36b83 96          <el-row style="margin-top: 20px">
97              <el-button @click="Release" type="primary">放行</el-button>
98          </el-row>
589dc7 99        </el-card>
b0742c 100
589dc7 101      </el-col>
102      <el-col :span="18">
5a6d6b 103        <el-tabs type="border-card"  style="height: 600px" v-model="activeName" @tab-click="changeMenu">
104          <el-tab-pane name="first">
589dc7 105            <span slot="label"> <a class="el-icon-date"></a>首页</span>
106            <el-col :span="8">
a36b83 107              <el-table :cell-style="rowStyle" :data="formulaChildList">
d3409e 108                <el-table-column label="排序" width="60" align="center" prop="stepSort">
109                </el-table-column>
110                <el-table-column label="操作内容" :show-overflow-tooltip='true' align="center" prop="operationSteps">
111                </el-table-column>
589dc7 112              </el-table>
113            </el-col>
114            <el-col :span="16">
115              <el-image style="height: 520px;width: 100%" :src="imgSrc"></el-image>
116            </el-col>
117          </el-tab-pane>
5a6d6b 118          <el-tab-pane name="second">
589dc7 119            <span slot="label"> <b class="el-icon-date"></b>物料BOM</span>
5a6d6b 120            <el-empty>
589dc7 121              <span slot="description">暂无数据</span>
122            </el-empty>
123          </el-tab-pane>
5a6d6b 124          <el-tab-pane name="third">
125            <span slot="label"> <b class="el-icon-date"></b>采集清单</span>
126            <el-empty>
589dc7 127              <span slot="description">暂无数据</span>
128            </el-empty>
129          </el-tab-pane>
5a6d6b 130          <el-tab-pane name="fourth">
131            <span slot="label"> <b class="el-icon-date"></b>安灯状态</span>
132            <el-empty>
589dc7 133              <span slot="description">暂无数据</span>
134            </el-empty>
135          </el-tab-pane>
5a6d6b 136          <el-tab-pane name="fifth">
137            <span slot="label"> <b class="el-icon-date"></b>工艺配方</span>
138            <el-empty>
589dc7 139              <span slot="description">暂无数据</span>
140            </el-empty>
141          </el-tab-pane>
142        </el-tabs>
143      </el-col>
144    </el-row>
b0742c 145   </div>
C 146 </template>
147 <script>
49ac5c 148 import {listWorkReport} from "@/api/main/om/workReport/workReport";
149 import {listStationConf,getIpv4} from "@/api/main/sc/stationConf";
a36b83 150 import {listFormulaChild, releaseCheck, updateResults} from "@/api/main/bs/formulaChild/formulaChild";
49ac5c 151
b0742c 152 export default {
49ac5c 153   name: "stationTerminal",
b0742c 154   data() {
C 155     return {
49138a 156       serialPortContent: '',
d3409e 157       // 查询参数
158       formulaChildParams: {
159         pageNum: 1,
160         pageSize: 10,
161         productCode: null,
162       },
163       // 配方配置子信息表格数据
164       formulaChildList: [],
49ac5c 165       ipAddress: '',
589dc7 166       imgSrc: '',
49ac5c 167       headContent: {
168         processesCode: 'OP1010',
169         processesName: '贴标机-贴码',
170         sfcCode: '1000000000000001',
171       },
172       workpieceInformation: {
173         workOrderCode: null,
174         productCode: null,
175         productModel: null,
176         productName: null,
177         beat: null,
178       },
179       // 查询参数
180       queryParams: {
181         pageNum: 1,
182         pageSize: 10,
183         sfcCode: null,
184       },
5f3a2e 185       // 查询参数
186       StationConfQueryParams: {
187         pageNum: 1,
188         pageSize: 10,
189         ipAddress: null,
190       },
49ac5c 191       cakeLamp: {
192         plcState: 1, //plc
193         scannerState: 1, //扫码枪
194         InPlace: 0, //工件到位
195         scanFinish: 0,
196         startWork: 0,
197         release: 0 //允许放行
5a6d6b 198       },
199       content: '',
5f3a2e 200       activeName: 'first',
a36b83 201       url: "ws://192.168.11.60:8080/websocket/message/",
5f3a2e 202       message: "",
203       text_content: "",
204       ws: null,
d3409e 205       inputValue: '9'
b0742c 206     }
5f3a2e 207   },
208   beforeDestroy() {
209     this.exit();
b0742c 210   },
49ac5c 211   created() {
5f3a2e 212     this.initStation();
213     // this.getStationConfList();
214     // setTimeout(() => {
215     //   this.connectWebsocket();
216     // }, 3000);
217   },
218   mounted() {
219
49ac5c 220   },
221   methods: {
a36b83 222     Release(){
223       releaseCheck().then(response => {
224         if(response.data === 0){
225           //改变状态
226           this.$message('放行成功!');
49138a 227
a36b83 228         }else {
229           this.$message('步骤未完成不许放行!');
230         }
231       });
232     },
233     serialPortMethod(){
234       let formulaChildParams = {
235         materialCode: this.serialPortContent
236       }
237       updateResults(formulaChildParams).then(response => {
238         this.getListFormulaChild()
239       });
240     },
241     rowStyle({ row }) {
242       if (row.results === 'OK') {
243         return 'background-color: PaleGreen';
244       } else if (row.results === 'NG') {
245         return 'background-color: LightSalmon';
246       }
247       return '';
49138a 248     },
d3409e 249     /** 查询配方配置子信息列表 */
250     getListFormulaChild() {
251       this.formulaChildParams.productCode = this.workpieceInformation.productCode
252       listFormulaChild(this.formulaChildParams).then(response => {
253         this.formulaChildList = response.rows;
254       });
255     },
5a6d6b 256     changeMenu(tab, event) {
257       console.log(tab, event);
258     },
49ac5c 259     clearClick(){
260       this.$message('这是一条清除消息提示');
261       this.headContent.sfcCode = null
262     },
263     scanCompleted(){
5a6d6b 264       this.$message('扫码完成'+this.content);
265       this.headContent.sfcCode = this.content
266       this.queryParams.sfcCode = this.content
49ac5c 267       this.getList()
a36b83 268       this.getListFormulaChild()
49ac5c 269       this.cakeLamp.scanFinish = 1
49138a 270       this.cakeLamp.startWork = 1
271
49ac5c 272     },
273     /** 查询报工记录 表列表 */
49138a 274     async getList() {
275       await listWorkReport(this.queryParams).then(response => {
49ac5c 276         let rowsData = response.rows[0];
a36b83 277         console.log(rowsData)
49ac5c 278         this.workpieceInformation.workOrderCode = rowsData.workOrderCode;
279         this.workpieceInformation.productCode = rowsData.productCode;
280         this.workpieceInformation.productModel = rowsData.productModel;
281         this.workpieceInformation.productName = rowsData.productName;
282         this.timer = setInterval(() => {
283           this.workpieceInformation.beat++;
284         }, 1000);
285       });
49138a 286       this.getListFormulaChild()
287
49ac5c 288     },
289     allowRelease(){
290       clearInterval(this.timer);
291       this.$message('保存节拍为'+this.workpieceInformation.beat+'秒');
292     },
293     /** 查询工位终端配置列表 */
49138a 294     // async getStationConfList() {
295     //   await getIpv4().then(response => {
296     //     this.StationConfQueryParams.ipAddress = response.msg
297     //     console.log('查询到本工位IP为'+this.StationConfQueryParams.ipAddress)
298     //   });
299     //   listStationConf(this.StationConfQueryParams).then(response => {
300     //     let rows = response.rows[0]
301     //     if(response.rows.length===0){
302     //       this.$message('该工位没有配置IP,请联系管理员配置IP');
303     //       return
304     //     }
305     //     this.headContent.processesName = rows.processesName
306     //     this.headContent.processesCode = rows.processesCode
307     //     console.log('设置工位编码'+this.headContent.processesCode)
308     //
309     //   });
310     // },
311     // connectWebsocket() {
312     //   console.log('websocket连接工位为'+this.headContent.processesCode)
313     //   const wsuri = this.url + this.headContent.processesCode;
314     //   this.ws = new WebSocket(wsuri);
315     //   const self = this;
316     //   this.ws.onopen = function (event) {
317     //     // self.text_content = self.text_content + "已经打开连接!" + "\n";
318     //     this.$message('websocket连接成功!');
319     //   };
320     //   this.ws.onmessage = function (event) {
321     //     self.text_content = event.data + "\n";
322     //     console.log(event.data)
323     //     if(event.data === "IN"){
324     //       self.cakeLamp.InPlace = "1"
325     //     }else if(event.data === "OUT"){
326     //       self.cakeLamp.outRsSign = "1"
327     //     }
328     //   };
329     // },
5f3a2e 330     exit() {
331       if (this.ws) {
332         this.ws.close();
333         this.ws = null;
334       }
335     },
336     send() {
337       if (this.ws) {
338         this.ws.send(this.message);
339       } else {
340         alert("未连接到服务器");
341       }
342     },
343     async initStation(){
344       await getIpv4().then(response => {
345         this.StationConfQueryParams.ipAddress = response.msg
346         console.log('查询到本工位IP为'+this.StationConfQueryParams.ipAddress)
347       });
348       await listStationConf(this.StationConfQueryParams).then(response => {
349         let rows = response.rows[0]
350         if(response.rows.length===0){
351           this.$message('该工位没有配置IP,请联系管理员配置IP');
352           return
353         }
354         this.headContent.processesName = rows.processesName
355         this.headContent.processesCode = rows.processesCode
356         console.log('设置工位编码'+this.headContent.processesCode)
357
358       });
359       console.log('websocket连接工位为'+this.headContent.processesCode)
360       const wsuri = this.url + this.headContent.processesCode;
361       this.ws = new WebSocket(wsuri);
362       const self = this;
363       this.ws.onopen = function (event) {
364         this.$message('websocket连接成功!');
365       };
366       this.ws.onmessage = function (event) {
367         self.text_content = event.data + "\n";
368         console.log(event.data)
49138a 369         if(event.data === "IN"){
370           self.cakeLamp.InPlace = 1
371         }else if(event.data === "OUT"){
372           self.cakeLamp.release = 1
373           setTimeout(() => {
374             this.resetting()
375           }, 2000); // 延时2秒触发
a36b83 376         }else if(event.data === 'TIGHTEN'){
377           console.log('开始拧紧')
378           self.getListFormulaChild()
5f3a2e 379         }
380       };
49138a 381     },
382     resetting() {
383       this.cakeLamp = {
384         InPlace: 0,
385         release: 0,
386         startWork: 0,
387         scanFinish: 0,
388       }
5f3a2e 389     }
49ac5c 390   }
b0742c 391 }
C 392
393 </script>
589dc7 394 <style scoped>
395 .bottom-card{
396   height: 600px;
b0742c 397 }
589dc7 398 .circle-button{
8586e1 399   height: 30px;
A 400   width: 30px;
401 }
49ac5c 402 .circle-red {
403   background-color: #e01a4f;
404 }
405 .circle-green {
406   background-color: green;
407 }
408 .circle-green-animate {
409   background-color: green;
410   animation: circle-green-animate 2s infinite;
411 }
412   @keyframes circle-green-animate {
413     50% {
414       opacity: 0.6;
415     }
416     0% {
417       opacity: 0.2;
418     }
419   }
420 .head-font{
421   font-weight: bold;
422   font-size: 25px;
423 }
8586e1 424 span{
A 425   font-size: 15px;
b0742c 426 }
a36b83 427 .el-table .warning-row {
428   background: oldlace;
429 }
430
431 .el-table .success-row {
432   background: #f0f9eb;
433 }
b0742c 434 </style>
5a6d6b 435