[代码完善](v2.5): v2.5 beta 修复角色管理中分配菜单后子菜单丢失的问题

问题:角色管理中的分配菜单由于是懒加载的,导致保存分配的菜单时只保存了选择的父节点
修复:在保存前先将部分菜单加载出来

2.5 Beta 详情:https://www.ydyno.com/archives/1225.html
This commit is contained in:
ZhengJie
2020-05-11 18:36:11 +08:00
parent 10b7a8c155
commit bd6e504f94
6 changed files with 20 additions and 13 deletions

View File

@@ -9,7 +9,7 @@ export function getDepts(params) {
}) })
} }
export function getSuperior(ids) { export function getDeptSuperior(ids) {
const params = { const params = {
ids: ids ids: ids
} }
@@ -43,4 +43,4 @@ export function edit(data) {
}) })
} }
export default { add, edit, del, getDepts, getSuperior } export default { add, edit, del, getDepts, getDeptSuperior }

View File

@@ -1,4 +1,5 @@
import request from '@/utils/request' import request from '@/utils/request'
import qs from 'qs'
export function getMenusTree(pid) { export function getMenusTree(pid) {
return request({ return request({
@@ -15,9 +16,12 @@ export function getMenus(params) {
}) })
} }
export function getSuperior(id) { export function getMenuSuperior(ids) {
const params = {
ids: ids
}
return request({ return request({
url: 'api/menus/superior?id=' + id, url: 'api/menus/superior?' + qs.stringify(params, { indices: false }),
method: 'get' method: 'get'
}) })
} }
@@ -53,4 +57,4 @@ export function edit(data) {
}) })
} }
export default { add, edit, del, getMenusTree, getSuperior, getMenus } export default { add, edit, del, getMenusTree, getMenuSuperior, getMenus }

View File

@@ -174,7 +174,7 @@ export default {
} }
}, },
getSupDepts(id) { getSupDepts(id) {
crudDept.getSuperior(id).then(res => { crudDept.getDeptSuperior(id).then(res => {
this.depts = res.content.map(function(obj) { this.depts = res.content.map(function(obj) {
if (obj.hasChildren && !obj.children) { if (obj.hasChildren && !obj.children) {
obj.children = null obj.children = null

View File

@@ -221,8 +221,8 @@ export default {
}, 100) }, 100)
}, },
getSupDepts(id) { getSupDepts(id) {
crudMenu.getSuperior(id).then(res => { crudMenu.getMenuSuperior(id).then(res => {
const children = res.content.map(function(obj) { const children = res.map(function(obj) {
if (!obj.leaf && !obj.children) { if (!obj.leaf && !obj.children) {
obj.children = null obj.children = null
} }

View File

@@ -128,8 +128,8 @@
<script> <script>
import crudRoles from '@/api/system/role' import crudRoles from '@/api/system/role'
import { getDepts, getSuperior } from '@/api/system/dept' import { getDepts, getDeptSuperior } from '@/api/system/dept'
import { getMenusTree } from '@/api/system/menu' import { getMenusTree, getMenuSuperior } from '@/api/system/menu'
import CRUD, { presenter, header, form, crud } from '@crud/crud' import CRUD, { presenter, header, form, crud } from '@crud/crud'
import rrOperation from '@crud/RR.operation' import rrOperation from '@crud/RR.operation'
import crudOperation from '@crud/CRUD.operation' import crudOperation from '@crud/CRUD.operation'
@@ -247,6 +247,9 @@ export default {
val.menus.forEach(function(data, index) { val.menus.forEach(function(data, index) {
_this.menuIds.push(data.id) _this.menuIds.push(data.id)
}) })
getMenuSuperior(this.menuIds).then(res => {
this.menus = res
})
} }
}, },
// 保存菜单 // 保存菜单
@@ -300,7 +303,7 @@ export default {
depts.forEach(dept => { depts.forEach(dept => {
ids.push(dept.id) ids.push(dept.id)
}) })
getSuperior(ids).then(res => { getDeptSuperior(ids).then(res => {
this.depts = res.content.map(function(obj) { this.depts = res.content.map(function(obj) {
if (obj.hasChildren && !obj.children) { if (obj.hasChildren && !obj.children) {
obj.children = null obj.children = null

View File

@@ -204,7 +204,7 @@
<script> <script>
import crudUser from '@/api/system/user' import crudUser from '@/api/system/user'
import { isvalidPhone } from '@/utils/validate' import { isvalidPhone } from '@/utils/validate'
import { getDepts, getSuperior } from '@/api/system/dept' import { getDepts, getDeptSuperior } from '@/api/system/dept'
import { getAll, getLevel } from '@/api/system/role' import { getAll, getLevel } from '@/api/system/role'
import { getAllJob } from '@/api/system/job' import { getAllJob } from '@/api/system/job'
import CRUD, { presenter, header, form, crud } from '@crud/crud' import CRUD, { presenter, header, form, crud } from '@crud/crud'
@@ -415,7 +415,7 @@ export default {
}) })
}, },
getSupDepts(deptId) { getSupDepts(deptId) {
getSuperior(deptId).then(res => { getDeptSuperior(deptId).then(res => {
this.depts = res.content.map(function(obj) { this.depts = res.content.map(function(obj) {
if (obj.hasChildren && !obj.children) { if (obj.hasChildren && !obj.children) {
obj.children = null obj.children = null