/*
 * title: unit-manage
 *
*/
layui.extend({
    common    :   'js/common',
}).use(['tree', 'table', 'jquery','layer','common','form','element'], function () {

    var tree = layui.tree;
    //  弹窗插件
    var layer = layui.layer;
    //  Jquery插件
    var $ = layui.jquery;
    //  引入公共模块
    var common = layui.common;
    //  引入表格
    var table = layui.table;
    //  引入表单
    var form = layui.form;

    var element = layui.element;

    var residentialId = $('#residentialId').val();


// 批量弹窗
    form.on('submit(add_batch)', function(data) {
        common.timer($('button[lay-filter="add_batch"]'));
        layer.load(1); //风格1的加载
        data.field.residentialId = residentialId;
        common.sendAsyncRequest("/estate/building/addBuildingBatch",'POST', data.field, callbackFn);

    });

    //回调函数
    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("批量添加失败");
        }
    }


});