

/**
 * 待办配置-编辑指标分类页面JS
 *
 * Modify by li.kui on 2021/4/7.
 */
'use strict';
var el = {
    form : '#form',
    id: '#id',
    name: '#name',
    code: '#code',
    description: '#description',
    sort: '#sort'
};


/**
 * 数据保存
 */
function dataSave(callback) {
    if($(el.form).form('validate')){
        var code = $.trim($(el.code).val()), name = $.trim($(el.name).val()), description = $.trim($(el.description).val()),
            sort = $(el.sort).numberbox('getValue'), id = $(el.id).val();
        if (sort.length > 6) {
            layer.msg('排序值必须小于1000000');
            return false;
        }
        var params = {};
        params.id = id;
        params.code = code;
        params.name = name;
        params.sort = sort;
        params.description = description;
        console.log(params)
        var loading = top.layer.msg('处理中', {icon: 16, shade: [0.1, '#000'], time: false});
        $.ajax({
            url: g.ctx + 'pc/sys/dealt/type/rest/saveOrUpdate',
            method: 'post',
            data: params,
            success: function (data) {
                top.layer.close(loading);
                callback();
            },
            complete: function(data) {
                top.layer.close(loading);
            },
            error: function (data) {
                top.layer.close(loading);
                layer.alert(JSON.parse(data.responseText).message);
            }
        });
    }else{
        layer.msg("红色框为必输项，请填写！");
    }
}
