wxr
2020-12-18 5ea6aa8ea047d4d7b6137fa86c03109aeb1b67ff
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
using System;
using System.Collections.Generic;
using HDL_ON.Entity;
 
namespace HDL_ON
{
    public class FloorSelectPopupDialog
    {
        public FloorSelectPopupDialog()
        {
        }
 
        /// <summary>
        /// 一级List
        /// </summary>
        List<RoomCellInfo> mFirstList = new List<RoomCellInfo>();
        /// <summary>
        /// 二级联动List
        /// </summary>
        List<List<RoomCellInfo>> mSecondList = new List<List<RoomCellInfo>>();
     
        /// <summary>
        /// 
        /// </summary>
        public void ShowView(Action<string> selectAction, string selectTag = DiySelectPopupDialog.ALLSELECT)
        {
 
            var floorList = SpatialInfo.CurrentSpatial.FloorList;
            var roomList = SpatialInfo.CurrentSpatial.RoomList;
 
            if (floorList == null || floorList.Count == 0)
            {
                //没有楼层只加载房间
                if (roomList == null)
                {
                    Utlis.WriteLine("roomList null");
                    return;
                }
 
                mFirstList.Clear();
                foreach (var room in roomList)
                {
                    mFirstList.Add(new RoomCellInfo() { Title = room.roomName, TagId = room.roomId });
                }
                var roomSelectPopupDialog = new DiySelectPopupDialog();
                roomSelectPopupDialog.ShowView(mFirstList, null, selectAction, selectTag);
            }
            else
            {
                mFirstList.Clear();
                mSecondList.Clear();
                //一级数组为楼层
                foreach (var floor in floorList)
                {
                    mFirstList.Add(new RoomCellInfo() { Title = floor.roomName, TagId = floor.roomId });
                    var mList = new List<RoomCellInfo>();
                    var allRoom = roomList.FindAll((room) => room.parentId == floor.roomId);
                    foreach (var mRoom in allRoom)
                    {
                        mList.Add(new RoomCellInfo() { Title = mRoom.roomName, TagId = mRoom.roomId });
                    }
 
                    if(mList == null)
                    {
                        mList = new List<RoomCellInfo>();
                    }
                    mSecondList.Add(mList);
                }
 
                var roomSelectPopupDialog = new DiySelectPopupDialog();
                roomSelectPopupDialog.ShowView(mFirstList, mSecondList, selectAction, selectTag);
 
            }
 
        }
       
    }
}