layui.extend({
    common    :   'js/common',
}).use(['common','table', 'jquery','layer','form','laydate'], function () {
    //  弹窗插件
    var layer = layui.layer;
    //  Jquery插件
    var $ = layui.jquery;
    //  引入公共模块
    var common = layui.common;
    //  引入表格
    var table = layui.table;
    //  引入表单
    var form = layui.form;

    var laydate = layui.laydate;

    var layuiTable = null;

    //处理时间
    laydate.render({
        elem: 'input[name="handleDate"]'
        ,type: 'datetime'
        ,format: 'yyyy-MM-dd HH:mm:ss'
        ,max: 0 //最大日期为当天
    });

    //监听提交
    form.on('submit(submitButton)', function(data){
        common.timer($('button[lay-filter="submitButton"]'));
        $.ajax({
            url:"/estate/userFeedback/handleFeedback",
            type:'POST',
            async:false,
            contentType:'application/json;charset=UTF-8',
            data:JSON.stringify(data.field),
            dataType:'text',
            success:function (data) {
                console.log(data,'result.data值');
                if(data!=null){
                    layer.msg('处理成功！',{
                        icon:1,
                        time:500,
                        shade : [0.1 , '#000' , true]
                    }, function () {
                        //获取当前弹窗出层的名字
                        var index = parent.layer.getFrameIndex(window.name);
                        //关闭弹窗层
                        parent.layer.close(index);
                        // 父页面刷新
                        parent.location.reload();
                    });
                }else {
                    layer.msg('处理失败！',{
                        icon:2,
                        time:500,
                        shade : [0.1 , '#000' , true]
                    },function () {
                        //获取当前弹窗出层的名字
                        var index = parent.layer.getFrameIndex(window.name);
                        //关闭弹窗层
                        parent.layer.close(index);
                        // 父页面刷新
                        parent.location.reload();
                    });
                }
            },
            error:function () {
                layer.msg('请求失败啦！');
            }
        });
    });
    //回调函数
    function callbackFn(result) {
        if(result.code=='200'){
            layer.msg("处理成功",{
                time: 500,
                shade : [0.1 , '#000' , true]
            },function () {
                //获取当前弹窗出层的名字
                var index = parent.layer.getFrameIndex(window.name);
                //关闭弹窗层
                parent.layer.close(index);
                // 父页面刷新
                parent.location.reload();
            });
        }else {//处理失败
            layer.msg("处理失败");
        }
    }


});