时间取值修改

This commit is contained in:
stt
2025-11-14 14:09:34 +08:00
parent d6bfd8b958
commit 49dcf440ff
13 changed files with 273 additions and 375 deletions

View File

@@ -58,11 +58,10 @@ const timeCacheStore = useTimeCacheStore()
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]
} }
} }
@@ -106,21 +105,8 @@ const tableStore: any = new TableStore({
column: [], column: [],
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] || getTimeOfTheMonth(prop.timeKey)[0]
tableStore.table.params.searchEndTime = endTime || prop.timeValue?.[1] || getTimeOfTheMonth(prop.timeKey)[1]
}, },
loadCallback: () => { loadCallback: () => {
let res = { let res = {
@@ -481,12 +467,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
} }
) )

View File

@@ -18,11 +18,11 @@ import { useRoute } from 'vue-router'
import { useTimeCacheStore } from '@/stores/timeCache' import { useTimeCacheStore } from '@/stores/timeCache'
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 }
}) })
@@ -34,11 +34,10 @@ const timeCacheStore = useTimeCacheStore()
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]
} }
} }
@@ -129,21 +128,8 @@ const tableStore: any = new TableStore({
column: [], column: [],
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] || getTimeOfTheMonth(prop.timeKey)[0]
tableStore.table.params.searchEndTime = endTime || prop.timeValue?.[1] || getTimeOfTheMonth(prop.timeKey)[1]
}, },
loadCallback: () => {} loadCallback: () => {}
}) })
@@ -171,12 +157,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
} }
) )

View File

@@ -29,11 +29,11 @@ import { useRoute } from 'vue-router'
import { useTimeCacheStore } from '@/stores/timeCache' import { useTimeCacheStore } from '@/stores/timeCache'
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 }
}) })
@@ -45,11 +45,10 @@ const timeCacheStore = useTimeCacheStore()
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]
} }
} }
// 计算是否全屏展示 // 计算是否全屏展示
@@ -113,11 +112,7 @@ const tableStore: any = new TableStore({
minWidth: '60', minWidth: '60',
render: 'customTemplate', render: 'customTemplate',
customTemplate: (row: any) => { customTemplate: (row: any) => {
if ( if (row.time !== null && row.time !== undefined && row.time !== '') {
row.time !== null &&
row.time !== undefined &&
row.time !== ''
) {
return `<span>${row.time}</span>` return `<span>${row.time}</span>`
} else { } else {
return `<span>/</span>` return `<span>/</span>`
@@ -139,20 +134,8 @@ 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: () => {
// 定义 x 轴标签顺序 // 定义 x 轴标签顺序
@@ -218,12 +201,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
} }
) )

View File

@@ -76,20 +76,8 @@ const tableStore: any = new TableStore({
exportName: '主要监测点列表', exportName: '主要监测点列表',
column: [], column: [],
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] || getTimeOfTheMonth(prop.timeKey)[0]
tableStore.table.params.searchEndTime = endTime || prop.timeValue?.[1] || getTimeOfTheMonth(prop.timeKey)[1]
}, },
loadCallback: () => {} loadCallback: () => {}
}) })
@@ -119,11 +107,11 @@ onMounted(() => {
}) })
const selectChange = (showSelect: any, height: any, datePickerValue?: any) => { const selectChange = (showSelect: any, height: any, datePickerValue?: any) => {
// 如果有传入 datePicker 的值
if (datePickerValue) { if (datePickerValue && datePickerValue.timeValue) {
// 更新表格参数 // 更新时间参数
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]
} }
} }
@@ -145,12 +133,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
} }
) )

View File

@@ -32,11 +32,11 @@ import { useRoute } from 'vue-router'
import { useTimeCacheStore } from '@/stores/timeCache' import { useTimeCacheStore } from '@/stores/timeCache'
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 }
}) })
@@ -48,11 +48,10 @@ const timeCacheStore = useTimeCacheStore()
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]
} }
} }
@@ -180,21 +179,8 @@ 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] || getTimeOfTheMonth(prop.timeKey)[0]
tableStore.table.params.searchEndTime = endTime || prop.timeValue?.[1] || getTimeOfTheMonth(prop.timeKey)[1]
}, },
loadCallback: () => { loadCallback: () => {
tableStore.table.data = [ tableStore.table.data = [
@@ -235,12 +221,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
} }
) )

