using PdmSwPlugin.Common.Util;
|
using PdmSwPlugin.PropertySetting.Entity;
|
using PdmSwPlugin.PropertySetting.Panel.Attr;
|
using System.Collections.Generic;
|
using System.Collections.ObjectModel;
|
|
namespace PdmSwPlugin.PropertySetting.Panel.Model
|
{
|
public class JgjBasePanelModel : BasePanelModel
|
{
|
private Dictionary<string, JgjType> datas;
|
private Dictionary<string, ObservableCollection<string>> stuffItemCache;
|
|
private Dictionary<string, ObservableCollection<string>> surfaceItemCache;
|
|
private Dictionary<string, ObservableCollection<string>> heatItemCache;
|
|
#region 下拉框数据源
|
private ObservableCollection<string> _jgjTypeItems;
|
public ObservableCollection<string> jgjTypeItems
|
{
|
get => _jgjTypeItems;
|
set => RaiseAndSetIfChanged(ref _jgjTypeItems, value);
|
}
|
|
private ObservableCollection<string> _stuffItems;
|
public ObservableCollection<string> stuffItems
|
{
|
get => _stuffItems;
|
set => RaiseAndSetIfChanged(ref _stuffItems, value);
|
}
|
|
private ObservableCollection<string> _surfaceItems;
|
public ObservableCollection<string> surfaceItems
|
{
|
get => _surfaceItems;
|
set => RaiseAndSetIfChanged(ref _surfaceItems, value);
|
}
|
|
private ObservableCollection<string> _heatItems;
|
public ObservableCollection<string> heatItems
|
{
|
get => _heatItems;
|
set => RaiseAndSetIfChanged(ref _heatItems, value);
|
}
|
|
private ObservableCollection<string> _materialTypeItems = new ObservableCollection<string> { "普通件",
|
"机罩","机架","大板"
|
};// "易损件","备件",
|
public ObservableCollection<string> materialTypeItems
|
{
|
get => _materialTypeItems;
|
set => RaiseAndSetIfChanged(ref _materialTypeItems, value);
|
}
|
|
private ObservableCollection<string> _docTypeItems = new ObservableCollection<string> { "加工件" };
|
public ObservableCollection<string> docTypeItems
|
{
|
get => _docTypeItems;
|
set => RaiseAndSetIfChanged(ref _docTypeItems, value);
|
}
|
#endregion
|
|
#region 加工件属性
|
private string _jgjType = "";
|
[PropertySettingAttr(Name = NameConstant.jgjType)]
|
public string jgjType
|
{
|
get => _jgjType;
|
set
|
{
|
if (_jgjType == value)
|
{
|
return;
|
}
|
RaiseAndSetIfChanged(ref _jgjType, value);
|
RefreshItem();
|
}
|
}
|
|
private string _stuff = "";
|
[PropertySettingAttr(Name = NameConstant.stuff)]
|
public string stuff
|
{
|
get => _stuff;
|
set
|
{
|
if (_stuff == value)
|
{
|
return;
|
}
|
RaiseAndSetIfChanged(ref _stuff, value);
|
RefreshItem();
|
}
|
}
|
|
private string _surface = "";
|
[PropertySettingAttr(Name = NameConstant.surface)]
|
public string surface
|
{
|
get => _surface;
|
set
|
{
|
if (_surface == value)
|
{
|
return;
|
}
|
RaiseAndSetIfChanged(ref _surface, value);
|
}
|
}
|
|
private string _heat = "";
|
[PropertySettingAttr(Name = NameConstant.heat)]
|
public string heat
|
{
|
get => _heat;
|
set
|
{
|
if (_heat == value)
|
{
|
return;
|
}
|
RaiseAndSetIfChanged(ref _heat, value);
|
}
|
}
|
#endregion
|
|
private void RefreshItem()
|
{
|
if (datas == null)
|
{
|
return;
|
}
|
var finalStuffs = stuffItemCache.Get(jgjType, new ObservableCollection<string> { "无" });
|
string key = $"{jgjType}_{stuff}";
|
var finalSurfaces = surfaceItemCache.Get(key, new ObservableCollection<string> { "无" });
|
var finalHeats = heatItemCache.Get(key, new ObservableCollection<string> { "无" });
|
|
stuffItems = finalStuffs;
|
surfaceItems = finalSurfaces;
|
heatItems = finalHeats;
|
}
|
|
public override bool SetSettings(object settings)
|
{
|
Dictionary<string, JgjType> datas = settings as Dictionary<string, JgjType>;
|
this.datas = datas;
|
|
stuffItemCache = new Dictionary<string, ObservableCollection<string>>();
|
|
surfaceItemCache = new Dictionary<string, ObservableCollection<string>>();
|
|
heatItemCache = new Dictionary<string, ObservableCollection<string>>();
|
|
ObservableCollection<string> jgjTypes = new ObservableCollection<string> { };
|
|
foreach (string key in datas.Keys)
|
{
|
jgjTypes.Add(key);
|
JgjType type = datas[key];
|
ObservableCollection<string> stuffs = new ObservableCollection<string> { "无" };
|
|
Dictionary<string, StuffType> stuffDatas = type.stuffMap;
|
foreach (string stuff in stuffDatas.Keys)
|
{
|
if (stuff != "无")
|
{
|
stuffs.Add(stuff);
|
}
|
StuffType stuffType = stuffDatas[stuff];
|
string key2 = key + "_" + stuff;
|
|
ObservableCollection<string> surfaces = new ObservableCollection<string> { "无" };
|
ObservableCollection<string> heats = new ObservableCollection<string> { "无" };
|
foreach (string surface in stuffType.surfaceParam)
|
{
|
if (surface != "无") surfaces.Add(surface);
|
}
|
foreach (string heat in stuffType.heatParam)
|
{
|
if (heat != "无") heats.Add(heat);
|
}
|
surfaceItemCache.Add(key2, surfaces);
|
heatItemCache.Add(key2, heats);
|
}
|
stuffItemCache.Add(key, stuffs);
|
if (!stuffItemCache.ContainsKey("无"))
|
{
|
stuffItemCache.Add("无", new ObservableCollection<string> { "无" });
|
}
|
}
|
|
jgjTypeItems = jgjTypes;
|
RefreshItem();
|
return true;
|
}
|
}
|
}
|