//分页参数
 var page_parameter = {
    index: 1,
    pagerows: 15,
    first: true
};
var pageqy_parameter = {
    index: 1,
    pagerows: 15,
    first: true
};
var flag=0;
var myUser=getCookie('user');
if(!myUser){
    layer.msg('无权限进入');
}else{
    myUser=JSON.parse(myUser);
}
//layui初始化
layui.use(['form','laypage','laydate','table','element'], function(){
    laydate = layui.laydate
    ,laypage=layui.laypage
    ,table=layui.table;
    //日期
    laydate.render({
    elem: '#csrq'
    });
    laydate.render({
    elem: '#zkcsrq'
    });
    laydate.render({
    elem: '#zkzlrq'
    });

    //initCombox();

    form = layui.form;
    form.render(); //更新全部    
    initbuildingtable();
    initpopulation();
    initqy();
});     
//多选下拉框的初始化
function initCombox(){
    //重点人员
    layui.formSelects.data('select_zdry', 'local', {
        arr: zdry_conf.map(item => {
            return {
                name: item.text1,
                value: item.marktype
            };
        })
    });
    //重点人员作为人员查询条件
    $('#selected_type_role').attr('valuefield', 'id');
    $('#selected_type_role').attr('textfield', 'name');
    $('#selected_type_role').empty();
    addOption($("#selected_type_role"));
    $('#selected_type_role').selectpicker("val", []);
    $('#selected_type_role').selectpicker('refresh');
   //监听重点人员下拉框
    layui.formSelects.on('select_zdry', function (id, vals, obj, isAdd, isDisabled) {
        xl_rytz.tag.forEach(function (item, idex, arr) {
            if ((obj.val == item.marktype) && (item.extenddata)) {
                item.show = isAdd;
                if (isAdd) {
                    setTimeout(() => {
                        $(".well-xq .nav-tabs li").removeClass("active");
                        $(".well-xq .tab-content div").removeClass("active");
                        $(".well-xq .nav-tabs li").eq(0).addClass("active");
                        $(".well-xq .tab-content div").eq(0).addClass("active");
                    }, 10);
                }
            }
        });
        return true;
    });
   //党员
    layui.formSelects.data('select_tag', 'local', {
        arr: [{name:"党员",value:"1"}]
    });
    //监听党员
    layui.formSelects.on('select_tag', function (id, vals, obj, isAdd, isDisabled) {
        vue_dyxl.tag=isAdd;
        setTimeout(() => {
            $(".well .nav-tabs li").removeClass("active");
            $(".well .tab-content div").removeClass("active");
            $(".well .nav-tabs li").eq(0).addClass("active");
            $(".well .tab-content div").eq(0).addClass("active");
        }, 10);
        return true;
    });
    layui.formSelects.config('select_zdry', {direction: 'up'});
    layui.formSelects.config('select_tag', {direction: 'up'});
}
function addOption(x) {
    x.empty();
    $.each(zdry_conf, function (i, item) {
        var option = $('<option></option>');
        option.attr('value', item.marktype);
        option.text(item.text1);
        x.append(option);
    });
}
//layui打开
function layerOpen(layui_open_option,callback) {
    layer.open({
        type: 1,
        title: layui_open_option.title,
        area: layui_open_option.area, //宽高
        content: layui_open_option.content,
        offset: ['50px'],
        shade :0,
        btn: ["确定","关闭"],

        resize: false,
        yes: function (index, layero) {
            if(callback){
                callback(index);
            }else{
                layer.close(index);
            }
        }
    });
}

//#region 楼栋数据
//楼栋查询界面
var vue_ldxz = new Vue({
    el: '#ldxzid',
    data: {
        datax: [],
        condition: { name: "", districtname: "" }
    },
    methods: {
        ldxzquery: function () {  //查询
            postByAjax("../rest/querypagebuilding", { index: 1, first: false, pagerows: 15, condition: this.condition }, resultx => {
                this.datax = resultx;
            });
        },
        queryld:function(item){//打开房屋结构
            queryBuildingStructure(item);
        },
    },
});

