HEX
Server: Apache/2.4.6 (CentOS) PHP/5.6.39
System: Linux izj6c6ukj0hyugxsgmuxz3z 3.10.0-514.6.2.el7.x86_64 #1 SMP Thu Feb 23 03:04:39 UTC 2017 x86_64
User: root (0)
PHP: 5.6.39
Disabled: NONE
Upload Files
File: /web/data/www.tbbprovision.com/static/manage/js/menuconfig.js
var menuconfigobj = {
    index : function(){
        //删除
        $('.del-btn').click(function(){
            var mid = $(this).attr('data-id');
            //询问框
            layer.confirm('确定删除此记录?', {
                skin:'layui-layer-molv',
                'title':'警告',
                icon:3,
                btn: ['删除','关闭'] //按钮
            }, function(){
                jQuery.ajax({
                    method:'post',
                    url:'/admin/menuConfig/menu_del/',
                    data:{mid:mid},
                    timeout: 5000,
                    dataType:'json',
                    beforeSend : function(){
                        layer.msg('数据处理中',{icon:16,time:0,shade:[0.8,'#000']});
                    },
                    success:function($d){
                        layer.msg($d.response_content, {icon: 1,time:1000},function(){
                            window.location.reload();
                        });
                    },
                    error:function(xhrData){
                        layer.msg(errorMessage(xhrData.responseText),{time:1000,icon:7});
                    }
                });
            });
        });
        //新增
        $('#add').click(function(){
            var index = layer.open({
                type: 2,
                title: ['新增后台菜单'],
                shadeClose: true,
                shade: [true,'rgba(0,0,0,.5)'],
                maxmin: true,
                shift: 2,
                scrollbar:false,
                offset: [0,'20%'],
                area: ['80%', '100%'],
                content: '/admin/menuConfig/menu_add/'
            });
        });
        //编辑
        $('.edit-btn').click(function(){
            var mid = $(this).attr('data-id');
            var index = layer.open({
                type: 2,
                title: ['编辑菜单详情'],
                shadeClose: true,
                shade: [true,'rgba(0,0,0,.5)'],
                maxmin: true,
                shift: 2,
                scrollbar:false,
                offset:[0,'20%'],
                area: ['80%', '100%'],
                content: '/admin/menuConfig/menu_edit/?mid='+mid
            });
        });
    },

    edit : function(){
        $('.i-checks').iCheck({
            checkboxClass: 'icheckbox_square-green',
            radioClass: 'iradio_square-green'
        });

        $('#defaultForm').bootstrapValidator({
            message: '这是个无效值',
            feedbackIcons: {/*input状态样式图片*/
                //valid: 'glyphicon glyphicon-ok',
                invalid: 'glyphicon glyphicon-remove',
                validating: 'glyphicon glyphicon-refresh'
            },
            fields: {/*验证:规则*/
                title: {//验证input项:验证规则
                    validators: {
                        notEmpty: { message: '菜单标题不能为空'},
                        stringLength: { min: 2, max: 15, message: '用户名长度必须在2到15之间'}
                    }
                },
                url: {
                    validators: {
                        notEmpty: { message: '链接路径不能为空' }
                    }
                },
                my_order:{
                    validators:{
                        regexp: {
                            regexp: /^[0-9]{0,3}$/,
                            message: '排序只能是0~3位数字'
                        }
                    }
                }
            }
        })
        .on('success.form.bv', function(e) {//点击提交之后
            e.preventDefault();
            var $form = $(e.target);
            var bv = $form.data('bootstrapValidator');
            $.ajax({
                type: "post",
                url: $form.attr('action'),
                dataType: 'json',
                data: $('body').find('form').serialize(),//表单数据
                beforeSend:function(){
                    layer.msg('数据处理中', {icon:16,time:0,shade: [0.8,'#000'] });
                    $('#validateBtn').button('loading');
                },
                success: function (d) {
                    layer.closeAll();
                    parent.layer.msg(d.response_content,{time:1000,icon:1},function(){
                        parent.location.reload();
                        parent.layer.closeAll();
                    });
                },
                error:function(xhrData){
                    layer.msg(errorMessage(xhrData.responseText),{time:1000,icon:7});
                    $('#validateBtn').button('reset');
                }
            });
        });
        $('#validateBtn').click(function(){
            $('#defaultForm').bootstrapValidator('validate');
        });
    }
}