春风项目四线(合箱线、总装线)
wujian
2024-07-12 d2daac02fbc20980162799fc7bf6b1ca59f5686a
提交 | 用户 | 时间
1c7036 1 <template>
Y 2   <div class="app-container">
3     <div style="width: 100%">
4       <el-card   class="box-card"  style="height: 60px" >
5         <template>
6           <div class="container" type="flex" justify="center" style="text-align:center">
7             <el-divider><span style="font-size:30px;color:black"><strong>活塞连杆扫码上线</strong></span></el-divider>
8           </div>
9         </template>
10       </el-card>
11       <el-row :gutter="3">
12         <el-col :span="6">
13           <el-card shadow="always" class="boxSize">
14             <div class="centerImg">
15               <img style="width: 140px;height: 30px;" src="@/assets/logo/jcdm2.png" alt="dark">
16             </div>
17
18           </el-card>
19         </el-col>
20         <el-col :span="3">
21           <el-card shadow="always" class="boxSize">
22             <span class="centerText" style="height: 60px">{{locationCode}}</span>
23           </el-card>
24         </el-col>
25         <el-col :span="15">
26           <el-card shadow="always" class="boxSize">
27             <span class="centerText" >{{locationName}}</span>
28           </el-card>
29         </el-col>
30       </el-row>
59e228 31       <!--      <el-card class="box-card" >-->
W 32       <!--        <el-form :model="from" size="large" :inline="true" label-width="68px" @submit.native.prevent>-->
33       <!--          <el-form-item label-width="200" label="活塞连杆托盘码" :prop="from.scanObject2"  style="align-content: center">-->
34       <!--            <input v-model="from.scanObject2"-->
35       <!--                   ref="inputdata"-->
36       <!--                   style="height: 39px; width: 300px"-->
37       <!--                   placeholder="请输入活塞连杆托盘码"-->
38       <!--            />-->
39       <!--          </el-form-item>-->
40       <!--&lt;!&ndash;          <el-button type="primary" icon="el-icon-refresh" @click="handleQuery">查询</el-button>&ndash;&gt;-->
41       <!--        </el-form>-->
42       <!--      </el-card>-->
1c7036 43       <el-col :span="24" >
Y 44         <el-card class="bottom-card">
45           <div slot="header" class="clearfix">
46             <i class="el-icon-tickets"></i>
47             <span style="font-weight: bold">当前产品信息</span>
48           </div>
49           <el-descriptions :column="1"  :label-style="{'font-size': '20px'}" border  :content-style="{'min-width': '300px'}">
50             <el-descriptions-item label="机型">
51               <span>{{queryParams.productSeries}}</span>
52             </el-descriptions-item>
59e228 53             <el-descriptions-item label="箱体对应SN码">
1c7036 54               <span>{{queryParams.scanObject1}}</span>
Y 55             </el-descriptions-item>
59e228 56             <el-descriptions-item label="曲轴对应SN码">
1c7036 57               <span>{{queryParams.scanObject2}}</span>
Y 58             </el-descriptions-item>
59             <el-descriptions-item label="结果">
5030f3 60               <span  style="color: #FFFFFF;"  :style="{ backgroundColor: queryParams.tileColor }">{{queryParams.words}}</span>
1c7036 61             </el-descriptions-item>
Y 62           </el-descriptions>
63           <el-divider></el-divider>
64         </el-card>
65       </el-col>
66     </div>
67   </div>
68 </template>
69 <script>
70 import VueQr from 'vue-qr'
71 import { listTileMatchRules, getTileMatchRules, delTileMatchRules, addTileMatchRules, updateTileMatchRules } from "@/api/main/bs/tileMatchRules/tileMatchRules";
72 import {listStationConf,getIp} from "@/api/main/sc/stationConf";
59e228 73 import {setBarcodeup, outSign, getDetailData} from "@/api/main/da/tileMatchMiddleware/tileMatchMiddleware";
W 74 import {getUrl} from "@/api/main/bs/orderScheduling/orderScheduling";
75 import WebSocketReconnect from "@/utils/WebsocketTool";
76 import result from "../../../../components/Crontab/result.vue";
1c7036 77 export default {
Y 78   name: "index",
79   dicts: ['colour_hex','productseries','axisname','neckname','tilename'],
80   components: {
81     VueQr,
82   },
83   data(){
84     return{
85       scannerFlag: false,
86       loading: true,
87       locationCode: "未配置",
88       locationName: "未配置工位",
89       tileMatchKbList: [],
90       qrCode: '',
91       // 查询参数
92       from:{
93         pageNum: 1,
94         pageSize: 10,
95         productSeries: null,
96         scanObject1: null,
97         //scanObject1: 'P0SQ0-01FZ01-1000;T231224116;DBBBBA',
5030f3 98         scanObject2: null,
1c7036 99         axisName: null,
Y 100         neckName: null,
101         tileName: null,
102         axisParameterNoPosition: null,
103         neckParameterPosition: null,
104         axisValue: null,
105         neckValue: null,
106         tileColor: null,
107         createUser: null,
108         updateUser: null,
109         state: null,
110         weight: null,
111       },
112       queryParams: {
113         pageNum: 1,
114         pageSize: 10,
115         productSeries: null,
116         scanObject1: null,
117         // scanObject1: 'P0SQ0-01FZ01-1000;T231224116;DBBBBA',
118         scanObject2: null,
119         axisName: null,
120         neckName: null,
121         tileName: null,
122         axisParameterNoPosition: null,
123         neckParameterPosition: null,
124         axisValue: null,
125         neckValue: null,
5030f3 126         words:"",
1c7036 127         tileColor: null,
Y 128         createUser: null,
129         updateUser: null,
130         state: null,
131         weight: null,
132       },
133     }
134   },
135   mounted() {
136     this.getStationConf()
59e228 137     this.getWebUrl()
W 138     this.getDetailMessage()
1c7036 139   },
Y 140   methods:{
59e228 141     getWebUrl(){
W 142       getUrl().then(res=>{
143         this.websocketUrl = res+"OP050"
144         console.log('websocketUrl:',this.websocketUrl)
145         this.initWebSocket()
1c7036 146       })
Y 147     },
59e228 148     initWebSocket: function (){
W 149       //判断当前浏览器是否支持WebSocket
150       if ('WebSocket' in window) {
151         //连接WebSocket节点
152         this.websocket = new WebSocketReconnect(this.websocketUrl);
153         //接收到消息的回调方法
154         this.websocket.socket.onmessage = (event) => {
155           let data = event.data;
156           if (data != null && data !== ''){
157             this.result = JSON.parse(data);
158             const resultMessage = this.result.server_message.split("*");
159             console.log('resultMessage',resultMessage)
d2daac 160             if (resultMessage.length >=2){
59e228 161               if (resultMessage[1] === "sfcCode"){
W 162                 this.queryParams.scanObject1 = resultMessage[0]
163                 this.queryParams.productSeries = resultMessage[2]
164                 this.queryParams.scanObject2 = resultMessage[3]
165               } else if (resultMessage[1] === "rodCode"){
166                 this.queryParams.scanObject2 = resultMessage[0]
167                 this.queryParams.productSeries = resultMessage[2]
168               } else if (resultMessage[1] === "clean"){
169                 this.queryParams.scanObject1 = ""
170                 this.queryParams.scanObject2 = ""
171                 this.queryParams.words = ""
172                 this.queryParams.tileColor = ""
173               }
5030f3 174             }
59e228 175             if (this.queryParams.scanObject1 !== null && this.queryParams.scanObject1 !== ''
W 176               && this.queryParams.scanObject2 !== null && this.queryParams.scanObject2 !== ''){
177               if (this.queryParams.scanObject1 === this.queryParams.scanObject2){
178                 this.queryParams.words = "配对成功"
179                 this.queryParams.tileColor = "#3dcc1d"
180                 //请求出站
181                 // this.passStation()
182               }else {
183                 this.queryParams.words = "配对失败"
184                 this.queryParams.tileColor = "#f50909"
185               }
186             }
187
188
189             // const parts3 = this.result.server_message.split("*");
190             // if (parts3.length >= 2) {
191             //   this.from.scanObject2=parts3[0];
192             //   this.queryParams.words=parts3[1];
193             //   this.queryParams.tileColor= parts3[2];
194             //   this.handleQuery();
195             // }
196           }
5030f3 197         }
59e228 198         //监听窗口关闭事件,当窗口关闭时,主动去关闭websocket连接,防止连接还没断开就关闭窗口,server端会抛异常。
W 199         window.onbeforeunload = function () {
200           this.websocket.close()
201         }
202         //关闭连接
203         function closeWebSocket() {
204           this.websocket.close()
205         }
206         //发送消息
207         function send() {
208           this.websocket.socket.send({ kk: 123 })
209         }
210       } else {
211         alert('浏览器不支持webSocket')
1c7036 212       }
Y 213     },
59e228 214     //刷新获取信息
W 215     getDetailMessage(){
216       getDetailData().then(res => {
217         if (res.data == 200){
218           console.log('res200',res)
219           this.queryParams.scanObject1 = res.SfcCode
220           this.queryParams.productSeries = res.productSeries
221         }
222       })
223     },
1c7036 224     /** 查询工位终端配置列表 */
Y 225     getStationConf() {
226       getIp().then(response => {
227         let queryParams = {
228           ipAddress: response.msg,
229         }
230         listStationConf(queryParams).then(response => {
231           this.locationName = response.rows[0].processesName
232           this.locationCode = response.rows[0].processesCode
233         });
234       });
235     },
59e228 236     passStation(){
W 237       outSign().then(res =>{
238         console.log("res",res)
239         if (res.code === 200){
240           console.log('1212121')
241           this.$message({
242             message: '匹配成功,已过站',
243             type: 'success',
244             duration:3000
245           });
246           this.queryParams.productSeries = ''
247           this.queryParams.scanObject1 = ''
248           this.queryParams.scanObject2 = ''
249           this.queryParams.words = ''
250           this.queryParams.tileColor = ''
251
252         }
253       })
254     },
1c7036 255     /** 搜索按钮操作 */
Y 256     handleQuery() {
257       this.clear();
59e228 258       if(this.from.scanObject2 !== null)
1c7036 259       {
59e228 260         this.insetFromToQueryParams();
W 261         //this.getList();
262       } else{
1c7036 263         const h = this.$createElement;
Y 264         this.$message({
265           message: h('p',null, [
266             h('span', null, '警告 '),
267             h('i', { style: 'color: black' }, '请填写所有搜索条件'),
268             h()]),
269           type: 'error',
270           center: true,
271           offset:300
272         });
273       }
274     },
59e228 275     cleanForm(){
W 276       this.queryParams.productSeries = ""
277       this.queryParams.scanObject1 = ""
278       this.queryParams.scanObject2 = ""
279       this.queryParams.words = ""
280       this.queryParams.tileColor = ""
1c7036 281     },
Y 282     //取配瓦颜色
283     getList() {
284       let queryParams = {
285         productSeries : this.queryParams.productSeries,
286         axisName : this.queryParams.axisName,
287         neckName : this.queryParams.neckName,
288         tileName : this.queryParams.tileName,
289         axisValue: this.queryParams.axisValue,
290         neckValue: this.queryParams.neckValue,
291       }
292       console.log(queryParams)
293       listTileMatchRules(queryParams).then(response => {
294         this.queryParams.tileColor = response.rows[0].tileColor;
295       });
296     },
297     clear(){
298       this.queryParams.axisValue=null;
299       this.queryParams.neckValue=null;
300     },
301     insetFromToQueryParams(){
302       this.queryParams.productSeries=this.from.productSeries;
303       this.queryParams.tileName=this.from.tileName;
304       this.queryParams.scanObject2=this.from.scanObject2;
305     }
306
307   },
308 }
309 </script>
310
311 <style scoped>
312 ::v-deep .el-form-item__label{
313   font-size: large;
314 }
315 ::v-deep .el-card__body{
316   padding: 15px 20px 0px 20px;
317 }
318 ::v-deep .el-input .el-input--medium .el-input--suffix{
319   width: 200px;
320 }
321 .boxSize{
322   height: 60px;
323 }
324 .centerText{
325   color: black;
326   font-weight: bold;
327   font-size: 20px;
328   display: flex;
329   justify-content: center;
330   margin-top: 5px
331 }
332 </style>