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"
class="nz-table2"
size="mini"
width="100%"
v-if="tableData.length"
>
<el-table-column

View File

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

View File

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

View File

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