diff --git a/src/components/cockpit/F47Curve/index.vue b/src/components/cockpit/F47Curve/index.vue index 79b05aa..8c12151 100644 --- a/src/components/cockpit/F47Curve/index.vue +++ b/src/components/cockpit/F47Curve/index.vue @@ -58,11 +58,10 @@ const timeCacheStore = useTimeCacheStore() const selectChange = (showSelect: any, height: any, datePickerValue?: any) => { headerHeight.value = height - // 如果有传入 datePicker 的值 - if (datePickerValue) { - // 更新表格参数 - tableStore.table.params.searchBeginTime = datePickerValue.timeValue?.[0] - tableStore.table.params.searchEndTime = datePickerValue.timeValue?.[1] + if (datePickerValue && datePickerValue.timeValue) { + // 更新时间参数 + tableStore.table.params.searchBeginTime = datePickerValue.timeValue[0] + tableStore.table.params.searchEndTime = datePickerValue.timeValue[1] } } @@ -105,22 +104,9 @@ const tableStore: any = new TableStore({ showPage: false, column: [], - beforeSearchFun: () => { - // 尝试从缓存获取时间值 - let beginTime, endTime - - if (fullscreen.value) { - const cached = timeCacheStore.getCache(route.path) - if (cached && cached.timeValue) { - beginTime = cached.timeValue[0] - endTime = cached.timeValue[1] - } - } - - // 如果缓存中没有则使用默认值 - tableStore.table.params.searchBeginTime = beginTime || prop.timeValue?.[0] || getTimeOfTheMonth(prop.timeKey)[0] - - tableStore.table.params.searchEndTime = endTime || prop.timeValue?.[1] || getTimeOfTheMonth(prop.timeKey)[1] + beforeSearchFun: () => { + tableStore.table.params.searchBeginTime = tableStore.table.params.searchBeginTime || prop.timeValue?.[0] + tableStore.table.params.searchEndTime = tableStore.table.params.searchEndTime || prop.timeValue?.[1] }, loadCallback: () => { let res = { @@ -481,12 +467,17 @@ watch( } ) watch( - () => prop.timeValue, // 监听的目标(函数形式避免直接传递 props 导致的警告) + () => prop.timeValue, (newVal, oldVal) => { - tableStore.index() + // 当外部时间值变化时,更新表格的时间参数 + if (newVal && (!oldVal || newVal[0] !== oldVal[0] || newVal[1] !== oldVal[1])) { + tableStore.table.params.searchBeginTime = newVal[0] + tableStore.table.params.searchEndTime = newVal[1] + tableStore.index() + } }, { - deep: true // 若 timeValue 是对象/数组,需开启深度监听 + deep: true } ) diff --git a/src/components/cockpit/directionStatistics/index.vue b/src/components/cockpit/directionStatistics/index.vue index 0358c9a..f55e879 100644 --- a/src/components/cockpit/directionStatistics/index.vue +++ b/src/components/cockpit/directionStatistics/index.vue @@ -18,11 +18,11 @@ import { useRoute } from 'vue-router' import { useTimeCacheStore } from '@/stores/timeCache' const prop = defineProps({ - w: { type: [String, Number]}, - h: { type: [String, Number]}, - width: { type: [String, Number]}, - height: { type: [String, Number]}, - timeKey: { type: [String, Number]}, + w: { type: [String, Number] }, + h: { type: [String, Number] }, + width: { type: [String, Number] }, + height: { type: [String, Number] }, + timeKey: { type: [String, Number] }, timeValue: { type: Object } }) @@ -34,11 +34,10 @@ const timeCacheStore = useTimeCacheStore() const selectChange = (showSelect: any, height: any, datePickerValue?: any) => { headerHeight.value = height - // 如果有传入 datePicker 的值 - if (datePickerValue) { - // 更新表格参数 - tableStore.table.params.searchBeginTime = datePickerValue.timeValue?.[0] - tableStore.table.params.searchEndTime = datePickerValue.timeValue?.[1] + if (datePickerValue && datePickerValue.timeValue) { + // 更新时间参数 + tableStore.table.params.searchBeginTime = datePickerValue.timeValue[0] + tableStore.table.params.searchEndTime = datePickerValue.timeValue[1] } } @@ -129,21 +128,8 @@ const tableStore: any = new TableStore({ column: [], beforeSearchFun: () => { - // 尝试从缓存获取时间值 - let beginTime, endTime - - if (fullscreen.value) { - const cached = timeCacheStore.getCache(route.path) - if (cached && cached.timeValue) { - beginTime = cached.timeValue[0] - endTime = cached.timeValue[1] - } - } - - // 如果缓存中没有则使用默认值 - tableStore.table.params.searchBeginTime = beginTime || prop.timeValue?.[0] || getTimeOfTheMonth(prop.timeKey)[0] - - tableStore.table.params.searchEndTime = endTime || prop.timeValue?.[1] || getTimeOfTheMonth(prop.timeKey)[1] + tableStore.table.params.searchBeginTime = tableStore.table.params.searchBeginTime || prop.timeValue?.[0] + tableStore.table.params.searchEndTime = tableStore.table.params.searchEndTime || prop.timeValue?.[1] }, loadCallback: () => {} }) @@ -171,12 +157,17 @@ watch( } ) watch( - () => prop.timeValue, // 监听的目标(函数形式避免直接传递 props 导致的警告) + () => prop.timeValue, (newVal, oldVal) => { - tableStore.index() + // 当外部时间值变化时,更新表格的时间参数 + if (newVal && (!oldVal || newVal[0] !== oldVal[0] || newVal[1] !== oldVal[1])) { + tableStore.table.params.searchBeginTime = newVal[0] + tableStore.table.params.searchEndTime = newVal[1] + tableStore.index() + } }, { - deep: true // 若 timeValue 是对象/数组,需开启深度监听 + deep: true } ) diff --git a/src/components/cockpit/exceedanceLevel/index.vue b/src/components/cockpit/exceedanceLevel/index.vue index e05fa3a..cccebe5 100644 --- a/src/components/cockpit/exceedanceLevel/index.vue +++ b/src/components/cockpit/exceedanceLevel/index.vue @@ -29,11 +29,11 @@ import { useRoute } from 'vue-router' import { useTimeCacheStore } from '@/stores/timeCache' const prop = defineProps({ - w: { type: [String, Number]}, - h: { type: [String, Number]}, - width: { type: [String, Number]}, - height: { type: [String, Number]}, - timeKey: { type: [String, Number]}, + w: { type: [String, Number] }, + h: { type: [String, Number] }, + width: { type: [String, Number] }, + height: { type: [String, Number] }, + timeKey: { type: [String, Number] }, timeValue: { type: Object } }) @@ -45,11 +45,10 @@ const timeCacheStore = useTimeCacheStore() const selectChange = (showSelect: any, height: any, datePickerValue?: any) => { headerHeight.value = height - // 如果有传入 datePicker 的值 - if (datePickerValue) { - // 更新表格参数 - tableStore.table.params.searchBeginTime = datePickerValue.timeValue?.[0] - tableStore.table.params.searchEndTime = datePickerValue.timeValue?.[1] + if (datePickerValue && datePickerValue.timeValue) { + // 更新时间参数 + tableStore.table.params.searchBeginTime = datePickerValue.timeValue[0] + tableStore.table.params.searchEndTime = datePickerValue.timeValue[1] } } // 计算是否全屏展示 @@ -113,11 +112,7 @@ const tableStore: any = new TableStore({ minWidth: '60', render: 'customTemplate', customTemplate: (row: any) => { - if ( - row.time !== null && - row.time !== undefined && - row.time !== '' - ) { + if (row.time !== null && row.time !== undefined && row.time !== '') { return `${row.time}` } else { return `/` @@ -139,20 +134,8 @@ const tableStore: any = new TableStore({ } ], beforeSearchFun: () => { - // 尝试从缓存获取时间值 - let beginTime, endTime - - if (fullscreen.value) { - const cached = timeCacheStore.getCache(route.path) - if (cached && cached.timeValue) { - beginTime = cached.timeValue[0] - endTime = cached.timeValue[1] - } - } - - // 如果缓存中没有则使用默认值 - tableStore.table.params.searchBeginTime = beginTime || prop.timeValue?.[0] - tableStore.table.params.searchEndTime = endTime || prop.timeValue?.[1] + tableStore.table.params.searchBeginTime = tableStore.table.params.searchBeginTime || prop.timeValue?.[0] + tableStore.table.params.searchEndTime = tableStore.table.params.searchEndTime || prop.timeValue?.[1] }, loadCallback: () => { // 定义 x 轴标签顺序 @@ -218,12 +201,17 @@ watch( } ) watch( - () => prop.timeValue, // 监听的目标(函数形式避免直接传递 props 导致的警告) + () => prop.timeValue, (newVal, oldVal) => { - tableStore.index() + // 当外部时间值变化时,更新表格的时间参数 + if (newVal && (!oldVal || newVal[0] !== oldVal[0] || newVal[1] !== oldVal[1])) { + tableStore.table.params.searchBeginTime = newVal[0] + tableStore.table.params.searchEndTime = newVal[1] + tableStore.index() + } }, { - deep: true // 若 timeValue 是对象/数组,需开启深度监听 + deep: true } ) diff --git a/src/components/cockpit/governanceReport/index.vue b/src/components/cockpit/governanceReport/index.vue index 4207b99..437cc82 100644 --- a/src/components/cockpit/governanceReport/index.vue +++ b/src/components/cockpit/governanceReport/index.vue @@ -75,21 +75,9 @@ const tableStore: any = new TableStore({ showPage: false, exportName: '主要监测点列表', column: [], - beforeSearchFun: () => { - // 尝试从缓存获取时间值 - let beginTime, endTime - - if (fullscreen.value) { - const cached = timeCacheStore.getCache(route.path) - if (cached && cached.timeValue) { - beginTime = cached.timeValue[0] - endTime = cached.timeValue[1] - } - } - - // 如果缓存中没有则使用默认值 - tableStore.table.params.searchBeginTime = beginTime || prop.timeValue?.[0] || getTimeOfTheMonth(prop.timeKey)[0] - tableStore.table.params.searchEndTime = endTime || prop.timeValue?.[1] || getTimeOfTheMonth(prop.timeKey)[1] + beforeSearchFun: () => { + tableStore.table.params.searchBeginTime = tableStore.table.params.searchBeginTime || prop.timeValue?.[0] + tableStore.table.params.searchEndTime = tableStore.table.params.searchEndTime || prop.timeValue?.[1] }, loadCallback: () => {} }) @@ -119,11 +107,11 @@ onMounted(() => { }) const selectChange = (showSelect: any, height: any, datePickerValue?: any) => { - // 如果有传入 datePicker 的值 - if (datePickerValue) { - // 更新表格参数 - tableStore.table.params.searchBeginTime = datePickerValue.timeValue?.[0] - tableStore.table.params.searchEndTime = datePickerValue.timeValue?.[1] + + if (datePickerValue && datePickerValue.timeValue) { + // 更新时间参数 + tableStore.table.params.searchBeginTime = datePickerValue.timeValue[0] + tableStore.table.params.searchEndTime = datePickerValue.timeValue[1] } } @@ -145,12 +133,17 @@ watch( } ) watch( - () => prop.timeValue, // 监听的目标(函数形式避免直接传递 props 导致的警告) + () => prop.timeValue, (newVal, oldVal) => { - tableStore.index() + // 当外部时间值变化时,更新表格的时间参数 + if (newVal && (!oldVal || newVal[0] !== oldVal[0] || newVal[1] !== oldVal[1])) { + tableStore.table.params.searchBeginTime = newVal[0] + tableStore.table.params.searchEndTime = newVal[1] + tableStore.index() + } }, { - deep: true // 若 timeValue 是对象/数组,需开启深度监听 + deep: true } ) diff --git a/src/components/cockpit/gridSideStatistics/index.vue b/src/components/cockpit/gridSideStatistics/index.vue index 55ed8b0..1a7bd3f 100644 --- a/src/components/cockpit/gridSideStatistics/index.vue +++ b/src/components/cockpit/gridSideStatistics/index.vue @@ -32,11 +32,11 @@ import { useRoute } from 'vue-router' import { useTimeCacheStore } from '@/stores/timeCache' const prop = defineProps({ - w: { type: [String, Number]}, - h: { type: [String, Number]}, - width: { type: [String, Number]}, - height: { type: [String, Number]}, - timeKey: { type: [String, Number]}, + w: { type: [String, Number] }, + h: { type: [String, Number] }, + width: { type: [String, Number] }, + height: { type: [String, Number] }, + timeKey: { type: [String, Number] }, timeValue: { type: Object } }) @@ -48,11 +48,10 @@ const timeCacheStore = useTimeCacheStore() const selectChange = (showSelect: any, height: any, datePickerValue?: any) => { headerHeight.value = height - // 如果有传入 datePicker 的值 - if (datePickerValue) { - // 更新表格参数 - tableStore.table.params.searchBeginTime = datePickerValue.timeValue?.[0] - tableStore.table.params.searchEndTime = datePickerValue.timeValue?.[1] + if (datePickerValue && datePickerValue.timeValue) { + // 更新时间参数 + tableStore.table.params.searchBeginTime = datePickerValue.timeValue[0] + tableStore.table.params.searchEndTime = datePickerValue.timeValue[1] } } @@ -180,21 +179,8 @@ const tableStore: any = new TableStore({ } ], beforeSearchFun: () => { - // 尝试从缓存获取时间值 - let beginTime, endTime - - if (fullscreen.value) { - const cached = timeCacheStore.getCache(route.path) - if (cached && cached.timeValue) { - beginTime = cached.timeValue[0] - endTime = cached.timeValue[1] - } - } - - // 如果缓存中没有则使用默认值 - tableStore.table.params.searchBeginTime = beginTime || prop.timeValue?.[0] || getTimeOfTheMonth(prop.timeKey)[0] - - tableStore.table.params.searchEndTime = endTime || prop.timeValue?.[1] || getTimeOfTheMonth(prop.timeKey)[1] + tableStore.table.params.searchBeginTime = tableStore.table.params.searchBeginTime || prop.timeValue?.[0] + tableStore.table.params.searchEndTime = tableStore.table.params.searchEndTime || prop.timeValue?.[1] }, loadCallback: () => { tableStore.table.data = [ @@ -235,12 +221,17 @@ watch( } ) watch( - () => prop.timeValue, // 监听的目标(函数形式避免直接传递 props 导致的警告) + () => prop.timeValue, (newVal, oldVal) => { - tableStore.index() + // 当外部时间值变化时,更新表格的时间参数 + if (newVal && (!oldVal || newVal[0] !== oldVal[0] || newVal[1] !== oldVal[1])) { + tableStore.table.params.searchBeginTime = newVal[0] + tableStore.table.params.searchEndTime = newVal[1] + tableStore.index() + } }, { - deep: true // 若 timeValue 是对象/数组,需开启深度监听 + deep: true } ) diff --git a/src/components/cockpit/indicatorDetails/index.vue b/src/components/cockpit/indicatorDetails/index.vue index cd5afb7..a636207 100644 --- a/src/components/cockpit/indicatorDetails/index.vue +++ b/src/components/cockpit/indicatorDetails/index.vue @@ -2,7 +2,13 @@
- + diff --git a/src/components/cockpit/transientStatistics/index.vue b/src/components/cockpit/transientStatistics/index.vue index 83d7d58..2fa1b98 100644 --- a/src/components/cockpit/transientStatistics/index.vue +++ b/src/components/cockpit/transientStatistics/index.vue @@ -32,11 +32,11 @@ import { useRoute } from 'vue-router' import { useTimeCacheStore } from '@/stores/timeCache' const prop = defineProps({ - w: { type: [String, Number]}, - h: { type: [String, Number]}, - width: { type: [String, Number]}, - height: { type: [String, Number]}, - timeKey: { type: [String, Number]}, + w: { type: [String, Number] }, + h: { type: [String, Number] }, + width: { type: [String, Number] }, + height: { type: [String, Number] }, + timeKey: { type: [String, Number] }, timeValue: { type: Object } }) @@ -48,11 +48,10 @@ const timeCacheStore = useTimeCacheStore() const selectChange = (showSelect: any, height: any, datePickerValue?: any) => { headerHeight.value = height - // 如果有传入 datePicker 的值 - if (datePickerValue) { - // 更新表格参数 - tableStore.table.params.searchBeginTime = datePickerValue.timeValue?.[0] - tableStore.table.params.searchEndTime = datePickerValue.timeValue?.[1] + if (datePickerValue && datePickerValue.timeValue) { + // 更新时间参数 + tableStore.table.params.searchBeginTime = datePickerValue.timeValue[0] + tableStore.table.params.searchEndTime = datePickerValue.timeValue[1] } } @@ -190,20 +189,8 @@ const tableStore: any = new TableStore({ } ], beforeSearchFun: () => { - // 尝试从缓存获取时间值 - let beginTime, endTime - - if (fullscreen.value) { - const cached = timeCacheStore.getCache(route.path) - if (cached && cached.timeValue) { - beginTime = cached.timeValue[0] - endTime = cached.timeValue[1] - } - } - - // 如果缓存中没有则使用默认值 - tableStore.table.params.searchBeginTime = beginTime || prop.timeValue?.[0] || getTimeOfTheMonth(prop.timeKey)[0] - tableStore.table.params.searchEndTime = endTime || prop.timeValue?.[1] || getTimeOfTheMonth(prop.timeKey)[1] + tableStore.table.params.searchBeginTime = tableStore.table.params.searchBeginTime || prop.timeValue?.[0] + tableStore.table.params.searchEndTime = tableStore.table.params.searchEndTime || prop.timeValue?.[1] }, loadCallback: () => { tableStore.table.data = [ @@ -259,12 +246,17 @@ watch( } ) watch( - () => prop.timeValue, // 监听的目标(函数形式避免直接传递 props 导致的警告) + () => prop.timeValue, (newVal, oldVal) => { - tableStore.index() + // 当外部时间值变化时,更新表格的时间参数 + if (newVal && (!oldVal || newVal[0] !== oldVal[0] || newVal[1] !== oldVal[1])) { + tableStore.table.params.searchBeginTime = newVal[0] + tableStore.table.params.searchEndTime = newVal[1] + tableStore.index() + } }, { - deep: true // 若 timeValue 是对象/数组,需开启深度监听 + deep: true } ) diff --git a/src/components/cockpit/trendComparison/index.vue b/src/components/cockpit/trendComparison/index.vue index fab2df8..76301ef 100644 --- a/src/components/cockpit/trendComparison/index.vue +++ b/src/components/cockpit/trendComparison/index.vue @@ -53,7 +53,10 @@
@@ -70,11 +73,11 @@ import { useConfig } from '@/stores/config' import { useRoute } from 'vue-router' import { useTimeCacheStore } from '@/stores/timeCache' const prop = defineProps({ - w: { type: [String, Number]}, - h: { type: [String, Number]}, - width: { type: [String, Number]}, - height: { type: [String, Number]}, - timeKey: { type: [String, Number]}, + w: { type: [String, Number] }, + h: { type: [String, Number] }, + width: { type: [String, Number] }, + height: { type: [String, Number] }, + timeKey: { type: [String, Number] }, timeValue: { type: Object } }) @@ -246,11 +249,10 @@ const headerHeight = ref(57) const selectChange = (showSelect: any, height: any, datePickerValue?: any) => { headerHeight.value = height - // 如果有传入 datePicker 的值 - if (datePickerValue) { - // 更新表格参数 - tableStore.table.params.searchBeginTime = datePickerValue.timeValue?.[0] - tableStore.table.params.searchEndTime = datePickerValue.timeValue?.[1] + if (datePickerValue && datePickerValue.timeValue) { + // 更新时间参数 + tableStore.table.params.searchBeginTime = datePickerValue.timeValue[0] + tableStore.table.params.searchEndTime = datePickerValue.timeValue[1] } } const tableStore: any = new TableStore({ @@ -260,30 +262,15 @@ const tableStore: any = new TableStore({ showPage: false, exportName: '主要监测点列表', column: [], - beforeSearchFun: () => { - // 尝试从缓存获取时间值 - let beginTime, endTime - - if (fullscreen.value) { - const cached = timeCacheStore.getCache(route.path) - if (cached && cached.timeValue) { - beginTime = cached.timeValue[0] - endTime = cached.timeValue[1] - } - } - - // 如果缓存中没有则使用默认值 - tableStore.table.params.searchBeginTime = beginTime || prop.timeValue?.[0] || getTimeOfTheMonth(prop.timeKey)[0] - - tableStore.table.params.searchEndTime = endTime || prop.timeValue?.[1] || getTimeOfTheMonth(prop.timeKey)[1] + beforeSearchFun: () => { + tableStore.table.params.searchBeginTime = tableStore.table.params.searchBeginTime || prop.timeValue?.[0] + tableStore.table.params.searchEndTime = tableStore.table.params.searchEndTime || prop.timeValue?.[1] }, loadCallback: () => { tableStore.table.height = `calc(${prop.height} - 80px)` } }) -const tableRef = ref() -provide('tableRef', tableRef) tableStore.table.params.power = '1' tableStore.table.params.indicator = '1' tableStore.table.params.exceedingTheLimit = '1' @@ -300,12 +287,17 @@ watch( } ) watch( - () => prop.timeValue, // 监听的目标(函数形式避免直接传递 props 导致的警告) + () => prop.timeValue, (newVal, oldVal) => { - tableStore.index() + // 当外部时间值变化时,更新表格的时间参数 + if (newVal && (!oldVal || newVal[0] !== oldVal[0] || newVal[1] !== oldVal[1])) { + tableStore.table.params.searchBeginTime = newVal[0] + tableStore.table.params.searchEndTime = newVal[1] + tableStore.index() + } }, { - deep: true // 若 timeValue 是对象/数组,需开启深度监听 + deep: true } )