From 32f3f239162db6d5035b39fde4802d2c85391fd3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=B0=8F=E8=AF=BA?= <1253070437@qq.com> Date: Tue, 18 Oct 2022 02:05:13 +0800 Subject: [PATCH] =?UTF-8?q?=E3=80=90=E6=9B=B4=E6=96=B0=E3=80=91=E4=BF=AE?= =?UTF-8?q?=E5=A4=8D=E4=B8=80=E4=B8=AA=E8=A7=92=E8=89=B2=E6=8E=88=E6=9D=83?= =?UTF-8?q?=E8=B5=84=E6=BA=90=E7=95=8C=E9=9D=A2=E6=97=A0=E6=B3=95=E5=B1=95?= =?UTF-8?q?=E7=A4=BA=E6=95=B0=E6=8D=AE=E9=94=99=E8=AF=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/views/sys/role/grantResourceForm.vue | 76 ++++++++++--------- 1 file changed, 39 insertions(+), 37 deletions(-) diff --git a/snowy-admin-web/src/views/sys/role/grantResourceForm.vue b/snowy-admin-web/src/views/sys/role/grantResourceForm.vue index d30171c1..9ac0e8a9 100644 --- a/snowy-admin-web/src/views/sys/role/grantResourceForm.vue +++ b/snowy-admin-web/src/views/sys/role/grantResourceForm.vue @@ -142,46 +142,48 @@ const echoModuleData = (data, resEcho) => { // 通过应用循环 data.forEach((module) => { - // 加入回显内容 - module.menu.forEach((item) => { - const menueCheck = ref(0) - if (resEcho.grantInfoList.length > 0) { - resEcho.grantInfoList.forEach((grant) => { - if (item.id === grant.menuId) { - menueCheck.value++ - // 处理按钮 - if (grant.buttonInfo.length > 0) { - grant.buttonInfo.forEach((button) => { - item.button.forEach((itemButton) => { - if (button === itemButton.id) { - itemButton.check = true - } + if (module.menu) { + // 加入回显内容 + module.menu.forEach((item) => { + const menueCheck = ref(0) + if (resEcho.grantInfoList.length > 0) { + resEcho.grantInfoList.forEach((grant) => { + if (item.id === grant.menuId) { + menueCheck.value++ + // 处理按钮 + if (grant.buttonInfo.length > 0) { + grant.buttonInfo.forEach((button) => { + item.button.forEach((itemButton) => { + if (button === itemButton.id) { + itemButton.check = true + } + }) }) - }) + } } - } - }) - } - // 回显前面的2个 - if (menueCheck.value > 0) { - item.parentCheck = true - item.nameCheck = true - } - }) + }) + } + // 回显前面的2个 + if (menueCheck.value > 0) { + item.parentCheck = true + item.nameCheck = true + } + }) - // 排序 - module.menu = module.menu.sort((a, b) => { - return a.parentId - b.parentId - }) - // 缓存加入索引 - module.menu.forEach((item, index) => { - // 下面就是用来知道不同的一级菜单里面有几个二级菜单,以及他们所在的索引 - if (firstShowMap[item.parentName]) { - firstShowMap[item.parentName].push(index) - } else { - firstShowMap[item.parentName] = [index] - } - }) + // 排序 + module.menu = module.menu.sort((a, b) => { + return a.parentId - b.parentId + }) + // 缓存加入索引 + module.menu.forEach((item, index) => { + // 下面就是用来知道不同的一级菜单里面有几个二级菜单,以及他们所在的索引 + if (firstShowMap[item.parentName]) { + firstShowMap[item.parentName].push(index) + } else { + firstShowMap[item.parentName] = [index] + } + }) + } }) return data }