コード例 #1
0
        public IActionResult Body()
        {
            string dictId   = Request.Querys("id");
            string parentId = Request.Querys("parentid");

            Model.Dictionary    dictionaryModel = null;
            Business.Dictionary dictionary      = new Business.Dictionary();
            if (dictId.IsGuid(out Guid guid))
            {
                dictionaryModel = dictionary.Get(guid);
            }
            if (null == dictionaryModel)
            {
                dictionaryModel = new Model.Dictionary
                {
                    Id       = Guid.NewGuid(),
                    ParentId = parentId.ToGuid(),
                    Sort     = dictionary.GetMaxSort(parentId.ToGuid())
                };
            }
            ViewData["id"]        = dictId.IsNullOrWhiteSpace() ? "" : dictId;
            ViewData["query"]     = Request.UrlQuery();
            ViewData["query1"]    = "appid=" + Request.Querys("appid") + "&tabid=" + Request.Querys("tabid");
            ViewData["refreshId"] = dictionaryModel.ParentId;
            ViewData["isRoot"]    = dictionaryModel.ParentId == Guid.Empty ? "1" : "0";//是否是根节点
            return(View(dictionaryModel));
        }
コード例 #2
0
        public string Dictionary_GetNames()
        {
            string        values        = Request.Forms("values");
            StringBuilder stringBuilder = new StringBuilder();

            Business.Dictionary dictionary = new Business.Dictionary();
            foreach (string value in values.Split(','))
            {
                if (value.IsGuid(out Guid dictId))
                {
                    var dictModel = dictionary.Get(dictId);
                    if (null != dictModel)
                    {
                        stringBuilder.Append(dictModel.Title);
                        stringBuilder.Append("、");
                    }
                }
            }
            return(stringBuilder.ToString().TrimEnd('、'));
        }
コード例 #3
0
 public string SaveBody(Model.Dictionary dictionaryModel)
 {
     if (!ModelState.IsValid)
     {
         return(Tools.GetValidateErrorMessag(ModelState));
     }
     Business.Dictionary dictionary = new Business.Dictionary();
     if (Request.Querys("id").IsGuid(out Guid guid))
     {
         var    oldModel = dictionary.Get(guid);
         string oldJSON  = null == oldModel ? "" : oldModel.ToString();
         dictionary.Update(dictionaryModel);
         Business.Log.Add("修改了数据字典-" + dictionaryModel.Title, type: Business.Log.Type.系统管理, oldContents: oldJSON, newContents: dictionaryModel.ToString());
     }
     else
     {
         dictionary.Add(dictionaryModel);
         Business.Log.Add("添加了数据字典-" + dictionaryModel.Title, dictionaryModel.ToString(), Business.Log.Type.系统管理);
     }
     return("保存成功");
 }
コード例 #4
0
        public IActionResult Sort()
        {
            string id = Request.Querys("id");

            Business.Dictionary dictionary = new Business.Dictionary();
            ViewData["queryString"] = Request.UrlQuery();
            if (id.IsGuid(out Guid guid))
            {
                var dict   = dictionary.Get(guid);
                var childs = dictionary.GetChilds(dict.ParentId);
                ViewData["refreshId"] = dict.ParentId;
                return(View(childs));
            }
            else
            {
                return(new ContentResult()
                {
                    Content = "没有找到当前字典项"
                });
            }
        }
コード例 #5
0
        public string SaveSort()
        {
            string sort = Request.Forms("sort");

            Business.Dictionary dictionary = new Business.Dictionary();
            int i = 0;
            List <Model.Dictionary> dictionaries = new List <Model.Dictionary>();

            foreach (string id in sort.Split(','))
            {
                if (id.IsGuid(out Guid guid))
                {
                    var dict = dictionary.Get(guid);
                    if (null != dict)
                    {
                        dict.Sort = i += 5;
                        dictionaries.Add(dict);
                    }
                }
            }
            dictionary.Update(dictionaries.ToArray());
            return("保存成功!");
        }
