Browse Source

指示灯

master
aBin 4 years ago
parent
commit
750d5b6ad1
  1. 37
      src/components/Panel/Panel.vue
  2. 19
      src/mixins/socket.js
  3. 5
      src/views/Index/Index.vue
  4. 2
      src/views/RfidGauge/index.vue

37
src/components/Panel/Panel.vue

@ -21,7 +21,7 @@
<span class="panel-con">{{ maintenanceDose }}</span>
</div>
</div>
<div style="width: 95%; padding-left: 5%">
<div style="width: 95%; padding-left: 5%; position: relative">
<div style="width: 120%">
<span :style="{ marginLeft: percentA }" class="tips">
{{ info }}
@ -32,6 +32,7 @@
<div class="flex-1" style="width: 106%; margin-left: -3%">
<div :key="index" class="flex-1" style="justify-content: center" v-for="(item, index) in lists">{{ item }}</div>
</div>
<div class="cir" v-if="cirAni"></div>
</div>
</div>
</div>
@ -54,15 +55,18 @@ export default {
},
lists: ['呼叫', '分诊', '一线', '采血', '心电', 'CT', '二线', '谈话', '签字', '团注', '介入', '置鞘', '病房'],
info: '呼叫',
cirAni: false,
cirTimer: null,
};
},
computed: mapState('messages', ['weightMessage', 'bolusDose', 'maintenanceDose', 'thrombolyticDose', 'startMessages', 'rfidMessage']),
watch: {
rfidMessage(val) {
if (this.startMessages || val.step === '0') {
if (this.startMessages || val.step === '0' || val.type - 0 === 0) {
this.percent = 0;
this.percentA = 0;
this.info = '呼叫';
this.startCirAni();
this.setStartMessages(false);
} else {
if ((val.step || val.step === '0') && val.step - 0 >= (this.percent * 12) / 100 && val.step - 0 <= 12) {
@ -79,11 +83,27 @@ export default {
this.percent = 0;
this.percentA = 0;
this.info = '呼叫';
this.startCirAni(val);
this.setStartMessages(false);
}
},
},
methods: { ...mapMutations('messages', ['setStartMessages']) },
methods: {
...mapMutations('messages', ['setStartMessages']),
startCirAni(val) {
console.log('val: ', val);
if (!this.cirTimer) {
const that = this;
this.cirTimer = setInterval(() => {
that.cirAni = !that.cirAni;
}, 500);
setTimeout(() => {
clearInterval(that.cirTimer);
that.cirTimer = null;
}, 3100);
}
},
},
// mounted() {
// const that = this;
// var add = setInterval(function() {
@ -100,6 +120,17 @@ export default {
</script>
<style lang="stylus" scoped>
.cir {
position: absolute !important;
top: 50% !important;
margin-top: -8px !important;
left: 8px !important;
height: 16px !important;
width: 16px !important;
border-radius: 50% !important;
background: #4ACA6D !important;
}
.panel-box {
height: 100%;
width: 100%;

19
src/mixins/socket.js

@ -35,6 +35,7 @@ const mixin = {
// 初始化websocket
initSocket() {
if (lockSocket) return;
console.log('初始化websocket');
lockSocket = true;
// const token = sessionStorage.getItem('anyringToken');
// if (!token) return;
@ -76,7 +77,6 @@ const mixin = {
break;
case 2: // RFID
this.messagesAddRfid(data.data);
console.log('data.data: ', data.data);
break;
case 3: // 称重传感器一
this.messagesAddWeighSensor1(data.data.value);
@ -145,6 +145,7 @@ const mixin = {
// 打开socket
websocketOpen() {
console.log('打开socket');
// console.warn('socket 打开成功', new Date().toLocaleString());
connected = true;
prevTimestamp = Date.now();
@ -157,6 +158,7 @@ const mixin = {
// 发送消息
sendSocketMessage(data) {
console.log('发送消息');
// console.warn('send:', data, new Date().toLocaleString());
if (connected) {
if (socket.readyState === 1) {
@ -169,6 +171,7 @@ const mixin = {
// 关闭socket
websocketClose(e) {
console.log('关闭socket');
// console.warn(e);
connected = false;
if (sendHeartTimer) clearInterval(sendHeartTimer);
@ -186,11 +189,13 @@ const mixin = {
// 连接失败
websocketError() {
console.log('连接失败');
console.warn('error = ', connected);
},
// websocket发送token进行认证
auth() {
console.log('进行认证');
// const token = sessionStorage.getItem('anyringToken');
// if (!token) return;
const query = this.$route.query;
@ -201,6 +206,7 @@ const mixin = {
// 心跳检测
sendHeart() {
console.log('心跳检测');
if (sendHeartTimer) clearInterval(sendHeartTimer);
sendHeartTimer = setInterval(() => {
if (Date.now() - prevTimestamp >= 15000) {
@ -219,17 +225,18 @@ const mixin = {
* @param {object} data 消息内容对象
*/
handleAuthMessage(data) {
console.log('认证信息');
if (data.data.authed) {
// 认证成功
this.sendHeart();
} else {
this.$message.error('消息系统认证失败, 请重新登录');
// this.$message.error('消息系统认证失败, 请重新登录');
// 清除掉本地无用的token
sessionStorage.removeItem('anyringToken');
// sessionStorage.removeItem('anyringToken');
socket = null;
setTimeout(() => {
this.$router.push('/user/login');
}, 1000);
// setTimeout(() => {
// this.$router.push('/user/login');
// }, 1000);
}
},
},

5
src/views/Index/Index.vue

@ -51,10 +51,7 @@
</div>
</div>
<div class="flex-2 ma-2" style="position: relative">
<iframe
class="fill-width fill-height"
src="https://www.thingjs.com/pp/6dab0a018283ef357a85684c"
></iframe>
<iframe class="fill-width fill-height" src="https://www.thingjs.com/pp/6dab0a018283ef357a85684c"></iframe>
<!-- 地图 -->
<shanxi-map class="sxmap" />
<!-- 视频 -->

2
src/views/RfidGauge/index.vue

@ -59,7 +59,7 @@ export default {
console.log(msg);
}
} catch (error) {
console.error(error);
console.error('error: ', error);
}
},
},

Loading…
Cancel
Save