- 优化 tree,查找问题,undefined异常
This commit is contained in:
parent
3575c6255c
commit
0c8a79a8ed
@ -101,7 +101,6 @@ export default {
|
|||||||
*roleAssignResource({ payload }, { call }) {
|
*roleAssignResource({ payload }, { call }) {
|
||||||
const { id, resourceIds, roleTreeData } = payload;
|
const { id, resourceIds, roleTreeData } = payload;
|
||||||
const assignNodes = findAllNodes(resourceIds, roleTreeData);
|
const assignNodes = findAllNodes(resourceIds, roleTreeData);
|
||||||
|
|
||||||
const params = {
|
const params = {
|
||||||
id,
|
id,
|
||||||
resourceIds: arrayToStringParams(assignNodes),
|
resourceIds: arrayToStringParams(assignNodes),
|
||||||
|
@ -200,9 +200,7 @@ export default {
|
|||||||
// const resultMenuData = data;
|
// const resultMenuData = data;
|
||||||
if (data !== 'all') {
|
if (data !== 'all') {
|
||||||
const moveChildrenMenusData = moveChildrenMenus(antMenuData);
|
const moveChildrenMenusData = moveChildrenMenus(antMenuData);
|
||||||
console.log('moveChildrenMenusData', moveChildrenMenusData);
|
|
||||||
const buildTreeMenuData = buildTreeMenu(antMenuData, moveChildrenMenusData, data);
|
const buildTreeMenuData = buildTreeMenu(antMenuData, moveChildrenMenusData, data);
|
||||||
console.log('buildTreeMenuData', buildTreeMenuData);
|
|
||||||
menuData = buildTreeMenuData;
|
menuData = buildTreeMenuData;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -3,19 +3,7 @@
|
|||||||
import React, { PureComponent, Fragment } from 'react';
|
import React, { PureComponent, Fragment } from 'react';
|
||||||
import { connect } from 'dva';
|
import { connect } from 'dva';
|
||||||
import moment from 'moment';
|
import moment from 'moment';
|
||||||
import {
|
import { Card, Form, Input, Spin, Button, Modal, message, Table, Divider, Tree } from 'antd';
|
||||||
Card,
|
|
||||||
Form,
|
|
||||||
Input,
|
|
||||||
Select,
|
|
||||||
Spin,
|
|
||||||
Button,
|
|
||||||
Modal,
|
|
||||||
message,
|
|
||||||
Table,
|
|
||||||
Divider,
|
|
||||||
Tree,
|
|
||||||
} from 'antd';
|
|
||||||
import PageHeaderWrapper from '@/components/PageHeaderWrapper';
|
import PageHeaderWrapper from '@/components/PageHeaderWrapper';
|
||||||
|
|
||||||
import styles from './RoleList.less';
|
import styles from './RoleList.less';
|
||||||
@ -39,10 +27,6 @@ const CreateForm = Form.create()(props => {
|
|||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
const selectStyle = {
|
|
||||||
width: 200,
|
|
||||||
};
|
|
||||||
|
|
||||||
const title = modalType === 'add' ? '添加一个 Role' : '更新一个 Role';
|
const title = modalType === 'add' ? '添加一个 Role' : '更新一个 Role';
|
||||||
const okText = modalType === 'add' ? '添加' : '更新';
|
const okText = modalType === 'add' ? '添加' : '更新';
|
||||||
return (
|
return (
|
||||||
|
@ -20,15 +20,13 @@ function findNodes(id, nodes) {
|
|||||||
if (node.key === id) {
|
if (node.key === id) {
|
||||||
res.push(node.key);
|
res.push(node.key);
|
||||||
break;
|
break;
|
||||||
} else {
|
} else if (node.children) {
|
||||||
const childNodes = findNodes(id, node.children);
|
const childNodes = findNodes(id, node.children);
|
||||||
if (childNodes.length) {
|
res.push(node.key);
|
||||||
res.push(node.key);
|
for (let j = 0; j < childNodes.length; j += 1) {
|
||||||
for (let j = 0; j < childNodes.length; j += 1) {
|
res.push(childNodes[j]);
|
||||||
res.push(childNodes[j]);
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return res;
|
return res;
|
||||||
|
Loading…
Reference in New Issue
Block a user