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