Exemplo n.º 1
0
        /// <summary>
        /// 附加按钮单个
        /// </summary>
        /// <param name="button"></param>
        public virtual void MakeThisButtons(ModuleButton button)
        {
            #region 基础按钮预处理
            if (Buttons == null)
            {
                Buttons = new List <ModuleButton>();
            }
            #endregion

            //判断是不是重复
            if (!HaveButton(button.ButtonKey))
            {
                button.TenantId = TenantId;
                Buttons.Add(button);
            }
        }
Exemplo n.º 2
0
        //{
        //    bool have = false;
        //    if (Buttons != null && Buttons.Count>0)
        //    {
        //        have = Buttons.Count(o => o.ButtonKey == ButtonKey) > 0;
        //        //if (Buttons.Count > 0)
        //        //{
        //        //    foreach (var Button in Buttons.Count(o=>o.ButtonKey==))
        //        //    {
        //        //        if (Button.ButtonKey == ButtonKey)
        //        //        {
        //        //            have = true;
        //        //            break;
        //        //        }
        //        //    }
        //        //}
        //    }
        //    return have;
        //}
        #endregion

        #region  钮构建的提供方法 1 构建默认按钮
        /// <summary>
        /// 构建默认按钮
        /// </summary>
        /// <param name="canDel">默认删除按钮</param>
        /// <param name="canAdd">默认添加按钮</param>
        /// <param name="canEdit">默认编辑按钮</param>
        /// <param name="canView">默认查看按钮</param>
        /// <param name="canMultiEdit">默认批量修改按钮</param>
        public virtual void MakeDefaultButtons(bool canDel = true, bool canAdd = true, bool canEdit = true, bool canView = true, bool canMultiEdit = true)
        {
            var pluginName = GetPluginName();

            #region 基础按钮预处理
            if (Buttons == null)
            {
                Buttons = new List <ModuleButton>();
            }
            #endregion

            #region 默认按钮

            var serviceName      = IsInterModule ? ModuleKey : "ModuleData";
            var camelServiceName = serviceName.Substring(0, 1).ToLower() + serviceName.Substring(1);

            //默认删除按钮
            var DelButton = new ModuleButton()
            {
                ButtonKey        = "Delete",
                ButtonName       = "删除",
                ConfirmMsg       = "确认删除?",
                ButtonType       = ButtonType.ForSingleRow | ButtonType.ForSelectedRows,
                ButtonActionType = ButtonActionType.Ajax,
                ButtonActionUrl  = $"abp.services.{pluginName}.{camelServiceName}.deleteEntity",
                ButtonClass      = "layui-btn-danger",
                Sort             = 3
            };

            //默认添加按钮
            var AddButton = new ModuleButton()
            {
                ButtonKey         = "Add",
                ButtonName        = "添加",
                ButtonType        = ButtonType.ForNoneRow,
                ButtonActionType  = ButtonActionType.Form,
                ButtonActionParam = "{\"area\": [\"80%\", \"90%\"]}",
                ButtonActionUrl   = $"/{serviceName}/Add",
                ButtonClass       = "",
                Sort = 1
            };

            //默认编辑按钮
            var EditButton = new ModuleButton()
            {
                ButtonKey         = "Edit",
                ButtonName        = "编辑",
                ButtonType        = ButtonType.ForSingleRow,
                ButtonActionType  = ButtonActionType.Form,
                ButtonActionParam = "{\"area\": [\"80%\", \"90%\"]}",
                ButtonActionUrl   = $"/{serviceName}/Edit",
                ButtonClass       = "",
                Sort = 0
            };

            //默认查看按钮
            var ViewButton = new ModuleButton()
            {
                ButtonKey         = "View",
                ButtonName        = "查看",
                ButtonType        = ButtonType.ForSingleRow,
                ButtonActionType  = ButtonActionType.Form,
                ButtonActionParam = "{\"area\": [\"80%\", \"90%\"],\"btn\":null}",
                ButtonActionUrl   = $"/{serviceName}/View",
                ButtonClass       = "",
                Sort = 0
            };

            //默认批量修改按钮
            var MultiEditButton = new ModuleButton()
            {
                ButtonKey         = "MultiEdit",
                ButtonName        = "批量修改",
                ButtonType        = ButtonType.ForSelectedRows,
                ButtonActionType  = ButtonActionType.Form,
                ButtonActionParam = "{\"area\": [\"80%\", \"90%\"]}",
                ButtonActionUrl   = $"/{serviceName}/MultiEdit",
                ButtonClass       = "",
                Sort = 5
            };


            #endregion

            #region 构建按钮 通过HaveButton判断是否重复
            //设定删除按钮
            if (canDel && !HaveButton("Delete"))
            {
                DelButton.TenantId = TenantId;
                Buttons.Add(DelButton);
            }

            //设定添加按钮
            if (canAdd && !HaveButton("Add"))
            {
                AddButton.TenantId = TenantId;
                Buttons.Add(AddButton);
            }

            //设定编辑按钮
            if (canEdit && !HaveButton("Edit"))
            {
                EditButton.TenantId = TenantId;
                Buttons.Add(EditButton);
            }

            //modi20181226查看按钮取消
            //设定查看按钮
            //if (canView && !HaveButton("View"))
            //{
            //    ViewButton.TenantId = TenantId;
            //    Buttons.Add(ViewButton);
            //}

            //设定批量修改按钮
            //if (canMultiEdit && !HaveButton("MultiEdit"))
            //{
            //    MultiEditButton.TenantId = TenantId;
            //    Buttons.Add(MultiEditButton);
            //}

            #endregion
        }