colly_wyx
2018-04-28 7f02c34d386f16edb9cbf71976651d6f9495c9f7
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
var validator_config = {
    message: '输入框内容不能为空',
    feedbackIcons: {
        valid: 'glyphicon glyphicon-ok',
        invalid: 'glyphicon glyphicon-remove',
        validating: 'glyphicon glyphicon-refresh'
    },
    fields:{
        module:{
            validators:{
                callback: {
                    message: '模块名不能为空',
                    callback: function(value, validator){
                        var parent = $('#parent').val();
                        if(parent == 0){
                            return true;
                        }
                        else{
                            if(value != ""){
                                return true;
                            }
                            else{
                                return false;
                            }
                        }
                    }
                },
            }
        },
        controller: {
            validators: {
                callback: {
                    message: '控制器名不能为空',
                    callback: function(value, validator){
                        var parent = $('#parent').val();
                        if(parent == 0){
                            return true;
                        }
                        else{
                            if(value != ""){
                                return true;
                            }
                            else{
                                return false;
                            }
                        }
                    }
                }
            }            
        },
        action: {
            validators: {
                callback: {
                    message: '动作名称不能为空',
                    callback:function(value, validator){
                        var parent = $('#parent').val();
                        if(parent == 0){
                            return true;
                        }
                        else{
                            if(value != ""){
                                return true;
                            }
                            else{
                                return false;
                            }
                        }
                    }
                }
            }
        },
        name: {
            validators: {
                notEmpty:{
                    message: '栏目名称不能为空',
                }
            }
        }
 
    }
 
 
}
 
$('#validateform').bootstrapValidator(validator_config).on('success.form.bv', function(e) {
        e.preventDefault();
 
        $("#dosubmit").attr("disabled","disabled");
        $.scojs_message('请稍候...', $.scojs_message.TYPE_WAIT);
        $.ajax({
            type: "POST",
            url: SITE_URL+"/module/manager/edit/id/"+ID,
            data:  $("#validateform").serialize(),
            success:function(response){
                var dataObj=jQuery.parseJSON(response);
                if(dataObj.code == 200)
                {
                    $.scojs_message('操作成功,3秒后将返回列表页...', $.scojs_message.TYPE_OK);
                    setTimeout(function(){window.location.href = SITE_URL+'/module/manager/index';}, 1800);
                }else
                {
                    $.scojs_message(dataObj.content, $.scojs_message.TYPE_ERROR);
                    $("#dosubmit").removeAttr("disabled");
                }
            },
            error: function (request, status, error) {
                $.scojs_message(request.responseText, $.scojs_message.TYPE_ERROR);
                $("#dosubmit").removeAttr("disabled");
            }
        });
 
    }).on('error.form.bv',function(e){ $.scojs_message('登录中遇到错误,请按照提示修改', $.scojs_message.TYPE_ERROR);$("#dosubmit").removeAttr("disabled");});