ke_junjie
2025-06-04 84620534eb627e95811b971a4b552b6a177829bf
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
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
using iWare.Wms.Core.Util.LowCode.Front.Model;
using Furion.Extras.iWare.Wms.Util.LowCode.Front.Att;
using Furion.Extras.iWare.Wms.Util.LowCode.Front.Code;
using Furion.Extras.iWare.Wms.Util.LowCode.Front.Interface;
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
 
namespace Furion.Extras.iWare.Wms.Util.LowCode.Front
{
    [FrontType("table")]
    public class Front_Table : IFront, IFrontLayout
    {
        public string Key { get; set; }
        public string Label { get; set; }
        public string Type { get; set; }
        public string Model { get; set; }
 
        /// <summary>
        /// 表格配置
        /// </summary>
        public Front_Table_Options Options { get; set; }
 
        /// <summary>
        /// 表格列
        /// </summary>
        public List<Front_Table_Trs> Trs { get; set; }
 
        public ViewDynamic Dynamic
        { get { return null; } }
 
        public IFront ConvertFront(JObject JData)
        {
            List<Front_Table_Trs> trs = new List<Front_Table_Trs>();
 
            var trs_obj = JData["trs"].Values<JObject>();
 
            if (trs != null)
            {
                foreach (var tr_item in trs_obj)
                {
                    var tds_obj = tr_item["tds"].Values<JObject>();
 
                    if (tds_obj != null)
                    {
                        List<Front_Table_Tds> tds = new List<Front_Table_Tds>();
 
                        foreach (var td_item in tds_obj)
                        {
                            tds.Add(new Front_Table_Tds()
                            {
                                Colspan = td_item["colspan"].Value<int>(),
                                Rowspan = td_item["rowspan"].Value<int>(),
                                List = AutoCode_Front.ReadFront(td_item["list"].Values<JObject>().ToList())
                            });
                        }
 
                        trs.Add(new Front_Table_Trs()
                        {
                            Tds = tds
                        });
                    }
                }
            }
 
            return new Front_Table()
            {
                Key = JData["key"].Value<string>(),
                Label = JData["label"].Value<string>(),
                Type = JData["type"].Value<string>(),
                Options = JsonConvert.DeserializeObject<Front_Table_Options>(JData["options"].ToString()),
                Trs = trs
            };
        }
 
        public void ReadFront(Action<IFront> action)
        {
            this.Trs.SelectMany(x => x.Tds.SelectMany(x_1 => x_1.List)).ToList().ForEach(item =>
            {
                if (item is IFrontLayout)
                {
                    (item as IFrontLayout).ReadFront(action);
                }
                else
                {
                    action(item);
                }
            });
        }
    }
 
    /// <summary>
    /// 表格列
    /// </summary>
    public class Front_Table_Trs
    {
        public List<Front_Table_Tds> Tds { get; set; }
    }
 
    /// <summary>
    /// 表格单元格
    /// </summary>
    public class Front_Table_Tds
    {
        /// <summary>
        /// 跨列
        /// </summary>
        public int Colspan { get; set; }
 
        /// <summary>
        /// 跨行
        /// </summary>
        public int Rowspan { get; set; }
 
        /// <summary>
        /// 组件集
        /// </summary>
        public List<IFront> List { get; set; }
    }
 
    public class Front_Table_Options
    {
        public string Width { get; set; }
        public bool Bordered { get; set; }
        public bool Bright { get; set; }
        public bool Small { get; set; }
        public string CustomStyle { get; set; }
    }
}