//楼栋数据
function initbuildingtable(){
    page_parameter.condition=Object.assign({},vue_buildingdata.condition);
    postByAjax("../rest/querypagebuilding", page_parameter, resultx => {
        vue_buildingdata.totals=resultx.number;
        laypage.render({
            elem: 'demo3',
            limit: 15,
            count: resultx.number,
            theme: '#337ab7',
            jump: function (data, first) {
                if (!first) {
                    postByAjax("../rest/querypagebuilding", {
                        condition:page_parameter.condition,
                        index: data.curr,
                        pagerows: 15,
                        first: false
                    }, result => {
                        vue_buildingdata.datax = result;
                        if(result.length==0){
                            layer.msg("未查找到数据");
                        }
                    });
                } else {
                    vue_buildingdata.datax = resultx.data;
                    if(resultx.data.length==0){
                        layer.msg("未查找到数据");
                    }
                }
            }
        });
    });
}
//楼栋
var vue_buildingdata = new Vue({
    el: '#fwgl',
    data: {
        datax: [],
        condition:{ name:'',districtname:'' ,facade:true},
        selectedHouse:null,
        totals:0
    },
    methods: {
        query:function(){
             initbuildingtable();
        },
        rkfw:function(item,index){
            queryBuildingStructure(item);
        }
    }
});
//获取房间
function getRoom(data,k,i,j){
    for(var n=0;n<data.length;n++){
        if(data[n].unitorder==k&&data[n].floororder==i&&data[n].roomorder==j)
            return data[n];
    }
    return null;
}
//查询建筑内企业和个体户和房屋信息
function queryBuildingStructure(data_building,data_house) {
    vue_buildingdata.selectedHouse=null;
    $(".fwjbxx input.districtname").val(data_building.districtname);
    $(".fwjbxx input.building").val(data_building.name);
    $('.tanchu  .right-div').empty(); //清空右侧
    $('#mydiv').html(''); //清空房屋结构
    let layui_open_option = {
        title: '<span class="layer_span6">楼栋信息</span>',
        content: $(".tanchu"),
        area: ['1280px', '660px'], //宽高
    };
    if (data_building.unitnum && data_building.floornum && data_building.roomnum) { //有房屋结构
        $('.tanchu  .right-div').append($('.tanchutable').html());
        getByAjax("../rest/queryfwjg/1/" + data_building.id, data =>{
            var unitnum = data_building.unitnum;
            var pienum = data_building.floornum;
            var roomnum = data_building.roomnum;
            for (var k = 0; k <= unitnum - 1; k++) {
                var div_unit = $('<div class="div_unit"></div>');
                var unit_num = k + 1;
                var addclass = "unit" + k;
                div_unit.addClass(addclass);
                var title_unit = $('<div class="title_unit"><span>第' + unit_num + '单元</span></div>');
                div_unit.append(title_unit);
                for (var i = pienum; i >= 1; i--) {
                    var myPlie = $('<div class="myplienum"></div>');
                    var mypie = "myPie" + i;
                    myPlie.addClass(mypie);
                    for (var j = 1; j < roomnum + 1; j++) {
                        var temp = getRoom(data, k + 1, i, j);
                        var myDiv = $('<div class="myroom"></div>');
                        if (temp != null) {
                            myDiv.append('<p class="roomnum">' + temp.name + '</p>');
                            //房间绑定数据和事件
                            myDiv[0].attributes.tag = temp;
                            myDiv.click(function () {
                                vue_buildingdata.selectedHouse=this.attributes.tag;
                                showRoomMember(this.attributes.tag, () => {});
                            });
                        } else { //不存在此户
                            myDiv.css('background-image', "url('../img/emptyhouse.png')");
                            myDiv.css('cursor', 'default');
                        }
                        //房间加入楼房
                        myPlie.append(myDiv);
                        div_unit.append(myPlie);
                    }
                }
                $('#mydiv').append(div_unit);
            }
        });
        showRoomMember(data_house?data_house:data_building, () => {
            layerOpen(layui_open_option);
        });
    } else { //无房屋结构
        getByAjax("../rest/queryfwjg/0/"+ data_building.id,data=>{
            layui_open_option = {
                title: '<span class="layer_span7">房屋信息</span>',
                content: $(".tanchutable"),
                area: ['803px', '630px'], //宽高
            };
            vue_buildingdata.selectedHouse=data_house;
            var xx=data_house;
            if (!xx) {
                if (data.length > 0) {
                     xx=data[0];
                     vue_buildingdata.selectedHouse=data[0];
                } else {
                     xx=data_building;
                     vue_buildingdata.selectedHouse=null;
                }
                xx = data;
            }
            showRoomMember(xx, () => {
                layerOpen(layui_open_option);
            });
        });
    }
}
 
