日历表格调整
This commit is contained in:
@@ -1,7 +1,14 @@
|
|||||||
<template>
|
<template>
|
||||||
<div>
|
<div>
|
||||||
<!--指标越限明细 -->
|
<!--指标越限明细 -->
|
||||||
<TableHeader :showReset="false" @selectChange="selectChange" datePicker v-if="fullscreen"></TableHeader>
|
<TableHeader
|
||||||
|
:showReset="false"
|
||||||
|
ref="TableHeaderRef"
|
||||||
|
@selectChange="selectChange"
|
||||||
|
datePicker
|
||||||
|
v-if="fullscreen"
|
||||||
|
:timeCacheFlag="false"
|
||||||
|
></TableHeader>
|
||||||
<el-calendar
|
<el-calendar
|
||||||
v-model="value"
|
v-model="value"
|
||||||
:style="{
|
:style="{
|
||||||
@@ -51,6 +58,8 @@ const headerHeight = ref(57)
|
|||||||
|
|
||||||
const list = ref()
|
const list = ref()
|
||||||
|
|
||||||
|
const TableHeaderRef = ref()
|
||||||
|
|
||||||
dayjs.en.weekStart = 1 //设置日历的周起始日为星期一
|
dayjs.en.weekStart = 1 //设置日历的周起始日为星期一
|
||||||
const value = ref(new Date())
|
const value = ref(new Date())
|
||||||
|
|
||||||
@@ -82,46 +91,18 @@ const getTextForDate = (date: string) => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const tableStore: any = new TableStore({
|
const tableStore: any = new TableStore({
|
||||||
// url: '/user-boot/role/selectRoleDetail?id=0',
|
|
||||||
url: '/harmonic-boot/limitRateDetailD/limitCalendarData',
|
url: '/harmonic-boot/limitRateDetailD/limitCalendarData',
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
showPage: false,
|
showPage: false,
|
||||||
column: [],
|
column: [],
|
||||||
beforeSearchFun: () => {
|
beforeSearchFun: () => {
|
||||||
tableStore.table.params.searchBeginTime = tableStore.table.params.searchBeginTime || prop.timeValue?.[0]
|
if (!fullscreen.value && prop.timeValue && Array.isArray(prop.timeValue)) {
|
||||||
tableStore.table.params.searchEndTime = tableStore.table.params.searchEndTime || prop.timeValue?.[1]
|
tableStore.table.params.searchBeginTime = prop.timeValue[0]
|
||||||
|
tableStore.table.params.searchEndTime = prop.timeValue[1]
|
||||||
|
}
|
||||||
},
|
},
|
||||||
loadCallback: () => {
|
loadCallback: () => {
|
||||||
value.value = tableStore.table.params.searchBeginTime
|
value.value = tableStore.table.params.searchBeginTime
|
||||||
// 将后端返回的数据整合到 list 中
|
|
||||||
// tableStore.table.data = [
|
|
||||||
// {
|
|
||||||
// "time": "2025-11-13",
|
|
||||||
// "items": [
|
|
||||||
// "闪变越限",
|
|
||||||
// "谐波电流越限"
|
|
||||||
// ],
|
|
||||||
// "status": 1
|
|
||||||
// },
|
|
||||||
// {
|
|
||||||
// "time": "2025-11-14",
|
|
||||||
// "items": [
|
|
||||||
// "频率偏差越限",
|
|
||||||
// "三相电压不平衡越限",
|
|
||||||
// "谐波电压越限",
|
|
||||||
// "谐波电流越限",
|
|
||||||
// "频率偏差越限",
|
|
||||||
// "三相电压不平衡越限",
|
|
||||||
// "谐波电压越限",
|
|
||||||
// "谐波电流越限",
|
|
||||||
// "频率偏差越限",
|
|
||||||
// "三相电压不平衡越限",
|
|
||||||
// "谐波电压越限",
|
|
||||||
// "谐波电流越限"
|
|
||||||
// ],
|
|
||||||
// "status": 2
|
|
||||||
// }
|
|
||||||
// ]
|
|
||||||
if (tableStore.table.data && tableStore.table.data.length > 0) {
|
if (tableStore.table.data && tableStore.table.data.length > 0) {
|
||||||
list.value = tableStore.table.data.map((item: any) => {
|
list.value = tableStore.table.data.map((item: any) => {
|
||||||
// 将 items 数组转换为带换行的文本
|
// 将 items 数组转换为带换行的文本
|
||||||
@@ -162,7 +143,15 @@ const setBackground = (value: string) => {
|
|||||||
provide('tableStore', tableStore)
|
provide('tableStore', tableStore)
|
||||||
|
|
||||||
onMounted(() => {
|
onMounted(() => {
|
||||||
|
nextTick(() => {
|
||||||
|
if (TableHeaderRef.value && typeof TableHeaderRef.value.setDatePicker === 'function') {
|
||||||
|
TableHeaderRef.value.setDatePicker([{ label: '月份', value: 3 }])
|
||||||
|
}
|
||||||
|
if (fullscreen.value) {
|
||||||
|
TableHeaderRef.value.setInterval(3)
|
||||||
|
}
|
||||||
tableStore.index()
|
tableStore.index()
|
||||||
|
})
|
||||||
})
|
})
|
||||||
watch(
|
watch(
|
||||||
() => prop.timeKey,
|
() => prop.timeKey,
|
||||||
@@ -172,20 +161,22 @@ watch(
|
|||||||
)
|
)
|
||||||
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.table.params.searchBeginTime = newVal[0]
|
||||||
tableStore.table.params.searchEndTime = newVal[1]
|
// tableStore.table.params.searchEndTime = newVal[1]
|
||||||
|
// tableStore.index()
|
||||||
|
// }
|
||||||
|
// },
|
||||||
|
val => {
|
||||||
tableStore.index()
|
tableStore.index()
|
||||||
}
|
|
||||||
},
|
},
|
||||||
|
|
||||||
{
|
{
|
||||||
deep: true
|
deep: true
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|
||||||
const addMenu = () => {}
|
|
||||||
</script>
|
</script>
|
||||||
<style lang="scss" scoped>
|
<style lang="scss" scoped>
|
||||||
:deep(.el-calendar) {
|
:deep(.el-calendar) {
|
||||||
|
|||||||
@@ -7,6 +7,7 @@
|
|||||||
@selectChange="selectChange"
|
@selectChange="selectChange"
|
||||||
datePicker
|
datePicker
|
||||||
v-if="fullscreen"
|
v-if="fullscreen"
|
||||||
|
:timeCacheFlag="false"
|
||||||
></TableHeader>
|
></TableHeader>
|
||||||
<el-calendar
|
<el-calendar
|
||||||
v-model="value"
|
v-model="value"
|
||||||
@@ -14,9 +15,16 @@
|
|||||||
height: `calc(${prop.height} - ${headerHeight}px + ${fullscreen ? 0 : 56}px )`,
|
height: `calc(${prop.height} - ${headerHeight}px + ${fullscreen ? 0 : 56}px )`,
|
||||||
overflow: 'auto'
|
overflow: 'auto'
|
||||||
}"
|
}"
|
||||||
|
v-loading="tableStore.table.loading"
|
||||||
>
|
>
|
||||||
<template #date-cell="{ data }">
|
<template #date-cell="{ data }">
|
||||||
<div style="height: 100%; padding: 8px" :style="{ background: setBackground(data.day) }">
|
<div
|
||||||
|
style="padding: 8px"
|
||||||
|
:style="{
|
||||||
|
background: setBackground(data.day),
|
||||||
|
height: `calc((${prop.height} - 100px - ${headerHeight}px + ${fullscreen ? 0 : 56}px) / 5 )`
|
||||||
|
}"
|
||||||
|
>
|
||||||
<p :class="data.isSelected ? 'is-selected' : ''">
|
<p :class="data.isSelected ? 'is-selected' : ''">
|
||||||
{{ data.day.split('-').slice(2).join('-') }}
|
{{ data.day.split('-').slice(2).join('-') }}
|
||||||
</p>
|
</p>
|
||||||
@@ -31,7 +39,7 @@
|
|||||||
</template>
|
</template>
|
||||||
<div
|
<div
|
||||||
style="text-decoration: underline"
|
style="text-decoration: underline"
|
||||||
:style="{ height: `calc(${prop.height} / 5 - 40px)`, overflow: 'auto' }"
|
class="details"
|
||||||
v-for="item in list?.filter((item:any) => item.name == data.day)"
|
v-for="item in list?.filter((item:any) => item.name == data.day)"
|
||||||
>
|
>
|
||||||
<div @click="descentClick">电压暂降:{{ item.eventDown || 0 }}</div>
|
<div @click="descentClick">电压暂降:{{ item.eventDown || 0 }}</div>
|
||||||
@@ -49,12 +57,9 @@
|
|||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import { ref, onMounted, provide, reactive, watch, nextTick } from 'vue'
|
import { ref, onMounted, provide, reactive, watch, nextTick } from 'vue'
|
||||||
import TableStore from '@/utils/tableStore'
|
import TableStore from '@/utils/tableStore'
|
||||||
import { getTimeOfTheMonth } from '@/utils/formatTime'
|
|
||||||
import { dayjs } from 'element-plus'
|
import { dayjs } from 'element-plus'
|
||||||
import TransientList from './components/transientList.vue'
|
import TransientList from './components/transientList.vue'
|
||||||
import TableHeader from '@/components/table/header/index.vue'
|
import TableHeader from '@/components/table/header/index.vue'
|
||||||
import { useRoute } from 'vue-router'
|
|
||||||
import { useTimeCacheStore } from '@/stores/timeCache'
|
|
||||||
|
|
||||||
const prop = defineProps({
|
const prop = defineProps({
|
||||||
w: { type: [String, Number] },
|
w: { type: [String, Number] },
|
||||||
@@ -79,11 +84,11 @@ const hasEventData = (day: string) => {
|
|||||||
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]
|
||||||
// tableStore.table.params.searchEndTime = datePickerValue.timeValue[1]
|
tableStore.table.params.searchEndTime = datePickerValue.timeValue[1]
|
||||||
// }
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// 计算是否全屏展示
|
// 计算是否全屏展示
|
||||||
@@ -113,13 +118,14 @@ const tableStore: any = new TableStore({
|
|||||||
column: [],
|
column: [],
|
||||||
|
|
||||||
beforeSearchFun: () => {
|
beforeSearchFun: () => {
|
||||||
if (prop.timeValue && Array.isArray(prop.timeValue)) {
|
if (!fullscreen.value && prop.timeValue && Array.isArray(prop.timeValue)) {
|
||||||
tableStore.table.params.searchBeginTime = prop.timeValue[0]
|
tableStore.table.params.searchBeginTime = prop.timeValue[0]
|
||||||
tableStore.table.params.searchEndTime = prop.timeValue[1]
|
tableStore.table.params.searchEndTime = prop.timeValue[1]
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
loadCallback: () => {
|
loadCallback: () => {
|
||||||
|
value.value = tableStore.table.params.searchBeginTime
|
||||||
list.value = tableStore.table.data
|
list.value = tableStore.table.data
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
@@ -182,20 +188,25 @@ const descentClick = () => {
|
|||||||
</script>
|
</script>
|
||||||
<style lang="scss" scoped>
|
<style lang="scss" scoped>
|
||||||
:deep(.el-calendar) {
|
:deep(.el-calendar) {
|
||||||
.el-calendar__header {
|
.el-calendar__button-group {
|
||||||
display: none;
|
display: none;
|
||||||
}
|
}
|
||||||
.el-calendar__body {
|
.el-calendar__body {
|
||||||
padding: 0px !important;
|
padding: 0px !important;
|
||||||
height: 100%;
|
height: calc(100% - 46px);
|
||||||
.el-calendar-table {
|
.el-calendar-table {
|
||||||
height: 100%;
|
height: 100%;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
.el-calendar-day {
|
.el-calendar-day {
|
||||||
|
// height: calc(912px / 5 );
|
||||||
height: 100%;
|
height: 100%;
|
||||||
padding: 0px;
|
padding: 0px;
|
||||||
overflow: hidden;
|
overflow: hidden;
|
||||||
|
.details {
|
||||||
|
height: calc(100% - 20px);
|
||||||
|
overflow-y: auto;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
.el-calendar-table__row {
|
.el-calendar-table__row {
|
||||||
.next {
|
.next {
|
||||||
|
|||||||
@@ -88,6 +88,7 @@ interface Props {
|
|||||||
theCurrentTime?: boolean //控制时间前3天展示上个月时间
|
theCurrentTime?: boolean //控制时间前3天展示上个月时间
|
||||||
showReset?: boolean //是否显示重置
|
showReset?: boolean //是否显示重置
|
||||||
showExport?: boolean //导出控制
|
showExport?: boolean //导出控制
|
||||||
|
timeCacheFlag?: boolean //是否取缓存时间
|
||||||
}
|
}
|
||||||
|
|
||||||
const props = withDefaults(defineProps<Props>(), {
|
const props = withDefaults(defineProps<Props>(), {
|
||||||
@@ -97,7 +98,8 @@ const props = withDefaults(defineProps<Props>(), {
|
|||||||
nextFlag: false,
|
nextFlag: false,
|
||||||
theCurrentTime: true,
|
theCurrentTime: true,
|
||||||
showReset: true,
|
showReset: true,
|
||||||
showExport: false
|
showExport: false,
|
||||||
|
timeCacheFlag: true
|
||||||
})
|
})
|
||||||
|
|
||||||
// 处理 DatePicker 值变化事件
|
// 处理 DatePicker 值变化事件
|
||||||
@@ -134,7 +136,7 @@ onMounted(() => {
|
|||||||
if (props.datePicker && datePickerRef.value) {
|
if (props.datePicker && datePickerRef.value) {
|
||||||
// 从缓存中获取值并设置
|
// 从缓存中获取值并设置
|
||||||
const cached = timeCacheStore.getCache(route.path)
|
const cached = timeCacheStore.getCache(route.path)
|
||||||
if (cached) {
|
if (props.timeCacheFlag && cached) {
|
||||||
if (cached.interval !== undefined) {
|
if (cached.interval !== undefined) {
|
||||||
datePickerRef.value.setInterval(cached.interval)
|
datePickerRef.value.setInterval(cached.interval)
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user