• 氚云前后代码小栗子,新增页面获取当前登录人管理的下级人员


    前端代码
    
     // 加载事件
        OnLoad: function() {
            if( !$.SmartForm.ResponseContext.IsCreateMode ) {
                return;
            }
            var that = this;
            var par = { a: 1 };
            var success = function( res ) {
                if( res.Successful == true ) {
                    var rd = res.ReturnData;
                    if( rd == null || rd.length == 0 ) {
                        $.IShowWarn( "没找到数据!" );
                        return;
                    }
                    var mx = that.D101303Fe4bca544e60546798cedc16678f7c8f5;//获取子表控件
                    mx.ClearRows(); //清空子表所有数据
                    var empList = rd.empList;
                    if( empList == null || empList.length == 0 ) {
                        $.IShowWarn( "没找到数据!" );
                        return;
                    }
                    for( var i = 0;i < empList.length;i++ ) {
                        var subObjectId = $.IGuid();
                        var subObject = empList[ i ].ValueTable;
                        mx.AddRow( subObjectId, { "D101303Fe4bca544e60546798cedc16678f7c8f5.F0000003": subObject[ "F0000003" ] });// 添加子表行
                    }
                }
            }
            var error = function( err ) {
                $.IShowError( "错误", JSON.stringify( err ) );
            }
            $.SmartForm.PostForm( "GetChildEmp", par, success, error, false );
        },
    View Code

     后端代码

    protected override void OnSubmit(string actionName, H3.SmartForm.SmartFormPostValue postValue, H3.SmartForm.SubmitSmartFormResponse response)
        {
            if(actionName == "GetChildEmp")
            {
                if(this.Request.BizObject.Status == H3.DataModel.BizObjectStatus.Draft)
                {
                    response.ReturnData = new Dictionary<string, object>();
                    
                    string userid = this.Request.UserContext.UserId;
                    H3.Organization.User user = (H3.Organization.User) this.Engine.Organization.GetUnit(userid);
                    string[] pIds = user.ParentIds;
                    string[] userIds = this.Request.Engine.Organization.GetChildren(pIds[0], H3.Organization.UnitType.User, true, H3.Organization.State.Active);
                    if(userIds == null || userIds.Length == 0)
                    {
                        response.Errors.Add("未找到当前子级人员");
                        return;
                    }
                   List < H3.Data.Serialization.VirtualObject > virtualList = new List<H3.Data.Serialization.VirtualObject>();
                    foreach(string id in userIds)
                    {
                        H3.Data.Serialization.VirtualObject vobject = new H3.Data.Serialization.VirtualObject();
                        //string name = (string) this.Engine.Organization.GetName(id, H3.Organization.NameType.Name);
                        vobject.ValueTable["F0000003"] = id;
                        virtualList.Add(vobject);
                    }
                    response.ReturnData.Add("empList", virtualList);
                }
            }
            else
            {
    
            }
            base.OnSubmit(actionName, postValue, response);
        }
    View Code
  • 相关阅读:
    Win7 vs2017 WDK 1803 1809 驱动开发 出错 KMDF
    http 请求 post get 长度限制
    IO模式和IO多路复用(阻塞IO、非阻塞IO、同步IO、异步IO等概念)
    select/poll 和 epoll 比较
    centos查看端口被哪个应用端口占用命令
    mysql索引知识简单记录
    Spring钩子方法和钩子接口的使用详解
    mysql使用自增Id为什么存储比较快
    分布式Id教程
    如何配置JVM系统属性及获取方式System.getProperty("pname")
  • 原文地址:https://www.cnblogs.com/miaololi/p/15242119.html
Copyright © 2020-2023  润新知