//显示选中房间信息
function showRoomMember(data_house, callback) {
    $(".housejbxx .house").val(data_house.name);
    $(".housejbxx .housemj").val(data_house.mj);
    var table = layui.table;
    //查询企业
    getByAjax("../rest/queryqydata/" + data_house.id, data => {
        table.render({
            elem: '#tbx',
            height: 190,
            cellMinWidth: 50,
            cols: [
                [ //标题栏
                    {
                        field: 'dwxxmc',
                        title: '单位详细名称',
                        width: 270,
                        align: 'center',
                        edit: 'text'
                    },
                    {
                        field: 'fddbr',
                        title: '法定代表人',
                        width: 100,
                        align: 'center',
                        edit: 'text'
                    },
                    {
                        field: 'yddh',
                        title: '移动电话',
                        width: 180,
                        align: 'center'
                    },
                    {
                        field: '',
                        title: '操作',
                        align: 'center',
                        width: 65,
                        templet: '<div><img src="../img/delete.png" title="删除" style="width:15px;height:17px;margin-left: 5px;cursor:pointer;" lay-event="deletejtcy"></div>'
                    }
                ]
            ],
            data: data,
            id: "tbx_data"
        });
         // 表格工具栏
        table.on('tool(demoEvent)', function (obj) {
            // 删除
            layer.confirm('确定要删除该成员吗？', {
                btn: ['确定', '取消'] //按钮
            }, function (index) { //确定删除
                //todo模拟成功
                obj.del();
                layer.msg("删除成功");
                // postByAjax("../edit/czrydata/1",{data:[obj.data],houseid:data_house.id},result=>{
                //     obj.del();
                //     postByAjax("../rest/querydyxq", {//重新更新地址信息
                //         zjhm: obj.data.zjhm
                //     }, result1 => {
                //         vue_rydz.datax=result1.data2;
                //     });
                //     layer.msg("删除成功");
                // });
            });
        });
        //展示个体户已知数据
        getByAjax("../rest/querygthdata/" + data_house.id, data1 => {
            table.render({
                elem: '#tbx1',
                height: 190,
                cellMinWidth: 50,
                cols: [
                    [ //标题栏     
                        {
                            field: 'gtjyhmc',
                            title: '个体经营户名称',
                            width: 320,
                            align: 'center',
                            edit: 'text'
                        },
                        {
                            field: 'gtjyhhzxm',
                            title: '个体经营户户主姓名',
                            width: 220,
                            align: 'center',
                            edit: 'text'
                        }, 
                        {
                            field: 'lxdh',
                            title: '联系电话',
                            width: 120,
                            align: 'center',
                            edit: 'text'
                        }, 
                        {
                            field: '',
                            title: '操作',
                            align: 'center',
                            width: 70,
                            templet: '<div><img src="../img/delete.png" title="删除" style="width:16px;height:17px;margin-left: 5px;cursor:pointer;" lay-event="deletezk"></div>'
                        }
                    ]
                ],
                data: data1,
                id: "tbx1_data"
            });
            table.on('tool(demoEventzk)', function (obj) {
                layer.confirm('确定要删除该租客吗？', {
                    btn: ['确定', '取消'] //按钮
                }, function (index) { //确定删除
                      //todo模拟成功
                     obj.del();
                     layer.msg("删除成功");
                    // postByAjax("../edit/zkrydata/1",{data:[obj.data],houseid:data_house.id},result=>{
                    //     obj.del();
                    //     postByAjax("../rest/querydyxq", {//重新更新地址信息
                    //         zjhm: obj.data.zjhm
                    //     }, result1 => {
                    //         vue_rydz.datax=result1.data2;
                    //     });
                    //     layer.msg("删除成功");
                    // });
                });
            });
        });
        callback();
    });
}

