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

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> <el-button class="f18" type="primary" @click="saveData">确认</el-button>
</div> </div>
<div v-else-if="type === 'edit'" style="text-align: right;"> <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> <el-button class="f18" type="primary" @click="saveData">更新</el-button>
</div> </div>
</el-form> </el-form>

View File

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