时间选择范围上下时段
This commit is contained in:
@ -62,15 +62,17 @@ export default {
|
||||
this.$emit('updateDate',this.dateRange)
|
||||
},
|
||||
timeLine(type){
|
||||
if(!this.dateRange || !this.dateRange[0] || !this.dateRange[1]) return
|
||||
const nowStartTimes = new Date(this.dateRange[0]).getTime(),nowEndTimes = new Date(this.dateRange[1]).getTime(),maxTime = new Date(this.defaultDateRange[1]).getTime()
|
||||
const nowDis = nowEndTimes - nowStartTimes//用户当前选择时间差 可能=0
|
||||
//baseTime,maxTime 毫秒数
|
||||
let baseTime = type === 'before' ? new Date(this.dateRange[0]).getTime() - ( 24 * 60 * 60 * 1000) :new Date(this.dateRange[1]).getTime() + ( 24 * 60 * 60 * 1000) ,
|
||||
maxTime = new Date(this.defaultDateRange[1]).getTime()
|
||||
//updateTime 毫秒数
|
||||
let updateTime = type === 'before' ? baseTime - 7 * 24 * 60 * 60 * 1000 : baseTime + 7 * 24 * 60 * 60 * 1000
|
||||
if(type === 'next' && updateTime >= maxTime) updateTime = maxTime
|
||||
const start = formatDate(type === 'before' ? updateTime : baseTime)
|
||||
const end = formatDate(type === 'before' ? baseTime : updateTime)
|
||||
this.dateRange = [start,end]
|
||||
const baseDis = this.dataUnit === 3 ? 24 * 60 * 60 * 1000 :this.dataUnit === 2 ? 60 * 60 * 1000 : 60 * 1000
|
||||
const calcDis = nowDis === 0 ? baseDis : nowDis
|
||||
let start = type === 'before' ? nowStartTimes - calcDis : nowStartTimes + calcDis
|
||||
start = Math.min(start,maxTime)
|
||||
let end = type === 'before' ? nowEndTimes - calcDis : nowEndTimes + calcDis
|
||||
end = Math.min(end,maxTime)
|
||||
this.dateRange = [formatDate(start,this.dataUnit !== 3),formatDate(end,this.dataUnit !== 3)]
|
||||
this.$emit('updateDate',this.dateRange)
|
||||
},
|
||||
}
|
||||
|
||||
@ -32,7 +32,7 @@ export default {
|
||||
return this.dataUnit === 3 ? 'daterange' : 'datetimerange'
|
||||
},
|
||||
valueFormat(){
|
||||
return this.dataUnit === 3 ? 'yyyy-MM-dd' :this.dataUnit === 2 ? 'yyyy-MM-dd HH:mm' : 'yyyy-MM-dd HH:mm:ss'
|
||||
return this.dataUnit === 3 ? 'yyyy-MM-dd' : 'yyyy-MM-dd HH:mm:ss'
|
||||
},
|
||||
disabledNextBtn(){
|
||||
if(this.dateRange && this.dateRange.length ===2){
|
||||
@ -97,19 +97,18 @@ export default {
|
||||
}
|
||||
},
|
||||
timeLine(type){
|
||||
if(!this.dateRange) return
|
||||
if(!this.dateRange || !this.dateRange[0] || !this.dateRange[1]) return
|
||||
const nowStartTimes = new Date(this.dateRange[0]).getTime(),nowEndTimes = new Date(this.dateRange[1]).getTime(),maxTime = new Date(this.defaultDateRange[1]).getTime()
|
||||
const nowDis = nowEndTimes - nowStartTimes//用户当前选择时间差 可能=0
|
||||
//baseTime,maxTime 毫秒数
|
||||
const baseTimes= this.dataUnit === 3 ? 24 * 60 * 60 * 1000 :this.dataUnit === 2 ? 60 * 60 * 1000 : 60 * 1000
|
||||
const baseDis = this.dataUnit === 3 ? 30 :this.dataUnit === 2 ? 24 : 60
|
||||
let baseTime = type === 'before' ? new Date(this.dateRange[0]).getTime() - baseTimes :new Date(this.dateRange[1]).getTime() + baseTimes ,
|
||||
maxTime = new Date(this.defaultDateRange[1]).getTime()
|
||||
//updateTime 毫秒数
|
||||
let updateTime = type === 'before' ? baseTime - baseDis * baseTimes : baseTime + baseDis * baseTimes
|
||||
if(type === 'next' && updateTime >= maxTime) updateTime = maxTime
|
||||
const start = formatDate(type === 'before' ? updateTime : baseTime,this.dataUnit !== 3)
|
||||
const end = formatDate(type === 'before' ? baseTime : updateTime,this.dataUnit !== 3)
|
||||
this.dateRange = [start,end]
|
||||
this.$emit('updateDate',this.dateRange || [])
|
||||
const baseDis = this.dataUnit === 3 ? 24 * 60 * 60 * 1000 :this.dataUnit === 2 ? 60 * 60 * 1000 : 60 * 1000
|
||||
const calcDis = nowDis === 0 ? baseDis : nowDis
|
||||
let start = type === 'before' ? nowStartTimes - calcDis : nowStartTimes + calcDis
|
||||
start = Math.min(start,maxTime)
|
||||
let end = type === 'before' ? nowEndTimes - calcDis : nowEndTimes + calcDis
|
||||
end = Math.min(end,maxTime)
|
||||
this.dateRange = [formatDate(start,this.dataUnit !== 3),formatDate(end,this.dataUnit !== 3)]
|
||||
this.$emit('updateDate',this.dateRange)
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
@ -283,8 +283,8 @@ export default {
|
||||
if(this.isDtdc && (this.form.child.length === 0 || this.form.child.length > 5 )){
|
||||
return this.$message.error('请选择单体电池且不能超过5个');
|
||||
}
|
||||
this.loading = true
|
||||
const{siteIds,dataUnit,categoryName,pointName,dataRange:[start='',end=''],child}=this.form
|
||||
if(!start || !end) return this.$message.error('请选择时间');
|
||||
let siteDeviceMap={}
|
||||
child.forEach(([first,second,third])=>{
|
||||
if(siteDeviceMap[first]){
|
||||
@ -307,7 +307,7 @@ export default {
|
||||
}else{
|
||||
endDate=end
|
||||
}
|
||||
|
||||
this.loading = true
|
||||
getPointValueList({siteIds:[siteIds],dataUnit,categoryName,pointName,startDate,endDate,siteDeviceMap}).then(response => {
|
||||
this.setOption(response?.data || [])
|
||||
}).finally(()=>{
|
||||
|
||||
Reference in New Issue
Block a user