微调
This commit is contained in:
@@ -141,7 +141,6 @@ const echartList = ref()
|
|||||||
const headerHeight = ref(57)
|
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
|
||||||
|
|
||||||
if (datePickerValue && datePickerValue.timeValue) {
|
if (datePickerValue && datePickerValue.timeValue) {
|
||||||
// 更新时间参数
|
// 更新时间参数
|
||||||
tableStore.table.params.searchBeginTime = datePickerValue.timeValue[0]
|
tableStore.table.params.searchBeginTime = datePickerValue.timeValue[0]
|
||||||
@@ -265,6 +264,7 @@ const initCode = () => {
|
|||||||
tableStore.table.params.power = powerList.value[0].id
|
tableStore.table.params.power = powerList.value[0].id
|
||||||
tableStore.table.params.indicator = indicatorList.value[0].id
|
tableStore.table.params.indicator = indicatorList.value[0].id
|
||||||
nextTick(() => {
|
nextTick(() => {
|
||||||
|
// setTime()
|
||||||
tableStore.index()
|
tableStore.index()
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
@@ -278,18 +278,19 @@ const tableStore: any = new TableStore({
|
|||||||
exportName: '主要监测点列表',
|
exportName: '主要监测点列表',
|
||||||
column: [],
|
column: [],
|
||||||
beforeSearchFun: () => {
|
beforeSearchFun: () => {
|
||||||
|
setTime()
|
||||||
// 设置时间参数
|
// 设置时间参数
|
||||||
// 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]
|
||||||
const time = getTime(
|
// const time = getTime(
|
||||||
prop.interval ?? 0,
|
// prop.interval ?? 0,
|
||||||
prop.timeKey,
|
// prop.timeKey,
|
||||||
tableStore.table.params.searchBeginTime && tableStore.table.params.searchEndTime
|
// tableStore.table.params.searchBeginTime && tableStore.table.params.searchEndTime
|
||||||
? [tableStore.table.params.searchBeginTime, tableStore.table.params.searchEndTime]
|
// ? [tableStore.table.params.searchBeginTime, tableStore.table.params.searchEndTime]
|
||||||
: prop.timeValue
|
// : prop.timeValue
|
||||||
)
|
// )
|
||||||
tableStore.table.params.searchBeginTime = time[0]
|
// tableStore.table.params.searchBeginTime = time[0]
|
||||||
tableStore.table.params.searchEndTime = time[1]
|
// 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) {
|
||||||
@@ -392,41 +393,57 @@ watch(
|
|||||||
)
|
)
|
||||||
|
|
||||||
onMounted(() => {
|
onMounted(() => {
|
||||||
if (fullscreen.value) {
|
// if (fullscreen.value) {
|
||||||
if (prop.interval == 4 || prop.interval == 5) {
|
// if (prop.interval == 4 || prop.interval == 5) {
|
||||||
const time = getTime(
|
// const time = getTime(
|
||||||
prop.interval ?? 0,
|
// prop.interval ?? 0,
|
||||||
prop.timeKey,
|
// prop.timeKey,
|
||||||
tableStore.table.params.searchBeginTime && tableStore.table.params.searchEndTime
|
// tableStore.table.params.searchBeginTime && tableStore.table.params.searchEndTime
|
||||||
? [tableStore.table.params.searchBeginTime, tableStore.table.params.searchEndTime]
|
// ? [tableStore.table.params.searchBeginTime, tableStore.table.params.searchEndTime]
|
||||||
: prop.timeValue
|
// : prop.timeValue
|
||||||
)
|
// )
|
||||||
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.setTimeInterval(prop.timeValue)
|
||||||
} else {
|
// } else {
|
||||||
TableHeaderRef.value.setInterval(5)
|
// TableHeaderRef.value.setInterval(5)
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
initLineList().then(() => {
|
initLineList().then(() => {
|
||||||
initCode()
|
initCode()
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
watch(
|
watch(
|
||||||
() => prop.timeKey,
|
() => prop.timeKey,
|
||||||
val => {
|
val => {
|
||||||
tableStore.index()
|
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
|
||||||
|
)
|
||||||
|
console.log("🚀 ~ setTime ~ time:", 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]])
|
||||||
|
}
|
||||||
|
|
||||||
watch(
|
watch(
|
||||||
() => prop.timeValue,
|
() => prop.timeValue,
|
||||||
(newVal, oldVal) => {
|
(newVal, oldVal) => {
|
||||||
// 当外部时间值变化时,更新表格的时间参数
|
// 当外部时间值变化时,更新表格的时间参数
|
||||||
if (newVal && (!oldVal || newVal[0] !== oldVal[0] || newVal[1] !== oldVal[1])) {
|
// if (newVal && (!oldVal || newVal[0] !== oldVal[0] || newVal[1] !== oldVal[1])) {
|
||||||
tableStore.table.params.searchBeginTime = newVal[0]
|
tableStore.index()
|
||||||
tableStore.table.params.searchEndTime = newVal[1]
|
|
||||||
tableStore.index()
|
// }
|
||||||
}
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
deep: true
|
deep: true
|
||||||
|
|||||||
@@ -101,6 +101,7 @@ const filteredTimeOptions = computed(() => {
|
|||||||
return timeOptions.value.filter((option: any) =>
|
return timeOptions.value.filter((option: any) =>
|
||||||
props.timeKeyList.includes(option.value.toString())
|
props.timeKeyList.includes(option.value.toString())
|
||||||
)
|
)
|
||||||
|
|
||||||
})
|
})
|
||||||
|
|
||||||
onMounted(() => {
|
onMounted(() => {
|
||||||
|
|||||||
@@ -352,6 +352,7 @@ 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)
|
||||||
return [formatDate(weekStart, 'YYYY-MM-DD'), formatDate(now, 'YYYY-MM-DD')]
|
return [formatDate(weekStart, 'YYYY-MM-DD'), formatDate(now, 'YYYY-MM-DD')]
|
||||||
|
|
||||||
case '5': // 日
|
case '5': // 日
|
||||||
@@ -367,26 +368,31 @@ 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 // 全屏是否全屏
|
||||||
*/
|
*/
|
||||||
export function getTime(interval: number, timeList: any, externalTime: any) {
|
export function getTime(interval: number | 3, timeList: any , externalTime: any, ) {
|
||||||
|
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]
|
||||||
|
|
||||||
// 匹配上了,返回外部传入时间 externalTime
|
// 匹配上了,返回外部传入时间 externalTime
|
||||||
if (externalTime && externalTime.length >= 2) {
|
// if (externalTime && externalTime.length >= 2) {
|
||||||
return [externalTime[0], externalTime[1]]
|
// return [externalTime[0], externalTime[1]]
|
||||||
} else {
|
// } else {
|
||||||
// 如果 externalTime 无效,回退到默认逻辑
|
// // 如果 externalTime 无效,回退到默认逻辑
|
||||||
return getTimeOfTheMonth(interval.toString())
|
// return getTimeOfTheMonth(interval.toString())
|
||||||
}
|
// }
|
||||||
} else {
|
} else {
|
||||||
|
return [...getTimeOfTheMonth(timeList[0]), timeList[0], ]
|
||||||
// 没有匹配上,返回 timeList 中最后一项的时间范围
|
// 没有匹配上,返回 timeList 中最后一项的时间范围
|
||||||
if (timeList && timeList.length > 0) {
|
// if (timeList && timeList.length > 0) {
|
||||||
const lastItem = timeList[timeList.length - 1]
|
// const lastItem = timeList[timeList.length - 1]
|
||||||
return getTimeOfTheMonth(lastItem)
|
// return getTimeOfTheMonth(lastItem)
|
||||||
} else {
|
// } else {
|
||||||
// 如果 timeList 为空,使用 interval 参数
|
// // 如果 timeList 为空,使用 interval 参数
|
||||||
return getTimeOfTheMonth(interval.toString())
|
// return getTimeOfTheMonth(interval.toString())
|
||||||
}
|
// }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user