From c021f23f625cd03fa31a6c103d1616e753551809 Mon Sep 17 00:00:00 2001 From: xh <11675084@qq.com> Date: Thu, 13 Nov 2025 11:24:58 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E7=A7=9F=E6=88=B7=E5=88=87?= =?UTF-8?q?=E6=8D=A2=E6=95=B0=E6=8D=AE=E6=B2=A1=E6=9C=89=E5=88=87=E6=8D=A2?= =?UTF-8?q?=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- web/README.md | 6 +++++- web/src/layout/components/TenantVisit/index.vue | 5 +++++ web/src/store/modules/handDetector.ts | 7 +++++++ web/src/views/gas/handdetector/index.vue | 10 +++++----- 4 files changed, 22 insertions(+), 6 deletions(-) diff --git a/web/README.md b/web/README.md index 39a9f38..675b482 100644 --- a/web/README.md +++ b/web/README.md @@ -1,3 +1,7 @@ sudo unzip -o /home/zdhlroot/roadmap.zip -d /opt/website/mobile.zdhlcn.com/roadmap/ -sudo cp /tmp/xiangheng/* /opt/website/mobile.zdhlcn.com/ -r \ No newline at end of file +sudo cp /tmp/xiangheng/* /opt/website/mobile.zdhlcn.com/ -r + +# 开发问题 +## 切换租户 +切换租户后,store 里面的租户相关数据需要清空。 diff --git a/web/src/layout/components/TenantVisit/index.vue b/web/src/layout/components/TenantVisit/index.vue index b44a0b9..cb6c9a6 100644 --- a/web/src/layout/components/TenantVisit/index.vue +++ b/web/src/layout/components/TenantVisit/index.vue @@ -19,6 +19,9 @@ import * as TenantApi from '@/api/system/tenant' import { getVisitTenantId, setVisitTenantId } from '@/utils/auth' import { useMessage } from '@/hooks/web/useMessage' import { useTagsView } from '@/hooks/web/useTagsView' +import { useHandDetectorStore } from '@/store/modules/handDetector' + +const handDetectorStore = useHandDetectorStore() const message = useMessage() // 消息弹窗 const tagsView = useTagsView() // 标签页操作 @@ -29,6 +32,8 @@ const tenants = ref([]) // 租户列表 const handleChange = (id: number) => { // 设置访问租户 ID setVisitTenantId(id) + // 清空手持探测器列表 + handDetectorStore.clear() // 关闭其他标签页,只保留当前页 tagsView.closeOther() // 刷新当前页面 diff --git a/web/src/store/modules/handDetector.ts b/web/src/store/modules/handDetector.ts index 54d8489..0a98a74 100644 --- a/web/src/store/modules/handDetector.ts +++ b/web/src/store/modules/handDetector.ts @@ -5,6 +5,7 @@ import { Type, TypeApi } from '@/api/gas/gastype' import { Fence, FenceApi } from '@/api/gas/fence' import { AlarmType, AlarmTypeApi } from '@/api/gas/alarmtype' + export const useHandDetectorStore = defineStore('handDetector', { state() { return { @@ -29,6 +30,12 @@ export const useHandDetectorStore = defineStore('handDetector', { } }, actions: { + clear() { + this.handDetectorList = [] + this.gasTypes = [] + this.fences = [] + this.alarmTypes = [] + }, async getAllHandDetector(refresh: boolean = false) { if (refresh || this.handDetectorList.length === 0) { const data = await HandDetectorApi.getListAll() diff --git a/web/src/views/gas/handdetector/index.vue b/web/src/views/gas/handdetector/index.vue index fde69c9..c9d45ce 100644 --- a/web/src/views/gas/handdetector/index.vue +++ b/web/src/views/gas/handdetector/index.vue @@ -197,6 +197,7 @@ import type { Type } from '@/api/gas/gastype' import { useHandDetectorStore } from '@/store/modules/handDetector' import { dateFormatter } from '@/utils/formatTime' import { handleTree } from '@/utils/tree' + /** GAS手持探测器 列表 */ defineOptions({ name: 'HandDetector' }) const handDetectorStore = useHandDetectorStore() @@ -257,12 +258,11 @@ const resetQuery = () => { /** 添加/修改操作 */ const formRef = ref() const openForm = (type: string, id?: number) => { - if (fences.value.length === 0) { + getAllFences() - } - if (gasTypes.value.length === 0) { + getAllGasTypes() - } + formRef.value.open(type, id) } @@ -325,7 +325,7 @@ const getAllGasTypes = async () => { gasTypes.value = await handDetectorStore.getAllGasTypes() } /** 初始化 **/ -onMounted(() => { +onMounted(() => { getList() getAllFences() getAllGasTypes()