feat : panel 的时间保留

This commit is contained in:
zhangyu
2021-12-23 20:22:40 +08:00
parent df7cdd72f4
commit 4403efc640
4 changed files with 39 additions and 13 deletions

View File

@@ -177,11 +177,13 @@ export default {
if (this.$refs.pickTime) { if (this.$refs.pickTime) {
if (this.$refs.pickTime.$refs.multipleTime) { if (this.$refs.pickTime.$refs.multipleTime) {
this.$refs.pickTime.$refs.multipleTime.showDropdown = false this.$refs.pickTime.$refs.multipleTime.showDropdown = false
this.$refs.pickTime.$refs.timePicker.setCustomTime(this.nowType)
} }
this.setSearchTime(this.nowType.type, this.nowType.value, this.nowType)
this.searchTime[0] = bus.timeFormate(this.timeRange[0], 'yyyy-MM-dd hh:mm:ss') this.searchTime[0] = bus.timeFormate(this.timeRange[0], 'yyyy-MM-dd hh:mm:ss')
this.searchTime[1] = bus.timeFormate(this.timeRange[1], 'yyyy-MM-dd hh:mm:ss') this.searchTime[1] = bus.timeFormate(this.timeRange[1], 'yyyy-MM-dd hh:mm:ss')
this.nowType.start_time = this.searchTime[0]
this.nowType.end_time = this.searchTime[1]
this.$refs.pickTime.$refs.timePicker.setCustomTime(this.nowType)
this.setSearchTime(this.nowType.type, this.nowType.value, this.nowType)
} }
} }
} }

View File

