| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899 |
- $(function () {
- $("#form-admin-group-edit").validate({
- rules:{
- name:{
- required:true,
- minlength: 1,
- maxlength: 60,
- remote: {
- url: pagePath+"/admin/group/isExist",
- type: "get",
- data: {
- name: function () {
- return $("#name").val();
- },
- id:$("#id").val()
- }
- }
- },
- perms:{
- required:true
- },
- 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/updateGroup",
- 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;
- }
|