切换路由自动关闭弹框

This commit is contained in:
joylink_zhaoerwei 2024-11-13 10:05:24 +08:00
parent 84fac01c7a
commit de94896fd7
2 changed files with 24 additions and 6 deletions

View File

@ -5,7 +5,7 @@
@show="onDialogShow" @show="onDialogShow"
title="故障查询" title="故障查询"
:width="990" :width="990"
:height="580" :height="600"
> >
<div class="dialogContainer"> <div class="dialogContainer">
<q-table <q-table
@ -17,7 +17,7 @@
:columns="columns" :columns="columns"
@request="onRequest" @request="onRequest"
:rows-per-page-options="[10, 20, 50, 100]" :rows-per-page-options="[10, 20, 50, 100]"
style="width: 500px; height: 580px" style="width: 500px; height: 600px"
> >
<template v-slot:body="props"> <template v-slot:body="props">
<q-tr <q-tr
@ -45,7 +45,7 @@
</template> </template>
</q-table> </q-table>
<q-scroll-area style="width: 490px; height: 560px"> <q-scroll-area style="width: 490px; height: 580px">
<div class="detaiRow"> <div class="detaiRow">
<div class="text"> <div class="text">
<span class="textHead">故障类型</span> {{ <span class="textHead">故障类型</span> {{
@ -200,6 +200,11 @@ const onRequest: QTable['onRequest'] = async (props) => {
rows.splice(0, rows.length, ...(resp.records as [])); rows.splice(0, rows.length, ...(resp.records as []));
if (rows.length) { if (rows.length) {
handleRowClick(rows[0]); handleRowClick(rows[0]);
} else {
clickRowInfo.faultType = '';
clickRowInfo.faultNameShower = '';
clickRowInfo.faultDriverShower = '';
clickRowInfo.resultMsg = '';
} }
} catch (err) { } catch (err) {
$q.notify({ $q.notify({
@ -331,7 +336,7 @@ const onDialogShow = () => {
} }
.box-card { .box-card {
width: 450px; width: 450px;
height: 225px; height: 235px;
margin-bottom: 10px; margin-bottom: 10px;
padding: 0 5px; padding: 0 5px;
.head { .head {

View File

@ -108,7 +108,7 @@
</template> </template>
<script setup lang="ts"> <script setup lang="ts">
import { ref, reactive, onMounted, onUnmounted, computed } from 'vue'; import { ref, reactive, onMounted, onUnmounted, computed, watch } from 'vue';
import SysMenu from 'src/components/SysMenu.vue'; import SysMenu from 'src/components/SysMenu.vue';
import { useRouter, useRoute } from 'vue-router'; import { useRouter, useRoute } from 'vue-router';
import { Dialog, DialogChainObject, useQuasar } from 'quasar'; import { Dialog, DialogChainObject, useQuasar } from 'quasar';
@ -141,6 +141,17 @@ const router = useRouter();
const route = useRoute(); const route = useRoute();
const lineStore = useLineStore(); const lineStore = useLineStore();
const lineNetStore = useLineNetStore(); const lineNetStore = useLineNetStore();
watch(
() => route.path,
() => {
if (!route.path.includes('line/monitor') && faultQueryDialogInstance) {
faultQueryDialogInstance.hide();
faultQueryDialogInstance = null;
}
}
);
function toggleLeftDrawer() { function toggleLeftDrawer() {
leftDrawerOpen.value = !leftDrawerOpen.value; leftDrawerOpen.value = !leftDrawerOpen.value;
onResize(); onResize();
@ -187,8 +198,10 @@ onMounted(() => {
socket = webSocketConnect(destination, handler); socket = webSocketConnect(destination, handler);
}); });
let faultQueryDialogInstance: DialogChainObject | null = null;
function openFaultQueryDialog() { function openFaultQueryDialog() {
$q.dialog({ if (faultQueryDialogInstance) return;
faultQueryDialogInstance = $q.dialog({
component: FaultQueryDialog, component: FaultQueryDialog,
}); });
} }