refactor: 优化视图标题校验

This commit is contained in:
wangjiahao 2022-04-20 18:56:31 +08:00
parent 4ea6c83fa2
commit c164999209

View File

@ -44,6 +44,7 @@
<script> <script>
import { COLOR_PANEL, DEFAULT_TITLE_STYLE } from '../../chart/chart' import { COLOR_PANEL, DEFAULT_TITLE_STYLE } from '../../chart/chart'
import { checkTitle } from '@/api/chart/chart' import { checkTitle } from '@/api/chart/chart'
import { checkViewTitle } from '@/components/canvas/utils/utils'
export default { export default {
name: 'TitleSelectorAntV', name: 'TitleSelectorAntV',
@ -108,18 +109,12 @@ export default {
this.titleForm.title = this.chart.title this.titleForm.title = this.chart.title
return return
} }
checkTitle({ id: this.chart.id, title: this.titleForm.title, sceneId: this.chart.sceneId }).then((rsp) => { if (checkViewTitle('update', this.chart.id, this.titleForm.title)) {
if (rsp.data === 'success') { this.$error(this.$t('chart.title_repeat'))
if (!this.titleForm.show) { this.titleForm.title = this.chart.title
this.isSetting = false return
} }
this.$emit('onTextChange', this.titleForm) this.$emit('onTextChange', this.titleForm)
} else {
this.$error(this.$t('chart.title_repeat'))
this.titleForm.title = this.chart.title
return
}
})
}, },
inputOnInput: function(e) { inputOnInput: function(e) {
this.$forceUpdate() this.$forceUpdate()