//添加企业和个体户
function xz_facade(type) {
    flag=type;
    $(".tab-content >div").each(function(){
        if($(this).hasClass('active')&&this.id=="profile"){
            addPerson(type,[Object.assign({},vue_ryedit.xq)]);
        }else if($(this).hasClass('active')&&this.id=="home"){//楼栋管理操作此按钮是添加搜索的企业或个体户
            var  layui_open_option = {
                title: ['新增成员信息', 'font-weight: 700;'],
                area: ['700px', '435px'],
                content: $('.xzcy-div')
            };
            table.render({
                elem: '#ryxxid'
                ,cellMinWidth: 80
                ,cols: [[
                 {checkbox:true}
                ,{field:(type=="0"?"dwxxmc":"gtjyhmc"), width:280, title: '名称',align:'center'}
                ,{field:(type=="0"?"yddh":"lxdh"), width:280, title: '联系电话',align:'center'}
                ]],
                height: 220
                ,data:[]
                ,id:'idTest'
            });
            layerOpen(layui_open_option,(layerindex)=>{
                    var checkStatus = table.checkStatus('idTest'), data= checkStatus.data;   
                    if(data.length !=0){
                        addPerson(type,data,layerindex);
                    }else{
                        layer.msg('未选择要添加的人员!', {
                            area: ['250px', '70px'],
                            icon: 5,
                            anim: 6
                        });
                    }
            });
        }
    });
}
//添加企业和个体户详细操作
function addPerson(type,data,layerindex){
    //现有添加进来
    var option={url:(type=="0"?"czrydata":"zkrydata"),tbname:(type=="0"?"tbx_data":"tbx1_data")};
    var dataAll= table.cache[option.tbname];
    var oldnum=dataAll.length;
    dataAll.distinctconcat(data,"id");  
    var newnum=dataAll.length;
    if(oldnum==newnum){
        layer.msg("已存在");
        return;
    }if(!vue_buildingdata.selectedHouse){
        layer.msg("尚未选中房间");
        return;
    }
    layerindex&&layer.close(layerindex);
    //todo模拟已经加入
    table.reload(option.tbname,{
        data:dataAll
    });
    // postByAjax('../edit/'+option.url+'/0', {data:data,houseid:vue_buildingdata.selectedHouse.id}, result => {
    //     postByAjax("../rest/querydyxq", {
    //         zjhm: data[0].zjhm
    //     }, result => {
    //         vue_rydz.datax=result.data2;
    //     });
    //     table.reload(option.tbname,{
    //         data:dataAll
    //     });
    //     layer.msg("成功添加"+(newnum-oldnum)+"条");
    // });        
}
//商业查找
$("#rkmhcx").click(function(){
    var url="querygthmh";
    if(flag=="0"){
        url="queryqymh";
    }
    postByAjax("../rest/"+url,{condition:{name:$("#cxryxxid").val()}},result=>{
        table.reload("idTest",{
            data:result
        });
    });
});
//商业查找
$("#cxryxxid").keydown(function(){
    var url="querygthmh";
    if(flag=="0"){
        url="queryqymh";
    }
    postByAjax("../rest/"+url,{condition:{name:$("#cxryxxid").val()}},result=>{
        table.reload("idTest",{
            data:result
        });
    });
});
//#endregion

