修改时间传值
This commit is contained in:
@@ -104,8 +104,8 @@ const tableStore: any = new TableStore({
|
|||||||
{ title: '主要存在的电能质量问题', field: 'problems', minWidth: '150', showOverflow: true }
|
{ title: '主要存在的电能质量问题', field: 'problems', minWidth: '150', showOverflow: true }
|
||||||
],
|
],
|
||||||
beforeSearchFun: () => {
|
beforeSearchFun: () => {
|
||||||
tableStore.table.params.searchBeginTime = tableStore.table.params.searchBeginTime ?? prop.timeValue?.[0]
|
tableStore.table.params.searchBeginTime = tableStore.table.params.searchBeginTime || prop.timeValue?.[0]
|
||||||
tableStore.table.params.searchEndTime = tableStore.table.params.searchEndTime ?? prop.timeValue?.[1]
|
tableStore.table.params.searchEndTime = tableStore.table.params.searchEndTime || prop.timeValue?.[1]
|
||||||
},
|
},
|
||||||
loadCallback: () => {
|
loadCallback: () => {
|
||||||
tableStore.table.height = `calc(${prop.height} - 80px)`
|
tableStore.table.height = `calc(${prop.height} - 80px)`
|
||||||
@@ -128,27 +128,6 @@ const cellClickEvent = ({ row, column }: any) => {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// 获取缓存的初始值
|
|
||||||
const getInitialInterval = (): 3 => {
|
|
||||||
if (fullscreen.value) {
|
|
||||||
const cached = timeCacheStore.getCache(route.path)
|
|
||||||
if (cached && cached.interval !== undefined) {
|
|
||||||
return cached.interval as 3 // 强制断言为 3 或根据实际类型调整
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return 3 // 明确返回字面量类型 3
|
|
||||||
}
|
|
||||||
// 外部总的时间值
|
|
||||||
const getInitialTimeValue = () => {
|
|
||||||
if (fullscreen.value) {
|
|
||||||
const cached = timeCacheStore.getCache(route.path)
|
|
||||||
if (cached && cached.timeValue) {
|
|
||||||
return cached.timeValue
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return prop.timeValue // 使用传入的默认值
|
|
||||||
}
|
|
||||||
|
|
||||||
// 在组件挂载时设置缓存值到 DatePicker
|
// 在组件挂载时设置缓存值到 DatePicker
|
||||||
onMounted(() => {
|
onMounted(() => {
|
||||||
tableStore.index()
|
tableStore.index()
|
||||||
@@ -160,12 +139,17 @@ watch(
|
|||||||
}
|
}
|
||||||
)
|
)
|
||||||
watch(
|
watch(
|
||||||
() => prop.timeValue, // 监听的目标(函数形式避免直接传递 props 导致的警告)
|
() => prop.timeValue,
|
||||||
(newVal, oldVal) => {
|
(newVal, oldVal) => {
|
||||||
|
// 当外部时间值变化时,更新表格的时间参数
|
||||||
|
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()
|
tableStore.index()
|
||||||
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
deep: true // 若 timeValue 是对象/数组,需开启深度监听
|
deep: true
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|||||||
@@ -26,18 +26,17 @@ import TableStore from '@/utils/tableStore'
|
|||||||
import Table from '@/components/table/index.vue'
|
import Table from '@/components/table/index.vue'
|
||||||
import TableHeader from '@/components/table/header/index.vue'
|
import TableHeader from '@/components/table/header/index.vue'
|
||||||
import MyEchart from '@/components/echarts/MyEchart.vue'
|
import MyEchart from '@/components/echarts/MyEchart.vue'
|
||||||
import { getTimeOfTheMonth } from '@/utils/formatTime'
|
|
||||||
import OverLimitDetails from '@/components/cockpit/overLimitStatistics/components/overLimitDetails.vue'
|
import OverLimitDetails from '@/components/cockpit/overLimitStatistics/components/overLimitDetails.vue'
|
||||||
import { useRoute } from 'vue-router'
|
import { useRoute } from 'vue-router'
|
||||||
import { useTimeCacheStore } from '@/stores/timeCache'
|
import { useTimeCacheStore } from '@/stores/timeCache'
|
||||||
import { totalLimitStatisticsData } from '@/api/harmonic-boot/cockpit/cockpit'
|
import { totalLimitStatisticsData } from '@/api/harmonic-boot/cockpit/cockpit'
|
||||||
|
|
||||||
const prop = defineProps({
|
const prop = defineProps({
|
||||||
w: { type: [String, Number]},
|
w: { type: [String, Number] },
|
||||||
h: { type: [String, Number]},
|
h: { type: [String, Number] },
|
||||||
width: { type: [String, Number]},
|
width: { type: [String, Number] },
|
||||||
height: { type: [String, Number]},
|
height: { type: [String, Number] },
|
||||||
timeKey: { type: [String, Number]},
|
timeKey: { type: [String, Number] },
|
||||||
timeValue: { type: Object }
|
timeValue: { type: Object }
|
||||||
})
|
})
|
||||||
|
|
||||||
@@ -51,12 +50,11 @@ const echartList = ref({})
|
|||||||
const selectChange = (showSelect: any, height: any, datePickerValue?: any) => {
|
const selectChange = (showSelect: any, height: any, datePickerValue?: any) => {
|
||||||
headerHeight.value = height
|
headerHeight.value = height
|
||||||
|
|
||||||
// 如果有传入 datePicker 的值
|
if (datePickerValue && datePickerValue.timeValue) {
|
||||||
// if (datePickerValue) {
|
// 更新时间参数
|
||||||
// // 更新表格参数
|
tableStore.table.params.searchBeginTime = datePickerValue.timeValue[0]
|
||||||
// tableStore.table.params.searchBeginTime = datePickerValue.timeValue?.[0]
|
tableStore.table.params.searchEndTime = datePickerValue.timeValue[1]
|
||||||
// tableStore.table.params.searchEndTime = datePickerValue.timeValue?.[1]
|
}
|
||||||
// }
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// 计算是否全屏展示
|
// 计算是否全屏展示
|
||||||
@@ -117,7 +115,6 @@ const initEcharts = () => {
|
|||||||
]
|
]
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -194,24 +191,12 @@ const tableStore: any = new TableStore({
|
|||||||
}
|
}
|
||||||
],
|
],
|
||||||
beforeSearchFun: () => {
|
beforeSearchFun: () => {
|
||||||
// 尝试从缓存获取时间值
|
tableStore.table.params.searchBeginTime = tableStore.table.params.searchBeginTime || prop.timeValue?.[0]
|
||||||
let beginTime, endTime
|
tableStore.table.params.searchEndTime = tableStore.table.params.searchEndTime || prop.timeValue?.[1]
|
||||||
|
|
||||||
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]
|
|
||||||
},
|
},
|
||||||
loadCallback: () => {
|
loadCallback: () => {
|
||||||
tableStore.table.height = `calc(${prop.height} - 80px)`
|
tableStore.table.height = `calc(${prop.height} - 80px)`
|
||||||
|
initEcharts()
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
@@ -233,7 +218,6 @@ const cellClickEvent = ({ row, column }: any) => {
|
|||||||
|
|
||||||
onMounted(() => {
|
onMounted(() => {
|
||||||
tableStore.index()
|
tableStore.index()
|
||||||
initEcharts()
|
|
||||||
})
|
})
|
||||||
watch(
|
watch(
|
||||||
() => prop.timeKey,
|
() => prop.timeKey,
|
||||||
@@ -243,13 +227,17 @@ watch(
|
|||||||
}
|
}
|
||||||
)
|
)
|
||||||
watch(
|
watch(
|
||||||
() => prop.timeValue, // 监听的目标(函数形式避免直接传递 props 导致的警告)
|
() => prop.timeValue,
|
||||||
(newVal, oldVal) => {
|
(newVal, oldVal) => {
|
||||||
|
// 当外部时间值变化时,更新表格的时间参数
|
||||||
|
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()
|
tableStore.index()
|
||||||
initEcharts()
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
deep: true // 若 timeValue 是对象/数组,需开启深度监听
|
deep: true
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user