From b5de1cec88ec74abb49eca4676853d5c1463a8e8 Mon Sep 17 00:00:00 2001 From: wisonic Date: Sun, 18 Aug 2024 17:28:01 +0800 Subject: [PATCH] =?UTF-8?q?refactor(=E5=9B=BE=E8=A1=A8):=20=E6=8C=89?= =?UTF-8?q?=E5=88=97=E9=85=8D=E7=BD=AE=E6=9C=80=E5=A4=A7=E5=AE=BD=E5=BA=A6?= =?UTF-8?q?=E9=99=90=E5=88=B6=200-200?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../components/BasicStyleSelector.vue | 20 +++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/core/core-frontend/src/views/chart/components/editor/editor-style/components/BasicStyleSelector.vue b/core/core-frontend/src/views/chart/components/editor/editor-style/components/BasicStyleSelector.vue index 1105d720c8..3915f499b7 100644 --- a/core/core-frontend/src/views/chart/components/editor/editor-style/components/BasicStyleSelector.vue +++ b/core/core-frontend/src/views/chart/components/editor/editor-style/components/BasicStyleSelector.vue @@ -11,6 +11,8 @@ import { cloneDeep, defaultsDeep } from 'lodash-es' import { SERIES_NUMBER_FIELD } from '@antv/s2' import { dvMainStoreWithOut } from '@/store/modules/data-visualization/dvMain' import { storeToRefs } from 'pinia' +import { isNumber } from 'mathjs' +import { ElMessage } from 'element-plus-secondary' const dvMainStore = dvMainStoreWithOut() const { batchOptStatus } = storeToRefs(dvMainStore) @@ -167,9 +169,25 @@ const changeFieldColumn = () => { } const changeFieldColumnWidth = () => { const { basicStyleForm, fieldColumnWidth } = state + let { width } = fieldColumnWidth + let validate = true + width = parseFloat(width) + if (isNaN(width) || !isNumber(width)) { + validate = false + } + if (width < 0 || width > 200) { + validate = false + } const fieldWidth = basicStyleForm.tableFieldWidth?.find( i => i.fieldId === fieldColumnWidth.fieldId ) + if (!validate) { + ElMessage.warning('宽度需要在 0-200 之间') + if (fieldWidth) { + fieldColumnWidth.width = fieldWidth.width + } + return + } if (fieldWidth) { fieldWidth.width = fieldColumnWidth.width changeBasicStyle('tableFieldWidth') @@ -745,8 +763,6 @@ onMounted(() => { v-model.number="state.fieldColumnWidth.width" type="number" class="basic-input-number" - :min="0" - :max="100" :effect="themes" :disabled="batchOptStatus" @change="changeFieldColumnWidth()"