View File

@@ -2,7 +2,13 @@
<div> <div>
<!--指标越限明细 --> <!--指标越限明细 -->
<TableHeader :showReset="false" @selectChange="selectChange" datePicker v-if="fullscreen"></TableHeader> <TableHeader :showReset="false" @selectChange="selectChange" datePicker v-if="fullscreen"></TableHeader>
<el-calendar v-model="value" :style="{ height: `calc(${prop.height} - ${headerHeight}px + ${fullscreen ? 0 : 56}px )`, overflow: 'auto' }"> <el-calendar
v-model="value"
:style="{
height: `calc(${prop.height} - ${headerHeight}px + ${fullscreen ? 0 : 56}px )`,
overflow: 'auto'
}"
>
<template #date-cell="{ data }"> <template #date-cell="{ data }">
<div style="height: 100%; padding: 8px" :style="{ background: setBackground(data.day) }"> <div style="height: 100%; padding: 8px" :style="{ background: setBackground(data.day) }">
<p :class="data.isSelected ? 'is-selected' : ''"> <p :class="data.isSelected ? 'is-selected' : ''">
@@ -38,11 +44,11 @@ import { useRoute } from 'vue-router'
import { useTimeCacheStore } from '@/stores/timeCache' import { useTimeCacheStore } from '@/stores/timeCache'
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 }
}) })
@@ -57,11 +63,10 @@ const value = ref(new Date())
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]
} }
} }
@@ -122,21 +127,8 @@ const tableStore: any = new TableStore({
column: [], column: [],
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] || getTimeOfTheMonth(prop.timeKey)[0]
tableStore.table.params.searchEndTime = endTime || prop.timeValue?.[1] || getTimeOfTheMonth(prop.timeKey)[1]
}, },
loadCallback: () => { loadCallback: () => {
tableStore.table.data = [] tableStore.table.data = []
@@ -176,12 +168,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
} }
) )

View File

