mirror of
https://github.com/jumpserver/lina.git
synced 2025-09-20 02:31:43 +00:00
perf: 重复逻辑抽离
This commit is contained in:
@@ -41,53 +41,23 @@ export default {
|
|||||||
shortcuts: [
|
shortcuts: [
|
||||||
{
|
{
|
||||||
text: this.$t('common.DateLast24Hours'),
|
text: this.$t('common.DateLast24Hours'),
|
||||||
onClick(picker) {
|
onClick: (picker) => this.handleShortcutClick(picker, 1)
|
||||||
const end = new Date()
|
|
||||||
const start = new Date()
|
|
||||||
start.setTime(start.getTime() - 3600 * 1000 * 24)
|
|
||||||
picker.$emit('pick', [start, end])
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
text: this.$t('common.DateLastWeek'),
|
text: this.$t('common.DateLastWeek'),
|
||||||
onClick(picker) {
|
onClick: (picker) => this.handleShortcutClick(picker, 7)
|
||||||
const end = new Date()
|
|
||||||
const start = new Date()
|
|
||||||
start.setTime(start.getTime() - 3600 * 1000 * 24 * 7)
|
|
||||||
picker.$emit('pick', [start, end])
|
|
||||||
}
|
|
||||||
}, {
|
}, {
|
||||||
text: this.$t('common.DateLastMonth'),
|
text: this.$t('common.DateLastMonth'),
|
||||||
onClick(picker) {
|
onClick: (picker) => this.handleShortcutClick(picker, 30)
|
||||||
const end = new Date()
|
|
||||||
const start = new Date()
|
|
||||||
start.setTime(start.getTime() - 3600 * 1000 * 24 * 30)
|
|
||||||
picker.$emit('pick', [start, end])
|
|
||||||
}
|
|
||||||
}, {
|
}, {
|
||||||
text: this.$t('common.DateLast3Months'),
|
text: this.$t('common.DateLast3Months'),
|
||||||
onClick(picker) {
|
onClick: (picker) => this.handleShortcutClick(picker, 90)
|
||||||
const end = new Date()
|
|
||||||
const start = new Date()
|
|
||||||
start.setTime(start.getTime() - 3600 * 1000 * 24 * 90)
|
|
||||||
picker.$emit('pick', [start, end])
|
|
||||||
}
|
|
||||||
}, {
|
}, {
|
||||||
text: this.$t('common.DateLastHarfYear'),
|
text: this.$t('common.DateLastHarfYear'),
|
||||||
onClick(picker) {
|
onClick: (picker) => this.handleShortcutClick(picker, 183)
|
||||||
const end = new Date()
|
|
||||||
const start = new Date()
|
|
||||||
start.setTime(start.getTime() - 3600 * 1000 * 24 * 183)
|
|
||||||
picker.$emit('pick', [start, end])
|
|
||||||
}
|
|
||||||
}, {
|
}, {
|
||||||
text: this.$t('common.DateLastYear'),
|
text: this.$t('common.DateLastYear'),
|
||||||
onClick(picker) {
|
onClick: (picker) => this.handleShortcutClick(picker, 365)
|
||||||
const end = new Date()
|
|
||||||
const start = new Date()
|
|
||||||
start.setTime(start.getTime() - 3600 * 1000 * 24 * 365)
|
|
||||||
picker.$emit('pick', [start, end])
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
@@ -102,6 +72,12 @@ export default {
|
|||||||
this.$log.debug('Date change: ', val)
|
this.$log.debug('Date change: ', val)
|
||||||
this.$emit('dateChange', val)
|
this.$emit('dateChange', val)
|
||||||
}
|
}
|
||||||
|
},
|
||||||
|
handleShortcutClick(picker, day) {
|
||||||
|
const end = new Date()
|
||||||
|
const start = new Date()
|
||||||
|
start.setTime(start.getTime() - 3600 * 1000 * 24 * day)
|
||||||
|
picker.$emit('pick', [start, end])
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -124,7 +100,7 @@ export default {
|
|||||||
.el-input__inner {
|
.el-input__inner {
|
||||||
border: 1px solid #dcdee2;
|
border: 1px solid #dcdee2;
|
||||||
border-radius: 3px;
|
border-radius: 3px;
|
||||||
height: 32x;
|
height: 32px;
|
||||||
}
|
}
|
||||||
|
|
||||||
.el-date-editor ::v-deep .el-range-separator {
|
.el-date-editor ::v-deep .el-range-separator {
|
||||||
|
Reference in New Issue
Block a user