diff --git a/src/stores/sealStore.ts b/src/stores/sealStore.ts index 3767677..ce67711 100644 --- a/src/stores/sealStore.ts +++ b/src/stores/sealStore.ts @@ -15,16 +15,16 @@ export const useSealStore = defineStore('seal', () => { }) const leakRemainingTime = ref('') - const _leakTimerId = ref(undefined) - const _leakStartTs = ref(0) + const leakTimerId = ref(undefined) + const leakStartTs = ref(0) function startLeakTimer() { - if (_leakTimerId.value) + if (leakTimerId.value) return - _leakStartTs.value = Date.now() + leakStartTs.value = Date.now() leakRemainingTime.value = '00:00:00' - _leakTimerId.value = window.setInterval(() => { - const diff = Date.now() - _leakStartTs.value + leakTimerId.value = window.setInterval(() => { + const diff = Date.now() - leakStartTs.value const secs = Math.floor(diff / 1000) const h = Math.floor(secs / 3600) const m = Math.floor((secs % 3600) / 60) @@ -37,12 +37,12 @@ export const useSealStore = defineStore('seal', () => { } function stopLeakTimer() { - if (_leakTimerId.value) { - clearInterval(_leakTimerId.value) - _leakTimerId.value = undefined + if (leakTimerId.value) { + clearInterval(leakTimerId.value) + leakTimerId.value = undefined } leakRemainingTime.value = '' - _leakStartTs.value = 0 + leakStartTs.value = 0 } function updateSealInfo(dataInfo: SealStateItem) { diff --git a/src/views/seal/index.vue b/src/views/seal/index.vue index 5e387f0..1f2f957 100644 --- a/src/views/seal/index.vue +++ b/src/views/seal/index.vue @@ -6,7 +6,7 @@ import SealInstrumentSvg from 'assets/images/seal/seal-instrument.svg' import SoftKeyboard from 'components/common/SoftKeyboard/index.vue' import DashboardChart from 'components/seal/DashboardChart.vue' import { roundNumber } from 'libs/utils' -import { computed, onMounted, ref } from 'vue' +import { computed, onMounted, ref, watch } from 'vue' import { getDeviceStatus } from '@/libs/deviceComm' import { FtMessage } from '@/libs/message' @@ -17,13 +17,18 @@ defineOptions({ name: 'Seal' }) const sealStore = useSealStore() +const initialPressure = ref('0') const sealInfo = computed(() => sealStore.sealInfo) const leakRemainingTime = computed(() => sealStore.leakRemainingTime) const currentPressure = computed(() => sealStore.currentPressure) -const diffPressure = computed(() => - Number(sealStore.currentPressure) - Number(sealStore.sealInfo.pressure), -) - +const diffPressure = computed(() => { + if (sealInfo.value.workState === 'leakTesting') { + return Math.abs( + Number(currentPressure.value) - Number(initialPressure.value), + ) + } + return 0 +}) const inputValue = ref('') const keyboardVisible = ref(false) const keyboardType = ref<'text' | 'number'>('number') @@ -31,6 +36,15 @@ const softKeyboardRef = ref() const inflationTime = ref() const loading = ref(false) +watch( + () => sealInfo.value.workState, + (newState, oldState) => { + if (oldState === 'stabilizingPressure' && newState === 'leakTesting') { + initialPressure.value = sealInfo.value.pressure + } + }, +) + onMounted(async () => { const res = await sendCmd({ className: 'AirLeakDetectTest', fnName: 'getServiceConfig' }) inflationTime.value = res.inflationTimeMs @@ -105,11 +119,17 @@ function handleConfirm(value: string) {
测试前气压:
-
- 未开始 +
+ 打压中
-
- {{ currentPressure }} +
+ 稳压中 +
+
+ {{ initialPressure }}Kp +
+
+ 未开始