diff --git a/core/core-frontend/src/views/chart/components/editor/index.vue b/core/core-frontend/src/views/chart/components/editor/index.vue index f8ef28dcc3..04670bc946 100644 --- a/core/core-frontend/src/views/chart/components/editor/index.vue +++ b/core/core-frontend/src/views/chart/components/editor/index.vue @@ -59,6 +59,9 @@ const snapshotStore = snapshotStoreWithOut() const dvMainStore = dvMainStoreWithOut() const { canvasCollapse, curComponent, componentData, editMode } = storeToRefs(dvMainStore) const router = useRouter() +let componentNameEdit = ref(false) +let inputComponentName = ref('') +let componentNameInput = ref(null) const { t } = useI18n() const loading = ref(false) @@ -93,6 +96,35 @@ const editCalcField = ref(false) const isCalcFieldAdd = ref(true) const calcEdit = ref() const route = useRoute() + +const onComponentNameChange = () => { + snapshotStore.recordSnapshotCache() +} + +const closeEditComponentName = () => { + componentNameEdit.value = false + if (!inputComponentName.value || !inputComponentName.value.trim()) { + return + } + if (inputComponentName.value.trim() === view.value.title) { + return + } + if (inputComponentName.value.trim().length > 64 || inputComponentName.value.trim().length < 2) { + ElMessage.warning('名称字段长度2-64个字符') + editComponentName() + return + } + view.value.title = inputComponentName.value + inputComponentName.value = '' +} + +const editComponentName = () => { + componentNameEdit.value = true + inputComponentName.value = view.value.title + nextTick(() => { + componentNameInput.value.focus() + }) +} const toolTip = computed(() => { return props.themes === 'dark' ? 'ndark' : 'dark' }) @@ -1511,7 +1543,9 @@ const drop = (ev: MouseEvent, type = 'xAxis') => {
- {{ view.title }} + {{ + view.title + }} @@ -2897,6 +2931,15 @@ const drop = (ev: MouseEvent, type = 'xAxis') => {
+ + +