fix: 请求添加error处理

This commit is contained in:
刘洪洪
2022-11-21 17:31:30 +08:00
parent 69735e438f
commit c3ffd01363
19 changed files with 392 additions and 155 deletions

View File

@@ -1,6 +1,15 @@
<template>
<div>
<div v-if="showSmall">
<div v-if="showDefault" class="error-component">
<div class="error-block" :style="{'max-width': localMaxWidth, 'width': localWidth}">
<svg class="icon item-popover-up error-icon1" aria-hidden="true">
<use xlink:href="#cn-icon-baocuo"></use>
</svg>
{{ content }}
</div>
</div>
<div id="error-com">
<div v-if="tooltip !== undefined">
<el-popover
:width="localPopoverWidth"
placement="top-start"
@@ -29,8 +38,8 @@
<!-- </span>-->
</div>
<div v-else class="error-block">
<div class="error-block-tooltip" :style="{'max-width': localMaxWidth, 'width': localWidth}">
<div class="error-block-info" v-if="info !== undefined">
<div>
<svg class="icon item-popover-up error-icon1" aria-hidden="true">
<use xlink:href="#cn-icon-baocuo"></use>
</svg>
@@ -45,21 +54,29 @@
组件在全局注册了调用时: <chart-error :content="content"></chart-error>
-->
<!--
在标题之后显示<chart-error small :content="content" />
目前有三种形式分别是defaulttooltipinfo
默认即红框展示<chart-error :content="content" />
在标题之后显示需要鼠标移动到图标上显示弹窗<chart-error tooltip :content="content" />
文字提示<chart-error tooltip :content="content" />
-->
<!--
自定义弹窗宽度<chart-error small width="300" :content="content" />
自定义弹窗宽度<chart-error tooltip width="300" :content="content" />
注意info模式不支持宽度设置
-->
<!--
自定义icon图标<chart-error small icon="baocuo" :content="content" />此时icon全称为'cn-icon-baocuo'
自定义icon图标<chart-error tooltip icon="baocuo" :content="content" />此时icon全称为'cn-icon-baocuo'
-->
<!-- end----------------调用方式----------------end -->
<script>
export default {
name: 'Error',
props: {
// 模块标识small即标题之后出现icon图标鼠标移入显示报错信息非small即在div内显示报错信息
small: {
// 工具栏提示类型
tooltip: {
type: String
},
// 文字提示类型
info: {
type: String
},
// 报错信息内容,如果不传,默认为"Error"
@@ -67,14 +84,14 @@ export default {
type: String,
default: 'Error'
},
// 报错信息模块宽度,如果选择small则为弹窗宽度
// 报错信息模块宽度,如果类型选择tooltip则为弹窗宽度info模式没有宽度设置
width: {
type: String
},
// 报错信息模块最大宽度
maxWidth: {
type: String,
default: '350'
type: String
// default: '350'
},
// 自定义icon图标
icon: {
@@ -87,10 +104,11 @@ export default {
},
data () {
return {
showDefault: false, // 是否显示default分别是default、tooltip、info
showSmall: false, // 显示错误的类型true为图表模块内显示报错false为标题后显示报错
localWidth: '',
localMaxWidth: '',
localPopoverWidth: '350'
localPopoverWidth: ''
}
},
mounted () {
@@ -98,11 +116,15 @@ export default {
},
methods: {
initData () {
if (this.small !== undefined) {
this.showSmall = true
if (this.tooltip !== undefined) {
this.showDefault = false
this.localPopoverWidth = this.width !== undefined
}
if (this.tooltip === undefined && this.info === undefined) {
this.showDefault = true
} else {
this.showSmall = false
this.showDefault = false
}
if (this.width) {