Exemplo n.º 1
0
        public JsonResult GetOrganizationList(int limit = 10, int offset = 1)
        {
            B_Organization b_org = new B_Organization();
            List <Order>   order = new List <Order>()
            {
                Order.Asc("sort_id")
            };

            List <Domain.Navigation> list = new List <Domain.Navigation>();
            List <SearchTemplate>    st   = new List <SearchTemplate>()
            {
                new SearchTemplate()
                {
                    key = "parent_id", value = 0, searchType = Common.EnumBase.SearchType.Eq
                },
                new SearchTemplate()
                {
                    key = "", value = new int[] { offset, limit }, searchType = Common.EnumBase.SearchType.Paging
                }
            };
            var list_org      = b_org.GetList(st, order);
            var list_org_cout = b_org.GetCount(st);

            return(Json(new { total = list_org_cout, rows = list_org }, JsonRequestBehavior.AllowGet));
        }
Exemplo n.º 2
0
        /// <summary>
        /// 这里只遍历两层
        /// </summary>
        /// <param name="helper"></param>
        /// <returns></returns>
        public static string select_org(this HtmlHelper helper)
        {
            B_Organization b_org = new B_Organization();
            List <Order>   order = new List <Order>()
            {
                Order.Asc("sort_id")
            };
            List <SearchTemplate> st = new List <SearchTemplate>()
            {
                new SearchTemplate()
                {
                    key = "parent_id", value = 0, searchType = Common.EnumBase.SearchType.Eq
                }
            };
            IList <Domain.Organization> list_org = b_org.GetList(st, order);
            StringBuilder sb = new StringBuilder();

            sb.Append("<select id=\"txt_parent_id\" name=\"txt_parent_id\" class=\"selectpicker show-tick form-control\" data-live-search=\"true\">");
            sb.Append("<optgroup label=\"一级菜单\">");
            sb.Append("<option data-subtext=\"一级菜单\" selected = \"true\">0</option>");
            sb.Append("</optgroup>");
            foreach (var item in list_org)
            {
                sb.Append("<optgroup label=" + item.name + ">");
                sb.Append("<option data-subtext=" + item.name + ">" + item.id + "</option>"); //一级菜单放第一个
                st = new List <SearchTemplate>()
                {
                    new SearchTemplate()
                    {
                        key = "parent_id", value = item.id, searchType = Common.EnumBase.SearchType.Eq
                    }
                };
                var list_suborg = b_org.GetList(st, order);
                foreach (var it in list_suborg)
                {
                    sb.Append("<option data-subtext=" + it.name + ">" + it.id + "</option>"); //二级菜单
                }
                sb.Append("</optgroup>");
            }
            sb.Append("</select>");
            return(sb.ToString());
        }
Exemplo n.º 3
0
        public JsonResult GetOrganizationSubList(string parent_id)
        {
            B_Organization b_org = new B_Organization();
            List <Order>   order = new List <Order>()
            {
                Order.Asc("sort_id")
            };
            List <SearchTemplate> st = new List <SearchTemplate>()
            {
                new SearchTemplate()
                {
                    key = "parent_id", value = Convert.ToInt32(parent_id), searchType = Common.EnumBase.SearchType.Eq
                }
            };
            var list_sub_org = b_org.GetList(st, order);

            return(Json(list_sub_org, JsonRequestBehavior.AllowGet));
        }