//#region 个体户数据
//查询个体户数据列表
function initpopulation(){
    page_parameter.condition=Object.assign({},vue_rydata.condition);
    postByAjax("../rest/querygthpage", page_parameter, resultx => {
        vue_rydata.totals=resultx.number;
        laypage.render({
            elem: 'demo4',
            limit: 15,
            count: resultx.number,
            theme: '#337ab7',
            jump: function (data, first) {
                if (!first) {
                    postByAjax("../rest/querygthpage", {
                        condition:page_parameter.condition,
                        index: data.curr,
                        pagerows: 15,
                        first: false
                    }, result => {
                        vue_rydata.datax = result;
                        if(result.length==0){
                            layer.msg("未查找到数据");
                        }
                    });
                } else {
                    vue_rydata.datax = resultx.data;
                    if(resultx.data.length==0){
                        layer.msg("未查找到数据");
                    }
                }
            }
        });
    });
}
//个体户管理列表
var vue_rydata = new Vue({
    el: '#rygl',
    data: {
        datax: [],
        condition: {
            name: ''
        },
        totals: 0
    },
    methods: {
        query:function(){
            initpopulation();
        },
        insert: function () {
            var layui_open_option = {
                title: ['新增人员', 'font-weight: 700;'],
                content: $('.gthbjtcc-div'),
                area: ['900px', '690px'], //宽高
            };
            //清除地址todo
            vue_rydz.datax = [];
            //清除基础信息
            vue_ryedit.xq = Object.assign({}, vue_ryedit.xq);
            for (var index in vue_ryedit.xq) {
                vue_ryedit.xq[index] = null;
            }
            //保留主键
            vue_ryedit.xq.id=uuid();
            vue_rydz.ban = true;
            //打开
            layerOpen(layui_open_option, (layerindex) => {
                layer.confirm('是否确定要保存？', {
                    btn: ['确定', '取消'] //按钮
                }, function (layerindex1) { //确定删除 
                    layer.close(layerindex1);    
                    layer.close(layerindex);
                    postByAjax('../edit/gthdata/0', vue_ryedit.xq, result => {
                        if (result==1) {
                            vue_rydata.datax.push(vue_ryedit.xq);
                            layer.confirm('添加成功,是否添加到房屋中？', {
                                btn: ['确定', '取消'] //按钮
                            }, function (layerindex2) {
                                layer.close(layerindex2);
                                vue_rydz.btnLDXX();
                            });
                        } else {
                            layer.msg("添加失败,已存在");
                        }
                    });
                });
            });
        },
        edit: function (item, index) {
            var layui_open_option = {
                title: ['编辑个体户信息', 'font-weight: 700;'],
                content: $('.gthbjtcc-div'),
                area: ['900px', '690px'], //宽高
            };
            //设置地址
            postByAjax("../rest/queryfacadeaddress", {
                id: item.id
            }, result => {
                vue_rydz.datax = result;
            });

            form.render();
            vue_ryedit.xq = Object.assign({}, item);

            vue_rydz.ban = false;
            //打开
            layerOpen(layui_open_option, (layerindex) => {
                layer.confirm('是否确定要保存？', {
                    btn: ['确定', '取消'] //按钮
                }, function (layerindex1) { //确定删除
                    layer.close(layerindex);
                    postByAjax('../edit/gthdata/2', vue_ryedit.xq, result => {
                        if (result) {
                            layer.msg("修改成功");
                            Vue.set(vue_rydata.datax, index, vue_ryedit.xq)
                        } else {
                            layer.msg("修改失败");
                        }
                    });
                    layer.close(layerindex1);
                });
            });
        },
        deletex: function (item, index) {
            layer.confirm('确定要删除吗？不可恢复!', {
                btn: ['确定', '取消'] //按钮
            }, function (layerindex) { //确定删除 
                postByAjax('../edit/gthdata/1', item, result => {
                    if(result){
                        layer.msg("删除成功");
                        vue_rydata.datax.splice(index, 1);
                        initpopulation();
                     }else{
                        layer.msg("删除失败");
                     }
                 });
                layer.close(layerindex);
            });
        }
    }
});
//弹出面板基本信息
var vue_ryedit=new Vue({
    el:'#person_edit',
    data:{
        xq:{}
    }
});

