时间选择范围问题修复

This commit is contained in:
白菜
2025-08-16 23:15:33 +08:00
parent ffefc21d96
commit 5ea121abf0
5 changed files with 438 additions and 456 deletions

View File

@ -1,10 +1,10 @@
<template>
<view class="time-range">
<uni-datetime-picker v-model="dateRange" type="daterange" start="2000-01-01" :end="defaultDateRange[1]"
:clear-icon="false" rangeSeparator="至" @change="changeTime" />
<uni-datetime-picker v-model="dateRange" type="daterange" :end="defaultDateRange[1]" :clear-icon="false"
rangeSeparator="至" @change="changeTime" />
<view class="btns-container">
<button size="mini" class="small" :disabled="loading" @click="reset">重置</button>
<button type="primary" class="small" size="mini" :disabled="loading" @click="search">搜索</button>
<!-- <button type="primary" class="small" size="mini" :disabled="loading" @click="search">搜索</button> -->
<button type="primary" class="large" size="mini" :disabled="loading"
@click="timeLine('before')">上一时段</button>
<button type="primary" class="large" size="mini" @click="timeLine('next')"
@ -41,6 +41,7 @@
},
changeTime(val) {
this.dateRange = val || []
this.$emit('updateDate', this.dateRange)
},
showBtnLoading(status) {
this.loading = status

View File

@ -1,11 +0,0 @@
<template>
<view class="">
一周功率曲线
</view>
</template>
<script>
</script>
<style>
</style>

View File

@ -1,16 +1,15 @@
<template>
<uni-popup ref="popup" type="center" @maskClick="show = false">
<view class="chart-popup">
<uni-datetime-picker v-model="range" type="daterange" start="2000-01-01" :end="end" rangeSeparator="至"
@change="changeTime" />
<view class="button-group" style="text-align: center;margin-top:20px;">
<uni-datetime-picker v-model="range" type="daterange" :end="end" rangeSeparator="至" @change="changeTime"
style="margin-bottom: 10px;" />
<!-- <view class="button-group" style="text-align: center;margin-top:20px;">
<button type="default" size="mini" @click="onReset">重置</button>
<button type="primary" size="mini" @click="onSearch" style="margin-left: 20px;">搜索</button>
</view>
</view> -->
<view class="chart-container">
<qiun-data-charts type="line" :reload="show" :chartData="chartsData" :canvas2d="true"
canvasId="scrollcolumnid" :optsWatch='false' :inScrollView="true" :pageScrollTop="pageScrollTop"
:opts="options" :ontouch="true" />
<qiun-data-charts type="line" :reload="show" :chartData="chartsData" :optsWatch='false'
:inScrollView="true" :pageScrollTop="pageScrollTop" :opts="options" :ontouch="true" />
</view>
</view>
</uni-popup>
@ -44,7 +43,7 @@
},
show: false,
range: [],
end: "",
end: Date.now(),
siteId: '',
deviceId: '',
clusterDeviceId: '',
@ -74,6 +73,7 @@
},
changeTime(val) {
this.range = val || []
this.getData()
},
onReset() {
this.range = []
@ -149,13 +149,6 @@
console.log('this.chartsData', this.chartsData)
}
},
mounted() {
const now = new Date(),
year = now.getFullYear(),
month = now.getMonth() + 1,
day = now.getDate()
this.end = year + '-' + month + '-' + day
}
}
</script>

View File

@ -42,8 +42,7 @@
<date-range-select ref="weekChartDateRangeSelect" @updateDate="updateWeekChartDate" />
<view style="width:100%;height: 250px;">
<qiun-data-charts type="line" :chartData="weekChartData" :optsWatch='false' :inScrollView="true"
:canvas2d="true" canvasId="scrollcolumnid" :pageScrollTop="pageScrollTop" :opts="options"
:ontouch="true" />
:pageScrollTop="pageScrollTop" :opts="options" :ontouch="true" />
</view>
</uni-section>
<!-- 当日功率曲线 uchart的组件最好放在同级-->
@ -51,15 +50,13 @@
<date-range-select ref="activeChartDateRangeSelect" @updateDate="updateActiveChartDate" />
<view style="width:100%;height: 250px;">
<qiun-data-charts type="line" :chartData="activeChartData" :optsWatch='false' :inScrollView="true"
:canvas2d="true" canvasId="scrollcolumnid" :pageScrollTop="pageScrollTop" :opts="options"
:ontouch="true" />
:pageScrollTop="pageScrollTop" :opts="options" :ontouch="true" />
</view>
</uni-section>
</view>
</template>
<script>
import WeekChart from './WeekChart.vue'
import DateRangeSelect from './DateRangeSelect.vue'
import {
getAllSites,
@ -68,7 +65,6 @@
} from '@/api/ems/site.js'
export default {
components: {
WeekChart,
DateRangeSelect
},
data() {

View File

@ -146,11 +146,14 @@ class Calendar {
year: dateObj.year,
date: i,
multiple: this.range ? checked : false,
beforeMultiple: this.isLogicBefore(currentDate, this.multipleStatus.before, this.multipleStatus.after),
afterMultiple: this.isLogicAfter(currentDate, this.multipleStatus.before, this.multipleStatus.after),
beforeMultiple: this.isLogicBefore(currentDate, this.multipleStatus.before, this
.multipleStatus.after),
afterMultiple: this.isLogicAfter(currentDate, this.multipleStatus.before, this
.multipleStatus.after),
month: dateObj.month,
disable: (this.startDate && !dateCompare(this.startDate, currentDate)) || (this.endDate && !dateCompare(
currentDate, this.endDate)),
disable: (this.startDate && !dateCompare(this.startDate, currentDate)) || (this.endDate && !
dateCompare(
currentDate, this.endDate)),
isToday,
userChecked: false,
extraInfo: info
@ -389,8 +392,8 @@ function getDefaultSecond(hideSecond) {
}
function dateCompare(startDate, endDate) {
startDate = new Date(fixIosDateFormat(startDate))
endDate = new Date(fixIosDateFormat(endDate))
startDate = new Date(fixIosDateFormat(startDate && typeof startDate === 'string' ? startDate.trim() : startDate))
endDate = new Date(fixIosDateFormat(endDate && typeof endDate === 'string' ? endDate.trim() : endDate))
return startDate <= endDate
}