时间选择范围问题修复

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> <template>
<view class="time-range"> <view class="time-range">
<uni-datetime-picker v-model="dateRange" type="daterange" start="2000-01-01" :end="defaultDateRange[1]" <uni-datetime-picker v-model="dateRange" type="daterange" :end="defaultDateRange[1]" :clear-icon="false"
:clear-icon="false" rangeSeparator="至" @change="changeTime" /> rangeSeparator="至" @change="changeTime" />
<view class="btns-container"> <view class="btns-container">
<button size="mini" class="small" :disabled="loading" @click="reset">重置</button> <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" <button type="primary" class="large" size="mini" :disabled="loading"
@click="timeLine('before')">上一时段</button> @click="timeLine('before')">上一时段</button>
<button type="primary" class="large" size="mini" @click="timeLine('next')" <button type="primary" class="large" size="mini" @click="timeLine('next')"
@ -41,6 +41,7 @@
}, },
changeTime(val) { changeTime(val) {
this.dateRange = val || [] this.dateRange = val || []
this.$emit('updateDate', this.dateRange)
}, },
showBtnLoading(status) { showBtnLoading(status) {
this.loading = 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> <template>
<uni-popup ref="popup" type="center" @maskClick="show = false"> <uni-popup ref="popup" type="center" @maskClick="show = false">
<view class="chart-popup"> <view class="chart-popup">
<uni-datetime-picker v-model="range" type="daterange" start="2000-01-01" :end="end" rangeSeparator="至" <uni-datetime-picker v-model="range" type="daterange" :end="end" rangeSeparator="至" @change="changeTime"
@change="changeTime" /> style="margin-bottom: 10px;" />
<view class="button-group" style="text-align: center;margin-top:20px;"> <!-- <view class="button-group" style="text-align: center;margin-top:20px;">
<button type="default" size="mini" @click="onReset">重置</button> <button type="default" size="mini" @click="onReset">重置</button>
<button type="primary" size="mini" @click="onSearch" style="margin-left: 20px;">搜索</button> <button type="primary" size="mini" @click="onSearch" style="margin-left: 20px;">搜索</button>
</view> </view> -->
<view class="chart-container"> <view class="chart-container">
<qiun-data-charts type="line" :reload="show" :chartData="chartsData" :canvas2d="true" <qiun-data-charts type="line" :reload="show" :chartData="chartsData" :optsWatch='false'
canvasId="scrollcolumnid" :optsWatch='false' :inScrollView="true" :pageScrollTop="pageScrollTop" :inScrollView="true" :pageScrollTop="pageScrollTop" :opts="options" :ontouch="true" />
:opts="options" :ontouch="true" />
</view> </view>
</view> </view>
</uni-popup> </uni-popup>
@ -44,7 +43,7 @@
}, },
show: false, show: false,
range: [], range: [],
end: "", end: Date.now(),
siteId: '', siteId: '',
deviceId: '', deviceId: '',
clusterDeviceId: '', clusterDeviceId: '',
@ -74,6 +73,7 @@
}, },
changeTime(val) { changeTime(val) {
this.range = val || [] this.range = val || []
this.getData()
}, },
onReset() { onReset() {
this.range = [] this.range = []
@ -149,13 +149,6 @@
console.log('this.chartsData', this.chartsData) 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> </script>

View File

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

View File

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