コード例 #6
0
        public IActionResult Dictionary_Index()
        {
            string        values        = Request.Querys("values");
            string        dataSource    = Request.Querys("datasource");
            StringBuilder stringBuilder = new StringBuilder();

            Business.Dictionary dictionary = new Business.Dictionary();
            foreach (string value in values.Split(','))
            {
                switch (dataSource)
                {
                case "0":
                    if (value.IsGuid(out Guid dictId))
                    {
                        var dictModel = dictionary.Get(dictId);
                        if (null != dictModel)
                        {
                            stringBuilder.Append("<div onclick=\"currentDel=this;showinfo('{0}');\" class=\"selectorDiv\" ondblclick=\"currentDel=this;del();\" value=\"" + value + "\">");
                            stringBuilder.Append(dictModel.Title);
                            stringBuilder.Append("</div>");
                        }
                    }
                    break;
                }
            }
            ViewData["defaults"]   = stringBuilder.ToString();
            ViewData["ismore"]     = Request.Querys("ismore");
            ViewData["isparent"]   = Request.Querys("isparent");
            ViewData["ischild"]    = Request.Querys("ischild");
            ViewData["isroot"]     = Request.Querys("isroot");
            ViewData["root"]       = Request.Querys("root");
            ViewData["eid"]        = Request.Querys("eid");
            ViewData["datasource"] = dataSource;
            ViewData["ismobile"]   = Request.Querys("ismobile");
            return(View());
        }
コード例 #7
0
        /// <summary>
        /// 加载树JSON
        /// </summary>
        /// <returns></returns>
        public string Tree1()
        {
            string rootId     = Request.Querys("root");
            string tempitem   = Request.Querys("tempitem");   //需要临时添加的项(如表单管理流程管理需要额外添加已删除的项目)
            string tempitemid = Request.Querys("tempitemid"); //需要临时添加项的ID

            Business.Dictionary dictionary = new Business.Dictionary();
            if (rootId.IsNullOrEmpty())
            {
                rootId = dictionary.GetRootId().ToString();
            }
            Newtonsoft.Json.Linq.JArray jArray = new Newtonsoft.Json.Linq.JArray();
            string[] rootIds = rootId.Split(',');
            foreach (string rid in rootIds)
            {
                if (!rid.IsGuid(out Guid rootGuid))
                {
                    continue;
                }
                var rootDict = dictionary.Get(rootGuid);
                if (null == rootDict)
                {
                    continue;
                }

                var childs = dictionary.GetChilds(rootGuid);
                Newtonsoft.Json.Linq.JObject jObject = new Newtonsoft.Json.Linq.JObject
                {
                    { "id", rootDict.Id },
                    { "parentID", rootDict.ParentId },
                    { "title", rootDict.Status == 1 ? "<span style='color:#999'>" + rootDict.Title + "[作废]</span>" : rootDict.Title },
                    { "type", childs.Count > 0 ? "0" : "2" },
                    { "ico", "fa-briefcase" },
                    { "hasChilds", childs.Count }
                };

                Newtonsoft.Json.Linq.JArray jArray1 = new Newtonsoft.Json.Linq.JArray();
                foreach (var child in childs)
                {
                    Newtonsoft.Json.Linq.JObject jObject1 = new Newtonsoft.Json.Linq.JObject
                    {
                        { "id", child.Id },
                        { "parentID", rootDict.Id },
                        { "title", child.Status == 1 ? "<span style='color:#999'>" + child.Title + "[作废]</span>" : child.Title },
                        { "type", "2" },
                        { "ico", "" },
                        { "hasChilds", dictionary.HasChilds(child.Id) ? 1 : 0 },
                        { "childs", new Newtonsoft.Json.Linq.JArray() }
                    };
                    jArray1.Add(jObject1);
                }


                if (!tempitem.IsNullOrWhiteSpace() && !tempitemid.IsNullOrWhiteSpace() && rid.Equals(rootIds[rootIds.Length - 1]))
                {
                    Newtonsoft.Json.Linq.JObject tempObject = new Newtonsoft.Json.Linq.JObject
                    {
                        { "id", tempitemid },
                        { "parentID", rootDict.Id },
                        { "title", tempitem },
                        { "type", "2" },
                        { "ico", "" },
                        { "hasChilds", 0 },
                        { "childs", new Newtonsoft.Json.Linq.JArray() }
                    };
                    jArray1.Add(tempObject);
                }

                jObject.Add("childs", jArray1);
                jArray.Add(jObject);
            }
            return(jArray.ToString());
        }