//加载小类树和对应的数据 private void InitLittleRawMaterial() { _LittleRootTreeNode = null; _LittleRootTreeNode = new TreeNodeModel("全部大类"); _LittleRootTreeNode.Expanded = true; List<Raw> raws = _MaterialDataService.FindAllBigRawByDeletedStatus(); if (raws != null) { LittleMaterialItems.Clear(); foreach (var raw in raws) { if (raw.ParentRawId == 0 || raw.ParentRawId == null) { TreeNodeModel node = new TreeNodeModel(raw.Name, _LittleRootTreeNode); _LittleRootTreeNode.Children.Add(node); node.Id = raw.RawId.ToString(); //根据大类编号查找全部的小类 List<Raw> childrens = _MaterialDataService.FindAllRawByBigRawIdAndDeletedStatus(raw.RawId); if (childrens != null) { foreach (var child in childrens) { _LittleRawMaterialBean = new LittleRawMaterialBean(); _LittleRawMaterialBean.CreateLittleRawMaterialBean(child); _LittleRawMaterialBean.Code = (LittleMaterialItems.Count + 1).ToString(); _LittleRawMaterialBean.ParentRaw = node.Text; _LittleMaterialItems.Add(LittleRawMaterialBean); } } } } } _LittleFirstGeneration = new ObservableCollection<TreeNodeModel>(new TreeNodeModel[] { _LittleRootTreeNode }); }
//加载选中项 private void LoadLittleRawMaterial(TreeNodeModel node) { new Task(() => { List<Raw> raws = _MaterialDataService.FindAllRawByBigRawIdAndDeletedStatus(int.Parse(node.Id)); DispatcherHelper.CheckBeginInvokeOnUI(() => { LittleMaterialItems.Clear(); if (raws != null) { foreach (var raw in raws) { _LittleRawMaterialBean = new LittleRawMaterialBean(); _LittleRawMaterialBean.Code = (LittleMaterialItems.Count + 1).ToString(); _LittleRawMaterialBean.ParentRaw = node.Text; _LittleRawMaterialBean.CreateLittleRawMaterialBean(raw); LittleMaterialItems.Add(LittleRawMaterialBean); } } }); }).Start(); }