Esempio n. 1
0
        public override async void Save()
        {
            try
            {
                if (string.IsNullOrWhiteSpace(GroupHeader.group.GroupCode) ||
                    string.IsNullOrWhiteSpace(GroupHeader.group.GroupName))
                {
                    await Msg.Warning("组代码和名称为必填项!");

                    return;
                }
                ;

                //把选择的功能对应的权限保存到提交的参数当中
                GroupHeader.GroupFuncs = new List <GroupFunc>();
                for (int i = 0; i < MenuModules.Count; i++)
                {
                    var m     = MenuModules[i];
                    int value = m.Modules.Where(t => t.IsChecked).Sum(t => t.Value);
                    if (value > 0)
                    {
                        GroupHeader.GroupFuncs.Add(new GroupFunc()
                        {
                            MenuCode = m.MenuCode,
                            Auth     = value
                        });
                    }
                }
                UpdateLoading(true, "正在保存...");
                var r = await service.SaveGroupAsync(GroupHeader);

                if (r == null || !r.success)
                {
                    await Msg.Error("保存数据异常!");

                    return;
                }
                await this.GetPageData(0);

                SelectPageTitle = "部门管理";
                base.Save();
            }
            catch (Exception ex)
            {
                await Msg.Error(ex.Message);

                Log.Error(ex.Message);
            }
            finally
            {
                UpdateLoading(false);
            }
        }