Feat:createUidForAppointNodes工具方法支持处理概要数据

This commit is contained in:
wanglin2 2025-02-01 11:29:00 +08:00
parent 1770cb98aa
commit b0a5c8c12a

View File

@ -508,7 +508,7 @@ export const loadImage = imgFile => {
// 移除字符串中的html实体 // 移除字符串中的html实体
export const removeHTMLEntities = str => { export const removeHTMLEntities = str => {
[[' ', ' ']].forEach(item => { ;[[' ', ' ']].forEach(item => {
str = str.replace(new RegExp(item[0], 'g'), item[1]) str = str.replace(new RegExp(item[0], 'g'), item[1])
}) })
return str return str
@ -1002,7 +1002,8 @@ export const addDataToAppointNodes = (appointNodes, data = {}) => {
export const createUidForAppointNodes = ( export const createUidForAppointNodes = (
appointNodes, appointNodes,
createNewId = false, createNewId = false,
handle = null handle = null,
handleGeneralization = false
) => { ) => {
const walk = list => { const walk = list => {
list.forEach(node => { list.forEach(node => {
@ -1012,6 +1013,14 @@ export const createUidForAppointNodes = (
if (createNewId || isUndef(node.data.uid)) { if (createNewId || isUndef(node.data.uid)) {
node.data.uid = createUid() node.data.uid = createUid()
} }
if (handleGeneralization) {
const generalizationList = formatGetNodeGeneralization(node.data)
generalizationList.forEach(gNode => {
if (createNewId || isUndef(gNode.uid)) {
gNode.uid = createUid()
}
})
}
handle && handle(node) handle && handle(node)
if (node.children && node.children.length > 0) { if (node.children && node.children.length > 0) {
walk(node.children) walk(node.children)
@ -1060,7 +1069,7 @@ export const generateColorByContent = str => {
// html转义 // html转义
export const htmlEscape = str => { export const htmlEscape = str => {
[ ;[
['&', '&'], ['&', '&'],
['<', '&lt;'], ['<', '&lt;'],
['>', '&gt;'] ['>', '&gt;']