fix(editor): 修改未包含数据源的配置,画布中没有实时更新

This commit is contained in:
roymondchen 2024-12-04 16:26:48 +08:00 committed by roymondchen
parent 945aaaddcb
commit 0d6420215c
3 changed files with 21 additions and 20 deletions

View File

@ -21,10 +21,10 @@ import {
Target, Target,
} from '@tmagic/core'; } from '@tmagic/core';
import { ChangeRecord } from '@tmagic/form'; import { ChangeRecord } from '@tmagic/form';
import { getNodes, isPage, traverseNode } from '@tmagic/utils'; import { getNodes, isPage, isValueIncludeDataSource, traverseNode } from '@tmagic/utils';
import PropsPanel from './layouts/PropsPanel.vue'; import PropsPanel from './layouts/PropsPanel.vue';
import { isIncludeDataSource, isValueIncludeDataSource } from './utils/editor'; import { isIncludeDataSource } from './utils/editor';
import { EditorProps } from './editorProps'; import { EditorProps } from './editorProps';
import { Services } from './type'; import { Services } from './type';
@ -418,7 +418,8 @@ export const initServiceEvents = (
isValueIncludeDataSource(record.value) isValueIncludeDataSource(record.value)
) { ) {
needRecollectNodes.push(newNode); needRecollectNodes.push(newNode);
break; } else {
normalNodes.push(newNode);
} }
} }
} else if (isIncludeDataSource(newNode, oldNode)) { } else if (isIncludeDataSource(newNode, oldNode)) {

View File

@ -25,13 +25,13 @@ import { NODE_CONDS_KEY, NodeType } from '@tmagic/core';
import type StageCore from '@tmagic/stage'; import type StageCore from '@tmagic/stage';
import { import {
calcValueByFontsize, calcValueByFontsize,
DATA_SOURCE_FIELDS_SELECT_VALUE_PREFIX,
getElById, getElById,
getNodePath, getNodePath,
isNumber, isNumber,
isPage, isPage,
isPageFragment, isPageFragment,
isPop, isPop,
isValueIncludeDataSource,
} from '@tmagic/utils'; } from '@tmagic/utils';
import { Layout } from '@editor/type'; import { Layout } from '@editor/type';
@ -302,22 +302,6 @@ export const moveItemsInContainer = (sourceIndices: number[], parent: MContainer
} }
}; };
export const isValueIncludeDataSource = (value: any) => {
if (typeof value === 'string' && /\$\{([\s\S]+?)\}/.test(value)) {
return true;
}
if (Array.isArray(value) && `${value[0]}`.startsWith(DATA_SOURCE_FIELDS_SELECT_VALUE_PREFIX)) {
return true;
}
if (value?.isBindDataSource && value.dataSourceId) {
return true;
}
if (value?.isBindDataSourceField && value.dataSourceId) {
return true;
}
return false;
};
const isIncludeDataSourceByDiffAddResult = (diffResult: any) => { const isIncludeDataSourceByDiffAddResult = (diffResult: any) => {
for (const value of Object.values(diffResult)) { for (const value of Object.values(diffResult)) {
const result = isValueIncludeDataSource(value); const result = isValueIncludeDataSource(value);

View File

@ -509,3 +509,19 @@ export const traverseNode = <T extends NodeItem = NodeItem>(
}); });
} }
}; };
export const isValueIncludeDataSource = (value: any) => {
if (typeof value === 'string' && /\$\{([\s\S]+?)\}/.test(value)) {
return true;
}
if (Array.isArray(value) && `${value[0]}`.startsWith(DATA_SOURCE_FIELDS_SELECT_VALUE_PREFIX)) {
return true;
}
if (value?.isBindDataSource && value.dataSourceId) {
return true;
}
if (value?.isBindDataSourceField && value.dataSourceId) {
return true;
}
return false;
};