<template>
  <div class="app-container">
    <el-form :model="queryParams" ref="queryForm" size="small" :inline="true" v-show="showSearch" label-width="70px">
      <el-form-item label="所属网格" prop="deptId">
        <treeselect v-model="queryParams.deptId" :options="deptOptions" :disable-branch-nodes="true" style="width:215px;"
                    placeholder="请选择所属网格"/>
      </el-form-item>
      <el-form-item label="户主姓名" prop="ownerName">
        <el-input
          v-model="queryParams.ownerName"
          placeholder="请输入户主姓名"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="身份证号" prop="cardId">
        <el-input
          v-model="queryParams.cardId"
          placeholder="请输入身份证号"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="小区名称" prop="houseName">
        <el-input
          v-model="queryParams.houseName"
          placeholder="请输入小区名称"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="楼栋名称" prop="ldName">
        <el-input
          v-model="queryParams.ldName"
          placeholder="请输入楼栋名称"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="单元" prop="unit">
        <el-input
          v-model="queryParams.unit"
          placeholder="请输入单元"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="门牌号" prop="doorNo">
        <el-input
          v-model="queryParams.doorNo"
          placeholder="请输入门牌号"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="房屋性质" prop="houseProp">
        <el-select
          v-model="queryParams.houseProp"
          placeholder="房屋性质"
          clearable
          style="width:100%"
        >
          <el-option
            v-for="dict in dict.type.szxc_fw_xz"
            :key="dict.value"
            :label="dict.label"
            :value="dict.value"
          />
        </el-select>
      </el-form-item>
      <el-form-item label="取暖方式" prop="qnfs">
        <el-select
          v-model="queryParams.qnfs"
          placeholder="取暖方式"
          clearable
          style="width:100%"
        >
          <el-option
            v-for="dict in dict.type.szxc_qnfs"
            :key="dict.value"
            :label="dict.label"
            :value="dict.value"
          />
        </el-select>
      </el-form-item>
      <el-form-item>
        <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
        <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
      </el-form-item>
    </el-form>

    <el-row :gutter="10" class="mb8">
      <el-col :span="1.5">
        <el-button
          type="primary"
          plain
          icon="el-icon-plus"
          size="mini"
          @click="handleAdd"
          v-hasPermi="['szxc:houseinfo:add']"
        >新增</el-button>
      </el-col>
      <el-col :span="1.5">
        <el-button
          type="success"
          plain
          icon="el-icon-edit"
          size="mini"
          :disabled="single"
          @click="handleUpdate"
          v-hasPermi="['szxc:houseinfo:edit']"
        >修改</el-button>
      </el-col>
      <el-col :span="1.5">
        <el-button
          type="danger"
          plain
          icon="el-icon-delete"
          size="mini"
          :disabled="multiple"
          @click="handleDelete"
          v-hasPermi="['szxc:houseinfo:remove']"
        >删除</el-button>
      </el-col>
      <el-col :span="1.5">
        <el-button
          type="warning"
          plain
          icon="el-icon-download"
          size="mini"
          @click="handleExport"
          v-hasPermi="['szxc:houseinfo:export']"
        >导出</el-button>
      </el-col>
      <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
    </el-row>

    <el-table v-loading="loading" :data="houseinfoList" @selection-change="handleSelectionChange" border>
      <el-table-column type="selection" width="55" align="center" />
      <el-table-column label="主键ID" align="center" prop="id" />
      <el-table-column label="所属网格" align="center" prop="deptName" />
      <el-table-column label="户主姓名" align="center" prop="ownerName" />
      <el-table-column label="身份证号" align="center" prop="cardId" />
      <el-table-column label="小区名称" align="center" prop="houseName" />
      <el-table-column label="楼栋名称" align="center" prop="ldName" />
      <el-table-column label="单元" align="center" prop="unit" />
      <el-table-column label="门牌号" align="center" prop="doorNo" />
      <el-table-column label="房屋类型" align="center" prop="houseType" >
        <template slot-scope="scope">
          <dict-tag :options="dict.type.szxc_xqfwlx" :value="scope.row.houseType"/>
        </template>
      </el-table-column>
      <el-table-column label="房屋面积" align="center" prop="houseArea" />
      <el-table-column label="房屋性质" align="center" prop="houseProp" >
        <template slot-scope="scope">
          <dict-tag :options="dict.type.szxc_fw_xz" :value="scope.row.houseProp"/>
        </template>
      </el-table-column>
      <el-table-column label="取暖方式" align="center" prop="qnfs" >
        <template slot-scope="scope">
          <dict-tag :options="dict.type.szxc_qnfs" :value="scope.row.qnfs"/>
        </template>
      </el-table-column>
      <el-table-column label="厕所类型" align="center" prop="toiletType" >
        <template slot-scope="scope">
          <dict-tag :options="dict.type.szxc_cs_type" :value="scope.row.toiletType"/>
        </template>
      </el-table-column>
      <el-table-column label="房屋简介" align="center" prop="houseIntro" />
      <el-table-column label="房屋照片" align="center" prop="housePicture" >
        <template slot-scope="scope">
          <image-preview :src="scope.row.housePicture" :width="50" :height="50"/>
        </template>
      </el-table-column>
      <el-table-column label="操作" align="center" class-name="small-padding fixed-width">
        <template slot-scope="scope">
          <el-button
            size="mini"
            type="text"
            icon="el-icon-edit"
            @click="handleUpdate(scope.row)"
            v-hasPermi="['szxc:houseinfo:edit']"
          >修改</el-button>
          <el-button
            size="mini"
            type="text"
            icon="el-icon-delete"
            @click="handleDelete(scope.row)"
            v-hasPermi="['szxc:houseinfo:remove']"
          >删除</el-button>
        </template>
      </el-table-column>
    </el-table>

    <pagination
      v-show="total>0"
      :total="total"
      :page.sync="queryParams.pageNum"
      :limit.sync="queryParams.pageSize"
      @pagination="getList"
    />

    <!-- 添加或修改房屋信息对话框 -->
    <el-dialog :title="title" :visible.sync="open" width="800px" append-to-body>
      <el-form ref="form" :model="form" :rules="rules" label-width="80px">

        <el-row :gutter="10" v-if="!form.id">
          <el-col :span="12">
            <el-form-item label="户主姓名" prop="ownerName">
              <el-input readonly
                        placeholder="请选择户主姓名"
                        v-model="form.ownerName">
                <el-button slot="append" icon="el-icon-search" @click="ownerSelect"></el-button>
              </el-input>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="身份证号" prop="cardId">
              <el-input v-model="form.cardId" placeholder="请输入身份证号" disabled/>
            </el-form-item>
          </el-col>
        </el-row>

        <el-row :gutter="10" v-if="!form.id">
          <el-col :span="12">
            <el-form-item label="小区名称" prop="houseName">
              <el-input readonly
                        placeholder="请选择小区名称"
                        v-model="form.houseName">
                <el-button slot="append" icon="el-icon-search" @click="houseSelect"></el-button>
              </el-input>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="楼栋名称" prop="ldName">
              <el-input readonly
                        placeholder="请选择楼栋名称"
                        v-model="form.ldName">
                <el-button slot="append" icon="el-icon-search" @click="ldSelect"></el-button>
              </el-input>
            </el-form-item>
          </el-col>
        </el-row>

        <el-row :gutter="10" v-if="!form.id">
          <el-col :span="12">
            <el-form-item label="所属网格" prop="deptName">
              <el-input v-model="form.deptName" placeholder="请输入所属网格" disabled/>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="取暖方式" prop="qnfs">
              <el-select
                v-model="form.qnfs"
                placeholder="取暖方式"
                clearable disabled
                style="width:100%"
              >
                <el-option
                  v-for="dict in dict.type.szxc_qnfs"
                  :key="dict.value"
                  :label="dict.label"
                  :value="dict.value"
                />
              </el-select>
            </el-form-item>
          </el-col>
        </el-row>

        <el-row :gutter="10">
          <el-col :span="12">
            <el-form-item label="单元" prop="unit">
              <el-input v-model="form.unit" placeholder="请输入单元" />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="门牌号" prop="doorNo">
              <el-input v-model="form.doorNo" placeholder="请输入门牌号" />
            </el-form-item>
          </el-col>
        </el-row>

        <el-row :gutter="10">
          <el-col :span="12">
            <el-form-item label="房屋面积" prop="houseArea">
              <el-input v-model="form.houseArea" placeholder="请输入房屋面积" />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="房屋性质" prop="houseProp">
              <el-select
                v-model="form.houseProp"
                placeholder="房屋性质"
                clearable
                style="width:100%"
              >
                <el-option
                  v-for="dict in dict.type.szxc_fw_xz"
                  :key="dict.value"
                  :label="dict.label"
                  :value="dict.value"
                />
              </el-select>
            </el-form-item>
          </el-col>
        </el-row>

        <el-row :gutter="10">
          <el-col :span="12">
            <el-form-item label="房屋类型" prop="houseType">
              <el-select
                v-model="form.houseType"
                placeholder="房屋类型"
                clearable
                style="width:100%"
              >
                <el-option
                  v-for="dict in dict.type.szxc_xqfwlx"
                  :key="dict.value"
                  :label="dict.label"
                  :value="dict.value"
                />
              </el-select>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="厕所类型" prop="toiletType">
              <el-select
                v-model="form.toiletType"
                placeholder="厕所类型"
                clearable
                style="width:100%"
              >
                <el-option
                  v-for="dict in dict.type.szxc_cs_type"
                  :key="dict.value"
                  :label="dict.label"
                  :value="dict.value"
                />
              </el-select>
            </el-form-item>
          </el-col>
        </el-row>

        <el-form-item label="房屋照片" prop="housePicture">
          <image-upload v-model="form.housePicture"/>
        </el-form-item>

        <el-form-item label="房屋简介" prop="houseIntro">
          <el-input v-model="form.houseIntro" type="textarea" placeholder="请输入房屋简介" />
        </el-form-item>

      </el-form>
      <div slot="footer" class="dialog-footer">
        <el-button type="primary" @click="submitForm">确 定</el-button>
        <el-button @click="cancel">取 消</el-button>
      </div>
    </el-dialog>

    <el-dialog title="选择居民" :visible.sync="jmin.visible" width="1000px" append-to-body>
      <el-form :model="jmin.queryParams" ref="queryForm" size="small" :inline="true" label-width="70px">
        <el-form-item label="身份证号" prop="cardId">
          <el-input
            v-model="jmin.queryParams.cardId"
            placeholder="请输入身份证号"
            clearable
            @keyup.enter.native="jminQuery"
          />
        </el-form-item>
        <el-form-item label="姓名" prop="name">
          <el-input
            v-model="jmin.queryParams.name"
            placeholder="请输入姓名"
            clearable
            @keyup.enter.native="jminQuery"
          />
        </el-form-item>
        <el-form-item>
          <el-button type="primary" icon="el-icon-search" size="mini" @click="jminQuery">搜索</el-button>
        </el-form-item>
      </el-form>
      <el-alert title="双击选择户主" type="warning" :closable="false"></el-alert>
      <el-table v-loading="jmin.loading" :data="jmin.list" border @cell-dblclick="jminDblclick">
        <el-table-column label="姓名" align="center" prop="name" min-width="80"/>
        <el-table-column label="身份证号" align="center" prop="cardId" min-width="180"/>
        <el-table-column label="所属网格" align="center" prop="deptName" min-width="100"/>
        <el-table-column label="性别" align="center" prop="sex">
          <template slot-scope="scope">
            <dict-tag :options="dict.type.sys_user_sex" :value="scope.row.sex"/>
          </template>
        </el-table-column>
        <el-table-column label="籍贯" align="center" prop="jg" min-width="180"/>
        <el-table-column label="手机号" align="center" prop="phone" min-width="120"/>
        <el-table-column label="现居住地" align="center" prop="currentAddress" min-width="180"/>
      </el-table>
      <pagination
        v-show="jmin.total>0"
        :total="jmin.total"
        :page.sync="jmin.queryParams.pageNum"
        :limit.sync="jmin.queryParams.pageSize"
        @pagination="getlistJminfo"
      />
    </el-dialog>

    <el-dialog title="选择小区" :visible.sync="xq.visible" width="1100px" append-to-body>
      <el-form :model="xq.queryParams" ref="queryForm" size="small" :inline="true" label-width="70px">
        <el-form-item label="小区名称" prop="name">
          <el-input
            v-model="xq.queryParams.name"
            placeholder="请输入小区名称"
            clearable
            @keyup.enter.native="xqQuery"
          />
        </el-form-item>
        <el-form-item>
          <el-button type="primary" icon="el-icon-search" size="mini" @click="xqQuery">搜索</el-button>
        </el-form-item>
      </el-form>
      <el-alert title="双击选择小区" type="warning" :closable="false"></el-alert>
      <el-table v-loading="xq.loading" :data="xq.list" border @cell-dblclick="xqDblclick">
        <el-table-column label="所属网格" align="center" prop="deptName" />
        <el-table-column label="小区类型" align="center" prop="xqType" >
          <template slot-scope="scope">
            <dict-tag :options="dict.type.szxc_xq_type" :value="scope.row.xqType"/>
          </template>
        </el-table-column>
        <el-table-column label="小区名称" align="center" prop="name" />
        <el-table-column label="物业管理方式" align="center" prop="wyType" >
          <template slot-scope="scope">
            <dict-tag :options="dict.type.szxc_wy_type" :value="scope.row.wyType"/>
          </template>
        </el-table-column>
        <el-table-column label="物业负责人" align="center" prop="wyResponse" />
        <el-table-column label="联系电话" align="center" prop="wyPhone" />
        <el-table-column label="小区地址" align="center" prop="xqAddress" />
        <el-table-column label="建成日期" align="center" prop="buildDate">
          <template slot-scope="scope">
            <span>{{ parseTime(scope.row.buildDate, '{y}-{m}-{d}') }}</span>
          </template>
        </el-table-column>
        <el-table-column label="小区描述" align="center" prop="xqDescribe" />
      </el-table>
      <pagination
        v-show="xq.total>0"
        :total="xq.total"
        :page.sync="xq.queryParams.pageNum"
        :limit.sync="xq.queryParams.pageSize"
        @pagination="getlistXqinfo"
      />
    </el-dialog>

    <el-dialog title="选择楼栋" :visible.sync="ld.visible" width="1000px" append-to-body>
      <el-form :model="ld.queryParams" ref="queryForm" size="small" :inline="true" label-width="70px">
        <el-form-item label="楼栋名称" prop="name">
          <el-input
            v-model="ld.queryParams.name"
            placeholder="请输入楼栋名称"
            clearable
            @keyup.enter.native="ldQuery"
          />
        </el-form-item>
        <el-form-item>
          <el-button type="primary" icon="el-icon-search" size="mini" @click="ldQuery">搜索</el-button>
        </el-form-item>
      </el-form>
      <el-alert title="双击选择楼栋" type="warning" :closable="false"></el-alert>
      <el-table v-loading="ld.loading" :data="ld.list" border @cell-dblclick="ldDblclick">
        <el-table-column label="所属网格" align="center" prop="deptName" />
        <el-table-column label="所属小区" align="center" prop="xqName" />
        <el-table-column label="楼栋名称" align="center" prop="ldName" />
        <el-table-column label="楼栋类型" align="center" prop="ldType" >
          <template slot-scope="scope">
            <dict-tag :options="dict.type.szxc_ld_type" :value="scope.row.ldType"/>
          </template>
        </el-table-column>
        <el-table-column label="楼栋类别" align="center" prop="ldSort" >
          <template slot-scope="scope">
            <dict-tag :options="dict.type.szxc_ldlb" :value="scope.row.ldSort"/>
          </template>
        </el-table-column>
        <el-table-column label="楼栋结构" align="center" prop="ldjg" >
          <template slot-scope="scope">
            <dict-tag :options="dict.type.szxc_ldjg" :value="scope.row.ldjg"/>
          </template>
        </el-table-column>
        <el-table-column label="取暖方式" align="center" prop="qnfs" >
          <template slot-scope="scope">
            <dict-tag :options="dict.type.szxc_qnfs" :value="scope.row.qnfs"/>
          </template>
        </el-table-column>
        <el-table-column label="楼层数" align="center" prop="lcNum" />
        <el-table-column label="单元数" align="center" prop="unitNum" />
        <el-table-column label="户数" align="center" prop="huNum" />
      </el-table>
      <pagination
        v-show="ld.total>0"
        :total="ld.total"
        :page.sync="ld.queryParams.pageNum"
        :limit.sync="ld.queryParams.pageSize"
        @pagination="getlistLdinfo"
      />
    </el-dialog>

  </div>
