NEZ-789 fix: 添加报错提示

This commit is contained in:
zhangyu
2021-07-02 14:03:17 +08:00
parent 08fa556310
commit 132b5f927c
8 changed files with 98 additions and 29 deletions

View File

@@ -7,7 +7,7 @@
<div class="resize-box resize-box-alert" ref="resizeBox"> <div class="resize-box resize-box-alert" ref="resizeBox">
<div class="chart-alert-info table-container" :id="'chartTableDiv'+chartIndex" @mouseenter="caretShow=true" @mouseleave="caretShow=false"> <div class="chart-alert-info table-container" :id="'chartTableDiv'+chartIndex" @mouseenter="caretShow=true" @mouseleave="caretShow=false">
<loading :ref="'localLoading'+chartIndex"></loading> <loading :ref="'localLoading'+chartIndex"></loading>
<div class="clearfix chartTitle" :class="{'dragTitle':dragTitleShow, 'drag-disabled': !data.draggable}" :id="'chartTitle'+chartIndex" v-show="!isPreview"> <div v-if="showTitle" class="clearfix chartTitle" :class="{'dragTitle':dragTitleShow, 'drag-disabled': !data.draggable}" :id="'chartTitle'+chartIndex" v-show="!isPreview">
<el-popover <el-popover
v-if="isError" v-if="isError"
:close-delay=10 :close-delay=10
@@ -159,6 +159,10 @@ export default {
type: Number, type: Number,
default: 0 default: 0
}, },
showTitle: {
type: Boolean,
default: true
},
editChartId: { editChartId: {
type: String, type: String,
default: 'editChartId' default: 'editChartId'
@@ -233,7 +237,6 @@ export default {
label: this.$t('alert.alertName'), label: this.$t('alert.alertName'),
prop: 'alertRule', prop: 'alertRule',
show: true, show: true,
width: 180
}, /* { }, /* {
label: this.$t("alert.list.type"), label: this.$t("alert.list.type"),
prop: 'type', prop: 'type',
@@ -905,3 +908,8 @@ export default {
} }
} }
</script> </script>
<style scoped>
.table-container{
height: calc(100% - 40px);
}
</style>

View File

@@ -168,7 +168,7 @@
</div> </div>
</template> </template>
<chart-alert-list v-if="chart.type === 'alertList'" ref="alertListChart" id="chartAlertListPreview" :chart-info="chart" :chart-data="chart" class="height-100"></chart-alert-list> <chart-alert-list v-if="chart.type === 'alertList'" :showTitle="false" ref="alertListChart" id="chartAlertListPreview" :chart-info="chart" :chart-data="chart" class="height-100"></chart-alert-list>
<template v-if="chart.type==='text'"> <template v-if="chart.type==='text'">
<div id="chartTextPreview" class="chart-text-preview height-100"> <div id="chartTextPreview" class="chart-text-preview height-100">
@@ -178,6 +178,14 @@
</div> </div>
</template> </template>
<template v-if="chart.type==='diagram'">
<div id="chartDiagramPreview" class="chart-text-preview height-100">
<div style="height: 100%; overflow: auto;">
<diagram :topoData="chart.param.topo" :fromChartBox="true" :topologyIndexF="-3"/>
</div>
</div>
</template>
<loading ref="loadingPreview" class="height-100"></loading> <loading ref="loadingPreview" class="height-100"></loading>
</el-dialog> </el-dialog>
</template> </template>
@@ -190,12 +198,14 @@ import chartDataFormat from './chartDataFormat'
import { randomcolor } from '../common/js/radomcolor/randomcolor.js' import { randomcolor } from '../common/js/radomcolor/randomcolor.js'
import chartAlertList from './chart-alert-list' import chartAlertList from './chart-alert-list'
import chartConfig from '../page/dashboard/overview/chartConfig' import chartConfig from '../page/dashboard/overview/chartConfig'
import diagram from '@/components/common/ChartDiagram/diagram'
import moment from 'moment-timezone' import moment from 'moment-timezone'
export default { export default {
name: 'chartPreview', name: 'chartPreview',
components: { components: {
loading: loading, loading: loading,
'chart-alert-list': chartAlertList 'chart-alert-list': chartAlertList,
diagram
}, },
props: { props: {
panelId: Number, panelId: Number,
@@ -288,6 +298,8 @@ export default {
chartContainerId = 'chartAlertListPreview' chartContainerId = 'chartAlertListPreview'
} else if (chartType == 'text') { } else if (chartType == 'text') {
chartContainerId = 'chartTextPreview' chartContainerId = 'chartTextPreview'
} else if (chartType == 'diagram') {
chartContainerId = 'chartDiagramPreview'
} }
// 设置高度 chart-table // 设置高度 chart-table
@@ -356,7 +368,7 @@ export default {
// //
} }
// 后台获得数据 // 后台获得数据
if (this.chart.type !== 'url' && this.chart.type !== 'text') { if (this.chart.type !== 'url' && this.chart.type !== 'text' && this.chart.type !== 'diagram') {
this.$refs.loadingPreview.startLoading() this.$refs.loadingPreview.startLoading()
this.getChartData() this.getChartData()
} else if (this.chart.type == 'url') { } else if (this.chart.type == 'url') {

View File

@@ -340,7 +340,7 @@ import { getMetricTypeValue } from '../js/tools'
import bus from '../../../libs/bus' import bus from '../../../libs/bus'
import CanvasContextMenu from '@/components/common/project/L5/CanvasContextMenu' import CanvasContextMenu from '@/components/common/project/L5/CanvasContextMenu'
// 注册到画布 // 注册到画布
registerNode('rectangleImg', myShape, myAnchors, myIconRect2, null) registerNode('rectangleImg', myShape, myAnchors, myIconRect2, myTextRect2)
registerNode('myCube', myCubec, myCubeAnchors, null, null) registerNode('myCube', myCubec, myCubeAnchors, null, null)
const canvasOptions = { const canvasOptions = {

View File

@@ -59,7 +59,7 @@
</button> </button>
</div> </div>
</div> </div>
<div :style="calcStyle" class="nz-transfer__box nz-transfer__box--right"> <div :style="calcStyle" class="nz-transfer__box nz-transfer__box--right" :class="showError?'error' : ''">
<div class="box__header"> <div class="box__header">
<slot name="title"></slot> <slot name="title"></slot>
<slot></slot> <slot></slot>
@@ -131,6 +131,10 @@ export default {
}, },
tableTitle: { tableTitle: {
type: Array type: Array
},
showError: {
type: Boolean,
default: false
} }
}, },
data () { data () {
@@ -315,4 +319,7 @@ export default {
.hide-row { .hide-row {
display: none !important; display: none !important;
} }
.error{
border-color: #F56C6C !important;
}
</style> </style>

View File

@@ -252,6 +252,7 @@ export function myIconRect2 (node) {
node.fullIconRect = node.rect node.fullIconRect = node.rect
} }
export function myTextRect2 (node) { export function myTextRect2 (node) {
node.data.text = ''
node.textRect = new Rect( node.textRect = new Rect(
node.rect.x + node.paddingLeft, node.rect.x + node.paddingLeft,
node.rect.y + node.rect.height - 20 - node.paddingBottom, node.rect.y + node.rect.height - 20 - node.paddingBottom,

View File

@@ -119,7 +119,7 @@
</div> </div>
</div> </div>
<!--endpoint--> <!--endpoint-->
<div class="right-box-endpoint-table"> <div class="right-box-endpoint-table" :class="showError?'error' : ''">
<div class="search-box" style="display: flex;justify-content: flex-end"> <div class="search-box" style="display: flex;justify-content: flex-end">
<el-button class="top-tool-btn" type="button" @click="showRightBox"> <el-button class="top-tool-btn" type="button" @click="showRightBox">
<i class="nz-icon-gear nz-icon"></i> <i class="nz-icon-gear nz-icon"></i>
@@ -181,6 +181,7 @@
</span> </span>
</div> </div>
</div> </div>
<div v-if="showError" class="el-form-item__error">{{this.$t('validate.required')}}</div>
</div> </div>
</el-form> </el-form>
</div> </div>
@@ -432,7 +433,8 @@ export default {
label: 'state', label: 'state',
disabled: false disabled: false
}] }]
} },
showError: false,
} }
}, },
methods: { methods: {
@@ -565,8 +567,11 @@ export default {
} }
endpointList.push(endpoint) endpointList.push(endpoint)
}) })
if (endpointList.length === 0) {
this.showError = true
}
this.$refs.addEndpoint.validate((valid) => { this.$refs.addEndpoint.validate((valid) => {
if (valid) { if (valid && !this.showError) {
this.$post('monitor/endpoint', endpointList).then(response => { this.$post('monitor/endpoint', endpointList).then(response => {
this.prevent_opt.save = false this.prevent_opt.save = false
if (response.code === 200) { if (response.code === 200) {
@@ -606,6 +611,7 @@ export default {
}) })
}, },
addEndpoint () { addEndpoint () {
this.showError = false
const arr = [] const arr = []
this.assetSelection.forEach(item => { this.assetSelection.forEach(item => {
if (this.endpointTableData.find(endpoint => endpoint.assetId === item.id)) { if (this.endpointTableData.find(endpoint => endpoint.assetId === item.id)) {
@@ -1230,4 +1236,7 @@ export default {
} }
} }
} }
.error{
border-color: #F56C6C !important;
}
</style> </style>

View File

@@ -188,7 +188,9 @@
<!-- 选择资产穿梭框 --> <!-- 选择资产穿梭框 -->
<div class="form__sub-title">{{$t('overall.select')}}</div> <div class="form__sub-title">{{$t('overall.select')}}</div>
<div style="position: relative">
<nz-transfer ref="transfer" <nz-transfer ref="transfer"
:showError="showError"
style="margin-bottom: 20px;" style="margin-bottom: 20px;"
:page-obj="transfer.pageObj" :page-obj="transfer.pageObj"
:search-msg="transfer.searchMsg" :search-msg="transfer.searchMsg"
@@ -200,6 +202,8 @@
@rightToLeft="removeAsset"> @rightToLeft="removeAsset">
<template v-slot:title>Selected</template> <template v-slot:title>Selected</template>
</nz-transfer> </nz-transfer>
<div v-if="showError" class="el-form-item__error">{{this.$t('validate.required')}}</div>
</div>
</el-form> </el-form>
</div> </div>
</div> </div>
@@ -330,8 +334,28 @@ export default {
total: 0 total: 0
} }
}, },
rules: {}, rules: {
metaData: [] editType: [
{ required: true, message: this.$t('validate.required'), trigger: 'change' }
],
authProtocol: [
{ required: true, message: this.$t('validate.required'), trigger: 'change' }
],
authUsername: [
{ required: true, message: this.$t('validate.required'), trigger: 'change' }
],
authPin: [
{ required: true, message: this.$t('validate.required'), trigger: 'change' }
],
authUserTip: [
{ required: true, message: this.$t('validate.required'), trigger: 'change' }
],
authPinTip: [
{ required: true, message: this.$t('validate.required'), trigger: 'change' }
]
},
metaData: [],
showError: false
} }
}, },
methods: { methods: {
@@ -345,12 +369,19 @@ export default {
}, },
save () { save () {
this.editData.ids = this.transfer.selectedData.map(d => d.id) this.editData.ids = this.transfer.selectedData.map(d => d.id)
if (this.editData.ids.length === 0) {
this.showError = true
}
this.$refs.assetEditForm.validate((valid) => {
if (valid && !this.showError) {
this.$put('asset/asset/bulkEdit', this.editData).then(res => { this.$put('asset/asset/bulkEdit', this.editData).then(res => {
if (res.code === 200) { if (res.code === 200) {
this.$message({ duration: 2000, type: 'success', message: this.$t('tip.saveSuccess') }) this.$message({ duration: 2000, type: 'success', message: this.$t('tip.saveSuccess') })
this.esc(true) this.esc(true)
} }
}) })
}
})
}, },
addLabel ([groupId, metaId]) { addLabel ([groupId, metaId]) {
const label = this.metaData.find(m => m.id === metaId) const label = this.metaData.find(m => m.id === metaId)
@@ -411,6 +442,7 @@ export default {
this.transfer.tableData.forEach(d => { this.transfer.tableData.forEach(d => {
this.$set(d, 'hide', this.transfer.selectedData.some(s => s.id === d.id)) this.$set(d, 'hide', this.transfer.selectedData.some(s => s.id === d.id))
}) })
this.showError = false
}, },
removeAsset (toRemove) { removeAsset (toRemove) {
this.transfer.selectedData = this.transfer.selectedData.filter(d => !toRemove.find(s => d.id === s.id)) this.transfer.selectedData = this.transfer.selectedData.filter(d => !toRemove.find(s => d.id === s.id))

View File

@@ -116,7 +116,7 @@
</ul> </ul>
</el-scrollbar> </el-scrollbar>
<ul v-else> <ul v-else>
<li v-for="(item,key) in brandSelect" :key="key" :class="search_select_style_num==key?'search-style-ind':''" @click="selectObject(val, item, $event)">{{item.name}}</li> <li v-for="(item,key) in groupSelect" :key="key" :class="search_select_style_num==key?'search-style-ind':''" @click="selectObject(val, item, $event)">{{item.name}}</li>
</ul> </ul>
</div> </div>
<div v-if="val.type === 'project'" :style="'top:' + selectDom.top +'; left:'+selectDom.left " class="select_info_list"> <div v-if="val.type === 'project'" :style="'top:' + selectDom.top +'; left:'+selectDom.left " class="select_info_list">