fix: 增加给药校验

This commit is contained in:
GranceWang 2024-08-24 11:06:35 +08:00
parent 5261834640
commit 853eeeb538

View File

@ -103,7 +103,8 @@
</template>
<template #default="scope">
<span style="margin-right:25px">{{scope.row.medicineRate}}</span>
<el-link type="success">+{{scope.row.change}}</el-link>
<el-link type="success" v-if="scope.row.change>=0">+{{scope.row.change}}</el-link>
<el-link type="danger" v-else>{{scope.row.change}}</el-link>
</template>
</el-table-column>
<el-table-column prop="countMedicine" label="累计药量(ml)" width="100">
@ -141,7 +142,8 @@
<el-table-column prop="medicineRate" label="剂量(ml)" width="120">
<template #default="scope">
<span style="margin-right:25px">{{scope.row.medicineRate}}</span>
<el-link type="success">+{{scope.row.change}}</el-link>
<el-link type="success" v-if="scope.row.change>=0">+{{scope.row.change}}</el-link>
<el-link type="danger" v-else>{{scope.row.change}}</el-link>
</template>
</el-table-column>
<el-table-column prop="countMedicine" label="累计药量(ml)" width="100">
@ -256,7 +258,7 @@ const unusual = ref([] as any);
const fixedTableData = ref([] as any[]);
const varTableData = ref([] as any[]);
const table1SpeedVal = ref('');
const whetherControl =ref(false);
const whetherControl =ref(true);
const subscribeMedicineData=ref(null);
const intervalFun=ref(null);
const timeDiffPing=ref(0);
@ -278,9 +280,11 @@ onMounted(() => {
});
onUnmounted(() => {
remoteWsStore.unsubscribeChat(currentRemote.value.patient, currentRemote.value.patientId, currentRemote.value.date, currentRemote.value.index);
remoteWsStore.unsubscribeMedicine(currentRemote.value.patient, currentRemote.value.patientId, currentRemote.value.date, currentRemote.value.index);
remoteWsStore.unsubscribeVital(currentRemote.value.patient, currentRemote.value.patientId, currentRemote.value.date, currentRemote.value.index);
if (currentRemote.value) {
remoteWsStore.unsubscribeChat(currentRemote.value.patient, currentRemote.value.patientId, currentRemote.value.date, currentRemote.value.index);
remoteWsStore.unsubscribeMedicine(currentRemote.value.patient, currentRemote.value.patientId, currentRemote.value.date, currentRemote.value.index);
remoteWsStore.unsubscribeVital(currentRemote.value.patient, currentRemote.value.patientId, currentRemote.value.date, currentRemote.value.index);
}
disconnect()
intervalFun.value=null
})
@ -637,7 +641,10 @@ const tableItemPlus = (e: any) => {
const medicineRate= e.row.medicineRate
const currTotal=_.add(Number(medicineRate),Number(e.row.change))
if (currTotal >=obj.total) {
e.row.change =_.subtract(obj.total , medicineRate)
ElMessage({
type: 'error',
message: '当前药物速率已超过最大值'
})
return
};
const currRate= Number(e.row.change);
@ -652,23 +659,31 @@ const tableItemMinus = (e: any) => {
const obj = medicineCustom.find(item => item.name === e.row.medicineName) || {plus: 1};
const medicineRate= e.row.medicineRate;
const change=e.row.change;
if (Number(change)<0) {
const reds=Number(change)+Number(medicineRate)
if (reds<=0) {
ElMessage({
type: 'error',
message: '当前药物速率不能小于0'
})
return
}
}
const nowTotal=_.subtract(Number(medicineRate) ,Number(change))
const res=_.subtract(obj.total,nowTotal)
if (res <= 0) return;
e.row.change = _.subtract(change,obj.plus)
if (e.row.change < 0) e.row.change = 0;
else e.row.change = _.floor(e.row.change,2)
e.row.change = _.floor(e.row.change,2)
}
const tableItemConfirm = (e: any, tableData: any) => {
const finalRate=_.add(Number(e.row.medicineRate),Number(e.row.change))
const final=_.floor(finalRate,2)
ElMessageBox.confirm('确定给药吗?', '确认提示', {
confirmButtonText: '确定',
cancelButtonText: '取消',
message: h('p', null, [
h('span', null, '确定给药吗?'),
h('div', { style: 'font-size:14px;color:#085a75' }, `药物名称:${e.row.medicineName}`),
h('div', { style: 'font-size:14px;color:#085a75' }, `速率:${finalRate}`),
h('div', { style: 'font-size:14px;color:#085a75' }, `速率:${final}`),
]),
})
.then(() => {