Commit d47f220e authored by tianhongyang's avatar tianhongyang

企业详情页面 样式异常调整

parent 808fe2e7
......@@ -629,59 +629,91 @@ export function queryConditionFiltering(params) {
* @param {Array<object>} selectList
* @returns
*/
export function getTreeSelectAreaList(selectList) {
console.log(selectList);
export function getTreeSelectAreaList(node, tree) {
try {
if (Object.prototype.toString.call(selectList) != "[object Array]") throw new Error("传入参数不是一个数组");
if (!selectList?.length) return [];
// 处理成原始数据
const _temp = selectList.map(item => {
return JSON.parse(JSON.stringify({
label: item.label,
value: item.value,
level: item.level,
parent: item?.parent ? {
label: item?.parent?.label,
value: item?.parent?.value,
level: item?.parent.level,
} : null
}));
});
if (Object.prototype.toString.call(node) != "[object Object]") throw new Error("传入参数不是一个对象");
// 创建映射
const selectMap = {};
const _result = [];
// 不是顶级目标
const _childResult = [];
const _tempTree = JSON.parse(JSON.stringify(tree));
// 多树形结构
if (Object.prototype.toString.call(_tempTree) == "[object Array]") {
if (_tempTree.length) {
for (const iterator of _tempTree) {
const nodeAncestors = findNodeAndAncestors(iterator, node.value, "value");
// 查找到
if (nodeAncestors) {
console.log(nodeAncestors);
}
}
}
}
_temp.forEach(item => {
selectMap[item.value] = item;
});
// 单树形结构
} catch (error) {
console.log(error);
}
}
_temp.forEach(item => {
const parent = selectMap[item?.parent?.value];
// 存在父节点,添加到父节点的chidren
if (parent) {
parent.children ? parent.children.push(item) : (parent.children = []).push(item);
parent.childCount = parent.children.length;
} else {
// 有父级 但是没有选择父级节点
if (item?.parent?.value) {
_childResult.push(item);
/**
* 根据节点信息 找到当前节点到祖先辈组成的树形结构
* @param {*} tree
* @param {*} targetId
* @returns
*/
export function findNodeAndAncestors(tree, targetId, idKey = "id", directAncestorsOnly = true) {
if (tree[idKey] === targetId) {
// 找到目标节点,directAncestorsOnly 只找直系节点的情况下 如果是根节点(没有parent父级),返回节点本身不带子节点,否则返回节点的树形结构
return directAncestorsOnly && !tree.parent ? { ...tree, children: [] } : tree;
}
if (tree?.children?.length) {
for (const child of tree.children) {
const result = findNodeAndAncestors(child, targetId, idKey, directAncestorsOnly);
if (result) {
// 如果找到目标节点,将该节点加入祖先辈的树形结构中
if (directAncestorsOnly) {
return {
...tree,
children: [result]
};
} else {
_result.push(item);
return {
...tree,
children: tree?.children?.map(c => (c[idKey] === result[idKey] ? result : c))
};
}
}
});
}
}
console.log(selectMap);
// 如果未找到目标节点,返回null
return null;
}
return _result;
} catch (error) {
console.log(error);
/**
* 根据节点唯一标识查找节点信息
* @param {*} tree
* @param {*} targetId
* @param {*} idKes
*/
export function findNodeFromTree(tree, targetId, idKes = "id") {
if (tree[idKes] == targetId) {
return tree;
}
if (tree?.children?.length) {
for (const child of tree.children) {
// 递归到孙子集查找
const result = findNodeFromTree(child, targetId);
if (result) {
// 如果找到目标节点,返回目标节点
return result;
}
}
}
return null;
}
// 甲方详情左侧菜单映射
......
......@@ -258,8 +258,13 @@ export default {
}
},
handleChange(params) {
const tree = this.$refs?.areaTree?.getCheckedNodes();
console.log(getTreeSelectAreaList(tree), "filter");
const selectNode = this.$refs?.areaTree?.getCheckedNodes();
if (selectNode?.length) {
const result = selectNode.map(item => {
return getTreeSelectAreaList(item, this.areaDataList);
});
console.log(result);
}
}
},
}
......
......@@ -411,9 +411,6 @@ export default {
.details-of-party {
width: 100%;
height: 100%;
position: absolute;
top: 0;
left: 0;
margin: 0px;
padding: 16px 24px;
box-sizing: border-box;
......@@ -425,18 +422,29 @@ export default {
}
::v-deep .part-main {
height: calc(100% - 56px - 12px);
height: calc(100% - 68px);
overflow-y: hidden;
overflow-x: hidden;
.part-right {
margin-left: 160px;
width: calc(100% - 160px);
overflow: auto;
}
}
overflow: hidden;
.part-common-container-style {
width: 100%;
height: 100%;
.part-common-container-style {
width: 100%;
height: 100%;
overflow: auto;
.app-container {
position: relative;
width: auto;
height: auto;
overflow: initial;
box-sizing: border-box;
}
}
}
}
}
</style>
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment