MCPcopy
hub / github.com/duxianwei520/react / app

Class app

app/pages/set/roleManage/roleModuleList.js:5–318  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

3import RoleCheckbox from './roleCheckbox';
4
5export default class app extends Component {
6 constructor(props) {
7 super(props);
8 this.state = {
9 // isFirst: true,
10 checkedIds: [],
11 };
12 this.simpleData = {};
13 this.checkedArr = {};
14 this.fatherArr = {};
15 this.forAllData = {};
16 }
17
18 componentWillMount() {
19 this.simplifySourceData(this.props.dataSource, this.simpleData);
20 if (this.props.checkedId) {
21 this.setState({
22 checkedIds: this.props.checkedId,
23 });
24 }
25 }
26
27 componentDidMount() {}
28
29 componentWillReceiveProps(nextProps) {
30 if (this.props.checkedId !== nextProps.checkedId) {
31 this.setState({
32 checkedIds: nextProps.checkedId,
33 });
34 }
35
36 if (this.props.dataSource !== nextProps.dataSource) {
37 this.simplifySourceData(nextProps.dataSource, this.simpleData);
38 }
39 }
40
41 // #region 收缩业务代码功能
42
43 // 简化源数据保留id上下级关系
44 simplifySourceData = (obj, resultData) => {
45 /* if (this.getJSONLength(obj) > 0) {
46 for (const key in obj) {
47 this.forAllData[obj[key].id] = obj[key]
48 if (obj.hasOwnProperty(key)) {
49 resultData[obj[key].id] = {}
50 if (obj[key].children) {
51 this.simplifySourceData(obj[key].children, resultData[obj[key].id])
52 }
53 }
54 }
55 } */
56 // 使用object.keys 替代for in语句s
57 const objArr = Object.keys(obj);
58 if (objArr.length > 0) {
59 objArr.map((key) => {
60 this.forAllData[obj[key].id] = obj[key];
61 resultData[obj[key].id] = {};
62 if (obj[key].children) {

Callers

nothing calls this directly

Calls 4

onInArrayMethod · 0.95
setNewFatherCheckedMethod · 0.95
removeFromArrayMethod · 0.95
getFatherByIdMethod · 0.95

Tested by

no test coverage detected