forked from github/dataease
Merge branch 'main' of github.com:dataease/dataease into main
This commit is contained in:
commit
ad29a59583
@ -13,7 +13,7 @@
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import { dateFormat } from '@/utils'
|
||||
import { timeSection } from '@/utils'
|
||||
export default {
|
||||
|
||||
props: {
|
||||
@ -29,7 +29,7 @@ export default {
|
||||
data() {
|
||||
return {
|
||||
options: null,
|
||||
operator: 'eq',
|
||||
operator: 'between',
|
||||
values: null
|
||||
}
|
||||
},
|
||||
@ -50,37 +50,26 @@ export default {
|
||||
this.inDraw && this.$store.dispatch('conditions/add', param)
|
||||
},
|
||||
dateChange(value) {
|
||||
// const nvalue = dateFormat(value, this.getFormat())
|
||||
// console.log(nvalue)
|
||||
this.setCondition()
|
||||
},
|
||||
formatValues(values) {
|
||||
if (!values || values.length === 0) {
|
||||
return []
|
||||
}
|
||||
return values.map(value => dateFormat(value, this.getFormat()))
|
||||
},
|
||||
getFormat() {
|
||||
let format = 'yyyy'
|
||||
switch (this.options.attrs.type) {
|
||||
case 'year':
|
||||
format = 'yyyy'
|
||||
break
|
||||
case 'month':
|
||||
format = 'yyyy-MM'
|
||||
break
|
||||
case 'date':
|
||||
format = 'yyyy-MM-dd'
|
||||
break
|
||||
case 'daterange':
|
||||
format = 'yyyy-MM-dd'
|
||||
this.operator = 'in'
|
||||
break
|
||||
default:
|
||||
format = 'yyyy'
|
||||
break
|
||||
if (this.options.attrs.type === 'daterange') {
|
||||
if (values.length !== 2) {
|
||||
return null
|
||||
}
|
||||
let start = values[0]
|
||||
let end = values[1]
|
||||
start = timeSection(start, 'date')[0]
|
||||
end = timeSection(end, 'date')[1]
|
||||
const results = [start, end]
|
||||
return results
|
||||
} else {
|
||||
const value = values[0]
|
||||
return timeSection(value, this.options.attrs.type)
|
||||
}
|
||||
return format
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -29,7 +29,7 @@ router.beforeEach(async(to, from, next) => {
|
||||
NProgress.done()
|
||||
} else {
|
||||
const hasGetUserInfo = store.getters.name
|
||||
if (hasGetUserInfo) {
|
||||
if (hasGetUserInfo || to.path.indexOf('/preview/') > -1) {
|
||||
next()
|
||||
store.dispatch('permission/setCurrentPath', to.path)
|
||||
} else {
|
||||
|
@ -1,7 +1,47 @@
|
||||
|
||||
/**
|
||||
* Created by PanJiaChen on 16/11/18.
|
||||
*/
|
||||
export function timeSection(date, type) {
|
||||
if (!date) {
|
||||
return null
|
||||
}
|
||||
const timeRanger = new Array(2)
|
||||
|
||||
date.setHours(0)
|
||||
date.setMinutes(0)
|
||||
date.setSeconds(0)
|
||||
date.setMilliseconds(0)
|
||||
const end = new Date(date)
|
||||
if (type === 'year') {
|
||||
date.setDate(1)
|
||||
date.setMonth(0)
|
||||
end.setFullYear(date.getFullYear() + 1)
|
||||
timeRanger[1] = end.getTime() - 1
|
||||
}
|
||||
if (type === 'month') {
|
||||
date.setDate(1)
|
||||
const currentMonth = date.getMonth()
|
||||
if (currentMonth === 11) {
|
||||
end.setFullYear(date.getFullYear() + 1)
|
||||
end.setMonth(0)
|
||||
} else {
|
||||
end.setMonth(date.getMonth() + 1)
|
||||
}
|
||||
timeRanger[1] = end.getTime() - 1
|
||||
}
|
||||
|
||||
if (type === 'date') {
|
||||
end.setHours(23)
|
||||
end.setMinutes(59)
|
||||
end.setSeconds(59)
|
||||
end.setMilliseconds(999)
|
||||
timeRanger[1] = end.getTime()
|
||||
}
|
||||
timeRanger[0] = date.getTime()
|
||||
|
||||
return timeRanger
|
||||
}
|
||||
export function dateFormat(date, fmt) {
|
||||
let ret
|
||||
const opt = {
|
||||
|
@ -241,7 +241,7 @@ export default {
|
||||
showPanel(type) {
|
||||
debugger
|
||||
if (this.showIndex === -1 || this.showIndex === type) {
|
||||
this.show = !this.show
|
||||
this.$nextTick(() => (this.show = !this.show))
|
||||
}
|
||||
this.showIndex = type
|
||||
},
|
||||
@ -254,6 +254,7 @@ export default {
|
||||
// 点击样式按钮 排除
|
||||
const stick = evt.target.closest('.el-icon-magic-stick')
|
||||
if (!parent && !self && !stick) {
|
||||
debugger
|
||||
this.show = false
|
||||
window.removeEventListener('click', this.closeSidebar)
|
||||
this.showIndex = -1
|
||||
@ -371,6 +372,7 @@ export default {
|
||||
this.openFilterDiolog()
|
||||
},
|
||||
closeLeftPanel() {
|
||||
debugger
|
||||
this.show = false
|
||||
// this.beforeDestroy()
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user