Browse Source

修复租户切换数据没有切换问题

master
xh 4 days ago
parent
commit
c021f23f62
  1. 6
      web/README.md
  2. 5
      web/src/layout/components/TenantVisit/index.vue
  3. 7
      web/src/store/modules/handDetector.ts
  4. 10
      web/src/views/gas/handdetector/index.vue

6
web/README.md

@ -1,3 +1,7 @@
sudo unzip -o /home/zdhlroot/roadmap.zip -d /opt/website/mobile.zdhlcn.com/roadmap/ sudo unzip -o /home/zdhlroot/roadmap.zip -d /opt/website/mobile.zdhlcn.com/roadmap/
sudo cp /tmp/xiangheng/* /opt/website/mobile.zdhlcn.com/ -r
sudo cp /tmp/xiangheng/* /opt/website/mobile.zdhlcn.com/ -r
# 开发问题
## 切换租户
切换租户后,store 里面的租户相关数据需要清空。

5
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 { getVisitTenantId, setVisitTenantId } from '@/utils/auth'
import { useMessage } from '@/hooks/web/useMessage' import { useMessage } from '@/hooks/web/useMessage'
import { useTagsView } from '@/hooks/web/useTagsView' import { useTagsView } from '@/hooks/web/useTagsView'
import { useHandDetectorStore } from '@/store/modules/handDetector'
const handDetectorStore = useHandDetectorStore()
const message = useMessage() // const message = useMessage() //
const tagsView = useTagsView() // const tagsView = useTagsView() //
@ -29,6 +32,8 @@ const tenants = ref<any[]>([]) // 租户列表
const handleChange = (id: number) => { const handleChange = (id: number) => {
// 访 ID // 访 ID
setVisitTenantId(id) setVisitTenantId(id)
//
handDetectorStore.clear()
// //
tagsView.closeOther() tagsView.closeOther()
// //

7
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 { Fence, FenceApi } from '@/api/gas/fence'
import { AlarmType, AlarmTypeApi } from '@/api/gas/alarmtype' import { AlarmType, AlarmTypeApi } from '@/api/gas/alarmtype'
export const useHandDetectorStore = defineStore('handDetector', { export const useHandDetectorStore = defineStore('handDetector', {
state() { state() {
return { return {
@ -29,6 +30,12 @@ export const useHandDetectorStore = defineStore('handDetector', {
} }
}, },
actions: { actions: {
clear() {
this.handDetectorList = []
this.gasTypes = []
this.fences = []
this.alarmTypes = []
},
async getAllHandDetector(refresh: boolean = false) { async getAllHandDetector(refresh: boolean = false) {
if (refresh || this.handDetectorList.length === 0) { if (refresh || this.handDetectorList.length === 0) {
const data = await HandDetectorApi.getListAll() const data = await HandDetectorApi.getListAll()

10
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 { useHandDetectorStore } from '@/store/modules/handDetector'
import { dateFormatter } from '@/utils/formatTime' import { dateFormatter } from '@/utils/formatTime'
import { handleTree } from '@/utils/tree' import { handleTree } from '@/utils/tree'
/** GAS手持探测器 列表 */ /** GAS手持探测器 列表 */
defineOptions({ name: 'HandDetector' }) defineOptions({ name: 'HandDetector' })
const handDetectorStore = useHandDetectorStore() const handDetectorStore = useHandDetectorStore()
@ -257,12 +258,11 @@ const resetQuery = () => {
/** 添加/修改操作 */ /** 添加/修改操作 */
const formRef = ref() const formRef = ref()
const openForm = (type: string, id?: number) => { const openForm = (type: string, id?: number) => {
if (fences.value.length === 0) {
getAllFences() getAllFences()
}
if (gasTypes.value.length === 0) {
getAllGasTypes() getAllGasTypes()
}
formRef.value.open(type, id) formRef.value.open(type, id)
} }
@ -325,7 +325,7 @@ const getAllGasTypes = async () => {
gasTypes.value = await handDetectorStore.getAllGasTypes() gasTypes.value = await handDetectorStore.getAllGasTypes()
} }
/** 初始化 **/ /** 初始化 **/
onMounted(() => {
onMounted(() => {
getList() getList()
getAllFences() getAllFences()
getAllGasTypes() getAllGasTypes()

Loading…
Cancel
Save