• 根据原始平行数据, 转换成树形结构的数据


    点击这里查看代码

    源数据

    var originData = [
        {
            "id":"7",
            "createDate":"2018-07-26 17:48:43",
            "updateDate":"2018-07-28 12:06:17",
            "tenantId":"C0132",
            "name":"月浦变电站",
            "code":"4405-S001-L001",
            "type":"S",
            "sort":"1",
            "address":"广东省汕头市金平区邦宝工业园(普宁路北)",
            "isValid":"1",
            "pid":"C0132O1",
            "lng":116.67923,
            "lat":23.408235,
            "photo":"https://www.eleclifecycle.com/sem/res/C0132/loc/2018/10/1539675997277.JPG",
            "principalId":"C0132U1",
            "principal":{
                "id":"C0132U1",
                "remarks":"租户管理员",
                "createDate":"2018-07-26 19:07:46",
                "updateDate":"2018-12-22 17:25:32",
                "tenantId":"C0132",
                "loginName":"stgdj",
                "no":"0001",
                "name":"公司超级管理员",
                "nickname":"南方呢",
                "gender":"男",
                "email":"7787@qq.com",
                "phone":"",
                "mobile":"13668986084",
                "loginIp":"119.131.142.158",
                "loginDate":"2018-12-22 17:17:22",
                "loginFlag":"1",
                "photo":"https://wx.qlogo.cn/mmopen/vi_32/41Ierpfk4FWAYXkYw5Yz0SrtCHvO5GM3jePcmnwhe5E72hROuUJwQu5niaq6TDQa3lwqlwjGFdqLYh4FODuWhOg/132",
                "oldLoginIp":"119.131.142.158",
                "oldLoginDate":"2018-12-22 17:17:22",
                "openid":"oGvYY44zGV9oTyav9VAPEQ0FGHjo",
                "admin":false,
                "dept":{
                    "id":"C0132O1",
                    "tenantId":"C0132",
                    "name":"汕头供电局",
                    "sort":30,
                    "type":"2",
                    "parentId":"C0132O1"
                },
                "photoUrl":"https://wx.qlogo.cn/mmopen/vi_32/41Ierpfk4FWAYXkYw5Yz0SrtCHvO5GM3jePcmnwhe5E72hROuUJwQu5niaq6TDQa3lwqlwjGFdqLYh4FODuWhOg/132",
                "roleNames":"管理员角色",
                "atWork":false
            },
            "remark":"",
            "orgId":"C0132O1",
            "state":"1",
            "pids":"C0132O1",
            "pname":"",
            "locations":"C0132O1,7",
            "isValidLabel":"是",
            "stateLabel":"正常",
            "typeLabel":"变电站"
        },
        {
            "id":"12",
            "createDate":"2018-07-26 17:48:43",
            "updateDate":"2018-10-16 11:52:19",
            "tenantId":"C0132",
            "name":"设备楼-高压室",
            "code":"4405-S001-L006",
            "type":"R",
            "sort":"1",
            "address":"广东省汕头市金平区邦宝工业园(普宁路北)",
            "isValid":"1",
            "pid":"7",
            "locationp":{
                "id":"7",
                "tenantId":"C0132",
                "name":"月浦变电站",
                "pname":"",
                "locations":"null,7",
                "isValidLabel":"",
                "stateLabel":"",
                "typeLabel":""
            },
            "lng":116.67923,
            "lat":23.408235,
            "photo":"https://www.eleclifecycle.com/sem/res/C0132/loc/2018/11/tmp_f8896a78f04248413ea3697efca8a8c8.jpg",
            "principalId":"C01320002",
            "principal":{
                "id":"C01320002",
                "remarks":"",
                "createDate":"2018-09-15 19:47:23",
                "updateDate":"2018-09-15 20:07:51",
                "tenantId":"C0132",
                "loginName":"13502932625@ga",
                "no":"",
                "name":"吴著宏",
                "nickname":"吴著宏",
                "gender":"M",
                "email":"",
                "mobile":"13502932625",
                "address":"",
                "userType":"",
                "level":"",
                "post":"GSLD",
                "loginIp":"183.44.210.0",
                "loginDate":"2018-12-11 11:21:06",
                "loginFlag":"1",
                "photo":"https://wx.qlogo.cn/mmopen/vi_32/Q0j4TwGTfTJJT9za8t01Ov585LkJLw2s7QQv0TGj9Vlbukq8dKGIYDKJd7D4EEr2LBM7nxqODcPRTTicgtNKIhA/132",
                "oldLoginIp":"183.44.210.0",
                "oldLoginDate":"2018-12-11 11:21:06",
                "openid":"oGvYY4wKzuytj0CExp9b4WujrSMA",
                "admin":false,
                "dept":{
                    "id":"b1ed9df429db45a6b1a04b31b8eea113",
                    "tenantId":"C0132",
                    "name":"本部",
                    "sort":30,
                    "type":"2",
                    "parentId":"C0132O1"
                },
                "photoUrl":"https://wx.qlogo.cn/mmopen/vi_32/Q0j4TwGTfTJJT9za8t01Ov585LkJLw2s7QQv0TGj9Vlbukq8dKGIYDKJd7D4EEr2LBM7nxqODcPRTTicgtNKIhA/132",
                "roleNames":"",
                "atWork":false
            },
            "remark":"",
            "orgId":"C0132O1",
            "state":"1",
            "pids":"C0132O1,7",
            "pname":"月浦变电站 ",
            "locations":"C0132O1,7,12",
            "graph":"st/yp/F1.json",
            "isValidLabel":"是",
            "stateLabel":"正常",
            "typeLabel":"房间"
        },
        {
            "id":"20",
            "createDate":"2018-07-26 17:48:43",
            "updateDate":"2018-10-16 15:57:13",
            "tenantId":"C0132",
            "name":"官埭变电站",
            "code":"4405-S002-L001",
            "type":"S",
            "sort":"1",
            "address":"广东省汕头市龙湖区洛河路11号(泰山路与洛河路交界处)",
            "isValid":"1",
            "pid":"C0132O1",
            "lng":116.740798,
            "lat":23.407678,
            "photo":"https://www.eleclifecycle.com/sem/res/C0132/loc/2018/10/1539676719374.JPG",
            "principalId":"C0132U1",
            "principal":{
                "id":"C0132U1",
                "remarks":"租户管理员",
                "createDate":"2018-07-26 19:07:46",
                "updateDate":"2018-12-22 17:25:32",
                "tenantId":"C0132",
                "loginName":"stgdj",
                "no":"0001",
                "name":"公司超级管理员",
                "nickname":"南方呢",
                "gender":"男",
                "email":"7787@qq.com",
                "phone":"",
                "mobile":"13668986084",
                "loginIp":"119.131.142.158",
                "loginDate":"2018-12-22 17:17:22",
                "loginFlag":"1",
                "photo":"https://wx.qlogo.cn/mmopen/vi_32/41Ierpfk4FWAYXkYw5Yz0SrtCHvO5GM3jePcmnwhe5E72hROuUJwQu5niaq6TDQa3lwqlwjGFdqLYh4FODuWhOg/132",
                "oldLoginIp":"119.131.142.158",
                "oldLoginDate":"2018-12-22 17:17:22",
                "openid":"oGvYY44zGV9oTyav9VAPEQ0FGHjo",
                "admin":false,
                "dept":{
                    "id":"C0132O1",
                    "tenantId":"C0132",
                    "name":"汕头供电局",
                    "sort":30,
                    "type":"2",
                    "parentId":"C0132O1"
                },
                "photoUrl":"https://wx.qlogo.cn/mmopen/vi_32/41Ierpfk4FWAYXkYw5Yz0SrtCHvO5GM3jePcmnwhe5E72hROuUJwQu5niaq6TDQa3lwqlwjGFdqLYh4FODuWhOg/132",
                "roleNames":"管理员角色",
                "atWork":false
            },
            "remark":"",
            "orgId":"C0132O1",
            "state":"1",
            "pids":"C0132O1",
            "pname":"",
            "locations":"C0132O1,20",
            "graph":"",
            "isValidLabel":"是",
            "stateLabel":"正常",
            "typeLabel":"变电站"
        },
        {
            "id":"C0132-F-0103",
            "createDate":"2018-09-25 18:07:54",
            "updateDate":"2018-10-16 10:04:03",
            "tenantId":"C0132",
            "name":"主控楼-#1蓄电池",
            "code":"C0132-F-0103",
            "type":"R",
            "sort":"1",
            "address":"",
            "isValid":"1",
            "pid":"20",
            "locationp":{
                "id":"20",
                "tenantId":"C0132",
                "name":"官埭变电站",
                "pname":"",
                "locations":"null,20",
                "isValidLabel":"",
                "stateLabel":"",
                "typeLabel":""
            },
            "photo":"https://www.eleclifecycle.com/sem/res/C0132/loc/2018/10/tmp_376c74905d1f6d9ff058b3cd9608af7e.jpg",
            "principalId":"C01320002",
            "principal":{
                "id":"C01320002",
                "remarks":"",
                "createDate":"2018-09-15 19:47:23",
                "updateDate":"2018-09-15 20:07:51",
                "tenantId":"C0132",
                "loginName":"13502932625@ga",
                "no":"",
                "name":"吴著宏",
                "nickname":"吴著宏",
                "gender":"M",
                "email":"",
                "mobile":"13502932625",
                "address":"",
                "userType":"",
                "level":"",
                "post":"GSLD",
                "loginIp":"183.44.210.0",
                "loginDate":"2018-12-11 11:21:06",
                "loginFlag":"1",
                "photo":"https://wx.qlogo.cn/mmopen/vi_32/Q0j4TwGTfTJJT9za8t01Ov585LkJLw2s7QQv0TGj9Vlbukq8dKGIYDKJd7D4EEr2LBM7nxqODcPRTTicgtNKIhA/132",
                "oldLoginIp":"183.44.210.0",
                "oldLoginDate":"2018-12-11 11:21:06",
                "openid":"oGvYY4wKzuytj0CExp9b4WujrSMA",
                "admin":false,
                "dept":{
                    "id":"b1ed9df429db45a6b1a04b31b8eea113",
                    "tenantId":"C0132",
                    "name":"本部",
                    "sort":30,
                    "type":"2",
                    "parentId":"C0132O1"
                },
                "photoUrl":"https://wx.qlogo.cn/mmopen/vi_32/Q0j4TwGTfTJJT9za8t01Ov585LkJLw2s7QQv0TGj9Vlbukq8dKGIYDKJd7D4EEr2LBM7nxqODcPRTTicgtNKIhA/132",
                "roleNames":"",
                "atWork":false
            },
            "remark":"",
            "orgId":"C0132O1",
            "state":"1",
            "pids":"C0132O1,20",
            "pname":"官埭变电站 ",
            "locations":"C0132O1,20,C0132-F-0103",
            "graph":"st/gd/F1.json",
            "isValidLabel":"是",
            "stateLabel":"正常",
            "typeLabel":"房间"
        },
        {
            "id":"10",
            "createDate":"2018-07-26 17:48:43",
            "updateDate":"2018-10-16 10:02:29",
            "tenantId":"C0132",
            "name":"主控楼-蓄电池室",
            "code":"4405-S001-L004",
            "type":"R",
            "sort":"2",
            "address":"广东省汕头市金平区邦宝工业园(普宁路北)",
            "isValid":"1",
            "pid":"7",
            "locationp":{
                "id":"7",
                "tenantId":"C0132",
                "name":"月浦变电站",
                "pname":"",
                "locations":"null,7",
                "isValidLabel":"",
                "stateLabel":"",
                "typeLabel":""
            },
            "lng":116.67923,
            "lat":23.408235,
            "photo":"https://www.eleclifecycle.com/sem/res/C0132/loc/2018/10/tmp_86f284718e534d9ee4ae3eed6bed0247.jpg",
            "principalId":"C01320002",
            "principal":{
                "id":"C01320002",
                "remarks":"",
                "createDate":"2018-09-15 19:47:23",
                "updateDate":"2018-09-15 20:07:51",
                "tenantId":"C0132",
                "loginName":"13502932625@ga",
                "no":"",
                "name":"吴著宏",
                "nickname":"吴著宏",
                "gender":"M",
                "email":"",
                "mobile":"13502932625",
                "address":"",
                "userType":"",
                "level":"",
                "post":"GSLD",
                "loginIp":"183.44.210.0",
                "loginDate":"2018-12-11 11:21:06",
                "loginFlag":"1",
                "photo":"https://wx.qlogo.cn/mmopen/vi_32/Q0j4TwGTfTJJT9za8t01Ov585LkJLw2s7QQv0TGj9Vlbukq8dKGIYDKJd7D4EEr2LBM7nxqODcPRTTicgtNKIhA/132",
                "oldLoginIp":"183.44.210.0",
                "oldLoginDate":"2018-12-11 11:21:06",
                "openid":"oGvYY4wKzuytj0CExp9b4WujrSMA",
                "admin":false,
                "dept":{
                    "id":"b1ed9df429db45a6b1a04b31b8eea113",
                    "tenantId":"C0132",
                    "name":"本部",
                    "sort":30,
                    "type":"2",
                    "parentId":"C0132O1"
                },
                "photoUrl":"https://wx.qlogo.cn/mmopen/vi_32/Q0j4TwGTfTJJT9za8t01Ov585LkJLw2s7QQv0TGj9Vlbukq8dKGIYDKJd7D4EEr2LBM7nxqODcPRTTicgtNKIhA/132",
                "roleNames":"",
                "atWork":false
            },
            "remark":"",
            "orgId":"C0132O1",
            "state":"1",
            "pids":"C0132O1,7",
            "pname":"月浦变电站 ",
            "locations":"C0132O1,7,10",
            "graph":"st/yp/F1.json",
            "isValidLabel":"是",
            "stateLabel":"正常",
            "typeLabel":"房间"
        },
        {
            "id":"C0132-R-0104",
            "createDate":"2018-09-25 18:10:26",
            "updateDate":"2018-10-16 10:04:56",
            "tenantId":"C0132",
            "name":"主控楼-#2蓄电池",
            "code":"C0132-R-0104",
            "type":"R",
            "sort":"2",
            "address":"",
            "isValid":"1",
            "pid":"20",
            "locationp":{
                "id":"20",
                "tenantId":"C0132",
                "name":"官埭变电站",
                "pname":"",
                "locations":"null,20",
                "isValidLabel":"",
                "stateLabel":"",
                "typeLabel":""
            },
            "photo":"https://www.eleclifecycle.com/sem/res/C0132/loc/2018/10/tmp_f58142405aa6c78bf7ed21b82ef273e7.jpg",
            "principalId":"C01320002",
            "principal":{
                "id":"C01320002",
                "remarks":"",
                "createDate":"2018-09-15 19:47:23",
                "updateDate":"2018-09-15 20:07:51",
                "tenantId":"C0132",
                "loginName":"13502932625@ga",
                "no":"",
                "name":"吴著宏",
                "nickname":"吴著宏",
                "gender":"M",
                "email":"",
                "mobile":"13502932625",
                "address":"",
                "userType":"",
                "level":"",
                "post":"GSLD",
                "loginIp":"183.44.210.0",
                "loginDate":"2018-12-11 11:21:06",
                "loginFlag":"1",
                "photo":"https://wx.qlogo.cn/mmopen/vi_32/Q0j4TwGTfTJJT9za8t01Ov585LkJLw2s7QQv0TGj9Vlbukq8dKGIYDKJd7D4EEr2LBM7nxqODcPRTTicgtNKIhA/132",
                "oldLoginIp":"183.44.210.0",
                "oldLoginDate":"2018-12-11 11:21:06",
                "openid":"oGvYY4wKzuytj0CExp9b4WujrSMA",
                "admin":false,
                "dept":{
                    "id":"b1ed9df429db45a6b1a04b31b8eea113",
                    "tenantId":"C0132",
                    "name":"本部",
                    "sort":30,
                    "type":"2",
                    "parentId":"C0132O1"
                },
                "photoUrl":"https://wx.qlogo.cn/mmopen/vi_32/Q0j4TwGTfTJJT9za8t01Ov585LkJLw2s7QQv0TGj9Vlbukq8dKGIYDKJd7D4EEr2LBM7nxqODcPRTTicgtNKIhA/132",
                "roleNames":"",
                "atWork":false
            },
            "remark":"",
            "orgId":"C0132O1",
            "state":"1",
            "pids":"C0132O1,20",
            "pname":"官埭变电站 ",
            "locations":"C0132O1,20,C0132-R-0104",
            "graph":"st/gd/F1.json",
            "isValidLabel":"是",
            "stateLabel":"正常",
            "typeLabel":"房间"
        },
        {
            "id":"11",
            "createDate":"2018-07-26 17:48:43",
            "updateDate":"2018-10-16 10:03:12",
            "tenantId":"C0132",
            "name":"主控楼-二楼中控室",
            "code":"4405-S001-L005",
            "type":"R",
            "sort":"3",
            "address":"广东省汕头市金平区邦宝工业园(普宁路北)",
            "isValid":"1",
            "pid":"7",
            "locationp":{
                "id":"7",
                "tenantId":"C0132",
                "name":"月浦变电站",
                "pname":"",
                "locations":"null,7",
                "isValidLabel":"",
                "stateLabel":"",
                "typeLabel":""
            },
            "lng":116.67923,
            "lat":23.408235,
            "photo":"https://www.eleclifecycle.com/sem/res/C0132/loc/2018/09/1537172684438.jpg",
            "principalId":"C01320002",
            "principal":{
                "id":"C01320002",
                "remarks":"",
                "createDate":"2018-09-15 19:47:23",
                "updateDate":"2018-09-15 20:07:51",
                "tenantId":"C0132",
                "loginName":"13502932625@ga",
                "no":"",
                "name":"吴著宏",
                "nickname":"吴著宏",
                "gender":"M",
                "email":"",
                "mobile":"13502932625",
                "address":"",
                "userType":"",
                "level":"",
                "post":"GSLD",
                "loginIp":"183.44.210.0",
                "loginDate":"2018-12-11 11:21:06",
                "loginFlag":"1",
                "photo":"https://wx.qlogo.cn/mmopen/vi_32/Q0j4TwGTfTJJT9za8t01Ov585LkJLw2s7QQv0TGj9Vlbukq8dKGIYDKJd7D4EEr2LBM7nxqODcPRTTicgtNKIhA/132",
                "oldLoginIp":"183.44.210.0",
                "oldLoginDate":"2018-12-11 11:21:06",
                "openid":"oGvYY4wKzuytj0CExp9b4WujrSMA",
                "admin":false,
                "dept":{
                    "id":"b1ed9df429db45a6b1a04b31b8eea113",
                    "tenantId":"C0132",
                    "name":"本部",
                    "sort":30,
                    "type":"2",
                    "parentId":"C0132O1"
                },
                "photoUrl":"https://wx.qlogo.cn/mmopen/vi_32/Q0j4TwGTfTJJT9za8t01Ov585LkJLw2s7QQv0TGj9Vlbukq8dKGIYDKJd7D4EEr2LBM7nxqODcPRTTicgtNKIhA/132",
                "roleNames":"",
                "atWork":false
            },
            "remark":"",
            "orgId":"C0132O1",
            "state":"1",
            "pids":"C0132O1,7",
            "pname":"月浦变电站 ",
            "locations":"C0132O1,7,11",
            "graph":"st/yp/F2.json",
            "isValidLabel":"是",
            "stateLabel":"正常",
            "typeLabel":"房间"
        },
        {
            "id":"21",
            "createDate":"2018-07-26 17:48:43",
            "updateDate":"2018-09-10 10:02:26",
            "tenantId":"C0132",
            "name":"主控楼-二楼中控室",
            "code":"4405-S002-L002",
            "type":"R",
            "sort":"3",
            "address":"广东省汕头市龙湖区洛河路11号(泰山路与洛河路交界处)",
            "isValid":"1",
            "pid":"20",
            "locationp":{
                "id":"20",
                "tenantId":"C0132",
                "name":"官埭变电站",
                "pname":"",
                "locations":"null,20",
                "isValidLabel":"",
                "stateLabel":"",
                "typeLabel":""
            },
            "lng":116.740798,
            "lat":23.407678,
            "photo":"https://www.eleclifecycle.com/sem/res/C0132/loc/2018/09/1537172556912.jpg",
            "principalId":"807c7cf564a2400e8341abd5518e2d5b",
            "principal":{
                "id":"807c7cf564a2400e8341abd5518e2d5b",
                "remarks":"",
                "createDate":"2018-06-22 16:42:38",
                "updateDate":"2018-08-30 16:45:14",
                "tenantId":"C0132",
                "loginName":"cs",
                "no":"0001",
                "name":"测试工程师",
                "nickname":"测试工程师",
                "gender":"M",
                "birthday":1529596800000,
                "email":"33@33.com",
                "phone":"13727670753",
                "mobile":"13668986084",
                "address":"黄村大街",
                "userType":"1",
                "level":"",
                "post":"YXRY",
                "loginIp":"0:0:0:0:0:0:0:1",
                "loginDate":"2018-09-08 16:58:41",
                "loginFlag":"1",
                "photo":"https://wx.qlogo.cn/mmopen/vi_32/41Ierpfk4FWAYXkYw5Yz0SrtCHvO5GM3jePcmnwhe5E72hROuUJwQu5niaq6TDQa3lwqlwjGFdqLYh4FODuWhOg/132",
                "oldLoginIp":"0:0:0:0:0:0:0:1",
                "oldLoginDate":"2018-09-08 16:58:41",
                "openid":"oGvYY4-irkIjTZKBih_gb71MacgE",
                "admin":false,
                "dept":{
                    "id":"7dff144f8b0b49219d78bfca4c705d2e",
                    "tenantId":"C0132",
                    "name":"西区巡维中心",
                    "sort":30,
                    "type":"2",
                    "parentId":"C0132O1"
                },
                "photoUrl":"https://wx.qlogo.cn/mmopen/vi_32/41Ierpfk4FWAYXkYw5Yz0SrtCHvO5GM3jePcmnwhe5E72hROuUJwQu5niaq6TDQa3lwqlwjGFdqLYh4FODuWhOg/132",
                "roleNames":"运行人员",
                "atWork":false
            },
            "remark":"",
            "orgId":"C0132O1",
            "state":"1",
            "pids":"C0132O1,20",
            "pname":"官埭变电站 ",
            "locations":"C0132O1,20,21",
            "graph":"st/gd/F2.json",
            "isValidLabel":"是",
            "stateLabel":"正常",
            "typeLabel":"房间"
        },
        {
            "id":"13",
            "createDate":"2018-07-26 17:48:43",
            "updateDate":"2018-10-16 10:03:42",
            "tenantId":"C0132",
            "name":"主控楼-二楼通信室",
            "code":"4405-S001-L007",
            "type":"R",
            "sort":"4",
            "address":"广东省汕头市金平区邦宝工业园(普宁路北)",
            "isValid":"1",
            "pid":"7",
            "locationp":{
                "id":"7",
                "tenantId":"C0132",
                "name":"月浦变电站",
                "pname":"",
                "locations":"null,7",
                "isValidLabel":"",
                "stateLabel":"",
                "typeLabel":""
            },
            "lng":116.67923,
            "lat":23.408235,
            "photo":"https://www.eleclifecycle.com/sem/res/C0132/loc/2018/10/tmp_8d9c0673c25bcccb951e42f693627a74.jpg",
            "principalId":"C01320002",
            "principal":{
                "id":"C01320002",
                "remarks":"",
                "createDate":"2018-09-15 19:47:23",
                "updateDate":"2018-09-15 20:07:51",
                "tenantId":"C0132",
                "loginName":"13502932625@ga",
                "no":"",
                "name":"吴著宏",
                "nickname":"吴著宏",
                "gender":"M",
                "email":"",
                "mobile":"13502932625",
                "address":"",
                "userType":"",
                "level":"",
                "post":"GSLD",
                "loginIp":"183.44.210.0",
                "loginDate":"2018-12-11 11:21:06",
                "loginFlag":"1",
                "photo":"https://wx.qlogo.cn/mmopen/vi_32/Q0j4TwGTfTJJT9za8t01Ov585LkJLw2s7QQv0TGj9Vlbukq8dKGIYDKJd7D4EEr2LBM7nxqODcPRTTicgtNKIhA/132",
                "oldLoginIp":"183.44.210.0",
                "oldLoginDate":"2018-12-11 11:21:06",
                "openid":"oGvYY4wKzuytj0CExp9b4WujrSMA",
                "admin":false,
                "dept":{
                    "id":"b1ed9df429db45a6b1a04b31b8eea113",
                    "tenantId":"C0132",
                    "name":"本部",
                    "sort":30,
                    "type":"2",
                    "parentId":"C0132O1"
                },
                "photoUrl":"https://wx.qlogo.cn/mmopen/vi_32/Q0j4TwGTfTJJT9za8t01Ov585LkJLw2s7QQv0TGj9Vlbukq8dKGIYDKJd7D4EEr2LBM7nxqODcPRTTicgtNKIhA/132",
                "roleNames":"",
                "atWork":false
            },
            "remark":"",
            "orgId":"C0132O1",
            "state":"1",
            "pids":"C0132O1,7",
            "pname":"月浦变电站 ",
            "locations":"C0132O1,7,13",
            "graph":"st/yp/F2.json",
            "isValidLabel":"是",
            "stateLabel":"正常",
            "typeLabel":"房间"
        },
        {
            "id":"22",
            "createDate":"2018-07-26 17:48:43",
            "updateDate":"2018-09-10 10:02:35",
            "tenantId":"C0132",
            "name":"主控楼-二楼继保室",
            "code":"4405-S002-L003",
            "type":"R",
            "sort":"4",
            "address":"广东省汕头市龙湖区洛河路11号(泰山路与洛河路交界处)",
            "isValid":"1",
            "pid":"20",
            "locationp":{
                "id":"20",
                "tenantId":"C0132",
                "name":"官埭变电站",
                "pname":"",
                "locations":"null,20",
                "isValidLabel":"",
                "stateLabel":"",
                "typeLabel":""
            },
            "lng":116.740798,
            "lat":23.407678,
            "photo":"https://www.eleclifecycle.com/sem/res/C0132/loc/2018/09/1537172483733.jpg",
            "principalId":"807c7cf564a2400e8341abd5518e2d5b",
            "principal":{
                "id":"807c7cf564a2400e8341abd5518e2d5b",
                "remarks":"",
                "createDate":"2018-06-22 16:42:38",
                "updateDate":"2018-08-30 16:45:14",
                "tenantId":"C0132",
                "loginName":"cs",
                "no":"0001",
                "name":"测试工程师",
                "nickname":"测试工程师",
                "gender":"M",
                "birthday":1529596800000,
                "email":"33@33.com",
                "phone":"13727670753",
                "mobile":"13668986084",
                "address":"黄村大街",
                "userType":"1",
                "level":"",
                "post":"YXRY",
                "loginIp":"0:0:0:0:0:0:0:1",
                "loginDate":"2018-09-08 16:58:41",
                "loginFlag":"1",
                "photo":"https://wx.qlogo.cn/mmopen/vi_32/41Ierpfk4FWAYXkYw5Yz0SrtCHvO5GM3jePcmnwhe5E72hROuUJwQu5niaq6TDQa3lwqlwjGFdqLYh4FODuWhOg/132",
                "oldLoginIp":"0:0:0:0:0:0:0:1",
                "oldLoginDate":"2018-09-08 16:58:41",
                "openid":"oGvYY4-irkIjTZKBih_gb71MacgE",
                "admin":false,
                "dept":{
                    "id":"7dff144f8b0b49219d78bfca4c705d2e",
                    "tenantId":"C0132",
                    "name":"西区巡维中心",
                    "sort":30,
                    "type":"2",
                    "parentId":"C0132O1"
                },
                "photoUrl":"https://wx.qlogo.cn/mmopen/vi_32/41Ierpfk4FWAYXkYw5Yz0SrtCHvO5GM3jePcmnwhe5E72hROuUJwQu5niaq6TDQa3lwqlwjGFdqLYh4FODuWhOg/132",
                "roleNames":"运行人员",
                "atWork":false
            },
            "remark":"",
            "orgId":"C0132O1",
            "state":"1",
            "pids":"C0132O1,20",
            "pname":"官埭变电站 ",
            "locations":"C0132O1,20,22",
            "graph":"st/gd/F2.json",
            "isValidLabel":"是",
            "stateLabel":"正常",
            "typeLabel":"房间"
        },
        {
            "id":"a0a4e8e40443453d9e1c8a796883e8dd",
            "createDate":"2018-09-08 13:13:26",
            "updateDate":"2018-09-10 10:35:12",
            "tenantId":"C0132",
            "name":"主控楼-二楼资料室",
            "code":"",
            "type":"R",
            "sort":"5",
            "address":"",
            "isValid":"1",
            "pid":"20",
            "locationp":{
                "id":"20",
                "tenantId":"C0132",
                "name":"官埭变电站",
                "pname":"",
                "locations":"null,20",
                "isValidLabel":"",
                "stateLabel":"",
                "typeLabel":""
            },
            "photo":"https://www.eleclifecycle.com/sem/res/C0132/loc/2018/09/1537171254141.jpg",
            "principalId":"",
            "remark":"",
            "orgId":"C0132O1",
            "state":"1",
            "pids":"C0132O1,20",
            "pname":"官埭变电站 ",
            "locations":"C0132O1,20,a0a4e8e40443453d9e1c8a796883e8dd",
            "graph":"st/gd/F2.json",
            "isValidLabel":"是",
            "stateLabel":"正常",
            "typeLabel":"房间"
        },
        {
            "id":"af042c74eee74a50a43cb862221cf947",
            "createDate":"2018-09-08 13:13:00",
            "updateDate":"2018-09-10 10:36:19",
            "tenantId":"C0132",
            "name":"主控楼-三楼通讯室",
            "code":"",
            "type":"R",
            "sort":"6",
            "address":"",
            "isValid":"1",
            "pid":"20",
            "locationp":{
                "id":"20",
                "tenantId":"C0132",
                "name":"官埭变电站",
                "pname":"",
                "locations":"null,20",
                "isValidLabel":"",
                "stateLabel":"",
                "typeLabel":""
            },
            "photo":"https://www.eleclifecycle.com/sem/res/C0132/loc/2018/09/1537171231094.jpg",
            "principalId":"",
            "remark":"",
            "orgId":"C0132O1",
            "state":"1",
            "pids":"C0132O1,20",
            "pname":"官埭变电站 ",
            "locations":"C0132O1,20,af042c74eee74a50a43cb862221cf947",
            "graph":"st/gd/F3.json",
            "isValidLabel":"是",
            "stateLabel":"正常",
            "typeLabel":"房间"
        },
        {
            "id":"C0132-D-0108",
            "createDate":"2018-12-17 10:09:29",
            "updateDate":"2018-12-17 10:09:29",
            "tenantId":"C0132",
            "name":"主控楼-低压室",
            "code":"C0132-D-0108",
            "type":"D",
            "sort":"10",
            "address":"广东省汕头市金平区邦宝工业园(普宁路北)",
            "isValid":"1",
            "pid":"7",
            "locationp":{
                "id":"7",
                "tenantId":"C0132",
                "name":"月浦变电站",
                "pname":"",
                "locations":"null,7",
                "isValidLabel":"",
                "stateLabel":"",
                "typeLabel":""
            },
            "lng":3,
            "lat":0,
            "principalId":"",
            "remark":"1121",
            "orgId":"C0132O1",
            "state":"1",
            "pids":"C0132O1,7",
            "pname":"月浦变电站 ",
            "locations":"C0132O1,7,C0132-D-0108",
            "graph":"",
            "isValidLabel":"是",
            "stateLabel":"正常",
            "typeLabel":"配电房"
        },
        {
            "id":"877c534769bf4d7496619c7d098a1798",
            "createDate":"2018-09-08 12:02:03",
            "updateDate":"2018-09-10 10:02:09",
            "tenantId":"C0132",
            "name":"设备楼-低压室",
            "code":"",
            "type":"R",
            "sort":"20",
            "address":"",
            "isValid":"1",
            "pid":"20",
            "locationp":{
                "id":"20",
                "tenantId":"C0132",
                "name":"官埭变电站",
                "pname":"",
                "locations":"null,20",
                "isValidLabel":"",
                "stateLabel":"",
                "typeLabel":""
            },
            "photo":"https://www.eleclifecycle.com/sem/res/C0132/loc/2018/09/1537172586677.jpg",
            "principalId":"C0132U1",
            "principal":{
                "id":"C0132U1",
                "remarks":"租户管理员",
                "createDate":"2018-07-26 19:07:46",
                "updateDate":"2018-12-22 17:25:32",
                "tenantId":"C0132",
                "loginName":"stgdj",
                "no":"0001",
                "name":"公司超级管理员",
                "nickname":"南方呢",
                "gender":"男",
                "email":"7787@qq.com",
                "phone":"",
                "mobile":"13668986084",
                "loginIp":"119.131.142.158",
                "loginDate":"2018-12-22 17:17:22",
                "loginFlag":"1",
                "photo":"https://wx.qlogo.cn/mmopen/vi_32/41Ierpfk4FWAYXkYw5Yz0SrtCHvO5GM3jePcmnwhe5E72hROuUJwQu5niaq6TDQa3lwqlwjGFdqLYh4FODuWhOg/132",
                "oldLoginIp":"119.131.142.158",
                "oldLoginDate":"2018-12-22 17:17:22",
                "openid":"oGvYY44zGV9oTyav9VAPEQ0FGHjo",
                "admin":false,
                "dept":{
                    "id":"C0132O1",
                    "tenantId":"C0132",
                    "name":"汕头供电局",
                    "sort":30,
                    "type":"2",
                    "parentId":"C0132O1"
                },
                "photoUrl":"https://wx.qlogo.cn/mmopen/vi_32/41Ierpfk4FWAYXkYw5Yz0SrtCHvO5GM3jePcmnwhe5E72hROuUJwQu5niaq6TDQa3lwqlwjGFdqLYh4FODuWhOg/132",
                "roleNames":"管理员角色",
                "atWork":false
            },
            "remark":"",
            "orgId":"C0132O1",
            "state":"1",
            "pids":"C0132O1,20",
            "pname":"官埭变电站 ",
            "locations":"C0132O1,20,877c534769bf4d7496619c7d098a1798",
            "isValidLabel":"是",
            "stateLabel":"正常",
            "typeLabel":"房间"
        },
        {
            "id":"25",
            "createDate":"2018-07-26 17:48:43",
            "updateDate":"2018-09-10 10:04:53",
            "tenantId":"C0132",
            "name":"设备楼-#1高压室",
            "code":"4405-S002-L006",
            "type":"R",
            "sort":"21",
            "address":"广东省汕头市龙湖区洛河路11号(泰山路与洛河路交界处)",
            "isValid":"1",
            "pid":"20",
            "locationp":{
                "id":"20",
                "tenantId":"C0132",
                "name":"官埭变电站",
                "pname":"",
                "locations":"null,20",
                "isValidLabel":"",
                "stateLabel":"",
                "typeLabel":""
            },
            "lng":116.740798,
            "lat":23.407678,
            "photo":"https://www.eleclifecycle.com/sem/res/C0132/loc/2018/09/1537172366406.jpg",
            "principalId":"807c7cf564a2400e8341abd5518e2d5b",
            "principal":{
                "id":"807c7cf564a2400e8341abd5518e2d5b",
                "remarks":"",
                "createDate":"2018-06-22 16:42:38",
                "updateDate":"2018-08-30 16:45:14",
                "tenantId":"C0132",
                "loginName":"cs",
                "no":"0001",
                "name":"测试工程师",
                "nickname":"测试工程师",
                "gender":"M",
                "birthday":1529596800000,
                "email":"33@33.com",
                "phone":"13727670753",
                "mobile":"13668986084",
                "address":"黄村大街",
                "userType":"1",
                "level":"",
                "post":"YXRY",
                "loginIp":"0:0:0:0:0:0:0:1",
                "loginDate":"2018-09-08 16:58:41",
                "loginFlag":"1",
                "photo":"https://wx.qlogo.cn/mmopen/vi_32/41Ierpfk4FWAYXkYw5Yz0SrtCHvO5GM3jePcmnwhe5E72hROuUJwQu5niaq6TDQa3lwqlwjGFdqLYh4FODuWhOg/132",
                "oldLoginIp":"0:0:0:0:0:0:0:1",
                "oldLoginDate":"2018-09-08 16:58:41",
                "openid":"oGvYY4-irkIjTZKBih_gb71MacgE",
                "admin":false,
                "dept":{
                    "id":"7dff144f8b0b49219d78bfca4c705d2e",
                    "tenantId":"C0132",
                    "name":"西区巡维中心",
                    "sort":30,
                    "type":"2",
                    "parentId":"C0132O1"
                },
                "photoUrl":"https://wx.qlogo.cn/mmopen/vi_32/41Ierpfk4FWAYXkYw5Yz0SrtCHvO5GM3jePcmnwhe5E72hROuUJwQu5niaq6TDQa3lwqlwjGFdqLYh4FODuWhOg/132",
                "roleNames":"运行人员",
                "atWork":false
            },
            "remark":"",
            "orgId":"C0132O1",
            "state":"1",
            "pids":"C0132O1,20",
            "pname":"官埭变电站 ",
            "locations":"C0132O1,20,25",
            "graph":"st/gd/SBF1.json",
            "isValidLabel":"是",
            "stateLabel":"正常",
            "typeLabel":"房间"
        },
        {
            "id":"0d0188fb46034389bca69fb0f73db560",
            "createDate":"2018-09-08 12:10:28",
            "updateDate":"2018-09-10 10:34:10",
            "tenantId":"C0132",
            "name":"设备楼-#2高压室",
            "code":"",
            "type":"R",
            "sort":"22",
            "address":"",
            "isValid":"1",
            "pid":"20",
            "locationp":{
                "id":"20",
                "tenantId":"C0132",
                "name":"官埭变电站",
                "pname":"",
                "locations":"null,20",
                "isValidLabel":"",
                "stateLabel":"",
                "typeLabel":""
            },
            "photo":"https://www.eleclifecycle.com/sem/res/C0132/loc/2018/09/1537172307608.jpg",
            "principalId":"",
            "remark":"",
            "orgId":"C0132O1",
            "state":"1",
            "pids":"C0132O1,20",
            "pname":"官埭变电站 ",
            "locations":"C0132O1,20,0d0188fb46034389bca69fb0f73db560",
            "graph":"st/gd/SBF1.json",
            "isValidLabel":"是",
            "stateLabel":"正常",
            "typeLabel":"房间"
        },
        {
            "id":"23",
            "createDate":"2018-07-26 17:48:43",
            "updateDate":"2018-09-10 10:04:40",
            "tenantId":"C0132",
            "name":"设备楼-#3高压室",
            "code":"4405-S002-L004",
            "type":"R",
            "sort":"23",
            "address":"广东省汕头市龙湖区洛河路11号(泰山路与洛河路交界处)",
            "isValid":"1",
            "pid":"20",
            "locationp":{
                "id":"20",
                "tenantId":"C0132",
                "name":"官埭变电站",
                "pname":"",
                "locations":"null,20",
                "isValidLabel":"",
                "stateLabel":"",
                "typeLabel":""
            },
            "lng":116.740798,
            "lat":23.407678,
            "photo":"https://www.eleclifecycle.com/sem/res/C0132/loc/2018/09/1537172395471.jpg",
            "principalId":"807c7cf564a2400e8341abd5518e2d5b",
            "principal":{
                "id":"807c7cf564a2400e8341abd5518e2d5b",
                "remarks":"",
                "createDate":"2018-06-22 16:42:38",
                "updateDate":"2018-08-30 16:45:14",
                "tenantId":"C0132",
                "loginName":"cs",
                "no":"0001",
                "name":"测试工程师",
                "nickname":"测试工程师",
                "gender":"M",
                "birthday":1529596800000,
                "email":"33@33.com",
                "phone":"13727670753",
                "mobile":"13668986084",
                "address":"黄村大街",
                "userType":"1",
                "level":"",
                "post":"YXRY",
                "loginIp":"0:0:0:0:0:0:0:1",
                "loginDate":"2018-09-08 16:58:41",
                "loginFlag":"1",
                "photo":"https://wx.qlogo.cn/mmopen/vi_32/41Ierpfk4FWAYXkYw5Yz0SrtCHvO5GM3jePcmnwhe5E72hROuUJwQu5niaq6TDQa3lwqlwjGFdqLYh4FODuWhOg/132",
                "oldLoginIp":"0:0:0:0:0:0:0:1",
                "oldLoginDate":"2018-09-08 16:58:41",
                "openid":"oGvYY4-irkIjTZKBih_gb71MacgE",
                "admin":false,
                "dept":{
                    "id":"7dff144f8b0b49219d78bfca4c705d2e",
                    "tenantId":"C0132",
                    "name":"西区巡维中心",
                    "sort":30,
                    "type":"2",
                    "parentId":"C0132O1"
                },
                "photoUrl":"https://wx.qlogo.cn/mmopen/vi_32/41Ierpfk4FWAYXkYw5Yz0SrtCHvO5GM3jePcmnwhe5E72hROuUJwQu5niaq6TDQa3lwqlwjGFdqLYh4FODuWhOg/132",
                "roleNames":"运行人员",
                "atWork":false
            },
            "remark":"",
            "orgId":"C0132O1",
            "state":"1",
            "pids":"C0132O1,20",
            "pname":"官埭变电站 ",
            "locations":"C0132O1,20,23",
            "graph":"st/gd/SBF1.json",
            "isValidLabel":"是",
            "stateLabel":"正常",
            "typeLabel":"房间"
        },
        {
            "id":"9a6b77ff27664b8ea885c5eafa657c05",
            "createDate":"2018-09-08 13:10:11",
            "updateDate":"2018-09-14 16:56:14",
            "tenantId":"C0132",
            "name":"一楼食堂",
            "code":"",
            "type":"R",
            "sort":"30",
            "address":"",
            "isValid":"1",
            "pid":"20",
            "locationp":{
                "id":"20",
                "tenantId":"C0132",
                "name":"官埭变电站",
                "pname":"",
                "locations":"null,20",
                "isValidLabel":"",
                "stateLabel":"",
                "typeLabel":""
            },
            "photo":"https://www.eleclifecycle.com/sem/res/C0132/loc/2018/09/1537171040619.JPG",
            "principalId":"",
            "remark":"",
            "orgId":"C0132O1",
            "state":"1",
            "pids":"C0132O1,20",
            "pname":"官埭变电站 ",
            "locations":"C0132O1,20,9a6b77ff27664b8ea885c5eafa657c05",
            "graph":"st/gd/F1.json",
            "isValidLabel":"是",
            "stateLabel":"正常",
            "typeLabel":"房间"
        },
        {
            "id":"3e41790f90bd4508a06bf7143a025d6c",
            "createDate":"2018-09-08 13:12:08",
            "updateDate":"2018-09-10 10:36:40",
            "tenantId":"C0132",
            "name":"警传",
            "code":"",
            "type":"R",
            "sort":"31",
            "address":"",
            "isValid":"1",
            "pid":"20",
            "locationp":{
                "id":"20",
                "tenantId":"C0132",
                "name":"官埭变电站",
                "pname":"",
                "locations":"null,20",
                "isValidLabel":"",
                "stateLabel":"",
                "typeLabel":""
            },
            "photo":"https://www.eleclifecycle.com/sem/res/C0132/loc/2018/09/1537171200461.jpg",
            "principalId":"",
            "remark":"",
            "orgId":"C0132O1",
            "state":"1",
            "pids":"C0132O1,20",
            "pname":"官埭变电站 ",
            "locations":"C0132O1,20,3e41790f90bd4508a06bf7143a025d6c",
            "graph":"st/gd/F1.json",
            "isValidLabel":"是",
            "stateLabel":"正常",
            "typeLabel":"房间"
        },
        {
            "id":"4cd10654213f4c7c853a79ea2a33fc6a",
            "createDate":"2018-09-10 11:58:28",
            "updateDate":"2018-09-14 16:55:20",
            "tenantId":"C0132",
            "name":"主控楼-二楼休息室",
            "code":"",
            "type":"R",
            "sort":"32",
            "address":"",
            "isValid":"1",
            "pid":"20",
            "locationp":{
                "id":"20",
                "tenantId":"C0132",
                "name":"官埭变电站",
                "pname":"",
                "locations":"null,20",
                "isValidLabel":"",
                "stateLabel":"",
                "typeLabel":""
            },
            "photo":"https://www.eleclifecycle.com/sem/res/C0132/loc/2018/09/1537171115009.JPG",
            "principalId":"",
            "remark":"",
            "orgId":"C0132O1",
            "state":"1",
            "pids":"C0132O1,20",
            "pname":"官埭变电站 ",
            "locations":"C0132O1,20,4cd10654213f4c7c853a79ea2a33fc6a",
            "graph":"st/gd/F2.json",
            "isValidLabel":"是",
            "stateLabel":"正常",
            "typeLabel":"房间"
        }
    ]
    

    js代码

    function filterArray(data, id) {
      let orgId;
      for (var i in data) {
        if (data[i].orgId) {
          orgId = data[i].orgId;
        }
      }
      id = orgId;
      var fa = function(parentid) {
        var _array = [];
        for (var i = 0; i < data.length; i++) {
          var n = data[i];
          if (n.pid === parentid) {
            n.children = fa(n.id);
            _array.push(n);
          }
        }
        return _array;
      }
      return fa(id);
    }
    //调用函数
    console.log(filterArray(originData))
    
  • 相关阅读:
    第6章 键盘_6.5 插入符号(不是光标)
    第6章 键盘_6.3-6.4 字符消息、键盘消息和字符集
    第6章 键盘_6.1-6.2 键盘基础与击键消息
    第5章 绘图基础_5.6 矩形、区域和剪裁
    第4章 进程(1)
    第3章 内核对象(2)
    第3章 内核对象(1)
    第2章 字符和字符串处理(2)
    第2章 字符和字符串处理(1)
    第1章 错误处理
  • 原文地址:https://www.cnblogs.com/lxk0301/p/10166977.html
Copyright © 2020-2023  润新知