CN-700 界面刷新保持状态-下钻table等

This commit is contained in:
hanyuxia
2022-09-16 17:46:20 +08:00
parent ddc47208e1
commit 7967f9a764
11 changed files with 633 additions and 478 deletions

View File

@@ -124,6 +124,9 @@
.el-tabs__content { .el-tabs__content {
height: 100% !important; height: 100% !important;
} }
.el-tabs__header {
display:none;
}
} }
.tab-search { .tab-search {
position:absolute; position:absolute;

View File

@@ -180,9 +180,10 @@
<script> <script>
import { useRoute } from 'vue-router' import { useRoute } from 'vue-router'
import { get, put } from '@/utils/http' import { get, put } from '@/utils/http'
import { entityType, storageKey, networkOverviewTabList, operationType, networkOverviewSearchUrl } from '@/utils/constants' import { entityType, storageKey, networkOverviewTabList, operationType, networkOverviewSearchUrl, curTabState } from '@/utils/constants'
import { api } from '@/utils/api' import { api } from '@/utils/api'
import { ref } from 'vue' import { ref } from 'vue'
import { urlParamsHandler, overwriteUrl } from '@/utils/tools'
import { getNowTime, getSecond } from '@/utils/date-util' import { getNowTime, getSecond } from '@/utils/date-util'
export default { export default {
@@ -229,7 +230,8 @@ export default {
path: '/detection/performanceEvent' path: '/detection/performanceEvent'
} }
], ],
curPageNum: 1 curPageNum: 1,
curTabState: curTabState
} }
}, },
computed: { computed: {
@@ -432,6 +434,13 @@ export default {
} }
}) })
}, },
changeTabState (param, value) {
const { query } = this.$route
const newQuery = {}
newQuery[param] = value
const newUrl = urlParamsHandler(window.location.href, query, newQuery)
overwriteUrl(newUrl)
},
jump (route, columnName, columnValue, opeType) { jump (route, columnName, columnValue, opeType) {
this.showMenu = false this.showMenu = false
if (opeType) { if (opeType) {
@@ -465,7 +474,7 @@ export default {
this.$store.commit('setPanelName', columnName) this.$store.commit('setPanelName', columnName)
const tabList = this.$store.getters.getNetworkOverviewTabList const tabList = this.$store.getters.getNetworkOverviewTabList
const curTab = tabList.filter(item => this.$t(item.label) === columnName)[0] const curTab = tabList.filter(item => this.$t(item.label) === columnName)[0]
this.$store.commit('setNetworkOverviewCurrentTab', curTab) this.changeTabState(this.curTabState.curTab, curTab)
this.$store.commit('setDimensionType', curTab ? curTab.prop : '') this.$store.commit('setDimensionType', curTab ? curTab.prop : '')
this.$store.commit('setQueryCondition', '') this.$store.commit('setQueryCondition', '')
this.$store.commit('setNetworkOverviewBeforeTab', null) this.$store.commit('setNetworkOverviewBeforeTab', null)
@@ -476,8 +485,8 @@ export default {
this.$store.commit('setBreadcrumbColumnName', '') this.$store.commit('setBreadcrumbColumnName', '')
this.$store.commit('setDimensionType', '') this.$store.commit('setDimensionType', '')
this.$store.commit('setPanelName', '') this.$store.commit('setPanelName', '')
this.$store.commit('setBreadcrumbColumnValueList', []) // this.$store.commit('setBreadcrumbColumnValueList', [])
this.$store.commit('setNetworkOverviewCurrentTab', null) this.changeTabState(this.curTabState.curTab, null)
this.$store.commit('setQueryCondition', '') this.$store.commit('setQueryCondition', '')
this.$store.commit('setNetworkOverviewBeforeTab', null) this.$store.commit('setNetworkOverviewBeforeTab', null)
} }
@@ -488,11 +497,11 @@ export default {
// console.log(this.$store.getters.getDimensionType) // console.log(this.$store.getters.getDimensionType)
if (opeType === 3) { if (opeType === 3) {
this.$router.push({ this.$router.push({
params: { ...this.$route.params, fourthPanel: '' } query: { ...this.$route.query, fourthPanel: '' }
}) })
} else if (opeType != 4) { } else if (opeType != 4) {
this.$router.push({ this.$router.push({
params: { ...this.$route.params, fourthPanel: '', thirdPanel: '' } query: { ...this.$route.query, fourthPanel: '', thirdPanel: '' }
}) })
} }
if (route === this.route) { if (route === this.route) {

View File

@@ -25,7 +25,6 @@ const panel = {
panelName、 panelName、
breadcrumbColumnName、 breadcrumbColumnName、
breadcrumbColumnValue、 breadcrumbColumnValue、
breadcrumbColumnValueList、
networkOverviewCurrentTab、 networkOverviewCurrentTab、
queryCondition queryCondition
点击顶部第二级菜单:与点击菜单相同 点击顶部第二级菜单:与点击菜单相同
@@ -42,8 +41,7 @@ const panel = {
breadcrumbColumnName: '', // 点击tab里的value都会修改此值,为面包屑的菜单 breadcrumbColumnName: '', // 点击tab里的value都会修改此值,为面包屑的菜单
dimensionType: '', // 维度 dimensionType: '', // 维度
breadcrumbColumnValue: '', // 点击tab里的value都会修改此值,为面包屑的菜单 breadcrumbColumnValue: '', // 点击tab里的value都会修改此值,为面包屑的菜单
breadcrumbColumnValueList: [], // 第四级面包屑的下拉列表 // networkOverviewCurrentTab: null, // 只代表选中的tab有时会与面包屑中显示的值不同
networkOverviewCurrentTab: null, // 只代表选中的tab有时会与面包屑中显示的值不同
networkOverviewBeforeTab: null, // 点击表格的值时使用记录点击当前tab表格的值之前点击的表格值所属的tab networkOverviewBeforeTab: null, // 点击表格的值时使用记录点击当前tab表格的值之前点击的表格值所属的tab
queryCondition: '', // 数据查询的条件 queryCondition: '', // 数据查询的条件
networkOverviewTabList: [], // 存储tab列表的一些状态如是否选中 networkOverviewTabList: [], // 存储tab列表的一些状态如是否选中
@@ -114,12 +112,9 @@ const panel = {
setBreadcrumbColumnValue (state, breadcrumbColumnValue) { setBreadcrumbColumnValue (state, breadcrumbColumnValue) {
state.breadcrumbColumnValue = breadcrumbColumnValue state.breadcrumbColumnValue = breadcrumbColumnValue
}, },
setBreadcrumbColumnValueList (state, breadcrumbColumnValueList) { // setNetworkOverviewCurrentTab (state, networkOverviewCurrentTab) {
state.breadcrumbColumnValueList = breadcrumbColumnValueList // state.networkOverviewCurrentTab = networkOverviewCurrentTab
}, // },
setNetworkOverviewCurrentTab (state, networkOverviewCurrentTab) {
state.networkOverviewCurrentTab = networkOverviewCurrentTab
},
setQueryCondition (state, queryCondition) { setQueryCondition (state, queryCondition) {
state.queryCondition = queryCondition state.queryCondition = queryCondition
}, },
@@ -200,12 +195,9 @@ const panel = {
getBreadcrumbColumnValue (state) { getBreadcrumbColumnValue (state) {
return state.breadcrumbColumnValue return state.breadcrumbColumnValue
}, },
getBreadcrumbColumnValueList (state) { // getNetworkOverviewCurrentTab (state) {
return state.breadcrumbColumnValueList // return state.networkOverviewCurrentTab
}, // },
getNetworkOverviewCurrentTab (state) {
return state.networkOverviewCurrentTab
},
getQueryCondition (state) { getQueryCondition (state) {
return state.queryCondition return state.queryCondition
}, },

View File

@@ -238,6 +238,15 @@ export const cycle = {
pre: 1 pre: 1
} }
export const curTabState = {
curTab: 'curTab',
tableMetric: 'tableMetric',
tableShowMore: 'tableShowMore',
tableSortColumn: 'tableSortColumn',
tableSortType: 'tableSortType',
tableSortTab: 'tableSortTab'
}
export const scoreUrl = [ export const scoreUrl = [
'/interface/application/performance/overview/drilldown/dimensionTcpSessionDelay', '/interface/application/performance/overview/drilldown/dimensionTcpSessionDelay',
'/interface/application/performance/overview/drilldown/dimensionSslConDelay', '/interface/application/performance/overview/drilldown/dimensionSslConDelay',

View File

@@ -837,6 +837,15 @@ export function computeScore (data, index) {
return score * k return score * k
} }
// 改变tab状态(url中)当前tab
export function changeTabState (param, value) {
const query = router.query
query[param] = JSON.stringify(value)
router.push({
query: query
})
}
// cleanOldParams: true|false是否清除oldParams // cleanOldParams: true|false是否清除oldParams
export function urlParamsHandler (url, oldParams, newParams, cleanOldParams) { export function urlParamsHandler (url, oldParams, newParams, cleanOldParams) {
let newUrl = url.split('?')[0] let newUrl = url.split('?')[0]

View File

@@ -20,11 +20,10 @@
:time-filter="timeFilter" :time-filter="timeFilter"
@toggleLoading="toggleLoading" @toggleLoading="toggleLoading"
></network-overview-performance-event> ></network-overview-performance-event>
<network-overview-tabs @getChartData="getChartData" <network-overview-tabs
v-else-if="chart.type === typeMapping.networkOverview.table" v-else-if="chart.type === typeMapping.networkOverview.table"
:time-filter="timeFilter" :time-filter="timeFilter"
:chart="chart" :chart="chart"
:chartData="chartData"
:ref="`tab${chart.id}`" :ref="`tab${chart.id}`"
@toggleLoading="toggleLoading" @toggleLoading="toggleLoading"
></network-overview-tabs> ></network-overview-tabs>

View File

@@ -148,8 +148,8 @@ export default {
const panel = ref({}) const panel = ref({})
let panelType = 1 // 取得panel的type let panelType = 1 // 取得panel的type
const { params, query } = useRoute() const { params, query } = useRoute()
const thirdPanel = params.thirdPanel const thirdPanel = query.thirdPanel
const fourthPanel = params.fourthPanel const fourthPanel = query.fourthPanel
if (fourthPanel) { if (fourthPanel) {
panelType = Number(fourthPanel) panelType = Number(fourthPanel)
} else if (thirdPanel) { } else if (thirdPanel) {

View File

@@ -118,7 +118,7 @@
<script> <script>
import unitConvert from '@/utils/unit-convert' import unitConvert from '@/utils/unit-convert'
import { storageKey, unitTypes, networkTable, operationType } from '@/utils/constants' import { storageKey, unitTypes, networkTable, operationType, curTabState } from '@/utils/constants'
import * as echarts from 'echarts' import * as echarts from 'echarts'
import { appListChartOption } from '@/views/charts2/charts/options/echartOption' import { appListChartOption } from '@/views/charts2/charts/options/echartOption'
import { ref, shallowRef } from 'vue' import { ref, shallowRef } from 'vue'
@@ -180,7 +180,8 @@ export default {
offset: 0, offset: 0,
flag: false, flag: false,
timerSearch: null, timerSearch: null,
loadingBody: false loadingBody: false,
curTabState: curTabState
} }
}, },
setup () { setup () {
@@ -370,16 +371,26 @@ export default {
const tabObjGroup = list.filter(item => item.checked) const tabObjGroup = list.filter(item => item.checked)
if (tabObjGroup && tabObjGroup.length > 0) { if (tabObjGroup && tabObjGroup.length > 0) {
const curTab = tabObjGroup[0] const curTab = tabObjGroup[0]
this.$store.commit('setNetworkOverviewCurrentTab', curTab) this.changeTabState(this.curTabState.curTab, curTab)
} }
this.$router.push({ this.$router.push({
params: { query: {
...this.$route.query,
thirdPanel: curTable.panelIdOfThirdMenu ? curTable.panelIdOfThirdMenu : '', thirdPanel: curTable.panelIdOfThirdMenu ? curTable.panelIdOfThirdMenu : '',
fourthPanel: toPanel || '' fourthPanel: toPanel || ''
} }
}) })
} }
}, },
changeTabState (param, value) {
const query = {
...this.$route.query
}
query[param] = value
this.$router.push({
query: query
})
},
initChart (obj) { initChart (obj) {
let chart = this.myChart.find(m => m.name === obj.name && m.type === obj.type) let chart = this.myChart.find(m => m.name === obj.name && m.type === obj.type)
if (!chart) { if (!chart) {

View File

@@ -107,14 +107,14 @@
</template> </template>
<script> <script>
import { unitTypes, npmCategoryInfoMapping, networkTable, operationType, npmCategoryToAppCategoryMap } from '@/utils/constants' import { unitTypes, npmCategoryInfoMapping, networkTable, operationType, npmCategoryToAppCategoryMap, curTabState } from '@/utils/constants'
import unitConvert from '@/utils/unit-convert' import unitConvert from '@/utils/unit-convert'
import { api } from '@/utils/api' import { api } from '@/utils/api'
import { getSecond } from '@/utils/date-util' import { getSecond } from '@/utils/date-util'
import { get } from '@/utils/http' import { get } from '@/utils/http'
import { getChainRatio, computeScore } from '@/utils/tools' import { getChainRatio, computeScore, changeCurTab } from '@/utils/tools'
import chartMixin from '@/views/charts2/chart-mixin' import chartMixin from '@/views/charts2/chart-mixin'
import ChartNoData from "@/views/charts/charts/ChartNoData"; import ChartNoData from '@/views/charts/charts/ChartNoData'
export default { export default {
name: 'NpmAppCategoryScore', name: 'NpmAppCategoryScore',
data () { data () {
@@ -138,7 +138,8 @@ export default {
{ label: 'network.outbound', prop: 'outbound' }, { label: 'network.outbound', prop: 'outbound' },
{ label: 'network.inbound', prop: 'inbound' } { label: 'network.inbound', prop: 'inbound' }
], ],
isNoData: false isNoData: false,
curTabState: curTabState
} }
}, },
components: { components: {
@@ -233,7 +234,8 @@ export default {
const value = npmCategoryToAppCategoryMap[key] const value = npmCategoryToAppCategoryMap[key]
const tabType = 'network.applicationCategories' const tabType = 'network.applicationCategories'
const oldCurTab = this.$store.getters.getNetworkOverviewBeforeTab const oldCurTab = this.$store.getters.getNetworkOverviewBeforeTab
const curTable = networkTable.networkOverview // const curTable = networkTable.networkOverview
const curTable = networkTable.networkAppPerformance
const list = this.$store.getters.getNetworkOverviewTabList const list = this.$store.getters.getNetworkOverviewTabList
const tabGroup = list.filter(item => item.label === tabType) const tabGroup = list.filter(item => item.label === tabType)
if (tabGroup && tabGroup.length > 0) { if (tabGroup && tabGroup.length > 0) {
@@ -286,14 +288,24 @@ export default {
const tabObjGroup = list.filter(item => item.checked) const tabObjGroup = list.filter(item => item.checked)
if (tabObjGroup && tabObjGroup.length > 0) { if (tabObjGroup && tabObjGroup.length > 0) {
const curTab = tabObjGroup[0] const curTab = tabObjGroup[0]
this.$store.commit('setNetworkOverviewCurrentTab', curTab) this.changeTabState(this.curTabState.curTab, curTab)
} }
this.$router.push({ this.$router.push({
params: { query: {
...this.$route.query,
thirdPanel: curTable.panelIdOfThirdMenu ? curTable.panelIdOfThirdMenu : '', thirdPanel: curTable.panelIdOfThirdMenu ? curTable.panelIdOfThirdMenu : '',
fourthPanel: toPanel || '' fourthPanel: toPanel || ''
} }
}) })
},
changeTabState (param, value) {
const query = {
...this.$route.query
}
query[param] = value
this.$router.push({
query: query
})
} }
}, },
mounted () { mounted () {

View File

@@ -77,6 +77,7 @@ export default {
}, },
mounted () { mounted () {
if (this.chart.panelId === drillDownPanelTypeMapping.npmOverviewIp) { if (this.chart.panelId === drillDownPanelTypeMapping.npmOverviewIp) {
const self = this
// 当client或server的session数为0时对应tab置灰不可选默认高亮另一个不为0的tab // 当client或server的session数为0时对应tab置灰不可选默认高亮另一个不为0的tab
const condition = this.$store.getters.getQueryCondition.split(/["|'](.*?)["|']/) const condition = this.$store.getters.getQueryCondition.split(/["|'](.*?)["|']/)
const params = { const params = {
@@ -86,28 +87,35 @@ export default {
} }
get(api.npm.overview.relatedSessions, params).then(res => { get(api.npm.overview.relatedSessions, params).then(res => {
if (res.code === 200) { if (res.code === 200) {
this.sessionData = res.data.result self.sessionData = res.data.result
this.clientSessions = this.sessionData.clientSessions / (this.sessionData.clientSessions * 1 + this.sessionData.serverSessions * 1) self.clientSessions = self.sessionData.clientSessions / (self.sessionData.clientSessions * 1 + self.sessionData.serverSessions * 1)
this.serverSessions = this.sessionData.serverSessions / (this.sessionData.clientSessions * 1 + this.sessionData.serverSessions * 1) self.serverSessions = self.sessionData.serverSessions / (self.sessionData.clientSessions * 1 + self.sessionData.serverSessions * 1)
} }
}).finally(() => { }).finally(() => {
if (this.clientSessions === 0) { if (self.clientSessions === 0) {
this.currentTab = 1 self.currentTab = 1
this.tabs[0].disable = true self.tabs[0].disable = true
this.tabs[1].disable = false self.tabs[1].disable = false
const tabEle = document.getElementById('tab-0') const tabEle = document.getElementById('tab-0')
tabEle.style.cssText = 'cursor: not-allowed;' tabEle.style.cssText = 'cursor: not-allowed;'
} else if (this.serverSessions === 0) { setTimeout(() => {
this.tabs[0].disable = false self.handleActiveBar(1)
this.tabs[1].disable = true }, 400)
} else if (self.serverSessions === 0) {
self.currentTab = 0
self.tabs[0].disable = false
self.tabs[1].disable = true
setTimeout(() => { setTimeout(() => {
const tabEle = document.getElementById('tab-1') const tabEle = document.getElementById('tab-1')
tabEle.style.cssText = 'cursor: not-allowed;' tabEle.style.cssText = 'cursor: not-allowed;'
this.handleActiveBar(0) self.handleActiveBar(0)
}, 400) }, 400)
} else { } else {
self.currentTab = 0
self.tabs[0].disable = false
self.tabs[1].disable = false
setTimeout(() => { setTimeout(() => {
this.handleActiveBar(0) self.handleActiveBar(0)
}, 400) }, 400)
} }
}) })