Compare commits

..

2 Commits

Author SHA1 Message Date
republicline f959c6bcc4 1, 远程控制, 待完成 2025-07-04 12:40:37 +08:00
republicline 0c2000064f 路由错误 2025-07-01 10:08:38 +08:00
4 changed files with 1003 additions and 1061 deletions

View File

@ -48,7 +48,7 @@ export const constantRoute = [
children: [
{
path: '/patients-manage/patients-manage',
name: '患者管理',
name: '患者管理2',
component: () => import('@/views/patients-manage/patients-manage.vue'),
},
{

View File

@ -249,7 +249,21 @@ export const useRemoteWsStore = defineStore("remoteWs", {
patient.vitalWS.onmessage = undefined;
}
},
createChatConnect(name: string, id: string, date: string, index: number) {
if (!this.patient[name + id + date + index]) this.patient[name + id + date + index] = {}
const patient = this.patient[name + id + date + index]
if (!patient['chatWS']) {
patient['chatWS'] = new WebSocket(chatUrl)
patient.chatWS.onopen = function () {
patient.chatWS.send(JSON.stringify({
patientName: name,
idNum: id,
date: date,
msgType: "init"
}))
}
}
},
sendMsg(name: string, id: string, date: string, msg: string, index: number, cb: any) {
const patient: any = this.patient[name + id + date + index]
if (patient) {

View File

@ -47,14 +47,15 @@
<!-- :value="item.value"/>-->
<!-- </el-select>-->
<el-button color="#C77000" style="width: 200px;" @click="viewPatientInfo">患者信息</el-button>
<!-- <el-button color="#C77000" style="width: 150px;">已连接</el-button>-->
<!-- <el-button color="#C77000" >机器人运行正常</el-button>-->
<!-- 远程控制 -->
<el-button color="#C77000" @click="connectionUnity('1')" v-if="!whetherControl">连接远程控制
</el-button>
<template v-else>
<el-button color="#C77000">已控制</el-button>
<el-button color="#C77000" @click="connectionUnity('0')">断开远程控制</el-button>
</template>
<!-- <el-button color="#C77000" style="width: 150px;">已连接</el-button>-->
<!-- <el-button color="#C77000" >机器人运行正常</el-button>-->
</div>
<el-button color="#e0e0e0" @click="backRemote">
<el-icon>
@ -131,46 +132,34 @@
<el-table :data="varTableData" height="100%" style="width: 100%">
<el-table-column type="index" label="泵号" width="80" align="center"/>
<el-table-column prop="name" label="药物名称" align="center"/>
<el-table-column prop="speed" label="速度(mL/h)" width="120">
<!-- <template #header>
<el-dropdown @command="table1SpeedCommand">
<span style="color: white;font-size: 14px;line-height: 20px;">
{{ table1SpeedVal || '请选择速度' }}
</span>
<template #dropdown>
<el-dropdown-menu>
<el-dropdown-item command="速度(ug/kg/min)">速度(ug/kg/min)</el-dropdown-item>
<el-dropdown-item command="速度(ml/h)">速度(ml/h)</el-dropdown-item>
</el-dropdown-menu>
</template>
</el-dropdown>
</template> -->
</el-table-column>
<el-table-column prop="total" label="累计药量(mL)" width="100"/>
<!-- <el-table-column prop="state" label="工作状态" width="150" align="center"/>-->
<!-- <el-table-column label="特殊情况人为干预" align="center">
<el-table-column prop="speed" label="速度(mL/h)" width="100"/>
<el-table-column prop="total" label="累计药量(ml)" width="100"></el-table-column>
<el-table-column prop="state" label="工作状态" width="70" align="center"/>
<el-table-column label="特殊情况人为干预" align="center">
<template #default="scope">
<div class="table-btn-box">
<el-button size="small" color="#006080" @click="tableItemPlus(scope)">
<el-button size="small" color="#006080" @click="tableItemPlus(scope)"
:disabled="!whetherControl">
<el-icon>
<Plus/>
</el-icon>
</el-button>
<el-button size="small" color="#006080" :disabled="scope.row.speed <= 0"
<el-button size="small" color="#006080" :disabled="!whetherControl"
@click="tableItemMinus(scope)">
<el-icon>
<Minus/>
</el-icon>
</el-button>
&lt;!&ndash; <el-button size="small" color="#006080" @click="tableItemConfirm(scope)"
:disabled="tableDataStore[scope.$index].speed === scope.row.speed">确定&ndash;&gt;-->
<!--<el-button size="small" color="#006080" @click="tableItemConfirm(scope, varTableData)">确定
<el-button size="small" color="#006080"
@click="tableItemConfirm(scope, varTableData)"
:disabled="!whetherControl">确定
</el-button>
<el-button size="small" color="#006080" @click="tableItemCancel(scope)">取消
<el-button size="small" color="#006080" @click="tableItemCancel(scope)"
:disabled="!whetherControl">取消
</el-button>
</div>
</template>
</el-table-column> -->
</el-table-column>
</el-table>
</div>
<!-- table2 -->
@ -180,28 +169,31 @@
<el-table-column prop="name" label="药物名称" align="center"/>
<el-table-column prop="speed" label="速度(mL/h)" width="100"/>
<el-table-column prop="total" label="累计药量(mL)" width="100"/>
<!-- <el-table-column prop="state" label="工作状态" width="150" align="center"/>-->
<!-- <el-table-column label="特殊情况人为干预" align="center">
<el-table-column label="特殊情况人为干预" align="center">
<template #default="scope">
<div class="table-btn-box">
<el-button size="small" color="#006080" @click="tableItemPlus(scope)">
<el-button size="small" color="#006080" @click="tableItemPlus(scope)"
:disabled="!whetherControl">
<el-icon>
<Plus/>
</el-icon>
</el-button>
<el-button size="small" color="#006080" :disabled="scope.row.speed <= 0"
<el-button size="small" color="#006080" :disabled="!whetherControl"
@click="tableItemMinus(scope)">
<el-icon>
<Minus/>
</el-icon>
</el-button>
<el-button size="small" color="#006080" @click="tableItemConfirm(scope, fixedTableData)">确定
<el-button size="small" color="#006080"
@click="tableItemConfirm(scope, fixedTableData)"
:disabled="!whetherControl">确定
</el-button>
<el-button size="small" color="#006080" @click="tableItemCancel(scope)">取消
<el-button size="small" color="#006080" @click="tableItemCancel(scope)"
:disabled="!whetherControl">取消
</el-button>
</div>
</template>
</el-table-column> -->
</el-table-column>
</el-table>
</div>
</div>
@ -225,7 +217,7 @@
</template>
<script lang="ts" setup>
import {onMounted, onUnmounted, onUpdated, reactive, ref, watch} from 'vue';
import {onMounted, onUnmounted, onUpdated, reactive, ref} from 'vue';
import {useRouter} from 'vue-router'
import {ElMessage, ElMessageBox} from 'element-plus';
import {dateFormater} from '@/utils/date-util';
@ -341,6 +333,32 @@ function subscribeWS() {
}
const onMedicineClose = () => {
remoteWsStore.medicineOnclose(currentRemote.value.patient, currentRemote.value.patientId, currentRemote.value.date, currentRemote.value.index, () => {
ElMessage.info('远程控制' + (currentRemote.value.index + 1) + ' 给药连接断开,正在尝试重连……')
setTimeout(() => {
remoteWsStore.createMedicineConnect(currentRemote.value.patient, currentRemote.value.patientId, currentRemote.value.date, currentRemote.value.index)
subscribeMedicine()
}, 3000)
})
}
const subscribeMedicine = () => {
onMedicineClose()
remoteWsStore.subscribeMedicine(currentRemote.value.patient, currentRemote.value.patientId, currentRemote.value.date, currentRemote.value.index,
(res: any) => {
const data = JSON.parse(res.data);
if (data.status != 1) {
if (data.medicine) {
if (varTableData.value[data.medicine]) varTableData.value[data.medicine] = medicineSpeedTemp[data.medicine];
if (fixedTableData.value[data.medicine]) fixedTableData.value[data.medicine] = medicineSpeedTemp[data.medicine];
}
} else {
ElMessage.error(data.msg)
}
})
}
const subscribeVital = () => {
remoteWsStore.createVital(currentRemote.value.patient, currentRemote.value.patientId, currentRemote.value.date, currentIndex)
remoteWsStore.subscribeVital(currentRemote.value.patient, currentRemote.value.patientId, currentRemote.value.date, currentIndex,
@ -348,7 +366,7 @@ const subscribeVital = () => {
const data = JSON.parse(res.data);
// 1 2 3 4
if (data.vitalSignsList != null) {
updateMedicineTable(data.aiMedicineList[0], undefined);
updateMedicineTable(data.aiMedicine, undefined);
chartDom1.value.updateChartData(data.vitalSignsList);
chartDom2.value.updateChartData(data.vitalSignsList);
chartDom3.value.updateChartData(data.vitalSignsList);
@ -415,30 +433,22 @@ function initData() {
}
function updateMedicineTable(aiMedicine: any, doctorMedicine: any) {
if (aiMedicine) {
delete aiMedicine._id;
delete aiMedicine.Time;
currentAIMedicine = aiMedicine;
//
if (varTableData.value.length > 0) {
// todo
// varTableData.value = varTableData.value.filter(medicine => {
// return medicine.name in aiMedicine; // aiMedicine medicine
// });
varTableData.value.forEach((medicine: any) => {
medicine.speed = aiMedicine[medicine.name] ? Number(aiMedicine[medicine.name]).toFixed(2) : '0.0'
medicine.total = aiMedicine[medicine.name + "sum"] ? Number(aiMedicine[medicine.name + "sum"]).toFixed(2) : '0.0'
})
medicine.speed = aiMedicine[medicine.name] ? Number(aiMedicine[medicine.name]).toFixed(2) : '0.0';
medicine.total = aiMedicine[medicine.name + "sum"] ? Number(aiMedicine[medicine.name + "sum"]).toFixed(2) : '0.0';
});
fixedTableData.value.forEach((medicine: any) => {
medicine.speed = aiMedicine[medicine.name] ? Number(aiMedicine[medicine.name]).toFixed(2) : '0.0'
medicine.total = aiMedicine[medicine.name + "sum"] ? Number(aiMedicine[medicine.name + "sum"]).toFixed(2) : '0.0'
})
// console.log(varTableData.value)
// console.log(fixedTableData.value)
medicine.speed = aiMedicine[medicine.name] ? Number(aiMedicine[medicine.name]).toFixed(2) : '0.0';
medicine.total = aiMedicine[medicine.name + "sum"] ? Number(aiMedicine[medicine.name + "sum"]).toFixed(2) : '0.0';
});
} else { //
const varTable: any = [];
const fixedTable: any = [];
@ -449,9 +459,9 @@ function updateMedicineTable(aiMedicine: any, doctorMedicine: any) {
speed: aiMedicine[key] ? Number(aiMedicine[key]).toFixed(2) : '0.0',
total: aiMedicine[key + "sum"] ? Number(aiMedicine[key + "sum"]).toFixed(2) : '0.0',
state: "正常"
}
};
varTable.push(medicine);
})
});
remoteWsStore.fixedMedicine.forEach(key => {
const medicine = {
Phase: 0,
@ -459,9 +469,9 @@ function updateMedicineTable(aiMedicine: any, doctorMedicine: any) {
speed: aiMedicine[key] ? Number(aiMedicine[key]).toFixed(2) : '0.0',
total: aiMedicine[key + "sum"] ? Number(aiMedicine[key + "sum"]).toFixed(2) : '0.0',
state: "正常"
}
};
fixedTable.push(medicine);
})
});
varTableData.value = varTable;
fixedTableData.value = fixedTable;
}
@ -474,8 +484,8 @@ function updateMedicineTable(aiMedicine: any, doctorMedicine: any) {
currentDocMedicine = doctorMedicine;
const keys = Object.keys(doctorMedicine);
keys.forEach(key => {
medicineSpeedTemp[key] = doctorMedicine[key];
})
medicineSpeedTemp.value[key] = doctorMedicine[key];
});
if (varTableData.value.length > 0) {
varTableData.value.forEach((medicine: any) => {
@ -485,7 +495,7 @@ function updateMedicineTable(aiMedicine: any, doctorMedicine: any) {
fixedTableData.value.forEach((medicine: any) => {
medicine.speed = (Number(doctorMedicine[medicine.name]) + Number(aiMedicine[medicine.name])).toFixed(2);
medicine.total = (Number(doctorMedicine[medicine.name + "sum"]) + Number(aiMedicine[medicine.name + "sum"])).toFixed(2);
})
});
} else {
const varTable: any = [];
const fixedTable: any = [];
@ -496,13 +506,13 @@ function updateMedicineTable(aiMedicine: any, doctorMedicine: any) {
speed: Number(doctorMedicine[key]) + Number(aiMedicine[key]),
total: Number(doctorMedicine[key + "sum"]) + Number(aiMedicine[key + "sum"]),
state: "正常"
}
};
if (remoteWsStore.varMedicine.includes(key)) {
varTable.push(medicine);
} else {
fixedTable.push(medicine);
}
})
});
varTableData.value = varTable;
fixedTableData.value = fixedTable;
}
@ -663,13 +673,11 @@ function startAI() {
});
}
/**
* 远程控制
*/
//
const whetherControl = ref(false);
const connectionUnityLoading = ref(false);
const subscribeMedicineData = ref(null);
//
function connectionUnity(flag: string) {
if (flag === "1") {
console.log("连接远程控制");
@ -681,7 +689,7 @@ function connectionUnity(flag: string) {
const params: any = {
name: currentRemote.value.patient,
id: currentRemote.value.patientId,
// date: currentRemote.value.date,
date: currentRemote.value.date,
index: currentRemote.value.index,
msgType: "webRequestConnection",
flag
@ -697,86 +705,6 @@ function connectionUnity(flag: string) {
//
}
const onMedicineClose = () => {
remoteWsStore.medicineOnclose(currentRemote.value.patient, currentRemote.value.patientId, currentRemote.value.date, currentRemote.value.index, () => {
ElMessage.info('远程控制' + (currentRemote.value.index + 1) + ' 给药连接断开,正在尝试重连……')
setTimeout(() => {
remoteWsStore.createMedicineConnect(currentRemote.value.patient, currentRemote.value.patientId, currentRemote.value.index)
subscribeMedicine()
}, 3000)
})
}
const subscribeMedicine = () => {
onMedicineClose()
remoteWsStore.createMedicineConnect(currentRemote.value.patient, currentRemote.value.patientId, currentRemote.value.index)
remoteWsStore.subscribeMedicine(currentRemote.value.patient, currentRemote.value.patientId, currentRemote.value.date, currentRemote.value.index,
(res: any) => {
const data = JSON.parse(res.data);
subscribeMedicineData.value = data;
if (data.status != 1) {
if (data.medicine) {
if (varTableData.value[data.medicine]) varTableData.value[data.medicine] = medicineSpeedTemp[data.medicine];
if (fixedTableData.value[data.medicine]) fixedTableData.value[data.medicine] = medicineSpeedTemp[data.medicine];
}
} else {
ElMessage.error(data.msg)
}
})
}
watch(subscribeMedicineData, (newValue: any, oldValue: any) => {
if (newValue) {
const {msgType, unityConnectionFlag, msg} = newValue;
switch (msgType) {
case 'unityRequestConnection':
const params: any = {
name: currentRemote.value.patient,
id: currentRemote.value.patientId,
date: currentRemote.value.date,
index: currentRemote.value.index,
msgType: "webResponseConnection",
flag: "1"
}
ElMessageBox.confirm('确定接受远程控制', '确认提示', {
confirmButtonText: '确定',
cancelButtonText: '拒绝',
})
.then(() => {
whetherControl.value = unityConnectionFlag === '1';
remoteWsStore.reqMedicineConnect({...params, flag: unityConnectionFlag}, (res: any) => {
console.log('res >>>>>', res);
});
})
.catch(() => {
//
whetherControl.value = false;
remoteWsStore.reqMedicineConnect({...params, flag: '0'}, (res: any) => {
console.log('res >>>>>', res);
});
});
break;
case 'unityResponseConnection':
connectionUnityLoading.value = false
whetherControl.value = unityConnectionFlag === '1';
if (unityConnectionFlag === '1') {
ElMessage.success('连接成功')
} else {
ElMessage.info('连接断开')
}
break;
case 'getMedicine':
ElMessage.success('给药成功')
break;
case 'pong':
// timeDiffPing.value = newValue.msg;
break;
case 'connectionMsg':
ElMessage.info(msg)
default:
break;
}
}
})
</script>
<style lang="scss" scoped>

View File

@ -26,15 +26,15 @@ export default defineConfig({
server: {
proxy: {
'/api': {
// target: 'http://127.0.0.1:6379', // 目标服务器地址
target: 'http://110.41.142.124:6379', // 目标服务器地址
target: 'http://127.0.0.1:6379', // 目标服务器地址
// target: 'http://110.41.142.124:6379', // 目标服务器地址
ws: true, // 是否启用 WebSocket
changeOrigin: true, // 是否修改请求头中的 Origin 字段
rewrite: (path) => path.replace(/^\/api/, ''),
},
'/socket.io': {
// target: 'ws://127.0.0.1:6379',
target: 'ws://110.41.142.124:6379',
target: 'ws://127.0.0.1:6379',
// target: 'ws://110.41.142.124:6379',
ws: true,
changeOrigin: true,
rewrite: (path) => path.replace(/^\/socket.io/, ''),