<template>
  <el-card shadow="never"
           class="aui-card--fill">
    <div class="mod-user__partyauthenticationfailed}">
      <el-form :inline="true"
               :model="dataForm"
               @keyup.enter.native="getDataList()">
        <el-form-item label="姓名">
          <el-input v-model="dataForm.realName"
                    placeholder="请输入"
                    clearable></el-input>
        </el-form-item>
        <el-form-item label="手机号">
          <el-input v-model="dataForm.mobile"
                    placeholder="请输入"
                    clearable></el-input>
        </el-form-item>
        <el-form-item label="身份证号">
          <el-input v-model="dataForm.identityNo"
                    placeholder="请输入"
                    clearable></el-input>
        </el-form-item>
        <el-form-item label="认证时间">
          <el-date-picker @change='setRegistTime'
                          v-model="time"
                          value-format="yyyy-MM-dd"
                          type="daterange"
                          range-separator="至"
                          start-placeholder="开始日期"
                          end-placeholder="结束日期"></el-date-picker>&nbsp;
          <el-form-item>
            <el-button @click="getDataList()">{{ $t('query') }}</el-button>
          </el-form-item>
          <el-form-item>
            <el-button type="primary"
                       @click="exportHandle()">{{ $t('export') }}</el-button>
          </el-form-item>
        </el-form-item>
      </el-form>
      <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="realName"
                         label="姓名"
                         header-align="center"
                         align="center"></el-table-column>
        <el-table-column prop="identityNo"
                         label="身份证号"
                         header-align="center"
                         align="center"></el-table-column>
        <el-table-column prop="mobile"
                         label="手机号"
                         header-align="center"
                         align="center"></el-table-column>
        <el-table-column prop="allDeptNames"
                         label="所属网格"
                         header-align="center"
                         align="center"></el-table-column>
        <el-table-column prop="createdTime"
                         label="认证时间"
                         header-align="center"
                         align="center"></el-table-column>
        <el-table-column prop="address"
                         label="居民住址"
                         header-align="center"
                         align="center"></el-table-column>
        <!-- <el-table-column :label="$t('handle')"
                         fixed="right"
                         header-align="center"
                         align="center"
                         width="150">
          <template slot-scope="scope">
            <el-button v-if="$hasPermission('partyauthenticationfailed:view')"
                       type="text"
                       size="small"
                       @click="addOrUpdateHandle(scope.row.userId)">{{ $t('look') }}</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>
    </div>
  </el-card>
</template>

<script>
import mixinViewModule from '@/mixins/view-module'
import AddOrUpdate from './partyauthenticationfailed-add-or-update'
export default {
  mixins: [mixinViewModule],
  data () {
    return {
      mixinViewModuleOptions: {
        getDataListURL: '/app-user/partyauthenticationfailed/page',
        getDataListIsPage: true,
        deleteURL: '/app-user/partyauthenticationfailed',
        deleteIsBatch: true,
        exportURL: '/app-user/partyauthenticationfailed/export',
        exportMoudle: '/app-user/partyauthenticationfailed/exportMoudle'
      },
      dataForm: {
        realName: '',
        mobile: '',
        identityNo: '',
        startTime: '',
        endTime: ''
      },
      time: ''
    }
  },
  created () {
    this.initTime()
  },
  methods: {
    initTime () {
      const end = new Date()
      const start = new Date()
      start.setTime(start.getTime() - 3600 * 1000 * 24 * 30)
      this.time = [start, end]
      let year = start.getFullYear()
      let month = start.getMonth() + 1
      if (month < 10) {
        month = '0' + month
      }
      let date = start.getDate()
      if (date < 10) {
        date = '0' + date
      }
      let startDate = year + '-' + month + '-' + date
      let yearend = end.getFullYear()
      let monthend = end.getMonth() + 1
      if (monthend < 10) {
        monthend = '0' + monthend
      }
      let dateend = end.getDate()
      if (dateend < 10) {
        dateend = '0' + dateend
      }
      let endDate = yearend + '-' + monthend + '-' + dateend
      this.dataForm.startTime = startDate
      this.dataForm.endTime = endDate
    },
    setRegistTime () {
      if (this.time === null) {
        this.dataForm.startTime = ''
        this.dataForm.endTime = ''
      } else {
        this.dataForm.startTime = this.time[0]
        this.dataForm.endTime = this.time[1]
      }
    },
    // 新增 / 修改
    addOrUpdateHandle (id) {
      this.addOrUpdateVisible = true
      this.$nextTick(() => {
        this.$refs.addOrUpdate.dataForm.id = id
        this.$refs.addOrUpdate.init()
      })
    }
  },
  components: {
    AddOrUpdate
  }
}
</script>
