text: /**
   * Admui-iframe v2.0.0 (http://www.admui.com/)
   * Copyright 2015-2018 Admui Team
   * Licensed under the Admui License 1.1 (http://www.admui.com/about/license)
   */
  !function(T,v,w){"use strict";v.App.extend({run:function(){var r,a=w.configs.ctx,t=w("#roleMemberTable"),o=w("#roleModal"),n=w("#roleGroupModal"),e=w("#roleForm"),s=w("#groupForm"),i=null,d=null,c={type:"add"},l={type:"add"},u=0,p=null,f=null,h=null,m=function(e,r){return w.each(e,function(e,t){!function r(o,e){w.each(e,function(e,t){t.li_attr.nodeId===o.id&&(t.state={selected:!0}),t.children&&r(o,t.children)})}(t,r)}),r},y=function(e){var t,r,o=w("#selectedMember"),n=!1;if(e.personLists)r=template("selectedMemberTpl",e),o.html(r);else{if(o.find("a").each(function(){w(this).attr("id")===e.li_attr.nodeId&&(n=!0)}),n)return;t={personLists:[{id:e.li_attr.nodeId,name:e.text}]},r=template("selectedMemberTpl",t),o.append(r)}},g=function(e,t,r){if("select_node"===r){if("U"!==e.type)return;y(e),"role"===t?w("#posTreeView").find('[nodeid="'+e.li_attr.nodeId+'"]').each(function(){var e=w(this);h.get_node(e)&&!h.is_selected(e)&&h.select_node(e)}):"dep"===t&&w("#roleTreeView").find('[nodeid="'+e.li_attr.nodeId+'"]').each(function(){var e=w(this);f.get_node(e)&&!f.is_selected(e)&&f.select_node(e)})}else"deselect_node"===r&&("role"===t?w("#posTreeView").find('[nodeid="'+e.li_attr.nodeId+'"]').each(function(){var e=w(this);h.get_node(e)&&h.is_selected(e)&&h.deselect_node(e)}):"dep"===t&&w("#roleTreeView").find('[nodeid="'+e.li_attr.nodeId+'"]').each(function(){var e=w(this);f.get_node(e)&&f.is_selected(e)&&f.deselect_node(e)}),w("#selectedMember").children("#"+e.li_attr.nodeId).remove())},_=function(e,n,a){0<e.children.length?w.each(e.children,function(e,t){var r,o;r=t,"dep"===n?o=h.get_node(r):"role"===n&&(o=f.get_node(r)),0===o.children.length?g(o,n,a):_(o,n,a)}):0===e.children.length&&g(e,n,a)},b=function(e){w.ajax({url:a+"/public/data/system/role/users.json",type:"GET",data:{roleId:e},dataType:"JSON",success:function(e){var o,t=[];e.success?(t=e.data,y({personLists:t})):toastr.error(e.msg),o=t,w("#posTreeView").jstree("destroy").jstree({types:{U:{icon:"fa-child"},C:{icon:"fa-building-o"}},checkbox:{keep_selected_style:!1},search:{show_only_matches:!0,show_only_matches_children:!0},plugins:["types","wholerow","search","checkbox"],core:{data:function(e,r){w.ajax({url:a+"/public/data/system/org/trees_type.json",data:{structureType:"OU"},type:"GET",dataType:"JSON",success:function(e){var t;e.success?(t=m(o,e.data),r.call(this,t)):toastr.error(e.msg)},error:function(e){toastr.error(e)}})}}}).on("ready.jstree",function(){(h=w(this).jstree(!0)).open_all()}).on("changed.jstree",function(e,t){"select_node"!==t.action&&"deselect_node"!==t.action||_(t.node,"dep",t.action)}),w("#roleTreeView").jstree("destroy").jstree({types:{default:{icon:"fa-folder-o"},R:{icon:"fa-file-o"},U:{icon:"fa-child"}},checkbox:{keep_selected_style:!1},search:{show_only_matches:!0,show_only_matches_children:!0},plugins:["types","wholerow","search","checkbox"],core:{data:function(e,r){w.ajax({url:a+"/public/data/system/role/trees_type.json",data:{structureType:"RU"},type:"GET",traditional:!0,dataType:"JSON",success:function(e){var t;e.success?(t=m(o,e.data),r.call(this,t)):toastr.error(e.msg)},error:function(e){toastr.error(e)}})}}}).on("ready.jstree",function(){(f=w(this).jstree(!0)).open_all()}).on("changed.jstree",function(e,t){"select_node"!==t.action&&"deselect_node"!==t.action||_(t.node,"role",t.action)})},error:function(e){toastr.error(e)}})};w("#roleTree").jstree({plugins:["types","search","wholerow"],types:{default:{icon:"fa-file-o"},D:{icon:"fa-folder-o"},G:{icon:"fa-folder-o"}},search:{show_only_matches:!0,show_only_matches_children:!0},core:{check_callback:!0,data:function(e,r){w.ajax({url:a+"/public/data/system/role/trees.json",type:"GET",dataType:"JSON",success:function(e){var t;e.success?(t=e.data,w.each(t,function(e,t){if("D"===t.type&&0<t.children.length)return!(t.children[0].state={selected:!0})}),r.call(this,t)):toastr.error(e.msg)},error:function(e){toastr.error(e)}})}}}).on("ready.jstree",function(){var e=w(this);(p=e.jstree(!0)).open_all(),t.asSelectable(w.concatCpt("selectable")),r=t.DataTable(w.concatCpt("dataTable",{dom:'<"row"<"col-lg-12"tr>><"row table-toolbar"<"col-sm-7"l><"col-sm-5"p>>',autoWidth:!0,processing:!0,serverSide:!0,searching:!0,pagingType:"simple_numbers",rowId:"id",columns:[{render:function(){return'<div class="checkbox-custom checkbox-primary user-select-item"><input type="checkbox" class="user-checkbox selectable-item"><label></label></div>'}},{data:"name"},{data:"sexName"},{data:"orgNames",render:function(e){return'<span class="inline-block text-truncate w-200">'+e+"</span>"}},{data:"mobile"},{data:"userName"},{data:"email"}],rowCallback:function(e,t){1===t.status&&w(e).addClass("table-disabled").find("input:checkbox").prop("disabled",!0)},ajax:function(e,r){var o=p.get_selected(!0)[0],t=o.id,n={pageIndex:e.start/e.length+1,pageSize:e.length,data:{roleId:t}};w.ajax({url:a+"/public/data/system/user/users.json",type:"GET",dataType:"JSON",data:n,success:function(e){var t={recordsTotal:e.total,recordsFiltered:e.total,data:e.pageList};u=e.total,r(t),w("#depMsg").find(">span").text(o.text+"("+e.total+")")},error:function(e){toastr.error(e)}})}}))}).on("select_node.jstree",function(e,t){"#"!==t.node.parent&&r.ajax.reload()}),w("#roleTreeSearch").on("keyup",function(){p.search(w(this).val())}),w("#operateDropdown").on("shown.bs.dropdown",function(){var e=p.get_selected(!0)[0],t=w(this).find(".dropdown-menu"),r=e.parent;"#"!==r&&"1001"!==r||(t.find(">.alter-role").attr("hidden",!0),t.find(">.delete-role").attr("hidden",!0)),"#"===r&&"1001"!==e.id||(t.find(">.alter-group").attr("hidden",!0),t.find(">.delete-group").attr("hidden",!0))}).on("hidden.bs.dropdown",function(){w(this).find(".dropdown-menu > .dropdown-item").attr("hidden",!1)}),w(".add-role").on("click",function(){c.type="add"}),w(".alter-role").on("click",function(){o.modal("show"),c={type:"edit",data:p.get_selected(!0)[0]}}),o.on("shown.bs.modal",function(){var e=w(this),t=p.get_selected(!0)[0],r=t,o="",n=w("#roleGroup");"edit"===c.type?e.find(".modal-title").text("编辑角色").end().find('[name="roleName"]').val(c.data.text).end().find('[name="id"]').val(c.data.id).end().find('[name="roleGroupId"]').attr("disabled",!0):e.find(".modal-title").text("添加角色").end().find('[name="roleGroupId"]').attr("disabled",!1),n.select2(w.concatCpt("select2",{minimumResultsForSearch:"Infinity",ajax:{url:a+"/rolegroup/dropdownlist",processResults:function(e){return w.each(e.data,function(e,t){"1001"===t.id&&(t.disabled=!0)}),{results:e.data}}}})),"#"!==t.parent&&(r=p.get_node(t.parent)),"edit"===c.type&&(n.append(new Option(r.text,r.id,!0,!0)).trigger("select2:select"),o=c.data.id),w.ajax({url:a+"/public/data/system/permission/checkboxlist.json",type:"GET",data:{roleId:o},dataType:"JSON",success:function(e){e.success?w("#permissionLists").html(template("permissionItemTpl",{permissionLists:e.data})):toastr.error(e.msg)},error:function(e){toastr.error(e)}})}).on("hide.bs.modal",function(){w(this).find("input").val(""),w("#roleGroup").val(null).trigger("change"),d.resetForm()}),d=e.validate({rules:{roleName:{required:!0},roleGroupId:{required:!0}},submitHandler:function(e){var t=w(e).serializeObject();t.permissionIds=[],w(e).find('[name="permissionIds"]:checked').each(function(){t.permissionIds.push(w(this).val())}),w.ajax({url:a+"/role",type:"POST",contentType:"application/json",data:JSON.stringify(t),dataType:"JSON",success:function(e){var t;e.success?(t=e.data,"edit"===c.type?p.rename_node(p.get_selected(),t.roleName):p.create_node(t.roleGroupId,{id:t.id,text:t.roleName}),toastr.success(e.msg),o.modal("hide")):toastr.error(e.msg)},error:function(){toastr.error("服务器异常，请配合后端程序使用")}})}}),w(".delete-role").on("click",function(){var r=p.get_selected(!0)[0];0<u?toastr.warning("该角色下有成员，不能被删除！"):v.top.layer.confirm("您确定要删除选中角色吗？",function(t){var e=r.id;w.ajax({url:a+"/role/"+e,type:"DELETE",traditional:!0,dataType:"JSON",success:function(e){e.success?(p.delete_node(r.id),p.select_node(p.get_json("1001").children[0]),toastr.success(e.msg),v.top.layer.close(t)):toastr.error(e.msg)},error:function(){toastr.error("服务器异常，请配合后端程序使用")}})})}),w(".add-group").on("click",function(){l.type="add"}),w(".alter-group").on("click",function(){l={type:"edit",data:p.get_selected(!0)[0]},n.modal("show")}),n.on("show.bs.modal",function(){var e=w(this);"edit"===l.type?e.find(".modal-title").text("编辑分组").end().find('[name="id"]').val(l.data.id).end().find('[name="groupName"]').val(l.data.text):e.find(".modal-title").text("添加分组")}).on("hide.bs.modal",function(){w(this).find("input").val(""),i.resetForm()}),i=s.validate({rules:{groupName:{required:!0}},submitHandler:function(e){w.ajax({url:a+"/rolegroup",type:"POST",data:JSON.stringify(w(e).serializeObject()),dataType:"JSON",contentType:"application/json",success:function(e){var t;e.success?(t=e.data,"edit"===l.type?p.rename_node(p.get_selected(),t.groupName):p.create_node("#",{id:t.id,text:t.groupName}),toastr.success(e.msg),n.modal("hide")):toastr.error(e.msg)},error:function(){toastr.error("服务器异常，请配合后端程序使用")}})}}),w(".delete-group").on("click",function(){var r=p.get_selected(!0)[0];0<r.children.length?toastr.warning("该分组下有角色，不能被删除！"):v.top.layer.confirm("您确定要删除选中分组吗？",function(t){w.ajax({url:a+"/rolegroup/"+r.id,type:"DELETE",dataType:"JSON",contentType:"application/json",success:function(e){e.success?(p.delete_node(r.id),toastr.success(e.msg),v.top.layer.close(t)):toastr.error(e.msg)},error:function(){toastr.error("服务器异常，请配合后端程序使用")}})})}),w(T).on("click",".add-member",function(){"#"!==p.get_selected(!0)[0].parent?w("#inviteModal").modal("show"):toastr.error("分组下不能添加成员，请选择分组下的角色进行添加！")}),w("#inviteModal").on("show.bs.modal",function(){b(p.get_selected()[0])}),w("#userTreeType").on("click","button",function(){var e=w(this);e.addClass("active").siblings().removeClass("active"),w("#treeTypeView").find('[data-target="'+e.data("type")+'"]').removeAttr("hidden").siblings().attr("hidden",!0)}),w("#userTreeSearch").on("keyup",function(){var e=w(this);("pos"===w("#userTreeType>button.active").data("type")?w("#posTreeView"):w("#roleTreeView")).jstree(!0).search(e.val())}),w("#selectedMember").on("click",".del-selected",function(){var e=w(this),t=e.parent().attr("id");e.parent().remove(),w("#posTreeView").find('[nodeid="'+t+'"]').each(function(){h.deselect_node(w(this))}),w("#roleTreeView").find('[nodeid="'+t+'"]').each(function(){f.deselect_node(w(this))})}),w("#saveMember").on("click",function(){var e=[],t=p.get_selected()[0];w("#selectedMember").children("a").each(function(){e.push(w(this).attr("id"))}),w.ajax({url:a+"/role/assignuser",type:"POST",dataType:"JSON",data:JSON.stringify({masterId:t,itemIds:e}),contentType:"application/json",success:function(e){e.success?(toastr.success(e.msg),w("#inviteModal").modal("hide")):toastr.error(e.msg)},error:function(){toastr.error("服务器异常，请配合后端程序使用")}})}),w(T).on("click",".delete-member",function(){var r=t.find("tbody > tr"),e=[],o=p.get_selected()[0];r.each(function(){w(this).find(":checkbox").is(":checked")&&e.push(w(this).attr("id"))}),0!==e.length?v.top.layer.confirm("您确定要移除所选成员吗？",function(t){w.ajax({url:a+"/role/userrole/"+o,type:"DELETE",data:JSON.stringify(e),dataType:"JSON",contentType:"application/json",success:function(e){e.success?(r.each(function(){w(this).find(":checkbox").is(":checked")&&w(this).remove()}),toastr.success(e.msg),v.top.layer.close(t)):toastr.error(e.msg)},error:function(){toastr.error("服务器异常，请配合后端程序使用")}})}):toastr.error("请选择需要移除的成员")})}}),w(function(){v.App.run()})}(document,window,jQuery);