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; }
///
/// 表格配置
///
public Front_Table_Options Options { get; set; }
///
/// 表格列
///
public List Trs { get; set; }
public ViewDynamic Dynamic
{ get { return null; } }
public IFront ConvertFront(JObject JData)
{
List trs = new List();
var trs_obj = JData["trs"].Values();
if (trs != null)
{
foreach (var tr_item in trs_obj)
{
var tds_obj = tr_item["tds"].Values();
if (tds_obj != null)
{
List tds = new List();
foreach (var td_item in tds_obj)
{
tds.Add(new Front_Table_Tds()
{
Colspan = td_item["colspan"].Value(),
Rowspan = td_item["rowspan"].Value(),
List = AutoCode_Front.ReadFront(td_item["list"].Values().ToList())
});
}
trs.Add(new Front_Table_Trs()
{
Tds = tds
});
}
}
}
return new Front_Table()
{
Key = JData["key"].Value(),
Label = JData["label"].Value(),
Type = JData["type"].Value(),
Options = JsonConvert.DeserializeObject(JData["options"].ToString()),
Trs = trs
};
}
public void ReadFront(Action 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);
}
});
}
}
///
/// 表格列
///
public class Front_Table_Trs
{
public List Tds { get; set; }
}
///
/// 表格单元格
///
public class Front_Table_Tds
{
///
/// 跨列
///
public int Colspan { get; set; }
///
/// 跨行
///
public int Rowspan { get; set; }
///
/// 组件集
///
public List 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; }
}
}