Browse Source

关联表单不应该能选择本表及本表之下的子表

lwx_v20
liwenxuan 9 months ago
parent
commit
ebd2c2f5e4
  1. 31
      src/components/DesignForm/formControlPropertiNew.vue

31
src/components/DesignForm/formControlPropertiNew.vue

@ -2577,10 +2577,39 @@ function getAssociatedFormsCurrentFieldTree1() {
} }
}); });
} }
function removeTreeNode(tree: any, targetId: any) {
//
const clonedTree = JSON.parse(JSON.stringify(tree));
//
function processNode(node) {
// null
if (node.id === targetId) return null;
//
if (node.children?.length) {
node.children = node.children
.map(child => processNode(child))
.filter(Boolean);
}
return node;
}
//
const result = Array.isArray(clonedTree)
? clonedTree.map(node => processNode(node)).filter(Boolean)
: processNode(clonedTree);
return result || null;
}
const customerFormTree = ref<Tree[]>(); const customerFormTree = ref<Tree[]>();
getCustomerFormList().then(({ data }) => { getCustomerFormList().then(({ data }) => {
let resData = ref(data.children); /* console.log(data.children)
console.log(props.customerformid) */
let datachildrenWithoutSelf = removeTreeNode(data.children,props.customerformid)
let resData = ref(datachildrenWithoutSelf);
customerFormTree.value = [ customerFormTree.value = [
{ {
id: data.id, id: data.id,

Loading…
Cancel
Save