feat: 抽取时间参数至vuex

This commit is contained in:
zhangyu
2021-12-09 16:59:46 +08:00
parent 6633eb9f8e
commit cbe6fdc60a
4 changed files with 41 additions and 3 deletions

View File

@@ -39,7 +39,6 @@
ref="logTable" ref="logTable"
class="nz-table2" class="nz-table2"
size="mini" size="mini"
width="100%"
v-if="tableData.length" v-if="tableData.length"
> >
<el-table-column <el-table-column

View File

@@ -21,6 +21,14 @@ export default {
chartOption: Object, chartOption: Object,
isFullscreen: Boolean isFullscreen: Boolean
}, },
computed: {
filterTime () {
return this.$store.getters.getTimeRange
},
nowTimeType () {
return this.$store.getters.getNowTimeType
}
},
methods: { methods: {
handleTimeSeries (chartInfo, seriesTemplate, originalDatas) { handleTimeSeries (chartInfo, seriesTemplate, originalDatas) {
const series = [] const series = []

View File

@@ -524,6 +524,10 @@ export default {
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)
this.$store.dispatch('dispatchPanelTime',{
time: this.searchTime,
nowTimeType: this.nowTimeType
})
}, },
setSearchTime (type, val, nowTimeType) { // 设置searchTime setSearchTime (type, val, nowTimeType) { // 设置searchTime
if (type === 'minute') { if (type === 'minute') {
@@ -763,6 +767,15 @@ export default {
}, },
created () { created () {
this.getTableData() this.getTableData()
this.$store.dispatch('dispatchPanelTime',{
time: this.searchTime,
nowTimeType: {
id: 4,
text: this.$t('dashboard.panel.lastOneHour'),
type: 'hour',
value: 1
}
})
}, },
mounted () { mounted () {
this.scrollbarWrap = this.$refs.dashboardScrollbar this.scrollbarWrap = this.$refs.dashboardScrollbar

View File

@@ -4,7 +4,9 @@ const panel = {
chart: '', chart: '',
delChart: false, delChart: false,
groupId: '', groupId: '',
type: '' type: '',
timeRange: [],
nowTimeType: {}
}, },
mutations: { mutations: {
setShowRightBox (state, flag) { setShowRightBox (state, flag) {
@@ -22,6 +24,12 @@ const panel = {
setGroupId (state, id) { setGroupId (state, id) {
state.groupId = id state.groupId = id
}, },
setPanelTime (state, time) {
state.timeRange = time
},
setPanelNowTimeType (state, nowTimeType) {
state.nowTimeType = nowTimeType
},
cleanPanel (state) { cleanPanel (state) {
state.showRightBox = false state.showRightBox = false
state.chart = '' state.chart = ''
@@ -43,6 +51,12 @@ const panel = {
getGroupId (state) { getGroupId (state) {
return state.groupId return state.groupId
}, },
getTimeRange (state) {
return state.timeRange
},
getNowTimeType (state) {
return state.nowTimeType
},
getDelChart (state) { getDelChart (state) {
return state.delChart return state.delChart
} }
@@ -59,6 +73,10 @@ const panel = {
store.commit('setChart', playload.chart) store.commit('setChart', playload.chart)
store.commit('setType', playload.type) store.commit('setType', playload.type)
}, },
dispatchPanelTime (store, playload) {
store.commit('setPanelTime', playload.time)
store.commit('setPanelNowTimeType', playload.nowTimeType)
},
dispatchEditChart (store, playload) { dispatchEditChart (store, playload) {
store.commit('setShowRightBox', true) store.commit('setShowRightBox', true)
store.commit('setChart', playload.chart) store.commit('setChart', playload.chart)