@@ -38,11 +38,11 @@ import { useRoute } from 'vue-router'
import { useTimeCacheStore } from '@/stores/timeCache' import { useTimeCacheStore } from '@/stores/timeCache'
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 }
}) })
@@ -61,11 +61,10 @@ const timeCacheStore = useTimeCacheStore()
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]
} }
} }
@@ -215,7 +214,7 @@ const fullscreen = computed(() => {
// } // }
// }) // })
var yAxisData=['闪变', '谐波电压', '谐波电流', '电压偏差', '三相不平衡'] var yAxisData = ['闪变', '谐波电压', '谐波电流', '电压偏差', '三相不平衡']
const echartList = ref({ const echartList = ref({
options: { options: {
@@ -231,7 +230,7 @@ const echartList = ref({
borderWidth: 0, borderWidth: 0,
formatter: function (params: any) { formatter: function (params: any) {
console.log(params, '33344') console.log(params, '33344')
var yIndex = params.value[1]; //获取y轴索引 var yIndex = params.value[1] //获取y轴索引
var tips = '' var tips = ''
// tips += '指标类型: ' + params.name + '</br>' // tips += '指标类型: ' + params.name + '</br>'
tips += '指标类型: ' + yAxisData[yIndex] + '</br>' tips += '指标类型: ' + yAxisData[yIndex] + '</br>'
@@ -297,7 +296,7 @@ const echartList = ref({
nameLocation: 'middle', nameLocation: 'middle',
nameGap: 30, nameGap: 30,
// data: ['闪变', '谐波电压', '谐波电流', '电压偏差', '三相不平衡'], // data: ['闪变', '谐波电压', '谐波电流', '电压偏差', '三相不平衡'],
data:yAxisData, data: yAxisData,
nameTextStyle: { nameTextStyle: {
color: '#111' color: '#111'
}, },
@@ -714,21 +713,8 @@ const tableStore: any = new TableStore({
showPage: false, showPage: false,
column: [], column: [],
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] || getTimeOfTheMonth(prop.timeKey)[0]
tableStore.table.params.searchEndTime = endTime || prop.timeValue?.[1] || getTimeOfTheMonth(prop.timeKey)[1]
}, },
loadCallback: () => { loadCallback: () => {
tableStore.table.data = [] tableStore.table.data = []
@@ -751,12 +737,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
} }
) )

View File

@@ -36,11 +36,10 @@ const timeCacheStore = useTimeCacheStore()
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]
} }
} }
@@ -112,21 +111,8 @@ const tableStore: any = new TableStore({
{ title: '最新数据时间', field: 'type6', minWidth: '140' } { title: '最新数据时间', field: 'type6', minWidth: '140' }
], ],
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] || getTimeOfTheMonth(prop.timeKey)[0]
tableStore.table.params.searchEndTime = endTime || prop.timeValue?.[1] || getTimeOfTheMonth(prop.timeKey)[1]
}, },
loadCallback: () => { loadCallback: () => {
tableStore.table.data = [ tableStore.table.data = [
@@ -200,12 +186,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
} }
) )

View File

@@ -31,11 +31,10 @@ const timeCacheStore = useTimeCacheStore()
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]
} }
} }
@@ -91,22 +90,10 @@ 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] || getTimeOfTheMonth(prop.timeKey)[0]
tableStore.table.params.searchEndTime = endTime || prop.timeValue?.[1] || getTimeOfTheMonth(prop.timeKey)[1]
}, },
loadCallback: () => { loadCallback: () => {
tableStore.table.data = [ tableStore.table.data = [
{ {
@@ -150,12 +137,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
} }
) )

View File

@@ -2,7 +2,13 @@
<div> <div>
<!--暂态事件明细 --> <!--暂态事件明细 -->
<TableHeader :showReset="false" @selectChange="selectChange" datePicker v-if="fullscreen"></TableHeader> <TableHeader :showReset="false" @selectChange="selectChange" datePicker v-if="fullscreen"></TableHeader>
<el-calendar v-model="value" :style="{ height: `calc(${prop.height} - ${headerHeight}px + ${fullscreen ? 0 : 56}px )`, overflow: 'auto' }"> <el-calendar
v-model="value"
:style="{
height: `calc(${prop.height} - ${headerHeight}px + ${fullscreen ? 0 : 56}px )`,
overflow: 'auto'
}"
>
<template #date-cell="{ data }"> <template #date-cell="{ data }">
<div style="height: 100%; padding: 8px" :style="{ background: setBackground(data.day) }"> <div style="height: 100%; padding: 8px" :style="{ background: setBackground(data.day) }">
<p :class="data.isSelected ? 'is-selected' : ''"> <p :class="data.isSelected ? 'is-selected' : ''">
@@ -50,11 +56,11 @@ import { useRoute } from 'vue-router'
import { useTimeCacheStore } from '@/stores/timeCache' import { useTimeCacheStore } from '@/stores/timeCache'
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 }
}) })
@@ -66,11 +72,10 @@ const timeCacheStore = useTimeCacheStore()
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]
} }
} }
@@ -142,30 +147,17 @@ const tableStore: any = new TableStore({
showPage: false, showPage: false,
column: [], column: [],
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] || getTimeOfTheMonth(prop.timeKey)[0]
tableStore.table.params.searchEndTime = endTime || prop.timeValue?.[1] || getTimeOfTheMonth(prop.timeKey)[1]
}, },
loadCallback: () => { loadCallback: () => {
tableStore.table.data = [] tableStore.table.data = []
} }
}) })
const tableRef = ref([])
const setBackground = (value: string) => { const setBackground = (value: string) => {
let data = [] let data = []
data = list.value?.filter(item => item.time == value) data = list.value?.filter(item => item.time == value)
@@ -179,8 +171,6 @@ const setBackground = (value: string) => {
return '#fff' return '#fff'
} }
provide('tableRef', tableRef)
provide('tableStore', tableStore) provide('tableStore', tableStore)
onMounted(() => { onMounted(() => {
@@ -193,12 +183,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
} }
) )
@@ -206,8 +201,6 @@ watch(
const descentClick = () => { const descentClick = () => {
transientListRef.value.open() transientListRef.value.open()
} }
</script> </script>
<style lang="scss" scoped> <style lang="scss" scoped>
:deep(.el-calendar) { :deep(.el-calendar) {

View File

@@ -5,12 +5,18 @@
<my-echart <my-echart
class="tall" class="tall"
:options="echartList" :options="echartList"
:style="{ width: prop.width, height: `calc(${prop.height} / 2 - ${headerHeight / 2}px + ${fullscreen ? 0 : 28}px )` }" :style="{
width: prop.width,
height: `calc(${prop.height} / 2 - ${headerHeight / 2}px + ${fullscreen ? 0 : 28}px )`
}"
/> />
<my-echart <my-echart
class="mt10" class="mt10"
:options="echartList1" :options="echartList1"
:style="{ width: prop.width, height: `calc(${prop.height} / 2 - ${headerHeight / 2}px + ${fullscreen ? 0 : 28}px )` }" :style="{
width: prop.width,
height: `calc(${prop.height} / 2 - ${headerHeight / 2}px + ${fullscreen ? 0 : 28}px )`
}"
/> />
</div> </div>
</template> </template>
@@ -25,11 +31,11 @@ import { useRoute } from 'vue-router'
import { useTimeCacheStore } from '@/stores/timeCache' import { useTimeCacheStore } from '@/stores/timeCache'
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 }
}) })
@@ -41,11 +47,10 @@ const timeCacheStore = useTimeCacheStore()
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]
} }
} }
@@ -342,21 +347,8 @@ const tableStore: any = new TableStore({
showPage: false, showPage: false,
column: [], column: [],
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] || getTimeOfTheMonth(prop.timeKey)[0]
tableStore.table.params.searchEndTime = endTime || prop.timeValue?.[1] || getTimeOfTheMonth(prop.timeKey)[1]
}, },
loadCallback: () => { loadCallback: () => {
tableStore.table.data = [] tableStore.table.data = []
@@ -378,15 +370,19 @@ 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
} }
) )
const addMenu = () => {} const addMenu = () => {}
</script> </script>
<style lang="scss" scoped></style> <style lang="scss" scoped></style>

