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