[AjaxPro.AjaxMethod]
public
DataTemp GetSendCity(
string
citylist,
string
schemeid)
{
StringBuilder data =
new
StringBuilder();
DataTemp datatmp =
new
DataTemp();
datatmp.Arraydata =
new
List<CustomTreeNode>();
try
{
Kaitone.Model.Scheme.Scheme schemetemp =
new
Scheme();
if
(schemeid.Length > 0)
//业务变更
{
schemetemp = schbll.GetSchemeModelByGUID(schemeid);
}
Kaitone.UI.BLL.SysConfig.City bll =
new
Kaitone.UI.BLL.SysConfig.City();
List<Kaitone.Model.City> list =
new
List<Kaitone.Model.City>();
list = bll.GetList().CityData;
StringBuilder sb =
new
StringBuilder();
string
[] strlist = citylist.Split(
';'
);
//这是拆分开的,每一个box对应的位置的guid哦
List<
int
> selectcity = schemetemp.SendCityList.Select(a => a.CityID).ToList();
if
(list !=
null
)
{
sb.Append(
"["
);
//{ id:1, pId:0, name:"随意勾选 父 1", open:true},
foreach
(Kaitone.Model.City pos
in
list.Where(a => a.ParentID == 0))
{
if
(selectcity.Contains(pos.CityID))
//包含这个城市了,被选择了。
{
sb.Append(
"{id:\""
+ pos.CityID.ToString() +
"\",pId:0,name:\""
+ pos.CityName.ToString() +
"\","
+ GetChildCity(selectcity,
true
, pos.CityID, list, datatmp) +
", checked:true , font:{'color':'blue'},iconSkin:\"pIcon01\"},"
);
CustomTreeNode onetree =
new
CustomTreeNode();
onetree.id = pos.CityID.ToString();
onetree.pId = pos.ParentID.ToString();
onetree.name = pos.CityName;
datatmp.Arraydata.Add(onetree);
}
else
{
sb.Append(
"{id:\""
+ pos.CityID.ToString() +
"\",pId:0,name:\""
+ pos.CityName.ToString() +
"\","
+ GetChildCity(selectcity,
false
, pos.CityID, list, datatmp) +
", font:{'color':'blue'},iconSkin:\"pIcon01\"},"
);
}
}
if
(sb.Length > 1)
{
sb.Remove(sb.Length - 1, 1);
}
sb.Append(
"]"
);
datatmp.TreeData = sb.ToString();
return
datatmp;
}
else
{
return
new
DataTemp();
}
}
catch
(Exception ex)
{
return
new
DataTemp();
}
}
/// <summary>
/// 根据位置获取对应的box列表
/// </summary>
/// <param name="pos"></param>
/// <returns></returns>
public
string
GetChildCity(List<
int
>selectcity,
bool
isparentchecked,
int
parentid,List<City> Citylist,DataTemp datatemp)
{
List<Kaitone.Model.City> list = Citylist.Where(a=>a.ParentID==parentid).ToList();
StringBuilder sb =
new
StringBuilder();
if
(list !=
null
)
{
sb.Append(
"childs:["
);
if
(list.Count == 0) {
return
"isParent:true,nocheck:true"
; }
foreach
(Kaitone.Model.City city
in
list)
{
if
((selectcity.Contains(city.CityID) || isparentchecked))
{
sb.Append(
"{id:\""
+ city.CityID.ToString() +
"\",pId:\""
+ parentid.ToString() +
"\",name:\""
+ city.CityName
+
"\", font:{'color':'blue'},checked:true},"
);
CustomTreeNode onetree =
new
CustomTreeNode();
onetree.id = city.CityID.ToString();
onetree.pId = city.ParentID.ToString();
onetree.name = city.CityName;
datatemp.Arraydata.Add(onetree);
}
else
{
sb.Append(
"{id:\""
+ city.CityID.ToString() +
"\",pId:\""
+ parentid.ToString() +
"\",name:\""
+ city.CityName
+
"\", font:{'color':'blue'}},"
);
}
}
if
(sb.Length > 1)
{
sb.Remove(sb.Length - 1, 1);
}
sb.Append(
"]"
);
return
sb.ToString();
}
else
{
return
"isParent:true,nocheck:true"
;
}
}
联系客服