</template>

<script>
import { listHouseinfo, getHouseinfo, delHouseinfo, addHouseinfo, updateHouseinfo } from "@/api/szxc/houseinfo";
import { listJminfo } from "@/api/szxc/jminfo";
import { listXqinfo } from "@/api/szxc/xqinfo";
import { listLdinfo } from "@/api/szxc/ldinfo";
import { deptTreeSelect } from "@/api/system/user";
import Treeselect from "@riophae/vue-treeselect";
import "@riophae/vue-treeselect/dist/vue-treeselect.css";

export default {
  name: "Houseinfo",
  dicts: ['szxc_qnfs', 'szxc_fw_xz', 'szxc_xq_type', 'szxc_wy_type', 'szxc_cs_type', 'szxc_xqfwlx'],
  components: { Treeselect },
  data() {
    return {
      // 遮罩层
      loading: true,
      // 选中数组
      ids: [],
      // 非单个禁用
      single: true,
      // 非多个禁用
      multiple: true,
      // 显示搜索条件
      showSearch: true,
      // 总条数
      total: 0,
      // 房屋信息表格数据
      houseinfoList: [],
      // 组织树选项
      deptOptions: undefined,
      // 弹出层标题
      title: "",
      // 是否显示弹出层
      open: false,
      // 查询参数
      queryParams: {
        pageNum: 1,
        pageSize: 10,
        ownerId: null,
        ownerName: null,
        cardId: null,
        xqId: null,
        houseName: null,
        buildId: null,
        ldName: null,
        unit: null,
        doorNo: null,
        houseType: null,
        houseArea: null,
        houseProp: null,
        qnfs: null,
        toiletType: null,
        houseIntro: null,
        housePicture: null,
        deptId: null,
        deptName: null,
        userId: null
      },
      // 表单参数
      form: {},
      // 表单校验
      rules: {
        ownerName: [
          { required: true, message: "户主姓名不能为空", trigger: "blur" }
        ],
        houseName: [
          { required: true, message: "小区名称不能为空", trigger: "blur" }
        ],
        deptId: [
          { required: true, message: "部门id不能为空", trigger: "blur" }
        ],
      },
      // 居民信息
      jmin: {
        visible: false,
        // 遮罩层
        loading: false,
        // 总条数
        total: 0,
        // 查询参数
        queryParams:{
          pageNum: 1,
          pageSize: 10,
          off: '0',
          cardId: '',
          name: ''
        },
        // 查询列表
        list: []
      },
      // 小区信息
      xq: {
        visible: false,
        // 遮罩层
        loading: false,
        // 总条数
        total: 0,
        // 查询参数
        queryParams:{
          pageNum: 1,
          pageSize: 10,
        },
        // 查询列表
        list: []
      },
      // 楼栋信息
      ld: {
        visible: false,
        // 遮罩层
        loading: false,
        // 总条数
        total: 0,
        // 查询参数
        queryParams:{
          pageNum: 1,
          pageSize: 10,
          xqId: null
        },
        // 查询列表
        list: []
      },
    };
  },
  created() {
    this.getList();
    this.getDeptTree();
  },
  methods: {
    /** 查询组织下拉树结构 */
    getDeptTree() {
      deptTreeSelect().then(response => {
        this.deptOptions = response.data;
      });
    },
    /** 查询房屋信息列表 */
    getList() {
      this.loading = true;
      listHouseinfo(this.queryParams).then(response => {
        this.houseinfoList = response.rows;
        this.total = response.total;
        this.loading = false;
      });
    },
    // 取消按钮
    cancel() {
      this.open = false;
      this.reset();
    },
    // 表单重置
    reset() {
      this.form = {
        id: null,
        ownerId: null,
        ownerName: null,
        cardId: null,
        xqId: null,
        houseName: null,
        buildId: null,
        ldName: null,
        unit: null,
        doorNo: null,
        houseType: null,
        houseArea: null,
        houseProp: null,
        qnfs: null,
        toiletType: null,
        houseIntro: null,
        housePicture: null,
        createBy: null,
        createTime: null,
        updateBy: null,
        updateTime: null,
        deptId: null,
        deptName: null,
        userId: null
      };
      this.resetForm("form");
    },
    /** 搜索按钮操作 */
    handleQuery() {
      this.queryParams.pageNum = 1;
      this.getList();
    },
    /** 重置按钮操作 */
    resetQuery() {
      this.resetForm("queryForm");
      this.handleQuery();
    },
    // 多选框选中数据
    handleSelectionChange(selection) {
      this.ids = selection.map(item => item.id)
      this.single = selection.length!==1
      this.multiple = !selection.length
    },
    /** 新增按钮操作 */
    handleAdd() {
      this.reset();
      this.open = true;
      this.title = "添加房屋信息";
    },
    /** 修改按钮操作 */
    handleUpdate(row) {
      this.reset();
      const id = row.id || this.ids
      getHouseinfo(id).then(response => {
        this.form = response.data;
        this.open = true;
        this.title = "修改房屋信息";
      });
    },
    /** 提交按钮 */
    submitForm() {
      this.$refs["form"].validate(valid => {
        if (valid) {
          if (this.form.id != null) {
            updateHouseinfo(this.form).then(response => {
              this.$modal.msgSuccess("修改成功");
              this.open = false;
              this.getList();
            });
          } else {
            addHouseinfo(this.form).then(response => {
              this.$modal.msgSuccess("新增成功");
              this.open = false;
              this.getList();
            });
          }
        }
      });
    },
    /** 删除按钮操作 */
    handleDelete(row) {
      const ids = row.id || this.ids;
      this.$modal.confirm('是否确认删除房屋信息编号为"' + ids + '"的数据项？').then(function() {
        return delHouseinfo(ids);
      }).then(() => {
        this.getList();
        this.$modal.msgSuccess("删除成功");
      }).catch(() => {});
    },
    /** 导出按钮操作 */
    handleExport() {
      this.download('szxc/houseinfo/export', {
        ...this.queryParams
      }, `houseinfo_${new Date().getTime()}.xlsx`)
    },
    // 点击选择居民
    ownerSelect(){
      this.jmin.visible = true;
      this.getlistJminfo()
    },
    /** 查询居民信息列表 */
    getlistJminfo() {
      this.jmin.loading = true;
      listJminfo(this.jmin.queryParams).then(response => {
        this.jmin.list = response.rows;
        this.jmin.total = response.total;
        this.jmin.loading = false;
      });
    },
    // 居民查询
    jminQuery(){
      this.jmin.queryParams.pageNum = 1;
      this.getlistJminfo();
    },
    // 居民选择 选中数据
    jminDblclick(row) {
      this.form.ownerId = row.id;
      this.form.ownerName = row.name;
      this.form.cardId = row.cardId;
      this.jmin.visible = false
    },
    // 点击选择小区
    houseSelect(){
      this.xq.visible = true;
      this.getlistXqinfo()
    },
    /** 查询小区信息列表 */
    getlistXqinfo() {
      this.xq.loading = true;
      listXqinfo(this.xq.queryParams).then(response => {
        this.xq.list = response.rows;
        this.xq.total = response.total;
        this.xq.loading = false;
      });
    },
    // 小区查询
    xqQuery(){
      this.xq.queryParams.pageNum = 1;
      this.getlistXqinfo();
    },
    // 小区选择 选中数据
    xqDblclick(row) {
      this.form.xqId = row.id;
      this.form.houseName = row.name;
      this.xq.visible = false
    },
    // 楼栋
    ldSelect(){
      if(this.form.xqId) {
        this.ld.queryParams.xqId = this.form.xqId;
        this.ld.visible = true;
        this.getlistLdinfo()
      }else {
        this.$confirm('还未选择小区，请先选择小区', '提示', {
          confirmButtonText: '确定',
          showConfirmButton: false,
          type: 'warning'
        })
      }
    },
    /** 查询楼栋信息列表 */
    getlistLdinfo() {
      this.ld.loading = true;
      listLdinfo(this.ld.queryParams).then(response => {
        this.ld.list = response.rows;
        this.ld.total = response.total;
        this.ld.loading = false;
      });
    },
    // 楼栋查询
    ldQuery(){
      this.ld.queryParams.pageNum = 1;
      this.getlistLdinfo();
    },
    // 楼栋选择 选中数据
    ldDblclick(row) {
      this.form.buildId = row.id;
      this.form.ldName = row.ldName;
      this.form.deptId = row.deptId;
      this.form.deptName = row.deptName;
      this.form.qnfs = row.qnfs;
      this.ld.visible = false
    },
  }
};
</script>
