This commit is contained in:
sjl
2025-08-07 14:44:04 +08:00
11 changed files with 477 additions and 4321 deletions

View File

@@ -120,7 +120,7 @@ import pie from '@/components/echarts/pie/default.vue'
import tree from '../components/tree.vue'
import Table from '../components/table.vue'
import { getBoundPqDevList, getPlanListByPattern, getPlanList } from '@/api/plan/plan'
import { onBeforeMount, onUnmounted, ref, watch } from 'vue'
import { onBeforeMount, onUnmounted, ref, watch, nextTick } from 'vue'
import { useModeStore } from '@/stores/modules/mode' // 引入模式 store
import { useDictStore } from '@/stores/modules/dict'
import { useViewSize } from '@/hooks/useViewSize'
@@ -223,16 +223,25 @@ const tableRef1 = ref() // 主表格组件引用
const currentId = ref('') // 当前选中的计划ID
// ============================ 监听器 ============================
let isUpdatingTabs = false // 防止重复调用的标志
/**
* 监听功能切换并通知表格组件更新配置
* 不再传递静态数据让表格组件通过API获取真实数据
*/
watch(
() => form.value.activeTabs,
(newTabs) => {
async (newTabs) => {
if (isUpdatingTabs) return // 如果正在更新中,跳过
isUpdatingTabs = true
// 只传递功能模式,不传递静态假数据
// 表格组件会根据功能模式通过API获取对应的真实数据
tableRef1.value && tableRef1.value.changeActiveTabs(newTabs)
// 等待一个微任务队列后重置标志
await nextTick()
isUpdatingTabs = false
}
// 去掉 immediate: true避免初始化时重复调用
)
@@ -662,7 +671,7 @@ const handleBatchGenerate = async () => {
// 重新获取饼图数据deviceData更新后watch会自动触发表格更新
getPieData(currentId.value)
// 移除重复的表格渲染调用 - watch监听器已经处理了这部分逻辑
// 批量操作后的表格刷新 - 这个调用与watch监听器无关是通过emit触发的
tableRef1.value && tableRef1.value.changeActiveTabs(form.value.activeTabs)
}
</script>