<!--
鉴权管理日志
@Author: linqian
@Date: 2021-05-27 11:30
-->

<template>
  <div>
    <!-- 搜索项 -->
    <search-bar ref="searchbar" :conditionForm="conditionForm" @submitSearch="receiveSearch"></search-bar>
    <!-- 表格 -->
    <new-table
      ref="table"
      :tableUrl="authServiceLogTableUrl"
      :tableHeader="authServiceLogTableHeader"
      :condition="condition"
      :sortProps="sort"
      :lazyLoad="true"
      :tableOptList="tableOptList"
      optColumnWidth="100"
      @submitTableOpt="receviceOpt"
    >
    </new-table>
  </div>
</template>

<script>
import searchBar from '@/components/search-bar';
import newTable from '@/components/new-table';
import { authServiceLogTableHeader, authServiceLogDetail } from './DataConfig';
import { authServiceLogTableUrl, getAuthServiceLogDetail } from '@/api/permiss-log-manage';
import { searchOpt, detailOpt } from '@/mixins/page-opt';
export default {
  components: {
    newTable,
    searchBar
  },
  mixins: [searchOpt, detailOpt],
  data() {
    return {
      authServiceLogTableHeader,
      authServiceLogTableUrl,
      conditionForm: [
        {
          label: '姓名',
          name: 'userName',
          op: 'like',
          component: 'ElInput'
        },
        {
          label: '身份证号码',
          name: 'userIdcard',
          op: 'like',
          component: 'ElInput'
        },
        {
          label: '鉴权类型',
          name: 'authenticationType',
          op: '=',
          component: 'DgSelect',
          attr: {
            enum: 'AuthenticationTypeEnum',
            style: 'width: 9rem'
          }
        },

        {
          label: '鉴权时间',
          name: 'createTime',
          op: 'between',
          type: 'DATE',
          value: '',
          valueFormat: 'yyyyMMddHHmmss',
          component: 'DgDatePicker',
          attr: {
            style: 'width: 16rem'
          }
        },
        {
          label: '鉴权结果',
          name: 'state',
          op: '=',
          component: 'DgSelect',
          attr: {
            enum: 'AuthResultEnum',
            style: 'width: 9rem'
          }
        }
      ],
      sort: {
        createTime: 'DESC'
      },
      tableOptList: ['详情']
    };
  },
  computed: {},
  methods: {
    receviceOpt(opt, row) {
      const otherParams = {
        config: authServiceLogDetail,
        labelWidth: '140px',
        area: ['800px', '600px']
      };
      this.handleViewDetail(row.id, otherParams);
    },
    getDetail(id) {
      return new Promise((resolve) => {
        getAuthServiceLogDetail(id).then((res) => {
          resolve(res.data.content);
        });
      });
    }
  },
  created() {
    const startTime = this.$moment().subtract('1', 'year').format('YYYYMMDD') + '000000';
    const endTime = this.$moment().format('YYYYMMDD') + '235959';
    this.conditionForm.find((item) => item.name == 'createTime').value = [startTime, endTime];
  },
  mounted() {
    this.$nextTick(() => {
      this.$refs.searchbar.handleSearch();
    });
  }
};
</script>

<style lang='scss'>
</style>