fix: 给药bug处理

This commit is contained in:
GranceWang 2024-08-15 18:38:49 +08:00
parent b10dc89005
commit 5983e407d1

View File

@ -117,7 +117,7 @@
<Plus/>
</el-icon>
</el-button>
<el-button size="small" color="#006080" :disabled="scope.row.speed <= 0 || !whetherControl"
<el-button size="small" color="#006080" :disabled="!whetherControl"
@click="tableItemMinus(scope)">
<el-icon>
<Minus/>
@ -155,7 +155,7 @@
<Plus/>
</el-icon>
</el-button>
<el-button size="small" color="#006080" :disabled="scope.row.speed <= 0 || !whetherControl"
<el-button size="small" color="#006080" :disabled="!whetherControl"
@click="tableItemMinus(scope)">
<el-icon>
<Minus/>
@ -192,6 +192,8 @@
</template>
<script lang="ts" setup>
import {h} from 'vue';
import _ from 'lodash';
import {computed, onMounted, onUnmounted, reactive, ref, watch} from 'vue';
import {useRouter} from 'vue-router'
import {ElMessage,ElMessageBox} from 'element-plus';
@ -632,31 +634,42 @@ function msgLogScrollBottom() {
const tableItemPlus = (e: any) => {
const obj = medicineCustom.find(item => item.name === e.row.medicineName) || {plus: 1};
if ((e.row.medicineRate + e.row.change) >=obj.total) {
e.row.change =obj.total - e.row.medicineRate
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)
return
};
let rate= Number(e.row.change);
if (isNaN(rate)) {
const currRate= Number(e.row.change);
if (isNaN(currRate)) {
return
}
rate += obj.plus;
e.row.change = rate.toFixed(2);
const rate=_.add(Number(currRate), Number(obj.plus));
e.row.change =_.floor(rate,2)
}
const tableItemMinus = (e: any) => {
const obj = medicineCustom.find(item => item.name === e.row.medicineName) || {plus: 1};
if (!isAIDose.value && e.row.medicineRate + e.row.change - obj.plus <= 0) return;
e.row.change -= obj.plus;
const medicineRate= e.row.medicineRate;
const change=e.row.change;
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 = Number(e.row.change).toFixed(2);
else 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))
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}`),
]),
})
.then(() => {
//
@ -668,7 +681,7 @@ const tableItemConfirm = (e: any, tableData: any) => {
date: currentRemote.value.date,
flag: "1",
medicine: e.row.medicineName,
value: Number(e.row.medicineRate)+Number(e.row.change),
value: _.add(Number(e.row.medicineRate),Number(e.row.change)),
index: currentRemote.value.index
}
remoteWsStore.sendMedicine(params, function () {