稳态电能质量分析时间修改
This commit is contained in:
@@ -7,7 +7,6 @@
|
||||
@selectChange="selectChange"
|
||||
datePicker
|
||||
v-if="fullscreen"
|
||||
:timeCacheFlag="false"
|
||||
:timeKeyList="['3']"
|
||||
></TableHeader>
|
||||
<el-calendar
|
||||
@@ -98,22 +97,8 @@ const tableStore: any = new TableStore({
|
||||
method: 'POST',
|
||||
showPage: false,
|
||||
column: [],
|
||||
// beforeSearchFun: () => {
|
||||
// if (!fullscreen.value && prop.timeValue && Array.isArray(prop.timeValue)) {
|
||||
// tableStore.table.params.searchBeginTime = prop.timeValue[0]
|
||||
// tableStore.table.params.searchEndTime = prop.timeValue[1]
|
||||
// }
|
||||
// },
|
||||
beforeSearchFun: () => {
|
||||
const time = getTime(
|
||||
prop.interval ?? 0,
|
||||
prop.timeKey,
|
||||
tableStore.table.params.searchBeginTime && tableStore.table.params.searchEndTime
|
||||
? [tableStore.table.params.searchBeginTime, tableStore.table.params.searchEndTime]
|
||||
: prop.timeValue
|
||||
)
|
||||
tableStore.table.params.searchBeginTime = time[0]
|
||||
tableStore.table.params.searchEndTime = time[1]
|
||||
setTime()
|
||||
},
|
||||
loadCallback: () => {
|
||||
value.value = tableStore.table.params.searchBeginTime
|
||||
@@ -158,43 +143,33 @@ provide('tableStore', tableStore)
|
||||
|
||||
onMounted(() => {
|
||||
nextTick(() => {
|
||||
// if (TableHeaderRef.value && typeof TableHeaderRef.value.setDatePicker === 'function') {
|
||||
// TableHeaderRef.value.setDatePicker([{ label: '月份', value: 3 }])
|
||||
// }
|
||||
if (fullscreen.value) {
|
||||
if (prop.interval == 3) {
|
||||
const time = getTime(
|
||||
prop.interval ?? 0,
|
||||
prop.timeKey,
|
||||
tableStore.table.params.searchBeginTime && tableStore.table.params.searchEndTime
|
||||
? [tableStore.table.params.searchBeginTime, tableStore.table.params.searchEndTime]
|
||||
: prop.timeValue
|
||||
)
|
||||
tableStore.table.params.searchBeginTime = time[0]
|
||||
tableStore.table.params.searchEndTime = time[1]
|
||||
TableHeaderRef.value.setTimeInterval(prop.timeValue)
|
||||
} else {
|
||||
TableHeaderRef.value.setInterval(3)
|
||||
}
|
||||
}
|
||||
tableStore.index()
|
||||
})
|
||||
})
|
||||
watch(
|
||||
() => prop.timeKey,
|
||||
val => {
|
||||
tableStore.index()
|
||||
|
||||
const setTime = () => {
|
||||
const time = getTime(
|
||||
(TableHeaderRef.value?.datePickerRef.interval || prop.interval) ?? 0,
|
||||
prop.timeKey,
|
||||
fullscreen.value
|
||||
? [tableStore.table.params.searchBeginTime, tableStore.table.params.searchEndTime]
|
||||
: prop.timeValue
|
||||
)
|
||||
if (Array.isArray(time)) {
|
||||
tableStore.table.params.searchBeginTime = time[0]
|
||||
tableStore.table.params.searchEndTime = time[1]
|
||||
TableHeaderRef.value?.setInterval(time[2] - 0)
|
||||
TableHeaderRef.value?.setTimeInterval([time[0], time[1]])
|
||||
} else {
|
||||
console.warn('获取时间失败,time 不是一个有效数组')
|
||||
}
|
||||
)
|
||||
}
|
||||
|
||||
|
||||
watch(
|
||||
() => prop.timeValue,
|
||||
(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()
|
||||
}
|
||||
},
|
||||
{
|
||||
deep: true
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
<template>
|
||||
<div>
|
||||
<!--主要监测点列表 -->
|
||||
<TableHeader :showReset="false" @selectChange="selectChange" v-if="fullscreen" datePicker ref="tableHeaderRef">
|
||||
<TableHeader :showReset="false" @selectChange="selectChange" v-if="fullscreen" datePicker ref="TableHeaderRef">
|
||||
<template v-slot:select>
|
||||
<el-form-item label="关键词">
|
||||
<el-input v-model="tableStore.table.params.keywords" clearable placeholder="请输关键字" />
|
||||
@@ -42,7 +42,7 @@ const headerHeight = ref(57)
|
||||
const route = useRoute()
|
||||
const timeCacheStore = useTimeCacheStore()
|
||||
|
||||
const tableHeaderRef = ref()
|
||||
const TableHeaderRef = ref()
|
||||
|
||||
// 计算是否全屏展示
|
||||
const fullscreen = computed(() => {
|
||||
@@ -104,18 +104,7 @@ const tableStore: any = new TableStore({
|
||||
{ title: '主要存在的电能质量问题', field: 'problems', minWidth: '150', showOverflow: true }
|
||||
],
|
||||
beforeSearchFun: () => {
|
||||
// tableStore.table.params.searchBeginTime = tableStore.table.params.searchBeginTime || prop.timeValue?.[0]
|
||||
// tableStore.table.params.searchEndTime = tableStore.table.params.searchEndTime || prop.timeValue?.[1]
|
||||
|
||||
const time = getTime(
|
||||
prop.interval ?? 0,
|
||||
prop.timeKey,
|
||||
tableStore.table.params.searchBeginTime && tableStore.table.params.searchEndTime
|
||||
? [tableStore.table.params.searchBeginTime, tableStore.table.params.searchEndTime]
|
||||
: prop.timeValue
|
||||
)
|
||||
tableStore.table.params.searchBeginTime = time[0]
|
||||
tableStore.table.params.searchEndTime = time[1]
|
||||
setTime()
|
||||
},
|
||||
loadCallback: () => {
|
||||
tableStore.table.height = `calc(${prop.height} - 80px)`
|
||||
@@ -138,25 +127,34 @@ const cellClickEvent = ({ row, column }: any) => {
|
||||
}
|
||||
}
|
||||
|
||||
const setTime = () => {
|
||||
const time = getTime(
|
||||
(TableHeaderRef.value?.datePickerRef.interval || prop.interval) ?? 0,
|
||||
prop.timeKey,
|
||||
fullscreen.value
|
||||
? [tableStore.table.params.searchBeginTime, tableStore.table.params.searchEndTime]
|
||||
: prop.timeValue
|
||||
)
|
||||
|
||||
if (Array.isArray(time)) {
|
||||
tableStore.table.params.searchBeginTime = time[0]
|
||||
tableStore.table.params.searchEndTime = time[1]
|
||||
// TableHeaderRef.value?.setInterval(time[2] - 0)
|
||||
// TableHeaderRef.value?.setTimeInterval([time[0], time[1]])
|
||||
} else {
|
||||
console.warn('获取时间失败,time 不是一个有效数组')
|
||||
}
|
||||
}
|
||||
|
||||
// 在组件挂载时设置缓存值到 DatePicker
|
||||
onMounted(() => {
|
||||
tableStore.index()
|
||||
})
|
||||
watch(
|
||||
() => prop.timeKey,
|
||||
val => {
|
||||
tableStore.index()
|
||||
}
|
||||
)
|
||||
|
||||
watch(
|
||||
() => prop.timeValue,
|
||||
(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()
|
||||
}
|
||||
},
|
||||
{
|
||||
deep: true
|
||||
|
||||
@@ -101,8 +101,6 @@ const lineList: any = ref()
|
||||
|
||||
const powerList: any = ref()
|
||||
|
||||
const countData: any = ref([])
|
||||
|
||||
const chartsList = ref<any>([])
|
||||
|
||||
// 计算是否全屏展示
|
||||
@@ -279,19 +277,6 @@ const tableStore: any = new TableStore({
|
||||
column: [],
|
||||
beforeSearchFun: () => {
|
||||
setTime()
|
||||
// 设置时间参数
|
||||
// tableStore.table.params.searchBeginTime = tableStore.table.params.searchBeginTime || prop.timeValue?.[0]
|
||||
// tableStore.table.params.searchEndTime = tableStore.table.params.searchEndTime || prop.timeValue?.[1]
|
||||
// const time = getTime(
|
||||
// prop.interval ?? 0,
|
||||
// prop.timeKey,
|
||||
// tableStore.table.params.searchBeginTime && tableStore.table.params.searchEndTime
|
||||
// ? [tableStore.table.params.searchBeginTime, tableStore.table.params.searchEndTime]
|
||||
// : prop.timeValue
|
||||
// )
|
||||
// tableStore.table.params.searchBeginTime = time[0]
|
||||
// tableStore.table.params.searchEndTime = time[1]
|
||||
|
||||
// 只有当 lineList 已加载且有数据时才设置默认 lineId
|
||||
if (!tableStore.table.params.lineId && lineList.value && lineList.value.length > 0) {
|
||||
tableStore.table.params.lineId = lineList.value[0].lineId
|
||||
@@ -393,22 +378,6 @@ watch(
|
||||
)
|
||||
|
||||
onMounted(() => {
|
||||
// if (fullscreen.value) {
|
||||
// if (prop.interval == 4 || prop.interval == 5) {
|
||||
// const time = getTime(
|
||||
// prop.interval ?? 0,
|
||||
// prop.timeKey,
|
||||
// tableStore.table.params.searchBeginTime && tableStore.table.params.searchEndTime
|
||||
// ? [tableStore.table.params.searchBeginTime, tableStore.table.params.searchEndTime]
|
||||
// : prop.timeValue
|
||||
// )
|
||||
// tableStore.table.params.searchBeginTime = time[0]
|
||||
// tableStore.table.params.searchEndTime = time[1]
|
||||
// TableHeaderRef.value.setTimeInterval(prop.timeValue)
|
||||
// } else {
|
||||
// TableHeaderRef.value.setInterval(5)
|
||||
// }
|
||||
// }
|
||||
initLineList().then(() => {
|
||||
initCode()
|
||||
})
|
||||
@@ -428,29 +397,27 @@ const setTime = () => {
|
||||
? [tableStore.table.params.searchBeginTime, tableStore.table.params.searchEndTime]
|
||||
: prop.timeValue
|
||||
)
|
||||
console.log("🚀 ~ setTime ~ time:", time)
|
||||
|
||||
if (Array.isArray(time)) {
|
||||
tableStore.table.params.searchBeginTime = time[0]
|
||||
tableStore.table.params.searchEndTime = time[1]
|
||||
TableHeaderRef.value?.setInterval(time[2] - 0)
|
||||
TableHeaderRef.value?.setTimeInterval([time[0], time[1]])
|
||||
} else {
|
||||
console.warn('获取时间失败,time 不是一个有效数组')
|
||||
}
|
||||
}
|
||||
|
||||
watch(
|
||||
() => prop.timeValue,
|
||||
(newVal, oldVal) => {
|
||||
// 当外部时间值变化时,更新表格的时间参数
|
||||
// if (newVal && (!oldVal || newVal[0] !== oldVal[0] || newVal[1] !== oldVal[1])) {
|
||||
tableStore.index()
|
||||
|
||||
// }
|
||||
},
|
||||
{
|
||||
deep: true
|
||||
}
|
||||
)
|
||||
|
||||
const addMenu = () => {}
|
||||
</script>
|
||||
<style lang="scss" scoped>
|
||||
// :deep(.el-select) {
|
||||
|
||||
@@ -352,8 +352,9 @@ export function getTimeOfTheMonth(key: any): [string, string] {
|
||||
const dayOfWeek = now.getDay() // 0是周日
|
||||
const diff = now.getDate() - dayOfWeek + (dayOfWeek === 0 ? -6 : 1) // 调整为周一
|
||||
const weekStart = new Date(year, month, diff)
|
||||
console.log("🚀 ~ getTimeOfTheMonth ~ weekStart:", weekStart)
|
||||
return [formatDate(weekStart, 'YYYY-MM-DD'), formatDate(now, 'YYYY-MM-DD')]
|
||||
const weekEnd = new Date(weekStart)
|
||||
weekEnd.setDate(weekEnd.getDate() + 6)
|
||||
return [formatDate(weekStart, 'YYYY-MM-DD'), formatDate(weekEnd, 'YYYY-MM-DD')]
|
||||
|
||||
case '5': // 日
|
||||
return [formatDate(now, 'YYYY-MM-DD'), formatDate(now, 'YYYY-MM-DD')]
|
||||
@@ -366,33 +367,19 @@ export function getTimeOfTheMonth(key: any): [string, string] {
|
||||
/**
|
||||
* 获取当月时间
|
||||
* @param interval 组件外部时间 1 年 2 季 3 月 4 周 5 日
|
||||
* @param timeList 组件勾选时间 []
|
||||
* @param timeList 驾驶舱里面组件勾选时间 []
|
||||
* @param externalTime //外部传入时间
|
||||
* @param fullscreen // 全屏是否全屏
|
||||
*/
|
||||
export function getTime(interval: number | 3, timeList: any , externalTime: any, ) {
|
||||
console.log("🚀 ~ getTime ~ timeList:", timeList)
|
||||
export function getTime(interval: number | 3, timeList: any, externalTime: any) {
|
||||
console.log('🚀 ~ getTime ~ timeList:', timeList)
|
||||
// 1、先匹配时间
|
||||
// 检查 interval 是否在 timeList 中
|
||||
if (timeList && timeList.includes(interval.toString())) {
|
||||
return [externalTime[0], externalTime[1], interval]
|
||||
|
||||
// 匹配上了,返回外部传入时间 externalTime
|
||||
// if (externalTime && externalTime.length >= 2) {
|
||||
// return [externalTime[0], externalTime[1]]
|
||||
// } else {
|
||||
// // 如果 externalTime 无效,回退到默认逻辑
|
||||
// return getTimeOfTheMonth(interval.toString())
|
||||
// }
|
||||
} else {
|
||||
return [...getTimeOfTheMonth(timeList[0]), timeList[0], ]
|
||||
// 没有匹配上,返回 timeList 中最后一项的时间范围
|
||||
// if (timeList && timeList.length > 0) {
|
||||
// const lastItem = timeList[timeList.length - 1]
|
||||
// return getTimeOfTheMonth(lastItem)
|
||||
// } else {
|
||||
// // 如果 timeList 为空,使用 interval 参数
|
||||
// return getTimeOfTheMonth(interval.toString())
|
||||
// }
|
||||
if (timeList && timeList.length > 0) {
|
||||
return [...getTimeOfTheMonth(timeList[0]), timeList[0]]
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user