<!--
鉴权风险日志
@Author: linqian
@Date: 2021-05-27 11:33
-->
<template>
  <div>
    <!-- 搜索项 -->
    <search-bar ref="searchbar" :conditionForm="conditionForm" @submitSearch="receiveSearch"></search-bar>
    <!-- 表格 -->
    <new-table
      ref="table"
      :tableUrl="authRiskLogTableUrl"
      :tableHeader="authRiskLogTableHeader"
      :condition="condition"
      :sortProps="sort"
      :lazyLoad="true"
      :tableOptList="tableOptList"
      @submitTableOpt="receviceOpt"
    >
    </new-table>
  </div>
</template>

<script>
import newTable from '@/components/new-table';
import { authRiskLogTableHeader, authRiskLogDetail } from './DataConfig';
import { authRiskLogTableUrl, getAuthRiskLogDetail } from '@/api/permiss-log-manage';
import searchBar from '@/components/search-bar';
import { searchOpt, detailOpt } from '@/mixins/page-opt';
export default {
  components: {
    newTable,
    searchBar
  },
  mixins: [searchOpt, detailOpt],
  data() {
    return {
      authRiskLogTableUrl,
      authRiskLogTableHeader,
      conditionForm: [
        {
          label: '风险产生方',
          name: 'creater',
          op: 'like',
          component: 'ElInput'
        },
        {
          label: '风险发生时间',
          name: 'createTime',
          op: 'between',
          type: 'DATE',
          value: '',
          valueFormat: 'yyyyMMddHHmmss',
          component: 'DgDatePicker'
        },
        {
          label: '风险类型',
          name: 'riskType',
          op: '=',
          component: 'DgSelect',
          attr: {
            enum: 'RiskProgrammeTypeEnum'
          }
        }
      ],
      sort: {
        createTime: 'DESC'
      },
      tableOptList: ["详情"]
    };
  },
  computed: {},
  methods: {
    receviceOpt(opt, row) {
      const otherParams = {
        config: authRiskLogDetail,
        labelWidth: '140px',
        area: ['800px', '500px']
      };
      this.handleViewDetail(row.id, otherParams);
    },
    getDetail(id) {
      return new Promise((resolve) => {
        getAuthRiskLogDetail(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>