|
@@ -1,7 +1,7 @@
|
|
|
/*
|
|
|
* @Author: your name
|
|
|
* @Date: 2021-12-13 09:43:22
|
|
|
- * @LastEditTime: 2022-06-01 11:37:15
|
|
|
+ * @LastEditTime: 2022-06-01 11:44:11
|
|
|
* @LastEditors: your name
|
|
|
* @Description: 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
|
|
|
*/
|
|
@@ -36,7 +36,6 @@ export function orgTree (str) {
|
|
|
}
|
|
|
|
|
|
// 岗位树构造
|
|
|
-<<<<<<< HEAD
|
|
|
// export function translateDataToTreeAll (data, parentKey, parentIDKey) {
|
|
|
// let parent = data.filter((value) => Number(value[parentKey]) <= 0);// 父数据
|
|
|
// let children = data.filter((value) => Number(value[parentKey]) > 0);// 子数据
|
|
@@ -92,41 +91,6 @@ export function translateDataToTreeAll(arr, parentKey, key) {
|
|
|
}
|
|
|
})
|
|
|
return result
|
|
|
-=======
|
|
|
-export function translateDataToTreeAll (data, parentKey, parentIDKey) {
|
|
|
- let parent = data.filter((value) => Number(value[parentKey]) <= 0);// 父数据
|
|
|
- let children = data.filter((value) => Number(value[parentKey]) > 0);// 子数据
|
|
|
- //console.log('--parent', parent)
|
|
|
- //console.log('--children', children)
|
|
|
- let translator = (parent, children) => {
|
|
|
- parent.forEach((parent) => {
|
|
|
- parent.children = [];
|
|
|
- children.forEach((current, index) => {
|
|
|
- if (current[parentKey] === parent[parentIDKey]) {
|
|
|
- const temp = JSON.parse(JSON.stringify(children));
|
|
|
- temp.splice(index, 1);
|
|
|
- translator([current], temp);
|
|
|
- typeof parent.children !== "undefined"
|
|
|
- ? parent.children.push(current)
|
|
|
- : (parent.children = [current]);
|
|
|
- }
|
|
|
- });
|
|
|
- // for (let i = 0; i < children.length;) {
|
|
|
- // if (children[i][parentKey] === parent[parentIDKey]) {
|
|
|
- // const temp = children.splice(i, 1)
|
|
|
- // typeof parent.children !== 'undefined'
|
|
|
- // ? parent.children.push(...temp)
|
|
|
- // : (parent.children = temp)
|
|
|
- // translator(temp, children)
|
|
|
- // } else {
|
|
|
- // i++
|
|
|
- // }
|
|
|
- // }
|
|
|
- });
|
|
|
- };
|
|
|
- translator(parent, children);
|
|
|
- return parent;
|
|
|
->>>>>>> 04ae07ca885de7a9cb5dc39ef96eca5b2292c339
|
|
|
}
|
|
|
|
|
|
export function deteleObject (obj) {
|