远程控制定时器离开页面后卸载,个人信息按钮修改

This commit is contained in:
gaofy 2023-12-28 15:42:38 +08:00
parent 4c4561b35d
commit 05fbbddd77
2 changed files with 12 additions and 5 deletions

View File

@ -87,7 +87,7 @@
<el-button class="f18" type="primary" @click="saveData">确认</el-button>
</div>
<div v-else-if="type === 'edit'" style="text-align: right;">
<el-button class="f18" @click="saveData">修改</el-button>
<el-button class="f18" @click="close">取消</el-button>
<el-button class="f18" type="primary" @click="saveData">更新</el-button>
</div>
</el-form>

View File

@ -131,7 +131,7 @@
</template>
<script lang="ts" setup>
import { onMounted, ref, reactive } from 'vue';
import { onMounted, ref, reactive, onBeforeUnmount } from 'vue';
import { useRouter, useRoute } from 'vue-router'
import { ElMessageBox, ElMessage } from 'element-plus';
import { useRemoteStore } from '@/stores/remote-info-store'
@ -210,6 +210,13 @@ onMounted(() => {
initScale();
});
//
onBeforeUnmount(() => {
clearInterval(featureTimer)
clearInterval(ecgTimer)
clearInterval(aiFlagTimer)
clearInterval(medicineTimer)
})
function initData() {
lungAlarm.value = false;
@ -273,7 +280,7 @@ function setTableData(res: any) {
function getMedicine() {
let isRunTimer = true;
clearInterval(medicineTimer);
setInterval(() => {
medicineTimer = setInterval(() => {
if (isRunTimer && JSON.stringify(tableDataStore) === JSON.stringify(tableData) && isAIDose.value) {
isRunTimer = false;
const url = isAIDose.value ? '/getaimedicine' : '/getdoctormedicine';
@ -291,12 +298,12 @@ function getChartData() {
let isRunTimer = true;
clearInterval(featureTimer);
clearInterval(ecgTimer);
setInterval(() => {
featureTimer = setInterval(() => {
if (isRunTimer) {
getData()
}
}, 2000);
setInterval(() => {
ecgTimer = setInterval(() => {
try {
chartDom4.value.updateChart(0, new Date());
} catch (error) { }