Browse Source

fix: 组件销毁时关闭保养提示框

Tong 2 years ago
parent
commit
75b99d4b66
1 changed files with 6 additions and 3 deletions
  1. 6 3
      src/views/biz/engineer/upkeep/index.vue

+ 6 - 3
src/views/biz/engineer/upkeep/index.vue

@@ -49,7 +49,7 @@
   </div>
 </template>
 <script lang="ts" setup>
-  import { onBeforeMount, ref } from 'vue';
+  import { onBeforeMount, onBeforeUnmount, ref } from 'vue';
   import { message } from 'ant-design-vue';
   import { BasicTable, useTable, TableAction } from '/@/components/TableCard';
   import { useMessage } from '/@/hooks/web/useMessage';
@@ -256,12 +256,11 @@
   // 查询是否有近日需要保养的设备
   async function handleDeviceListRecently() {
     const res = await getDeviceListRecently();
-
     if (res && res.length > 0) {
       await message.warning({
         key: '1',
         content: '有需要保养的设备',
-        duration: 10,
+        duration: 8,
         style: {
           color: '#1890ff',
           cursor: 'pointer',
@@ -276,6 +275,10 @@
       });
     }
   }
+  // 页面销毁卸载前事件
+  onBeforeUnmount(async () => {
+    await message.destroy('1');
+  });
 </script>
 <style lang="less" scoped>
   .table-dot {