| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348 |
- var managerTree = "";
- var int_value = "";
- $(document).ready(
- function() {
- var currentUser = $("input[name='loginName']").val();
- if (currentUser == 'admin')
- filterStr = "";
- managerTree = userRoleTree("userTree.do?isMultiDept=1", "userTree",
- clickEvent, onSuccess, onAppend);
- /*
- * if(managerTree != null && managerTree != ""){ var id = -init();
- * if(id < 0){ var groupid = $("#groupid").val(); clearCheck(); var
- * params = {"userId":id,"groupid":groupid};
- * sendAjaxParam(params,"queryUserRole.do","json",userCallBack); } }
- */
- });
- function userRoleTree(treeAction, treeId, clickEvent, onSuccess, onAppend) {
- var manager = "";
- $("#" + treeId).ligerTree({
- url : getProjectName() + "/" + changePath(treeAction),
- checkbox : true,
- folderCheckbox : false,
- single : true,
- childIcon : 'folder',
- idFieldName : 'id',
- parentIDFieldName : 'pid',
- openFolderEven : false,
- slide : false,
- nodeWidth : 170,
- attribute : [ 'id', 'pid', 'url', 'gtLevel' ],
- onSelect : function(node) {
- },
- onCheck : function(node) {
- clickEvent(node);
- },
- onAppend : function(parentNode, newdata) {
- if (onAppend)
- onAppend(parentNode, newdata);
- },
- onSuccess : function() {
- if (onSuccess)
- onSuccess();
- }
- });
- manager = $("#" + treeId).ligerGetTreeManager();
- return manager;
- }
- function moreUserRoleTree(treeAction, treeId, clickEvent, onSuccess, onAppend) {
- var manager = "";
- $("#" + treeId).ligerTree({
- url : PROJECT_NAME + "/" + changePath(treeAction),
- checkbox : true,
- folderCheckbox : false,
- single : false,
- childIcon : 'folder',
- idFieldName : 'id',
- parentIDFieldName : 'pid',
- openFolderEven : false,
- slide : false,
- nodeWidth : 170,
- attribute : [ 'id', 'pid', 'url', 'gtLevel' ],
- onSelect : function(node) {
- },
- onclick : function(node) {
- clickEvent(node);
- },
- onAppend : function(parentNode, newdata) {
- if (onAppend)
- onAppend(parentNode, newdata);
- },
- onSuccess : function() {
- if (onSuccess)
- onSuccess();
- }
- });
- manager = $("#" + treeId).ligerGetTreeManager();
- return manager;
- }
- function onAppend(parentNode, newdata) {
- var initid = init();
- var isDept = false;
- var selectId = -initid + "";
- isAppend(parentNode, newdata, selectId, isDept);
- }
- function isAppend(parentNode, newdata, selectId, isDept) {
- for (var i = 0; i < newdata.length; i++) {
- if (newdata[i].children != undefined) {
- if (isDept)
- appendLi(newdata[i], selectId);
- isAppend(newdata, newdata[i].children, selectId, isDept);
- } else {
- appendLi(newdata[i], selectId);
- }
- }
- }
- function appendLi(newdata, selectId) {
- var id = newdata.id;
- var selctIds = selectId.split(",");
- if (isExist(id, selctIds)) {
- newdata.ischecked = true;
- }
- }
- function clickEvent(node) {
- var id = node.data.id;
- if (id < 0) {
- // unit = changRoleList(node,'user');
- $("#selectUserId").val(id);
- var params = {
- "userId" : id,
- "type" : "1"
- };
- sendAsyncAjax(params, "queryUserRole.do", "html", userCallBack);
- }
- }
- function userCallBack(data) {
- $(".roleTr").each(function() {
- $(this).remove();
- });
- $("#roleTable tbody").append(data);
- }
- function checkgroup_unit(groupid) {
- var flag = '';
- $.ajax({
- // 请求的类型,有GET或者POST
- type : "POST",
- // 请求的url
- url : "checkMessage.do?date=" + new Date() + "&action=checkgroup_unit",
- // 向服务发送数据
- data : "groupid=" + groupid,
- // 服务器响应客户端的输出类型,text,html,xml,json
- async : false, // 同步
- dataType : "json",
- error : function(data) {
- flag = 'no';
- },
- // 服务器成功响应客户端时的回调方法
- success : function(data) {
- flag = data.unit;
- }
- });
- return flag;
- }
- function checkuser_unit(userid) {
- var flag = '';
- $.ajax({
- // 请求的类型,有GET或者POST
- type : "POST",
- // 请求的url
- url : "checkMessage.do?date=" + new Date() + "&action=checkuser_unit",
- // 向服务发送数据
- data : "userid=" + userid,
- // 服务器响应客户端的输出类型,text,html,xml,json
- async : false, // 同步
- dataType : "json",
- error : function(data) {
- flag = 'no';
- },
- // 服务器成功响应客户端时的回调方法
- success : function(data) {
- flag = data.unit;
- }
- });
- return flag;
- }
- function onSuccess() {
- managerTree.expandFirst();
- }
- function embed() {
- var e = findIframeByName("listcontent", "items");
- if (e != null) {
- clearInterval(int_value);
- var id = -init();
- if (id < 0) {
- var groupid = $("#groupid").val();
- var params = {
- "userId" : id,
- "groupid" : groupid
- };
- sendAjaxParam(params, "queryUserRole.do", "html", userCallBack);
- }
- }
- }
- //
- // function clearCheck(){
- // var items = findIframeByNames("listcontent","items");
- // $(items).each(function(){
- // $(this).attr("checked",false);
- // });
- // }
- function sumbitUserRole(action) {
- var e = findIframeByName("listcontent", "checkedItems");
- var isSuccess = true;
- var ids = $(e).val();
- // if(isSuccess&&ids==""){
- // addError("请选择角色!");
- // isSuccess = false;
- // }
- var checkIds = managerTree.getChecked();
- $("input[name='roleIds']").val(ids);
- var userIds = "";
- for (var i = 0; i < checkIds.length; i++) {
- var id = checkIds[i].data.id;
- if (id > 0)
- continue;
- userIds += "," + id;
- }
- if (isSuccess && userIds == "") {
- addError("请选择用户!");
- isSuccess = false;
- }
- if (userIds != "")
- userIds = userIds.substring(1);
- $("input[name='userIds']").val(userIds);
- var groupid = $("#groupid").val();
- var params = {
- "userIds" : userIds,
- "roleIds" : ids,
- "groupid" : groupid
- };
- if (isSuccess)
- sendAsyncAjax(params, action, "json", callback);
- }
- function callback(data) {
- displayAjaxMsg(data);
- }
- function moreSelect() {
- managerTree = $("#userTree").ligerTree({
- single : false
- });
- }
- function singleSelect() {
- managerTree = $("#userTree").ligerTree({
- single : true
- });
- // managerTree.clear();
- // $("#layout1").ligerLayout({ leftWidth: 250});
- // var height = $(".l-layout-center").height();
- // $("#accordion1").height(height-24);
- // var uid = $("#groupid").val();
- // var url = 'includelist.do?v=T_ROLE&k=groupid@2@'+uid+'@3';
- // document.getElementsByName("listcontent")[0].src = url;
- // var currentUser = $("input[name='loginName']").val();
- // if(currentUser == 'admin')filterStr="";
- // managerTree =
- // userRoleTree("userTree.do?isMultiDept=1","userTree",clickEvent,onSuccess,onAppend);
- }
- function selectRole(gxid, e) {
- var type = "2";
- if (gxid == null) {
- var selectNode = managerTree.getChecked();
- if (selectNode[0])
- gxid = selectNode[0].data.id;
- type = "3";
- }
- if (gxid == '' || gxid == null) {
- addError("请选择人员的部门/岗位!");
- return;
- }
- gxid = gxid + "";
- if (gxid.indexOf(",") == -1) {
- type = "2";
- }
- var params = {
- "gxId" : gxid,
- "type" : type
- };
- $(".roleTr").removeClass("gxSelect");
- $(e).parent().parent().addClass("gxSelect");
- sendAsyncAjax(params, "queryUserRole.do", "html", selectRoleBack);
- }
- function selectRoleBack(data) {
- dialog = $.ligerDialog.open({
- title : '编辑角色',
- content : data,
- width : 450,
- height : 250,
- isHidden : false
- });
- }
- function addRole() {
- var gxId = $("#gxId").val();
- var roleIds = "";
- $("input[name='roles']:checked").each(function() {
- roleIds += "," + $(this).val();
- });
- if (roleIds != "")
- roleIds = roleIds.substring(1);
- if (roleIds == "") {
- addError("至少选择一个角色!");
- return;
- }
- var params = {
- "gxId" : gxId,
- "roleIds" : roleIds
- };
- sendAjaxParam(params, "addUserRole.do", "json", addRoleBack);
- dialog.close();
- var params = {
- "userId" : $("#selectUserId").val(),
- "type" : "1"
- };
- sendAsyncAjax(params, "queryUserRole.do", "html", userCallBack);
- $("[name='all']").attr("checked", false);
- }
- function addRoleBack(data) {
- displayAjaxMsg(data);
- }
- function findAllgxId() {
- var gxId = "";
- $("[name='groupUserId']:checked").each(function() {
- gxId += "," + $(this).val();
- });
- if (gxId != "")
- gxId = gxId.substring(1);
- return gxId;
- }
- function checkAll(e) {
- var all = $(e).attr("checked");
- if (all)
- all = true;
- else
- all = false;
- $("[name='groupUserId']").each(function() {
- $(this).attr("checked", all);
- });
- }
|