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/statis.js
/**
 *  author      : liaoyaping
 *  createTime  : 2017/5/25 16:42
 *  description :
 */
var statisobj = {
    list : function(){
        $('.del-btn').click(function(){
            var that = $(this);
            layer.confirm('确认删除此记录',{
                title: '警告',
                icon: 3,
                btn: ['删除','取消']
            },function(){
                jQuery.ajax({
                    url : "/admin/statis/del/?sid="+that.attr('data-id'),
                    method: 'get',
                    dataType: 'json',
                    timeout: 5000,
                    beforeSend : function(){layer.msg('数据处理中',{time:0,icon:16,shade:[0.8,'#000']});},
                    success: function(xhrData){
                        layer.msg(xhrData.response_content,{time:1000,icon:1},function(){
                            that.parents('tr').remove();
                        });
                    },
                    error: function(xhrData){
                        layer.msg(errorMessage(xhrData.responseText),{time:1000,icon:7});
                    },
                    complete: function(){}
                });
            },function(){
                layer.msg('操作取消',{time:500});
            });
        });

        //新增
        $('#add').click(function(){
            var index = layer.open({
                type: 2,
                title: ['新增统计代码'],
                shadeClose: true,
                shade: [true,'rgba(0,0,0,.5)'],
                maxmin: true,
                shift:2,
                offset:['0','20%'],
                area: ['80%', '100%'],
                content: '/admin/statis/add/'
            });
        });
        //编辑
        $('.edit-btn').click(function(){
            var sid = $(this).attr('data-id');
            var index = layer.open({
                type: 2,
                title: ['编辑统计代码'],
                shadeClose: true,
                shift:2,
                shade: [true,'rgba(0,0,0,.5)'],
                maxmin: true,
                offset:['0','20%'],
                area: ['80%', '100%'],
                content: '/admin/statis/edit/?sid='+sid
            });
        });
    },
    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: {/*验证:规则*/
                name: {//验证input项:验证规则
                    validators: {
                        notEmpty: { message: '名称不能为空'},
                        stringLength: { min: 2, max: 30, message: '名称长度必须在2到30之间'}
                    }
                }
            }
        })
            .on('success.form.bv', function(e) {//点击提交之后
                e.preventDefault();
                var $form = $(e.target);
                var bv = $form.data('bootstrapValidator');
                $.ajax({
                    type: "post",
                    url: $('#defaultForm').attr('action'),
                    dataType: 'json',
                    timeout:10000,
                    data: $('body').find('form').serialize(),//表单数据
                    beforeSend:function(){
                        $('#validateBtn').button('loading');
                        layer.msg('数据处理中',{icon:16,time:0,shade:[0.8,'#000']});
                    },
                    success: function (d) {
                        parent.location.reload();
                        parent.layer.closeAll('iframe');//关闭弹窗
                    },
                    error:function(xhrData){
                        layer.msg(errorMessage(xhrData.responseText),{time:2000,icon:7});
                        $('#validateBtn').button('reset');
                    }
                });
            });
        $('#validateBtn').click(function(){
            $('#defaultForm').bootstrapValidator('validate');
        });
    }
}