rax-medical/src/views/remote-manage/remote-manage.vue

166 lines
4.6 KiB
Vue
Raw Normal View History

2023-11-10 17:45:10 +08:00
<template>
2023-12-20 14:54:01 +08:00
<div class="remote-manage-page">
<div class="header-box">
<div class="task-btn-item" v-for="(item, index) in remoteTask" :key="'task-' + index"
:class="{ 'connecting': item.patientName || item.patientCode, 'alarm': item.dataAlarm }" @click="editTask(item, index)">
<span>{{ item.title || ('新建任务' + (index + 1)) }}</span>
</div>
</div>
<div class="content-box">
<div class="remote-box">
<RemotePart ref="remotePartRef" />
</div>
<div class="message-box">
<MessagePart ref="messagePartRef" />
</div>
</div>
</div>
<RemoteDialog ref="remoteDialogRef" @confirmRemote="confirmRemote" @errorRemote="errorRemote" @breakRemote="breakRemote" />
2023-11-10 17:45:10 +08:00
</template>
2023-12-20 14:54:01 +08:00
<script lang='ts' setup>
import { onMounted, reactive, ref, toRefs, watch } from 'vue'
import { useRouter } from 'vue-router'
import { useRemoteStore } from '@/stores/remote-info-store'
import type { RemoteItem } from '@/utils/public-interface'
import RemoteDialog from './part/remote-dialog.vue'
import RemotePart from './part/remote-part.vue'
import MessagePart from './part/message-part.vue'
const router = useRouter()
const remotePartRef = ref()
const messagePartRef = ref()
const remoteDialogRef = ref()
const remoteTask = ref([] as Array<RemoteItem>)
initRemoteTask()
function initRemoteTask() {
remoteTask.value = []
while (remoteTask.value.length < 10) {
const obj = {
isRemote: true, // 连接状态
dataAlarm: false, // 异常状态
title: '',
serverUser: '', // 服务器用户名
patientName: '', // 病人名称
patientCode: '', // 病人身份证
}
if(remoteTask.value.length < 3) {
obj.title = '远程控制' + (remoteTask.value.length + 1)
obj.serverUser = 'root'
obj.patientName = '测试' + (remoteTask.value.length + 1)
}
if(remoteTask.value.length == 1) obj.dataAlarm = true
remoteTask.value.push(obj)
}
}
2023-11-20 09:13:16 +08:00
2023-12-20 14:54:01 +08:00
// 打开任务连接弹窗
const editTask = (item: RemoteItem, index: number) => {
item.index = index
remoteDialogRef.value.open(item)
}
2023-12-20 14:54:01 +08:00
// 连接成功
const confirmRemote = (e: RemoteItem) => {
console.log(e)
messagePartRef.value.setData({
time: new Date(),
title: e.title,
state: '连接成功'
})
remotePartRef.value.initData(e)
useRemoteStore().setCurrentRemote(e)
2023-11-10 17:45:10 +08:00
}
2023-12-20 14:54:01 +08:00
// 连接失败
const errorRemote = (e: RemoteItem) => {
messagePartRef.value.setData({
time: new Date(),
title: e.title,
state: '连接失败'
})
2023-11-10 17:45:10 +08:00
}
2023-12-20 14:54:01 +08:00
// 断开连接
const breakRemote = (e: RemoteItem) => {
remotePartRef.value.initData({})
messagePartRef.value.setData({
time: new Date(),
title: e.title,
state: '断开连接'
})
2023-11-10 17:45:10 +08:00
}
</script>
2023-12-20 14:54:01 +08:00
<style lang='scss' scoped>
.remote-manage-page {
width: 100%;
height: 100%;
padding-top: 15px;
.header-box {
width: 100%;
2023-12-20 17:00:47 +08:00
height: 190px;
2023-12-20 14:54:01 +08:00
background: white;
2023-12-20 17:00:47 +08:00
padding: 10px 50px;
2023-12-20 14:54:01 +08:00
display: flex;
flex-wrap: wrap;
justify-content: space-between;
2023-12-20 17:00:47 +08:00
align-items: center;
2023-12-20 14:54:01 +08:00
.task-btn-item {
cursor: pointer;
width: 17%;
2023-12-20 15:12:29 +08:00
height: 70px;
2023-12-20 14:54:01 +08:00
border: 2px solid $main-color;
color: $main-color;
border-radius: 5px;
font-size: 20px;
display: flex;
justify-content: center;
align-items: center;
transition: all .6s;
&:hover {
background: rgba($main-color, .1);
transition: all .6s;
}
&.connecting {
background: $main-color;
color: white;
&:hover {
background: rgba($main-color, .8);
}
}
&.alarm {
background: #f80000;
border-color: #f80000;
color: white;
&:hover {
background: rgba(#f80000, .8);
}
}
}
}
.content-box {
width: 100%;
2023-12-20 17:00:47 +08:00
height: calc(100% - 205px);
2023-12-20 14:54:01 +08:00
margin-top: 15px;
background: white;
padding: 20px 50px;
display: flex;
justify-content: space-between;
.remote-box {
width: calc(100% - 370px);
height: 100%;
}
.message-box {
width: 350px;
height: 100%;
}
}
}</style>