diff --git a/src/widget/lowcodetransfer/lowcodeTransfer.vue b/src/widget/lowcodetransfer/lowcodeTransfer.vue index a7b9525..facde37 100644 --- a/src/widget/lowcodetransfer/lowcodeTransfer.vue +++ b/src/widget/lowcodetransfer/lowcodeTransfer.vue @@ -196,7 +196,70 @@ const selectedValueCompu = computed({ const url = transferConfig.value.apiUrl;/* '/javasys/lowCode/transfer/getOrgAndManTree' */ let resData = ref([]) - +function endsWithGetOrgAndManTree(str) { + // 检查输入是否为字符串 + if (typeof str !== 'string') { + return false; + } + const suffix = 'getOrgAndManTree'; + // 当字符串长度小于后缀长度时,直接返回false + if (str.length < suffix.length) { + return false; + } + // 获取字符串末尾与后缀长度相同的子字符串并比较 + return str.slice(-suffix.length) === suffix; +} +function processTreeData(node) { + if(!endsWithGetOrgAndManTree(url)){ + return node + } + // 检查节点及其所有子孙节点中是否存在id长度大于4的节点 + function hasLongIdNode(node) { + // 检查当前节点id长度 + if (node.id && node.id.length > 4) { + return true; + } + + // 处理子节点(考虑children为null的情况) + if (node.children && Array.isArray(node.children) && node.children.length > 0) { + for (const child of node.children) { + if (hasLongIdNode(child)) { + return true; + } + } + } + + return false; + } + + // 递归处理节点 + function processNode(node) { + // 如果当前节点及其所有子孙都没有长id,则移除该节点 + if (!hasLongIdNode(node)) { + return null; + } + + // 复制节点避免修改原对象 + const newNode = {...node}; + + // 处理子节点 + if (newNode.children && Array.isArray(newNode.children) && newNode.children.length > 0) { + // 递归处理每个子节点并过滤掉需要移除的 + newNode.children = newNode.children + .map(child => processNode(child)) + .filter(child => child !== null); + + // 如果所有子节点都被移除,保持children为null + if (newNode.children.length === 0) { + newNode.children = null; + } + } + + return newNode; + } + + return processNode(node); +} function getDetail() { //console.log(11111) @@ -209,8 +272,15 @@ function getDetail() { } if (transferConfig.value.transferDataSource === "数据源") { getDetail().then(({ data }) => { + + + const data1 = processTreeData(data) + + + + //console.log(`获取穿梭框接口数据`); - resData.value = data.children + resData.value = data1.children // 全选方法2:插入 全选node userList.value = [{ id: '全选', @@ -614,8 +684,10 @@ watch(transferConfig, (newValue, oldValue) => { getDetail().then(({ data }) => { + + const data1 = processTreeData(data) //console.log(`获取穿梭框接口数据`); - resData.value = data.children + resData.value = data1.children // 全选方法2:插入 全选node userList.value = [{ id: '全选',