<template>
  <div class="mod-axis__caResident}">
    <el-card>
      <el-form :inline="true" :model="dataForm" @keyup.enter.native="getDataList()">
        <el-form-item label="身份证号" prop="idCard">
          <el-input v-model="dataForm.idCard" placeholder="身份证号" clearable></el-input>
        </el-form-item>
        <el-form-item label="姓名" prop="residentName">
          <el-input
            v-model="dataForm.residentName"
            placeholder="姓名"
            clearable
          ></el-input>
        </el-form-item>
        <el-form-item label="联系方式" prop="telephone">
          <el-input
            v-model="dataForm.telephone"
            placeholder="联系方式"
            clearable
          ></el-input>
        </el-form-item>
        <el-form-item label="网格下拉" prop="gridId">
          <el-cascader
            :options="caLouDongOptions"
            :props="{ checkStrictly: true }"
            clearable
            @change="handlePartyChange">
          </el-cascader>
        </el-form-item>
        <el-form-item>
          <el-button type="primary" @click="getDataList()">{{ $t("query") }}</el-button>
        </el-form-item>
        <!-- <el-form-item>
            <el-button v-if="$hasPermission('axis:caResident:save')" type="primary" @click="addOrUpdateHandle()">{{ $t('add') }}</el-button>
          </el-form-item>
          <el-form-item>
            <el-button v-if="$hasPermission('axis:caResident:delete')" type="danger" @click="deleteHandle()">{{ $t('deleteBatch') }}</el-button>
          </el-form-item> -->
      </el-form>
    </el-card>
    <el-card shadow="never" class="aui-card--fill">
      <el-table
        v-loading="dataListLoading"
        :data="dataList"
        border
        @selection-change="dataListSelectionChangeHandle"
        style="width: 100%"
      >
        <el-table-column
          type="selection"
          header-align="center"
          align="center"
          width="50"
        ></el-table-column>
        <el-table-column
          prop="idCard"
          label="证件号码（公民身份证号）"
          header-align="center"
          align="center"
        ></el-table-column>
        <el-table-column
          prop="residentName"
          label="姓名"
          header-align="center"
          align="center"
        ></el-table-column>
        <el-table-column
          prop="sex"
          label="性别"
          header-align="center"
          align="center"
        ></el-table-column>
        <el-table-column
          prop="birthday"
          label="出生日期"
          header-align="center"
          align="center"
        ></el-table-column>
        <el-table-column
          prop="telephone"
          label="联系方式"
          header-align="center"
          align="center"
        ></el-table-column>
        <el-table-column
          prop="householdAddressDetail"
          label="户籍详址"
          header-align="center"
          align="center"
          :show-overflow-tooltip="true"
        ></el-table-column>
        <el-table-column
          prop="curliveAddressDetail"
          label="现住详址"
          header-align="center"
          align="center"
          :show-overflow-tooltip="true"
        ></el-table-column>
        <el-table-column :label="$t('handle')" fixed="right" align="center" width="100">
          <template slot-scope="scope">
            <el-button
              type="text"
              class="div-table-button--detail"
              size="small"
              @click="addOrUpdateHandle(scope.row.idCard)"
              >查看</el-button
            >
          </template>
        </el-table-column>
      </el-table>
      <el-pagination
        :current-page="page"
        :page-sizes="[10, 20, 50, 100]"
        :page-size="limit"
        :total="total"
        layout="total, sizes, prev, pager, next, jumper"
        @size-change="pageSizeChangeHandle"
        @current-change="pageCurrentChangeHandle"
      >
      </el-pagination>
      <!-- 弹窗, 新增 / 修改 -->
      <add-or-update
        v-if="addOrUpdateVisible"
        ref="addOrUpdate"
        @refreshDataList="getDataList"
      ></add-or-update>
    </el-card>
  </div>
</template>

<script>
import mixinViewModule from "@/mixins/view-post";
import AddOrUpdate from "./caresident-add-or-update";
export default {
  mixins: [mixinViewModule],
  data() {
    return {
      mixinViewModuleOptions: {
        getDataListURL: "/opendata/caResident/getPage",
        getDataListIsPage: true,
        deleteURL: "",
        deleteIsBatch: true,
      },
      dataForm: {
        idCard: "",
        residentName: "",
        telephone: "",
        gridId:""
      },
      caLouDongOptions:[]
    };
  },
  methods:{
    getloudongOptions(){
      this.$http.post(`/opendata/caLoudong/getLouDongCascade`).then(resp => {
        if(resp.data.code === 0){
          this.caLouDongOptions = resp.data.data
        }
      }).catch(error => {
        this.$message.error(error)
      })
          
  },
  handlePartyChange(val) {
      console.log('val------pp', val)
      this.dataForm.gridId = val[val.length - 1]
    },
  },
created(){
    this.getloudongOptions()
  },
  components: {
    AddOrUpdate,
  },
};
</script>
