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 @@
@@ -38,11 +44,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 } }) @@ -57,11 +63,10 @@ const value = ref(new Date()) 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] } } @@ -121,22 +126,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: () => { tableStore.table.data = [] @@ -176,12 +168,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/indicatorDistribution/index.vue b/src/components/cockpit/indicatorDistribution/index.vue index b13e3d4..7a9341b 100644 --- a/src/components/cockpit/indicatorDistribution/index.vue +++ b/src/components/cockpit/indicatorDistribution/index.vue @@ -38,11 +38,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 } }) @@ -61,11 +61,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] } } @@ -215,7 +214,7 @@ const fullscreen = computed(() => { // } // }) -var yAxisData=['闪变', '谐波电压', '谐波电流', '电压偏差', '三相不平衡'] +var yAxisData = ['闪变', '谐波电压', '谐波电流', '电压偏差', '三相不平衡'] const echartList = ref({ options: { @@ -231,7 +230,7 @@ const echartList = ref({ borderWidth: 0, formatter: function (params: any) { console.log(params, '33344') - var yIndex = params.value[1]; //获取y轴索引 + var yIndex = params.value[1] //获取y轴索引 var tips = '' // tips += '指标类型: ' + params.name + '' tips += '指标类型: ' + yAxisData[yIndex] + '' @@ -297,7 +296,7 @@ const echartList = ref({ nameLocation: 'middle', nameGap: 30, // data: ['闪变', '谐波电压', '谐波电流', '电压偏差', '三相不平衡'], - data:yAxisData, + data: yAxisData, nameTextStyle: { color: '#111' }, @@ -363,7 +362,7 @@ const echartList = ref({ name: '0-20%', data: [ // [xIndex, yIndex, value] - [0, 0, 5], // 闪变 - 0-20% + [0, 0, 5], // 闪变 - 0-20% [0, 1, 10], // 谐波电压 - 0-20% [0, 2, 8], // 谐波电流 - 0-20% [0, 3, 15], // 电压偏差 - 0-20% @@ -393,10 +392,10 @@ const echartList = ref({ type: 'bar3D', name: '20-40%', // data: chartData.map(function (item) { - // return { - // value: [item[1], item[0], item[2]] - // }; - // }), + // return { + // value: [item[1], item[0], item[2]] + // }; + // }), data: [ [1, 0, 10], // 闪变 - 20-40% [1, 1, 20], // 谐波电压 - 20-40% @@ -714,21 +713,8 @@ 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] + 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 = [] @@ -751,12 +737,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/monitoringPointList/index.vue b/src/components/cockpit/monitoringPointList/index.vue index 7c66941..6436191 100644 --- a/src/components/cockpit/monitoringPointList/index.vue +++ b/src/components/cockpit/monitoringPointList/index.vue @@ -36,11 +36,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] } } @@ -112,21 +111,8 @@ const tableStore: any = new TableStore({ { title: '最新数据时间', field: 'type6', minWidth: '140' } ], 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 = [ @@ -200,12 +186,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/sensitiveLoad/index.vue b/src/components/cockpit/sensitiveLoad/index.vue index 5fb15c0..ccd7e28 100644 --- a/src/components/cockpit/sensitiveLoad/index.vue +++ b/src/components/cockpit/sensitiveLoad/index.vue @@ -31,11 +31,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] } } @@ -90,23 +89,11 @@ const tableStore: any = new TableStore({ minWidth: '80' } ], - 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.data = [ { @@ -150,12 +137,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/transientDetails/index.vue b/src/components/cockpit/transientDetails/index.vue index 8efcd71..8098ace 100644 --- a/src/components/cockpit/transientDetails/index.vue +++ b/src/components/cockpit/transientDetails/index.vue @@ -2,7 +2,13 @@
@@ -27,7 +33,7 @@ :style="{ height: `calc(${prop.height} / 5 - 47px)`, overflow: 'auto' }" v-for="item in list?.filter(item => item.time == data.day)" > -