<!--
授权管理日志
@Author: linqian
@Date: 2021-05-27 11:29
-->
<template>
  <div>
    <!-- 搜索项 -->
    <search-bar ref="searchbar" :conditionForm="conditionForm" @submitSearch="receiveSearch"></search-bar>
    <!-- 表格 -->
    <new-table
      ref="table"
      :tableUrl="authManageLogTableUrl"
      :tableHeader="authManageLogTableHeader"
      :condition="condition"
      :sortProps="sort"
      :lazyLoad="true"
      :tableOptList="tableOptList"
      @submitTableOpt="receiveOpt"
    >
    </new-table>
  </div>
</template>

<script>
import newTable from '@/components/new-table';
import detail from './log-detail/auth-manage';
import { authManageLogTableHeader } from './DataConfig';
import { authManageLogTableUrl } from '@/api/permiss-log-manage';
import searchBar from '@/components/search-bar';
import { searchOpt } from '@/mixins/page-opt';
export default {
  components: {
    newTable,
    searchBar
  },
  mixins: [searchOpt],
  data() {
    return {
      authManageLogTableUrl,
      authManageLogTableHeader,
      conditionForm: [
        {
          label: '授权管理类型',
          name: 'authorizeType',
          op: '=',
          component: 'DgSelect',
          attr: {
            enum: 'AuthorizeTypeEnum'
          }
        },
        {
          label: '处理时间',
          name: 'createTime',
          op: 'between',
          type: 'DATE',
          value: '',
          valueFormat: 'yyyyMMddHHmmss',
          component: 'DgDatePicker'
        },
        {
          label: '权限处理者',
          name: 'authorizeHandlerNames',
          op: 'like',
          component: 'ElInput'
        }
      ],
      sort: {
        createTime: 'DESC'
      },
      tableOptList: ['详情']
    };
  },
  computed: {},
  methods: {
    receiveOpt(opt, row) {
      this.handleViewDetail(row);
    },
    /**
     *  详情
     */
    handleViewDetail(row) {
      const layer = this.$dgLayer({
        title: `详情`,
        shade: [0.4, '#FFF'],
        content: detail,
        props: {
          id: row.id
        },
        on: {
          success() {
            layer.close(layer.dialogIndex);
          }
        },
        area: ['900px', '800px']
      });
    }
  },
  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>