CN-1035: 多页签图表loading和error交互开发

This commit is contained in:
刘洪洪
2023-05-22 16:39:20 +08:00
parent 8c74be31bb
commit c50e41e649
4 changed files with 131 additions and 105 deletions

View File

@@ -1,9 +1,9 @@
<template> <template>
<div> <div>
<chart-error v-if="showError" :content="errorMsg" style="margin-top: 18px;margin-left: 8px;"></chart-error> <chart-error v-if="showError" :content="errorMsg" class="entity-detail-event-error"></chart-error>
<chart-no-data v-if="isNoData && !showError"></chart-no-data> <chart-no-data v-if="isNoData && !showError"></chart-no-data>
<div class="digital-certificate" v-if="!showError && !isNoData" :style="{width: moreCertificatesWidth}"> <div v-if="!isNoData && !showError && !loading" class="digital-certificate" :style="{width: moreCertificatesWidth}">
<div class="digital-certificate-header"> <div class="digital-certificate-header">
<div class="digital-certificate-header__icon"></div> <div class="digital-certificate-header__icon"></div>
<div class="digital-certificate-header-name"> <div class="digital-certificate-header-name">
@@ -51,9 +51,9 @@ export default {
data () { data () {
return { return {
showError: false, showError: false,
isNoData: false,
infoList: [], infoList: [],
errorMsg: '' errorMsg: '',
loading: true // 添加loading为了避免初始化loading时标题显示而在loading结束error出现时标题隐藏导致闪一下的效果
} }
}, },
mixins: [chartMixin], mixins: [chartMixin],
@@ -88,6 +88,7 @@ export default {
name: this.entityName // 实体名称 name: this.entityName // 实体名称
} }
this.loading = true
this.toggleLoading(true) this.toggleLoading(true)
// todo 接口、数据不明确故没有模拟mock数据后续此处需修改 // todo 接口、数据不明确故没有模拟mock数据后续此处需修改
axios.get(api.entity.performanceEvent, { params: params }).then(response => { axios.get(api.entity.performanceEvent, { params: params }).then(response => {
@@ -160,6 +161,7 @@ export default {
console.error(e) console.error(e)
this.httpError(e) this.httpError(e)
}).finally(() => { }).finally(() => {
this.loading = false
this.toggleLoading(false) this.toggleLoading(false)
}) })
}, },

View File

@@ -1,6 +1,9 @@
<template> <template>
<div>
<chart-error v-if="showError" :content="errorMsg" class="entity-detail-event-error"></chart-error>
<chart-no-data v-if="isNoData && !showError"></chart-no-data> <chart-no-data v-if="isNoData && !showError"></chart-no-data>
<div class="type-data__column">
<div v-if="!isNoData && !showError && !loading" class="type-data__column">
<div class="type-data"> <div class="type-data">
<div class="type-title"> <div class="type-title">
<span class="title-mark" ></span>{{ $t('entities.tab.relatedApp') }}&nbsp;&nbsp;({{relatedAppList.length}})</div> <span class="title-mark" ></span>{{ $t('entities.tab.relatedApp') }}&nbsp;&nbsp;({{relatedAppList.length}})</div>
@@ -23,6 +26,7 @@
</div> </div>
</div> </div>
</div> </div>
</div>
</template> </template>
<script> <script>
import { getNowTime, getSecond } from '@/utils/date-util' import { getNowTime, getSecond } from '@/utils/date-util'
@@ -42,7 +46,9 @@ export default {
relatedAppList: [], relatedAppList: [],
relatedIpList: [], relatedIpList: [],
relatedDomainList: [], relatedDomainList: [],
showError: false showError: false,
errorMsg: '',
loading: true
} }
}, },
mounted () { mounted () {
@@ -79,6 +85,7 @@ export default {
endTime: getSecond(this.timeFilter.endTime), endTime: getSecond(this.timeFilter.endTime),
ip: '116.178.70.242' ip: '116.178.70.242'
} }
this.loading = true
this.toggleLoading(true) this.toggleLoading(true)
const relatedApp = new Promise(resolve => { const relatedApp = new Promise(resolve => {
axios.get(api.entity.domainNameResolutionRelatedApp, { params: params }).then(response => { axios.get(api.entity.domainNameResolutionRelatedApp, { params: params }).then(response => {
@@ -140,6 +147,7 @@ export default {
}) })
Promise.all([relatedApp, relatedIp, relatedDomain]).finally(response => { Promise.all([relatedApp, relatedIp, relatedDomain]).finally(response => {
this.toggleLoading(false) this.toggleLoading(false)
this.loading = false
}) })
}, },
httpError (e) { httpError (e) {

View File

@@ -1,5 +1,10 @@
<template> <template>
<div class="information-aggregation__table"> <div>
<!--初步方案error提示替换table后续若改为table内error提示记得在此修改-->
<chart-error v-if="showError" :content="errorMsg" class="entity-detail-event-error"></chart-error>
<chart-no-data v-if="isNoData && !showError"></chart-no-data>
<div v-if="!isNoData && !showError" class="information-aggregation__table">
<el-table <el-table
style="width: 100%" style="width: 100%"
tooltip-effect="light" tooltip-effect="light"
@@ -78,6 +83,7 @@
</el-table-column> </el-table-column>
</el-table> </el-table>
</div> </div>
</div>
</template> </template>
<script> <script>
@@ -87,7 +93,9 @@ export default {
name: 'InformationAggregation', name: 'InformationAggregation',
data () { data () {
return { return {
informationAggregationList: [] informationAggregationList: [],
errorMsg: '',
showError: false
} }
}, },
mixins: [chartMixin], mixins: [chartMixin],

View File

@@ -1,6 +1,9 @@
<template> <template>
<div>
<chart-error v-if="showError" :content="errorMsg" class="entity-detail-event-error"></chart-error>
<chart-no-data v-if="isNoData && !showError"></chart-no-data> <chart-no-data v-if="isNoData && !showError"></chart-no-data>
<div class="type-data__column">
<div v-if="!showError && !isNoData && !loading" class="type-data__column">
<div class="type-data"> <div class="type-data">
<div class="type-title"> <div class="type-title">
<span class="title-mark" ></span>{{ $t('entities.tab.currentDevelopmentPortsAndServices') }}&nbsp;&nbsp;(5)</div> <span class="title-mark" ></span>{{ $t('entities.tab.currentDevelopmentPortsAndServices') }}&nbsp;&nbsp;(5)</div>
@@ -9,6 +12,7 @@
</div> </div>
</div> </div>
</div> </div>
</div>
</template> </template>
<script> <script>
import { getNowTime, getSecond } from '@/utils/date-util' import { getNowTime, getSecond } from '@/utils/date-util'
@@ -26,7 +30,9 @@ export default {
data () { data () {
return { return {
openPortList: [], openPortList: [],
showError: false showError: false,
errorMsg: '',
loading: true
} }
}, },
mounted () { mounted () {
@@ -64,6 +70,7 @@ export default {
} }
this.toggleLoading(true) this.toggleLoading(true)
this.loading = true
axios.get(api.entity.openPort, { params: params }).then(response => { axios.get(api.entity.openPort, { params: params }).then(response => {
const res = response.data const res = response.data
if (res.code === 200) { if (res.code === 200) {
@@ -80,6 +87,7 @@ export default {
this.httpError(e) this.httpError(e)
}).finally(() => { }).finally(() => {
this.toggleLoading(false) this.toggleLoading(false)
this.loading = false
}) })
}, },
httpError (e) { httpError (e) {