/**
 * 系统设置
 */
var locked = false;
var SysConfig = {
    sysConfigInfoData: {},
    validateFields: {
    }
    /*
     'register[jjrc_4341]': {validators: {notEmpty: {message: '晋江市现代产业体系人才-4341现代产业体系企业开放注册时间不能为空'}}},
     'register[jjrc_no4341]': {validators: {notEmpty: {message: '晋江市现代产业体系人才-非4341现代产业体系企业开放注册时间不能为空'}}},
     'register[jcrc]': {validators: {notEmpty: {message: '集成电路优秀人才开放注册时间不能为空'}}},
     'register[mbfqy]': {validators: {notEmpty: {message: '民办非企业开放注册时间不能为空'}}},
     'register[sy_nomedia]': {validators: {notEmpty: {message: '事业单位-非媒体单位开放注册时间不能为空'}}},
     'register[sy_media]': {validators: {notEmpty: {message: '事业单位-媒体单位开放注册时间不能为空'}}}
     */
};

/**
 * 验证数据
 */
SysConfig.validate = function () {
    $('#configForm').data("bootstrapValidator").resetForm();
    $('#configForm').bootstrapValidator('validate');
    return $("#configForm").data('bootstrapValidator').isValid();
}

/**
 * 保存
 */
SysConfig.save = function () {
    if (!SysConfig.validate()) {
        return;
    }
    if (locked) {
        return;
    }
    locked = true;
    $("#configForm")[0].submit();
}

//回调
SysConfig.callback = function (data) {
    locked = false;
    if (data.code == 200) {
        Feng.success(data.msg);
    } else {
        Feng.error(data.msg);
    }
}

$(function () {
    $('#configForm').bootstrapValidator({
        feedbackIcons: {
            valid: 'glyphicon glyphicon-ok',
            invalid: 'glyphicon glyphicon-remove',
            validating: 'glyphicon glyphicon-refresh'
        },
        container: 'tooltip',
        group: '.rowGroup',
        fields: SysConfig.validateFields,
        live: 'enabled',
        message: '该字段不能为空'
    }).on('error.field.bv', function (e, data) {
        // Get the tooltip
        var $parent = data.element.parents('#configForm'),
                $icon = $parent.find('.form-control-feedback[data-bv-icon-for="' + data.field + '"]'),
                title = $icon.data('bs.tooltip').getTitle();
        $icon.tooltip('show').tooltip({
            html: true,
            placement: 'right',
            title: title,
            container: 'body'
        });
    });
    //批量加载时间控件
    $(".rangedate").each(function () {
        laydate.render({
            elem: this,
            type: "date",
            range: true,
            trigger: "click"
        })
    })
});


