动态表单点击按钮弹出列表【并控制权限】原创
金蝶云社区-云强_东
云强_东
17人赞赏了该文章 250次浏览 未经作者许可,禁止转载编辑于2024年08月17日 11:05:35

【1.以下代码先判断当前用户是不是全功能用户】

【之前遇到了困难,因为权限问题搞了好久,通过不停的摸索学习终于搞订了,以下代码就是我的学习,大家可以参考。】


//获取当前登录人ID

long userId = this.Context.UserId;


//根据当前登录人ID获取角色,判断是不是全功能角色

Boolean allRole = false;

string roleSql = $@"

SELECT distinct T_SEC_USER.fuserid 用户id,

T_SEC_USER.fname 用户名称,

T_ORG_ORGANIZATIONS.fnumber 组织编码,

T_ORG_ORGANIZATIONS_L.fname 组织名称

,t_SEC_role.FNUMBER 角色编码,

t_SEC_role_L.fname 角色名称

FROM T_SEC_USER

INNER JOIN T_SEC_USERORG ON T_SEC_USERORG.FUSERID= T_SEC_USER.FUSERID

LEFT JOIN T_SEC_USERROLEMAP ON T_SEC_USERROLEMAP.FENTITYID = T_SEC_USERORG.FENTITYID

LEFT JOIN T_ORG_ORGANIZATIONS ON T_ORG_ORGANIZATIONS.FORGID=T_SEC_USERORG.FORGID

left join T_ORG_ORGANIZATIONS_L on T_ORG_ORGANIZATIONS.forgid=T_ORG_ORGANIZATIONS_L.forgid and T_ORG_ORGANIZATIONS_L.FLOCALEID=2052

left join t_SEC_role on t_SEC_role.FROLEID=T_SEC_USERROLEMAP.FROLEID

left join t_SEC_role_L on t_SEC_role.FROLEID=t_SEC_role_L.FROLEID

where T_ORG_ORGANIZATIONS.FNUMBER=100 and T_SEC_USER.FUSERID={userId}";

DynamicObjectCollection result2 = DBServiceHelper.ExecuteDynamicObject(this.Context, roleSql);

if (result2 != null && result2.Count > 0)

{

    foreach (DynamicObject item in result2)

    {

        if (item["角色编码"] != null)

        {

            if (item["角色编码"].ToString() == "BD11_SYS" || item["角色编码"].ToString() == "XD003")

            {

                allRole = true;//是全功能角色,可以查看全部客户

                break;

            }

        }

    }

//列表弹框

 ListSelBillShowParameter billShowParameter = new ListSelBillShowParameter();

 billShowParameter.UseOrgId = orgId;

 billShowParameter.FormId = formId;

 billShowParameter.PermissionItemId = "6e44119a58cb4a8e86f6c385e14a17ad";

 billShowParameter.IsShowApproved = true;

 billShowParameter.IsShowFilter = false;

 billShowParameter.MultiSelect = true;

 billShowParameter.ParentPageId = this.View.PageId;

 billShowParameter.IsLookUp = true;

 billShowParameter.ListFilterParameter.Filter = " FDocumentStatus = 'C' AND FCancelStatus = 'A' ";

 if (sBaseDataIsolationSql.Equals("")&& allRole)

 {


 }

 else if (sBaseDataIsolationSql.Equals("") && !allRole)

 {

     throw new Exception("当前用户没有销售订单查看权限!");

 }

}


////////////////////////////////////////////////////////////////////////这里是根据传的客户,判断当前用户对哪些客户有权限

 string formId2 = "BD_Customer";//仓库单据ID


 Kingdee.BOS.Core.Metadata.FormMetadata stockFormMetaData = MetaDataServiceHelper.GetFormMetaData(this.View.Context, formId2);


 DataRuleFilterParamenter filterParameter = new DataRuleFilterParamenter(formId2)


 {


     PermissionItemId = Kingdee.BOS.Core.Permission.PermissionConst.View,


     SubSystemId = stockFormMetaData.BusinessInfo.GetForm().SubsysId,


     BusinessInfo = stockFormMetaData.BusinessInfo


 };




 DataRuleFilterObject filterObject = PermissionServiceHelper.LoadDataRuleFilter(this.View.Context, filterParameter);//获取当前用户可以访问哪些仓库(过滤条件)


 Kingdee.BOS.Core.SqlBuilder.QueryBuilderParemeter queryParameter = new Kingdee.BOS.Core.SqlBuilder.QueryBuilderParemeter


 {


     FormId = formId2,


     BusinessInfo = stockFormMetaData.BusinessInfo,


     PermissionItemId = Kingdee.BOS.Core.Permission.PermissionConst.View,


     FilterClauseWihtKey = filterObject.FilterString,//过滤条件


 };

 Kingdee.BOS.Orm.DataEntity.DynamicObject[] stockObjects = BusinessDataServiceHelper.Load(this.View.Context, stockFormMetaData.BusinessInfo.GetDynamicObjectType(), queryParameter);

 string wheres = "FCustId=0";

 for (int i = 0; i < stockObjects.Length; i++)

 {

     wheres += $@" or FCustId={stockObjects[i]["Id"]}";

 }


 const string sReportId = "SAL_SaleOrder";

 //var listBaseDataTempTable = filter.BaseDataTempTable;


 IPermissionService perService = Kingdee.BOS.Contracts.ServiceFactory.GetPermissionService(Context);

 var listBaseDataTempTable = perService.GetBaseDataTempTable(Context, sReportId, new List<long>() { Context.CurrentOrganizationInfo.ID });


 IBDCommonService service = Kingdee.K3.BD.Contracts.ServiceFactory.GetService<IBDCommonService>(this.Context);


 string sBaseDataIsolationSql = service.GetBaseDataIsolationSql(Context, "T_BAS_RptDataRuleConfig", sReportId, listBaseDataTempTable);


图标赞 17
17人点赞
还没有人点赞,快来当第一个点赞的人吧!
图标打赏
0人打赏
还没有人打赏,快来当第一个打赏的人吧!