<template>
  <ai-list class="notice">
    <template slot="title">
      <ai-title title="走访排查情况统计" isShowBottomBorder :isShowArea="true" v-model="search.areaId" :instance="instance" @change="getList"></ai-title>
    </template>
    <template slot="content">
      <ai-search-bar>
        <template #left>
          <el-date-picker
            value-format="yyyy-MM"
            v-model="search.beginDate"
            type="month"
            size="small"
            unlink-panels
            placeholder="请选择考核开始月份"
            @change="search.current = 1, getList()" />
          <el-date-picker
            value-format="yyyy-MM"
            v-model="search.endDate"
            type="month"
            size="small"
            unlink-panels
            placeholder="请选择考核结束月份"
            @change="search.current = 1, getList()" />
        </template>
        <template #right>
          <el-input
            v-model="search.name"
            size="small"
            placeholder="网格员姓名"
            clearable
            v-throttle="() => {search.current = 1, getList()}"
            @clear="search.current = 1, search.name = '', getList()"
            suffix-icon="iconfont iconSearch">
          </el-input>
        </template>
      </ai-search-bar>
      <ai-table
        :tableData="tableData"
        :col-configs="colConfigs"
        :total="total"
        style="margin-top: 12px;"
        :current.sync="search.current"
        :size.sync="search.size"
        @selection-change="(v) => (ids = v.map((e) => e.id))"
        @getList="getList">
      </ai-table>
    </template>
  </ai-list>
</template>

<script>
  import { mapState } from 'vuex'
  export default {
    name: 'List',

    props: {
      instance: Function,
      dict: Object
    },

    data() {
      return {
        search: {
          current: 1,
          size: 10,
          title: '',
          areaId: '',
          beginDate: '',
          endDate: ''
        },
        ids: [],
        total: 10,
        tableData: []
      }
    },

    computed: {
      ...mapState(['user']),

      colConfigs () {
        return [
          { prop: 'title', label: '考核月份', align: 'left' },
          { prop: 'createUserName', label: '网格员姓名', align: 'center' },
          { prop: 'createTime', label: '网格员联系方式', align: 'center' },
          { prop: 'createTime', label: '监测家庭数量', align: 'center' },
          { prop: 'createUserName', label: '开展走访次数', align: 'center' },
          { prop: 'createTime', label: '已走访家庭数量', align: 'center' },
          { prop: 'createTime', label: '走访进度', align: 'center' }
        ]
      }
    },

    created () {
      this.search.areaId = this.user.info.areaId
      this.dict.load('epidemicRecentTestResult').then(() => {
        this.getList()
      })
    },

    methods: {
      getList() {
        this.instance.post(`/app/appmininotice/list`, null, {
          params: {
            ...this.search
          }
        }).then(res => {
          if (res.code == 0) {
            this.tableData = res.data.records
            this.total = res.data.total
          }
        })
      }
    }
  }
</script>

<style lang="scss" scoped>
</style>
