/**
* 用户角色分配管理
*
*/
$.namespace("user.userrole");
user.userrole.allData = null;
// 页面初始化展示
user.userrole.init = function() {
var str = "";
var jsonallData = $.parseJSON(user.userrole.allData);
if (jsonallData) {
for ( var i = 0; i < jsonallData.length; i++) {
var all = jsonallData[i];
str += "
";
str += "" + all.roleName + " ";
/*一个问题 怎么加是否同步判断,数据库没有这个字*/
if (all.sel&&all.sfcytb=="1"&&all.sftb) {
str += " 已同步 ";
} else if(all.sel&&all.sfcytb=="1"&&!all.sftb){
str += " ";
}else if(all.sel&&all.sfcytb!="1"){
str += " ";
}else if(!all.sel&&all.sfcytb=="1"&&all.sftb){
str += " 已同步 ";
}else if(!all.sel&&all.sfcytb=="1"&&!all.sftb){
str += " ";
}else if(!all.sel&&all.sfcytb!="1"){
str += " ";
}
str += " ";
}
$("#divcontent").empty();
$("#divcontent").append(str);
}
// 返回按钮功能实现
user.userrole.back = function() {
location.href = $.app + "/user/querylist.html";
};
// 全选按钮功能实现
user.userrole.all = function() {
$(".roleClass").each(function() {
$(this).prop("checked", true);
});
$(".sfClass").each(function() {
$(this).prop("checked", true);
});
};
// 全不选按钮功能实现
user.userrole.notall = function() {
$(".roleClass").each(function() {
$(this).prop("checked", false);
});
$(".sfClass").each(function() {
$(this).prop("checked", false);
});
};
};
//保存分配给该用户的角色的功能实现
user.userrole.save = function() {
var roleids = new Array();
var rolecodes=new Array();
$(".roleClass").each(function() {
if ($(this).prop("checked")) {
roleids.push($(this).val());
rolecodes.push($('#a'+$(this)[0].id).val()||'');
}
});
var sfids = new Array();
$(".sfClass").each(function() {
if ($(this).prop("checked")) {
sfids.push($(this).val());
}
});
/*
console.log({
userId : $("#userId").val(),
roles : roleids.join(","),
sfids : sfids.join(","),
rolecodes:rolecodes.join(",")
})
*/
$.ajax({
type : 'POST',
url : $.app + "/user/saveuserrole.html",
dataType:"json",
data : {
userId : $("#userId").val(),
roles : roleids.join(","),
sfids : sfids.join(","),
rolecodes:rolecodes.join(",")
},
success : function(data) {
if (data.success) {
$.alert({
title : '提示',
content : data.message,
confirm : function() {
location.href = $.app + "/user/querylist.html";
}
});
} else {
$.alert({
title : '提示',
content : data.message,
confirm : function() {
}
});
}
}
});
};
user.userrole.liandong = function(data) {
if ($('#' + data + '').is(":checked")) {
$('#a' + data + '').prop("checked", true);
} else {
$('#a' + data + '').prop("checked", false);
}
}
user.userrole.sfliandong=function(data) {
if ($('#a' + data + '').is(":checked")) {
$('#' + data + '').prop("checked", true);
}
}