workflow表单js中数据插入修改删除功能

workflow表单js中数据插入修改删除功能

var row   = GetObject('treegrid1').GetSelected();
if(row==null)
{
    ShowAlert('请先选择一个角色');
    return;
}
var roleid = GetObject('treegrid1').GetSelected().id;
var rolemc = GetObject('treegrid1').GetSelected().caption;
function saveRoleUserRelData(){
    var vs     = GetObject('tree1').GetNodesChecked();
    if(vs)
    {   
        var clientid = GetValue('txt_clientid');
         for(var index in vs)
         {   
             var resid = vs[index].id;
             var d     = GetDataBySQL2("select id from yzh_auth_resource where id='"+resid+"'");
             if(d && d.rows.length<=0){
                 var dd    = GetDataBySQL2("select * from sys_applicationfunction where id='"+resid+"'");
                 if(dd && dd.rows.length>0){
                     var dbFdStr = "id,pid,restype,clientid,caption,abstract,content,sid,rootid,icon";
                     var dbFdV   = "'"+resid+"'";
                     dbFdV+=",'"+dd.rows[0].pid+"'";
                     dbFdV+=",'menu'";
                     dbFdV+=",'"+clientid+"'";
                     dbFdV+=",'"+dd.rows[0].caption+"'";
                     dbFdV+=",'"+dd.rows[0].code+"'";
                     dbFdV+=",''";
                     dbFdV+=","+dd.rows[0].sid+"";
                     dbFdV+=",'root'";
                     dbFdV+=",'"+dd.rows[0].imagekey+"'";
                     DataInsert("yzh_auth_resource",dbFdStr,dbFdV,null,null,"");
                 }
             }
             else{
                 var dd    = GetDataBySQL2("select * from sys_applicationfunction where id='"+resid+"'");
                 if(dd && dd.rows.length>0){
                     var dbFdV   = "id='"+resid+"'";
                     dbFdV+=",pid='"+dd.rows[0].pid+"'";
                     dbFdV+=",restype='menu'";
                     dbFdV+=",clientid='"+clientid+"'";
                     dbFdV+=",caption='"+dd.rows[0].caption+"'";
                     dbFdV+=",abstract='"+dd.rows[0].code+"'";
                     dbFdV+=",content=''";
                     dbFdV+=",sid="+dd.rows[0].sid+"";
                     dbFdV+=",rootid='root'";
                     dbFdV+=",icon='"+dd.rows[0].imagekey+"'";
                     DataUpdate("yzh_auth_resource",dbFdV,"id='"+resid+"'",null,null,"");
                 }
             }
             //保存role 和resource的关系记录
             var dbfieldStr = "id,roleid,resourceid,content,remark";
             var dbfieldV   = "'"+GetNewGuid2()+"'";
             dbfieldV+=",'"+roleid+"'";
             dbfieldV+=",'"+resid+"'";
             dbfieldV+=",'{\"Create\":true, \"Modify\":true, \"Delete\":true, \"Approve\":true, \"Disapprove\":true, \"Browse\":true, \"Forbid\":false}'";
             dbfieldV+=",'角色:"+rolemc+"<=被授于菜单::"+vs[index].text+"'";
             DataInsert("yzh_auth_roleresource",dbfieldStr,dbfieldV,null,null,"");
         }
         ShowAlert('保存完毕');
    }
};
var tNoWhere="roleid='"+roleid+"' and resourceid in(select id from yzh_auth_resource where restype='menu')"
DataDelete("yzh_auth_roleresource",tNoWhere,saveRoleUserRelData,null);

已标记关键词 清除标记
©️2020 CSDN 皮肤主题: 大白 设计师:CSDN官方博客 返回首页