// 地址详情
var vue_rydz=new Vue({
    el:'#personaddress',
    data:{
      datax:[],
      ban:true
    },
    methods:{
        deleteaddress:function(item){
            //todo
            // layer.confirm('确定要删除该成员吗？', {
            //     btn: ['确定', '取消'] //按钮
            // }, function (index) { //确定删除 
            //     postByAjax("../edit/czrydata/1",{data:[vue_ryedit.xq],houseid:item.id},result=>{
            //         vue_rydz.datax.remove(item);
            //         layer.msg("删除成功");
            //     });
            // });
        },
        detailaddress:function(item){
            var bd = {
                    id: item.buildingid,
                    districtname:item.districtname,
                    name: item.name
                },
                hd = {
                    id: item.id,
                    mj: item.mj,
                    name: item.mph
                };
            queryBuildingStructure(bd, hd);
        },
        //楼栋选择（编辑商业信息时）
        btnLDXX:function (){
            layerOpen({
                title: ['楼栋选择', 'font-weight: 700;'],
                area: ['800px', '625px'],
                content: $('.lddzxz-div'),
            });
        }
    }
});
//#endregion

//#region 企业数据
// 查询企业数据列表
function initqy(){
    pageqy_parameter.condition=Object.assign({},vue_qydata.condition);
    postByAjax("../rest/queryqypage", pageqy_parameter, resultx => {
        vue_qydata.totals=resultx.number;
        laypage.render({
            elem: 'demo5',
            limit: 15,
            count: resultx.number,
            theme: '#337ab7',
            jump: function (data, first) {
                if (!first) {
                    postByAjax("../rest/queryqypage", {
                        condition:pageqy_parameter.condition,
                        index: data.curr,
                        pagerows: 15,
                        first: false
                    }, result => {
                        vue_qydata.datax = result;
                        if(result.length==0){
                            layer.msg("未查找到数据");
                        }
                    });
                } else {
                    vue_qydata.datax = resultx.data;
                    if(resultx.data.length==0){
                        layer.msg("未查找到数据");
                    }
                }
            }
        });
    });
}
//企业管理列表
var vue_qydata = new Vue({
    el: '#qygl',
    data: {
        datax: [],
        condition: {
            name: '',
            djzclx: '',
            jglx: ''
        },
        totals: 0,
        arr_types:{djzclxs:[],jglxs:[],yyzts:[]},
    },
    methods: {
        query:function(){
            initqy();
        },
        insert: function () {
            var layui_open_option = {
                title: ['新增企业信息', 'font-weight: 700;'],
                content: $('.qybjtcc-div'),
                area: ['900px', '730px'], //宽高
            };
            //清除上一个地址todo
            vue_qydz.datax = [];
            //清空基础信息
            vue_qyedit.xq = Object.assign({}, vue_qyedit.xq);
            for (var index in vue_qyedit.xq) {
                vue_qyedit.xq[index] = null;
            }
             //清空其他信息
             vue_qtxq.types = Object.assign({}, vue_qtxq.types);
             for (var index in vue_qtxq.types) {
                vue_qtxq.types[index] = null;
             }
              //保留主键
            vue_qyedit.xq.id=uuid();
            vue_qydz.ban = true;
            //打开
            layerOpen(layui_open_option, (layerindex) => {
                layer.confirm('是否确定要保存？', {
                    btn: ['确定', '取消'] //按钮
                }, function (layerindex1) { //确定删除 
                    layer.close(layerindex1);
                    layer.close(layerindex);
                    postByAjax('../edit/qydata/0', vue_qyedit.xq, result => {
                        if (result==1) {
                            vue_qydata.datax.push(vue_qyedit.xq);
                            layer.confirm('添加成功,是否添加到房屋中？', {
                                btn: ['确定', '取消'] //按钮
                            }, function (layerindex2) {
                                layer.close(layerindex2);
                                vue_qydz.btnLDXX();
                            });
                        } else {
                            layer.msg("添加失败,已存在");
                        }
                    });
                });
            });
        },
        edit: function (item, index) {
            var layui_open_option = {
                title: ['编辑企业信息', 'font-weight: 700;'],
                content: $('.qybjtcc-div'),
                area: ['900px', '730px'], //宽高
            };
         
            vue_qyedit.xq=Object.assign({},item);
            form.render();
            //其他信息
            vue_qtxq.types=vue_qyedit.xq;
            vue_qydz.ban = false;
            //设置地址
            postByAjax("../rest/queryfacadeaddress", {
                id: item.id
            }, result => {
                vue_rydz.datax = result;
            });
            //打开
            layerOpen(layui_open_option, (layerindex) => {
                layer.confirm('是否确定要保存？', {
                    btn: ['确定', '取消'] //按钮
                }, function (layerindex1) { //确定删除 
                    layer.close(layerindex);
                    postByAjax('../edit/qydata/2', vue_qyedit.xq, result => {
                        if (result) {
                            layer.msg("修改成功");
                            Vue.set(vue_qydata.datax, index, vue_qyedit.xq)
                        } else {
                            layer.msg("修改失败");
                        }
                    });
                    layer.close(layerindex1);
                });
            });
        },
        deletex: function (item, index) {
            layer.confirm('确定要删除吗？不可恢复!', {
                btn: ['确定', '取消'] //按钮
            }, function (layerindex) { //确定删除 
                postByAjax('../edit/qydata/1', item, result => {
                    if(result){
                        layer.msg("删除成功");
                        vue_qydata.datax.splice(index, 1);
                        initqy();
                     }else{
                        layer.msg("删除失败");
                     }
                 });
                layer.close(layerindex);
            });
        }
    }
});
//弹出面板基本信息
var vue_qyedit=new Vue({
    el:'#qy_edit',
    data:{
        xq:{}
    }
});
// 其他详情
var vue_qtxq=new Vue({
    el:'#qt_edit',
    data:{
        datax:{djzclxs:[],jglxs:[],yyzts:[]},
        types:{djzclx:"",jglx:"",yyzt:""}
    },
    methods:{

    }
});
// 地址详情
var vue_qydz=new Vue({
    el:'#qyaddress',
    data:{
      datax:[],
      ban:true
    },
    methods:{
        deleteaddress:function(item){
            //todo
            // layer.confirm('确定要删除该成员吗？', {
            //     btn: ['确定', '取消'] //按钮
            // }, function (index) { //确定删除 
            //     postByAjax("../edit/czrydata/1",{data:[vue_ryedit.xq],houseid:item.id},result=>{
            //         vue_rydz.datax.remove(item);
            //         layer.msg("删除成功");
            //     });
            // });
        },
        detailaddress:function(item){
            var bd = {
                    id: item.buildingid,
                    districtname:item.districtname,
                    name: item.name
                },
                hd = {
                    id: item.id,
                    mj: item.mj,
                    name: item.mph
                };
            queryBuildingStructure(bd, hd);
        },
        //楼栋选择（编辑人员信息时）
        btnLDXX:function (){
            layerOpen({
                title: ['楼栋选择', 'font-weight: 700;'],
                area: ['800px', '625px'],
                content: $('.lddzxz-div'),
            });
        }
    }
});

//初始化类型
getByAjax("../rest/typesquery",function(data){
    vue_qtxq.datax=data;
    vue_qydata.arr_types=data;
});
 //#endregion