View File

@@ -32,11 +32,11 @@ import { useRoute } from 'vue-router'
import { useTimeCacheStore } from '@/stores/timeCache' import { useTimeCacheStore } from '@/stores/timeCache'
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 }
}) })
@@ -48,11 +48,10 @@ const timeCacheStore = useTimeCacheStore()
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]
} }
} }
@@ -190,20 +189,8 @@ 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] || getTimeOfTheMonth(prop.timeKey)[0]
tableStore.table.params.searchEndTime = endTime || prop.timeValue?.[1] || getTimeOfTheMonth(prop.timeKey)[1]
}, },
loadCallback: () => { loadCallback: () => {
tableStore.table.data = [ tableStore.table.data = [
@@ -259,12 +246,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
} }
) )

View File

@@ -53,7 +53,10 @@
<my-echart <my-echart
class="tall" class="tall"
:options="echartList" :options="echartList"
:style="{ width: prop.width, height: `calc(${prop.height} - ${headerHeight}px + ${fullscreen ? 0 : 56}px)` }" :style="{
width: prop.width,
height: `calc(${prop.height} - ${headerHeight}px + ${fullscreen ? 0 : 56}px)`
}"
/> />
</div> </div>
</template> </template>
@@ -70,11 +73,11 @@ import { useConfig } from '@/stores/config'
import { useRoute } from 'vue-router' import { useRoute } from 'vue-router'
import { useTimeCacheStore } from '@/stores/timeCache' import { useTimeCacheStore } from '@/stores/timeCache'
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 }
}) })
@@ -246,11 +249,10 @@ const headerHeight = ref(57)
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]
} }
} }
const tableStore: any = new TableStore({ const tableStore: any = new TableStore({
@@ -261,29 +263,14 @@ const tableStore: any = new TableStore({
exportName: '主要监测点列表', exportName: '主要监测点列表',
column: [], column: [],
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] || getTimeOfTheMonth(prop.timeKey)[0]
tableStore.table.params.searchEndTime = endTime || prop.timeValue?.[1] || getTimeOfTheMonth(prop.timeKey)[1]
}, },
loadCallback: () => { loadCallback: () => {
tableStore.table.height = `calc(${prop.height} - 80px)` tableStore.table.height = `calc(${prop.height} - 80px)`
} }
}) })
const tableRef = ref()
provide('tableRef', tableRef)
tableStore.table.params.power = '1' tableStore.table.params.power = '1'
tableStore.table.params.indicator = '1' tableStore.table.params.indicator = '1'
tableStore.table.params.exceedingTheLimit = '1' tableStore.table.params.exceedingTheLimit = '1'
@@ -300,12 +287,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
} }
) )