@@ -12,6 +12,9 @@ export default {
if (qv && val.type == 'array') { if (qv && val.type == 'array') {
qv = qv.split(',') qv = qv.split(',')
} }
if (qv && val.type == 'jsonParse') {
qv = JSON.parse(qv)
}
setTimeout(() => { setTimeout(() => {
this.setSearchInput(val, qv) this.setSearchInput(val, qv)
if (qv && val.type2 == 'array') { if (qv && val.type2 == 'array') {

View File

@@ -172,9 +172,10 @@ export default {
this.$set(this.showTime, 'text', this.searchTime[0] + ' ' + this.$t('dashboard.panel.to') + ' ' + this.searchTime[1]) this.$set(this.showTime, 'text', this.searchTime[0] + ' ' + this.$t('dashboard.panel.to') + ' ' + this.searchTime[1])
this.$emit('change', this.searchTime) this.$emit('change', this.searchTime)
}, },
setCustomTime (timeGroup) { setCustomTime (timeGroup,timeRange) {
if (timeGroup) { if (timeGroup) {
this.showTime = this.nowTimeType = this.timeData.find(item => item.id == timeGroup.id) this.showTime = this.nowTimeType = this.timeData.find(item => item.id == timeGroup.id)
console.log(this.showTime)
if (this.showTime) { if (this.showTime) {
this.showTime = Object.assign({}, this.showTime) this.showTime = Object.assign({}, this.showTime)
this.$set(this.searchTime, 0, timeGroup.start_time) this.$set(this.searchTime, 0, timeGroup.start_time)

View File

@@ -316,7 +316,9 @@ export default {
this.filter.panelId = this.showPanel.id this.filter.panelId = this.showPanel.id
this.panelId = this.showPanel.id this.panelId = this.showPanel.id
const param = { const param = {
panelId: this.panelId panelId: this.panelId,
nowTimeType: JSON.stringify(this.nowTimeType),
searchTime: JSON.stringify(this.searchTime)
} }
// this.dateChange() // this.dateChange()
// this.getTableData() // this.getTableData()
@@ -554,8 +556,15 @@ export default {
this.filter.end_time = bus.timeFormate(this.searchTime[1], 'yyyy-MM-dd hh:mm:ss') this.filter.end_time = bus.timeFormate(this.searchTime[1], 'yyyy-MM-dd hh:mm:ss')
this.filter.value = this.searchTime[2] this.filter.value = this.searchTime[2]
this.filter.id = this.$refs.pickTime.$refs.timePicker.showTime.id this.filter.id = this.$refs.pickTime.$refs.timePicker.showTime.id
this.getTableData() // this.getTableData()
this.getData(this.filter) this.getData(this.filter)
const param = {
panelId: this.panelId,
nowTimeType: JSON.stringify(this.nowTimeType),
searchTime: JSON.stringify(this.searchTime)
}
const path = this.fromRoute.panel
this.updatePath(param, path)
this.$store.dispatch('dispatchPanelTime', { this.$store.dispatch('dispatchPanelTime', {
time: this.searchTime, time: this.searchTime,
nowTimeType: this.nowTimeType nowTimeType: this.nowTimeType
@@ -581,7 +590,7 @@ export default {
this.$set(this.searchTime, 1, endTime) this.$set(this.searchTime, 1, endTime)
this.$set(this.searchTime, 2, val + 'd') this.$set(this.searchTime, 2, val + 'd')
} }
this.$refs.pickTime.$refs.timePicker.searchTime = this.searchTime this.$refs.pickTime && (this.$refs.pickTime.$refs.timePicker.searchTime = this.searchTime)
}, },
/* 时间条件查询--end */ /* 时间条件查询--end */
// 公用操作 // 公用操作
@@ -800,22 +809,26 @@ export default {
const searchKeys = { const searchKeys = {
// key: path 键 // key: path 键
// value: vue set 参数 // value: vue set 参数
panelId: { target: this, propertyName: 'panelId', type: 'number' } panelId: { target: this, propertyName: 'panelId', type: 'number' },
searchTime: { target: this, propertyName: 'searchTime', type: 'jsonParse' },
nowTimeType: { target: this, propertyName: 'nowTimeType', type: 'jsonParse' }
} }
setTimeout(() => { setTimeout(() => {
this.showPanel.id = this.panelId this.showPanel.id = this.panelId
this.filter.panelId = this.panelId this.filter.panelId = this.panelId
}) })
this.initQueryFromPath(searchKeys) this.initQueryFromPath(searchKeys)
if (this.nowTimeType.type) {
this.setSearchTime(this.nowTimeType.type, this.nowTimeType.value, this.nowTimeType)
this.filter.start_time = bus.timeFormate(this.searchTime[0], 'yyyy-MM-dd hh:mm:ss')
this.filter.end_time = bus.timeFormate(this.searchTime[1], 'yyyy-MM-dd hh:mm:ss')
this.filter.end_time = bus.timeFormate(this.searchTime[1], 'yyyy-MM-dd hh:mm:ss')
this.filter.value = this.searchTime[2]
}
this.getTableData() this.getTableData()
this.$store.dispatch('dispatchPanelTime', { this.$store.dispatch('dispatchPanelTime', {
time: this.searchTime, time: this.searchTime,
nowTimeType: { nowTimeType: this.nowTimeType
id: 4,
text: this.$t('dashboard.panel.lastOneHour'),
type: 'hour',
value: 1
}
}) })
}, },
mounted () { mounted () {
@@ -826,6 +839,13 @@ export default {
if (!document.onmousemove) { // 添加鼠标移动事件监听 if (!document.onmousemove) { // 添加鼠标移动事件监听
document.onmousemove = lineChartMove document.onmousemove = lineChartMove
} }
if (this.nowTimeType) {
this.nowTimeType.start_time = this.searchTime[0]
this.nowTimeType.end_time = this.searchTime[1]
setTimeout(() => {
this.$refs.pickTime.$refs.timePicker.setCustomTime(this.nowTimeType)
}, 100)
}
}, },
watch: { watch: {
'filter.searchName': function (n, o) { 'filter.searchName': function (n, o) {