layui.extend({
    common    :   'js/common'
}).use(['jquery','table','layer','form','common','util'], function () {
    var $ = layui.jquery;
    var table = layui.table;
    //  弹窗插件
    var layer = layui.layer;
    //  表单插件
    var form = layui.form;
    var common = layui.common;


    //监听提交
    form.on('submit(submitButton)', function(data){
        common.sendAsyncRequest("/ad/push/task/thresholdSet/save",'POST',data.field,callbackFn);
    });

    //回调函数
    function callbackFn(result) {
        if(result.code=='200'){
            layer.msg("设置成功",{time:1000,shade : [0.1 , '#000' , true]},function () {
                //获取当前弹窗出层的名字
                var mylay = parent.layer.getFrameIndex(window.name);
                //关闭弹窗层
                parent.layer.close(mylay);
            });
        }else {//添加失败
            layer.msg("设置失败");
        }
    }

    //取消按钮
    $(document).on("click","#cancel_btn",function(){
        //获取当前弹窗出层的名字
        var mylay = parent.layer.getFrameIndex(window.name);
        //关闭弹窗层
        parent.layer.close(mylay);
    });

});

