|
|
@@ -11,6 +11,7 @@ namespace RMYY_CallCenter_Api.Controllers.System
|
|
11
|
11
|
public class DepartmentController : BaseController
|
|
12
|
12
|
{
|
|
13
|
13
|
private Bll.T_Sys_Department departmentBLL = new Bll.T_Sys_Department();
|
|
|
14
|
+ private Bll.T_Wowo_repairyqbll yqBll = new Bll.T_Wowo_repairyqbll();
|
|
14
|
15
|
|
|
15
|
16
|
// GET: Department
|
|
16
|
17
|
/// <summary>
|
|
|
@@ -61,45 +62,60 @@ namespace RMYY_CallCenter_Api.Controllers.System
|
|
61
|
62
|
/// </summary>
|
|
62
|
63
|
/// <returns></returns>
|
|
63
|
64
|
[HttpGet]
|
|
64
|
|
- public ActionResult GetTreeList()
|
|
|
65
|
+ public ActionResult GetTreeList(int hosid=0,int pid=0)
|
|
65
|
66
|
{
|
|
|
67
|
+ var hoslist = yqBll.GetListall();
|
|
66
|
68
|
var dptmodel = departmentBLL.GetModelList(" F_State=1");
|
|
67
|
69
|
dptmodel.Sort((x, y) => x.F_Sort ?? 0 - y.F_Sort ?? 0);//排序
|
|
68
|
70
|
var treeList = new List<TreeModel>();
|
|
69
|
|
- foreach (var item in dptmodel.Where(p =>p.F_ParentId == 0).ToList())
|
|
|
71
|
+ if (hoslist.Count > 0)
|
|
70
|
72
|
{
|
|
71
|
|
- TreeModel treeModel = new TreeModel();
|
|
72
|
|
- treeModel.id = item.F_DeptId.ToString();
|
|
73
|
|
- treeModel.IconCls = "";
|
|
74
|
|
- treeModel.text = item.F_DeptName;
|
|
75
|
|
- treeModel.parentid = item.F_ParentId.ToString();
|
|
76
|
|
- treeModel.children = TreeRecursion(dptmodel, item.F_DeptId.ToString());
|
|
77
|
|
- treeList.Add(treeModel);
|
|
|
73
|
+ foreach (var hositem in hoslist)
|
|
|
74
|
+ {
|
|
|
75
|
+ TreeModel treeModel = new TreeModel();
|
|
|
76
|
+ treeModel.id = hositem.T_Woid.ToString();
|
|
|
77
|
+ treeModel.IconCls = "";
|
|
|
78
|
+ treeModel.text = hositem.T_Woname;
|
|
|
79
|
+ treeModel.parentid = "-1";
|
|
|
80
|
+ treeModel.TypeId = 1;
|
|
|
81
|
+ treeModel.children = TreeRecursion(dptmodel, "0", hositem.T_Woid);
|
|
|
82
|
+ treeList.Add(treeModel);
|
|
|
83
|
+ //var dptlist = dptmodel.Where(p => p.F_ParentId == 0 && p.T_Woid == hositem.T_Woid).ToList();
|
|
|
84
|
+ }
|
|
78
|
85
|
}
|
|
79
|
86
|
//return Content(treeList.ToJson());
|
|
80
|
87
|
return Success("获取菜单树成功", treeList);
|
|
81
|
88
|
}
|
|
82
|
89
|
|
|
83
|
|
- private List<TreeModel> TreeRecursion(List<Model.T_Sys_Department> data, string parentId = "0")
|
|
|
90
|
+ private List<TreeModel> TreeRecursion(List<Model.T_Sys_Department> data, string parentId = "0", int hosid = 0)
|
|
84
|
91
|
{
|
|
|
92
|
+ List<Model.T_Sys_Department> item = null;
|
|
85
|
93
|
List<TreeModel> newList = new List<TreeModel>();
|
|
86
|
|
- if (parentId != "0")
|
|
|
94
|
+ //if (parentId != "0")
|
|
|
95
|
+ //{
|
|
|
96
|
+ if (hosid != 0)
|
|
|
97
|
+ {
|
|
|
98
|
+ item = data.FindAll(t => t.F_ParentId.ToString() == parentId && t.T_Woid == hosid);//data建议在调用此扩展方法前已经排序过
|
|
|
99
|
+ }
|
|
|
100
|
+ else
|
|
|
101
|
+ {
|
|
|
102
|
+ item = data.FindAll(t => t.F_ParentId.ToString() == parentId);//data建议在调用此扩展方法前已经排序过
|
|
|
103
|
+ }
|
|
|
104
|
+ if (item.Count > 0)
|
|
87
|
105
|
{
|
|
88
|
|
- List<Model.T_Sys_Department> item = data.FindAll(t => t.F_ParentId.ToString() == parentId);//data建议在调用此扩展方法前已经排序过
|
|
89
|
|
- if (item.Count > 0)
|
|
|
106
|
+ foreach (Model.T_Sys_Department entity in item)
|
|
90
|
107
|
{
|
|
91
|
|
- foreach (Model.T_Sys_Department entity in item)
|
|
92
|
|
- {
|
|
93
|
|
- TreeModel treeModel = new TreeModel();
|
|
94
|
|
- treeModel.id = entity.F_DeptId.ToString();
|
|
95
|
|
- treeModel.IconCls = "";
|
|
96
|
|
- treeModel.text = entity.F_DeptName;
|
|
97
|
|
- treeModel.parentid = entity.F_ParentId.ToString();
|
|
98
|
|
- treeModel.children = TreeRecursion(item, entity.F_DeptId.ToString());
|
|
99
|
|
- newList.Add(treeModel);
|
|
100
|
|
- }
|
|
|
108
|
+ TreeModel treeModel = new TreeModel();
|
|
|
109
|
+ treeModel.id = entity.F_DeptId.ToString();
|
|
|
110
|
+ treeModel.IconCls = "";
|
|
|
111
|
+ treeModel.text = entity.F_DeptName;
|
|
|
112
|
+ treeModel.parentid = entity.F_ParentId.ToString();
|
|
|
113
|
+ treeModel.TypeId = 2;
|
|
|
114
|
+ treeModel.children = TreeRecursion(item, entity.F_DeptId.ToString());
|
|
|
115
|
+ newList.Add(treeModel);
|
|
101
|
116
|
}
|
|
102
|
117
|
}
|
|
|
118
|
+ //}
|
|
103
|
119
|
return newList;
|
|
104
|
120
|
}
|
|
105
|
121
|
|