<!--
鉴权预警信息
@Author: linqian
@Date: 2021-07-07
-->
<template>
  <main class="auth-earlywarning-plan">
    <!-- 搜索项 -->
    <search-bar ref="searchbar" :conditionForm="conditionForm" @submitSearch="receiveSearch"></search-bar>
    <new-table
      ref="table"
      :tableUrl="tableUrl"
      :tableHeader="EarlyWarningInfo"
      :condition="condition"
      :sortProps="sort"
      @submitTableOpt="receviceOpt"
    >
    </new-table>
  </main>
</template>

<script>
import newTable from '@/components/new-table';
import { EarlyWarningInfo } from '../DataConfig';
import { getAuthEarlyWarningDetail, authEarlyWarningInfo } from '@/api/log-manage';
import Detail from './auth-earlywarning-info-detail';
import searchBar from '@/components/search-bar';
import { searchOpt } from '@/mixins/page-opt';
export default {
  name: 'auth-earlywarning-info',
  components: { searchBar, newTable },
  mixins: [searchOpt],
  data() {
    return {
      EarlyWarningInfo,
      conditionForm: [
        {
          label: '姓名',
          name: 'creater',
          op: 'like',
          component: 'ElInput'
        },
        {
          label: '身份证号码',
          name: 'createrId',
          op: 'like',
          component: 'ElInput'
        },
        {
          label: '预警类型',
          name: 'programmeType',
          op: '=',
          component: 'DgSelect',
          attr: {
            enum: 'WarningProgrammeTypeEnum'
          }
        },
        {
          label: '预警时间',
          name: 'createTime',
          op: 'between',
          type: 'DATE',
          value: '',
          valueFormat: 'yyyyMMddHHmmss',
          component: 'DgDatePicker'
        }
      ],
      tableUrl: authEarlyWarningInfo,
      sort: {
        createTime: 'DESC'
      },
      // tableOptList: ['详情']
    };
  },
  methods: {
    receviceOpt(opt, row) {
      this.handleViewDetail(row);
    },
    /**
     * @description:详情
     */
    handleViewDetail({ id }) {
      const that = this;
      getAuthEarlyWarningDetail(id)
        .then((res) => {
          const sizeForm = res;
          const layer = this.$dgLayer({
            title: `详情`,
            shade: [0.4, '#FFF'],
            content: Detail,
            props: {
              sizeForm
            },
            on: {
              success() {
                layer.close(layer.dialogIndex);
              }
            },
            area: ['900px', '500px']
          });
        })
        .catch((error) => {
          that.$message.error('详情获取失败');
        });
    }
  }
};
</script>
<style lang="scss" scoped></style>
