Commit 53af05fa authored by xcc's avatar xcc

增加工位选择

parent 11da8045
......@@ -59,6 +59,7 @@
<script>
let codeDianshi = '1194168167242801152'
new Vue({
el: '#app',
vuetify: new Vuetify(),
......@@ -150,65 +151,26 @@
]
}),
created(){
this.getSite();
},
methods: {
// 工位切换
gongweiFunc(o,i){
getSite(){
fetch('http://127.0.0.1:8180/stage-api/base/site/selectListSite',
{method: 'GET', headers: {'Authorization': 'Bearer_b3e1b7b2-51c8-451b-944b-dccf3491ad32'}})
{method: 'GET', headers: {'Authorization': 'Bearer_4b33504b-9b9a-4b93-8f1c-87729b9282d1'}})
.then(response => response.json())
.then(data => {
this.gongweiList=data.data.map((o)=> Object.assign({},o,{active:false,lable:o.siteName}));
})
.catch(error => console.error('Error:', error));
// this.gongweiList= ( JSON.parse(JSON.stringify(this.gongweiList)) ).map((o)=> Object.assign({},o,{active:false}) )
this.$nextTick(()=>{
const _data=JSON.parse(JSON.stringify(this.gongweiList))
_data[i].active=true
this.gongweiList=[]
this.$nextTick(()=>{
this.gongweiList=_data
})
})
},
// 确定
submit1(){
const _data=JSON.parse(JSON.stringify(this.gongweiList)).filter(o=>o.active)
// 选中值
console.log(_data)
this.showDilog=false
this.$nextTick(()=>{
// 显示第一个 ifream
$("#myiframe1").removeClass("hidden")
})
}
}
})
</script>
<script>
$(document).ready(function() {
initWebSocket(){
console.log('1111+++='+codeDianshi)
var iframe1 = document.getElementById('myiframe1').contentWindow;
var iframe2 = document.getElementById('myiframe2').contentWindow;
var iframe3 = document.getElementById('myiframe3').contentWindow;
const codeDianshi = '1194168167242801152'
let bwsState = 0; // bwsWebSocket 状态
let wsState = 0; // wsWebSocket 状态
function initUlocWebsocketFunc() {
// 生产工位websocket
// 初始化
......@@ -216,7 +178,7 @@ $(document).ready(function() {
//监听是否连接成功
ws.onopen = function () {
wsState = ws.readyState
console.log('ws连接状态:' + ws.readyState);
// console.log('ws连接状态:' + ws.readyState);
var _json1={
type:'conStatusChange',
newStatus:false
......@@ -227,13 +189,13 @@ $(document).ready(function() {
}
// 接听服务器发回的信息并处理展示
ws.onmessage = function (option = {}) {
console.log('ws收到消息');
console.log('ws连接状态:' + ws.readyState);
// console.log('ws收到消息');
// console.log('ws连接状态:' + ws.readyState);
wsState = ws.readyState
const {data = "{}"} = option
const _data = JSON.parse(data)
console.log(_data);
// console.log(_data);
iframe1.postMessage(JSON.stringify(_data), '*');
iframe2.postMessage(JSON.stringify(_data), '*');
iframe3.postMessage(JSON.stringify(_data), '*');
......@@ -242,7 +204,7 @@ $(document).ready(function() {
ws.onclose = function () {
wsState = ws.readyState
// 监听整个过程中websocket的状态
console.log('ws连接关闭状态:' + ws.readyState);
// console.log('ws连接关闭状态:' + ws.readyState);
var _json1={
type:'conStatusChange',
newStatus:true
......@@ -261,8 +223,8 @@ $(document).ready(function() {
iframe1.postMessage(JSON.stringify(_json1), '*');
iframe2.postMessage(JSON.stringify(_json1), '*');
iframe3.postMessage(JSON.stringify(_json1), '*');
console.log('错误error' + error);
console.log('错误:ws连接状态:' + ws.readyState);
// console.log('错误error' + error);
// console.log('错误:ws连接状态:' + ws.readyState);
}
}
function initBroadcastWebsocketFunc() {
......@@ -272,7 +234,7 @@ $(document).ready(function() {
//监听是否连接成功
broadcastWs.onopen = function () {
bwsState = broadcastWs.readyState;
console.log('bws连接状态:' + broadcastWs.readyState);
// console.log('bws连接状态:' + broadcastWs.readyState);
var _json1={
type:'conStatusChange',
newStatus:false
......@@ -283,14 +245,14 @@ $(document).ready(function() {
}
// 接听服务器发回的信息并处理展示
broadcastWs.onmessage = function (option = {}) {
console.log('bws收到信息');
console.log('bws连接状态:' + broadcastWs.readyState);
// console.log('bws收到信息');
// console.log('bws连接状态:' + broadcastWs.readyState);
bwsState = broadcastWs.readyState
const {data = "{}"} = option
const _data = JSON.parse(data)
console.log(_data);
// console.log(_data);
iframe1.postMessage(JSON.stringify(_data), '*');
iframe2.postMessage(JSON.stringify(_data), '*');
iframe3.postMessage(JSON.stringify(_data), '*');
......@@ -299,7 +261,7 @@ $(document).ready(function() {
broadcastWs.onclose = function () {
bwsState = broadcastWs.readyState
// 监听整个过程中websocket的状态
console.log('bws连接关闭状态:' + broadcastWs.readyState);
// console.log('bws连接关闭状态:' + broadcastWs.readyState);
var _json1={
type:'conStatusChange',
newStatus:true
......@@ -318,8 +280,8 @@ $(document).ready(function() {
iframe1.postMessage(JSON.stringify(_json1), '*');
iframe2.postMessage(JSON.stringify(_json1), '*');
iframe3.postMessage(JSON.stringify(_json1), '*');
console.log('错误error' + error);
console.log('错误:bws连接状态:' + broadcastWs.readyState);
// console.log('错误error' + error);
// console.log('错误:bws连接状态:' + broadcastWs.readyState);
}
}
......@@ -336,7 +298,7 @@ $(document).ready(function() {
initBroadcastWebsocketFunc() // 初始化
// $("#selectCodeContainer").css("z-index",-999)
window.IntervalItemCenter13 = setInterval(() => {
console.log('111==='+wsState+'222==='+bwsState);
// console.log('111==='+wsState+'222==='+bwsState);
if (wsState != 1 || bwsState != 1 ) {
initUlocWebsocketFunc() // 初始化
initBroadcastWebsocketFunc() // 初始化
......@@ -352,7 +314,49 @@ $(document).ready(function() {
WebSocketInitHandle()
}, 500);
});
</script>
},
// 工位切换
gongweiFunc(o,i){
this.gongweiList= ( JSON.parse(JSON.stringify(this.gongweiList)) ).map((o)=> Object.assign({},o,{active:false}) )
this.$nextTick(()=>{
const _data=JSON.parse(JSON.stringify(this.gongweiList))
_data[i].active=true
this.gongweiList=[]
this.$nextTick(()=>{
this.gongweiList=_data
})
})
},
// 确定
submit1(){
const _data=JSON.parse(JSON.stringify(this.gongweiList)).filter(o=>o.active)
codeDianshi=_data[0].tmBasSiteId;
this.initWebSocket();
this.showDilog=false;
this.$nextTick(()=>{
// 显示第一个 ifream
$("#myiframe1").removeClass("hidden")
})
}
}
})
$(document).ready(function() {
});
</script>
</body>
</html>
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment