| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269 |
- $(function () {
- $('.skin-minimal input').iCheck({
- checkboxClass: 'icheckbox-blue',
- radioClass: 'iradio-blue',
- increaseArea: '20%'
- });
- $("#form-admin-group-add").validate({
- rules:{
- name:{
- required:true,
- minlength: 1,
- maxlength: 60,
- remote: {
- url: pagePath+"/admin/group/isExist",
- type: "get",
- data: {
- name: function () {
- return $("#name").val();
- }
- }
- }
- },
- remark:{
- minlength: 1,
- maxlength: 200
- }
- },
- messages : {
- name : {
- remote: "该组名已经存在!"
- }
- },
- onkeyup:false,
- focusCleanup:true,
- focusInvalid:false,
- success:"valid",
- submitHandler:function(form){
- var userIds=[]
- $(".add_users tr").each(function(){
- userIds.push($(this).find(".user_id").attr("id"));
- });
- $("#userIds").val(userIds);
- $(form).ajaxSubmit({
- type: 'post',
- url: pagePath+"/admin/group/saveGroup",
- dataType:"json",
- success: function(data){
- if (data.success) {
- succeedMessage(data.message);
- setTimeClose();
- }else {
- errorMessage(data.message);
- }
- }
- });
- return false; // 非常重要,如果是false,则表明是不跳转,在本页上处理,也就是ajax,如果是非false,则传统的form跳转。
- }
- });
- $("#form-admin-department-group-add").validate({
- rules:{
- name:{
- required:true,
- minlength: 1,
- maxlength: 60,
- },
- remark:{
- minlength: 1,
- maxlength: 200
- }
- },
- messages : {},
- onkeyup:false,
- focusCleanup:true,
- focusInvalid:false,
- success:"valid",
- submitHandler:function(form){
- var userIds=[]
- $(".add_users tr").each(function(){
- userIds.push($(this).find(".user_id").attr("id"));
- });
- $("#departmentIds").val(userIds.toString());
- $(form).ajaxSubmit({
- type: 'post',
- url: pagePath+"/admin/group/saveDepartmentGroup",
- dataType:"json",
- success: function(data){
- if (data.success) {
- succeedMessage(data.message);
- setTimeClose();
- }else {
- errorMessage(data.message);
- }
- }
- });
- return false; // 非常重要,如果是false,则表明是不跳转,在本页上处理,也就是ajax,如果是非false,则传统的form跳转。
- }
- });
- $("#form-admin-department-group-edit").validate({
- rules:{
- name:{
- required:true,
- minlength: 1,
- maxlength: 60,
- },
- remark:{
- minlength: 1,
- maxlength: 200
- }
- },
- messages : {},
- onkeyup:false,
- focusCleanup:true,
- focusInvalid:false,
- success:"valid",
- submitHandler:function(form){
- var userIds=[]
- $(".add_users tr").each(function(){
- userIds.push($(this).find(".user_id").attr("id"));
- });
- $("#departmentIds").val(userIds.toString());
- $(form).ajaxSubmit({
- type: 'post',
- url: pagePath+"/admin/group/editDepartmentGroup",
- dataType:"json",
- success: function(data){
- if (data.success) {
- succeedMessage(data.message);
- setTimeClose();
- }else {
- errorMessage(data.message);
- }
- }
- });
- return false; // 非常重要,如果是false,则表明是不跳转,在本页上处理,也就是ajax,如果是非false,则传统的form跳转。
- }
- });
- });
- /*选择用户*/
- function select_user(title, url, w, h) {
- layer_show(title, pagePath+url, w, h);
- }
- function addUsers(userLists){
- var userIds=[];
- $(".no_data").remove();
- var html="";
- $(".add_users tr").each(function(){
- userIds.push($(this).find(".user_id").attr("id"));
- });
- // debugger;
- $.each(userLists, function(index, obj) {
- if(!array_contain(userIds,obj.id)){
- html+="<tr class='text-c'>";
- html+="<td>"+obj.nick_name+"</td>";
- html+="<td>"+obj.user_name+"</td>";
- html+="<td>"+obj.role_names+"</td>";
- html+="<td>"+obj.department_name+"</td>";
- html+="<td class='user_id' id="+obj.id+" onclick='removeLine(this,"+obj.id+")'>删除</td>";
- html+="</tr>";
- }
- });
- $(".add_users").append(html);
- }
- function removeLine(obj) {
- $(obj).parents("tr").remove();
- }
- function array_contain(array, obj){
- for (var i = 0; i < array.length; i++){
- if (array[i] == obj)
- return true;
- }
- return false;
- }
- //选择部门select_department
- function select_department(title, url, w, h) {
- layer_show(title, pagePath+url, w, h);
- }
- function addDepartment(departmentList){
- var departmentIds=[];
- $(".no_data").remove();
- var html="";
- $(".add_users tr").each(function(){
- departmentIds.push($(this).find(".user_id").attr("id"));
- });
- //debugger;
- $.each(departmentList, function(index, obj) {
- if(!array_contain(departmentIds,obj.id)){
- html+="<tr class='text-c'>";
- html+="<td>"+obj.name+"</td>";
- html+="<td class='user_id' id="+obj.id+" onclick='removeLine(this,"+obj.id+")'>删除</td>";
- html+="</tr>";
- }
- });
- $(".add_users").append(html);
- }
|