@ -47,14 +47,15 @@
<!-- : value = "item.value" / > -- >
<!-- < / e l - s e l e c t > - - >
< el -button color = "#C77000" style = "width: 200px;" @click ="viewPatientInfo" > 患者信息 < / el -button >
<!-- < el -button color = "#C77000" style = "width: 150px;" > 已连接 < / e l - b u t t o n > - - >
<!-- < el -button color = "#C77000" > 机器人运行正常 < / e l - b u t t o n > - - >
<!-- 远程控制 -- >
< el -button color = "#C77000" @click ="connectionUnity('1')" v-if ="!whetherControl" > 连接远程控制
< / e l - b u t t o n >
< template v-else >
< el -button color = "#C77000" > 已控制 < / e l - b u t t o n >
< el -button color = "#C77000" @click ="connectionUnity('0')" > 断开远程控制 < / el -button >
< / template >
<!-- < el -button color = "#C77000" style = "width: 150px;" > 已连接 < / e l - b u t t o n > - - >
<!-- < el -button color = "#C77000" > 机器人运行正常 < / e l - b u t t o n > - - >
< / 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 ) < / e l - d r o p d o w n - i t e m >
< el -dropdown -item command = "速度(ml/h)" > 速度 ( ml / h ) < / e l - d r o p d o w n - i t e m >
< / e l - d r o p d o w n - m e n u >
< / template >
< / e l - d r o p d o w n >
< / template > -- >
< / e l - t a b l e - c o l u m n >
< 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" > < / e l - t a b l e - c o l u m n >
< 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 / >
< / e l - i c o n >
< / e l - b u t t o n >
< 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 / >
< / e l - i c o n >
< / e l - b u t t o n >
& 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" >确定
< / e l - b u t t o n >
< el -button size = "small" color = "#006080" @click ="tableItemCancel(scope)" > 取消
< el -button size = "small" color = "#006080" @click ="tableItemCancel(scope)"
: disabled = "!whetherControl" > 取消
< / e l - b u t t o n >
< / div >
< / template >
< / e l - t a b l e - c o l u m n > - - >
< / e l - t a b l e - c o l u m n >
< / e l - t a b l e >
< / 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 / >
< / e l - i c o n >
< / e l - b u t t o n >
< 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 / >
< / e l - i c o n >
< / e l - b u t t o n >
< el -button size = "small" color = "#006080" @ click = "tableItemConfirm(scope, fixedTableData)" > 确定
< el -button size = "small" color = "#006080"
@ click = "tableItemConfirm(scope, fixedTableData)"
: disabled = "!whetherControl" > 确定
< / e l - b u t t o n >
< el -button size = "small" color = "#006080" @click ="tableItemCancel(scope)" > 取消
< el -button size = "small" color = "#006080" @click ="tableItemCancel(scope)"
: disabled = "!whetherControl" > 取消
< / e l - b u t t o n >
< / div >
< / template >
< / e l - t a b l e - c o l u m n > - - >
< / e l - t a b l e - c o l u m n >
< / e l - t a b l e >
< / 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 . aiMedicine List[ 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 ) {
/ / t o d o 鬼 屎 代 码
/ / v a r T a b l e D a t a . v a l u e = v a r T a b l e D a t a . v a l u e . f i l t e r ( m e d i c i n e = > {
/ / r e t u r n m e d i c i n e . n a m e i n a i M e d i c i n e ; / / 只 保 留 存 在 于 a i M e d i c i n e 中 的 m e d i c i n e
/ / } ) ;
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'
} )
/ / c o n s o l e . l o g ( v a r T a b l e D a t a . v a l u e )
/ / c o n s o l e . l o g ( f i x e d T a b l e D a t a . v a l u e )
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 ,
/ / d a t e : c u r r e n t R e m o t e . v a l u e . d a t e ,
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' :
/ / t i m e D i f f P i n g . v a l u e = n e w V a l u e . m s g ;
break ;
case 'connectionMsg' :
ElMessage . info ( msg )
default :
break ;
}
}
} )
< / script >
< style lang = "scss" scoped >