From 6810243ab70731b4da48635d3c3a9e5836a02c45 Mon Sep 17 00:00:00 2001 From: RuoYi Date: Fri, 9 Apr 2021 08:31:13 +0800 Subject: [PATCH 01/11] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E6=A0=91=E8=A1=A8?= =?UTF-8?q?=E6=95=B0=E6=8D=AE=E6=98=BE=E7=A4=BA=E4=B8=8D=E5=85=A8&?= =?UTF-8?q?=E5=8A=A0=E8=BD=BD=E6=85=A2=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ruoyi-ui/src/utils/ruoyi.js | 63 +++++++++++++++++++++++++------------ 1 file changed, 43 insertions(+), 20 deletions(-) diff --git a/ruoyi-ui/src/utils/ruoyi.js b/ruoyi-ui/src/utils/ruoyi.js index 81ee9c70..bf8390e9 100644 --- a/ruoyi-ui/src/utils/ruoyi.js +++ b/ruoyi-ui/src/utils/ruoyi.js @@ -58,7 +58,7 @@ export function addDateRange(params, dateRange, propName) { var search = params; search.params = {}; if (null != dateRange && '' != dateRange) { - if (typeof(propName) === "undefined") { + if (typeof (propName) === "undefined") { search.params["beginTime"] = dateRange[0]; search.params["endTime"] = dateRange[1]; } else { @@ -129,24 +129,47 @@ export function praseStrEmpty(str) { * @param {*} id id字段 默认 'id' * @param {*} parentId 父节点字段 默认 'parentId' * @param {*} children 孩子节点字段 默认 'children' - * @param {*} rootId 根Id 默认 0 */ -export function handleTree(data, id, parentId, children, rootId) { - id = id || 'id' - parentId = parentId || 'parentId' - children = children || 'children' - rootId = rootId || Math.min.apply(Math, data.map(item => { return item[parentId] })) || 0 - //对源数据深度克隆 - const cloneData = JSON.parse(JSON.stringify(data)) - //循环所有项 - const treeData = cloneData.filter(father => { - let branchArr = cloneData.filter(child => { - //返回每一项的子级数组 - return father[id] === child[parentId] - }); - branchArr.length > 0 ? father.children = branchArr : ''; - //返回第一层 - return father[parentId] === rootId; - }); - return treeData != '' ? treeData : data; +export function handleTree(data, id, parentId, children) { + let config = { + id: id || 'id', + parentId: parentId || 'parentId', + childrenList: children || 'children' + }; + + var childrenListMap = {}; + var nodeIds = {}; + var tree = []; + + for (let d of data) { + let parentId = d[config.parentId]; + if (childrenListMap[parentId] == null) { + childrenListMap[parentId] = []; + } + nodeIds[d[config.id]] = d; + childrenListMap[parentId].push(d); + } + + for (let d of data) { + let parentId = d[config.parentId]; + if (nodeIds[parentId] == null) { + tree.push(d); + } + } + + for (let t of tree) { + adaptToChildrenList(t); + } + + function adaptToChildrenList(o) { + if (childrenListMap[o[config.id]] !== null) { + o[config.childrenList] = childrenListMap[o[config.id]]; + } + if (o[config.childrenList]) { + for (let c of o[config.childrenList]) { + adaptToChildrenList(c); + } + } + } + return tree; } From ccf05b697db8676056838cbd0633aeadf8e3810a Mon Sep 17 00:00:00 2001 From: hechieh <361020878@qq.com> Date: Sat, 10 Apr 2021 17:08:49 +0800 Subject: [PATCH 02/11] =?UTF-8?q?=E5=AF=8C=E6=96=87=E6=9C=AC=E7=BC=96?= =?UTF-8?q?=E8=BE=91=E5=99=A8=E8=87=AA=E5=AE=9A=E4=B9=89=E4=B8=8A=E4=BC=A0?= =?UTF-8?q?=E5=9C=B0=E5=9D=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ruoyi-ui/src/components/Editor/index.vue | 40 ++++++++++++++++++++++++ 1 file changed, 40 insertions(+) diff --git a/ruoyi-ui/src/components/Editor/index.vue b/ruoyi-ui/src/components/Editor/index.vue index ba2ea736..cc343cc4 100644 --- a/ruoyi-ui/src/components/Editor/index.vue +++ b/ruoyi-ui/src/components/Editor/index.vue @@ -1,5 +1,20 @@ + + diff --git a/ruoyi-ui/src/layout/components/Navbar.vue b/ruoyi-ui/src/layout/components/Navbar.vue index db46ec55..db69e1df 100644 --- a/ruoyi-ui/src/layout/components/Navbar.vue +++ b/ruoyi-ui/src/layout/components/Navbar.vue @@ -2,7 +2,8 @@