<!--
 * @Author: Liugh
 * @Date: 2021-05-25 13:49:40
 * @LastEditTime: 2021-05-27 17:15:49
 * @LastEditors: Do not edit
 * @FilePath: \auth-web\src\pages\log-manage\err-auth-earlywarning-manage\auth-earlywarning-plan.vue
 * @Description: 鉴权预警方案
-->
<template>
  <main>
    <!-- 搜索项 -->
    <search-bar ref="searchbar" :conditionForm="conditionForm" @submitSearch="receiveSearch"></search-bar>
    <new-table
      ref="table"
      :tableUrl="tableUrl"
      :tableHeader="earlyWarningPlanTable"
      :condition="condition"
      :sortProps="sort"
      :tableOptList="tableOptList"
      @submitTableOpt="receviceOpt"
    >
    </new-table>
  </main>
</template>

<script>
import newTable from '@/components/new-table';
import { earlyWarningPlanTable } from '../DataConfig';
import { warningProgrammeTableUrl } from '@/api/log-manage';
import detail from './auth-earlywarning-plan-detail';
import edit from './auth-earlywarning-plan-edit';
import searchBar from '@/components/search-bar';
import { searchOpt } from '@/mixins/page-opt';
export default {
  name: 'auth-earlywarning-plan', // 组件名称
  components: { searchBar, newTable }, // 注册局部组件
  mixins: [searchOpt],
  data() {
    // 组件内部参数
    return {
      // 参数名称及默认值
      earlyWarningPlanTable,
      sort: {
        updateTime: 'DESC'
      },
      conditionForm: [
        {
          label: '鉴权预警方案名称',
          name: 'name',
          op: 'like',
          component: 'ElInput'
        },
        {
          label: '方案状态',
          name: 'state',
          op: '=',
          component: 'DgSelect',
          attr: {
            enum: 'ProgrammeStateEnum'
          }
        }
      ],
      tableUrl: warningProgrammeTableUrl,
      tableOptList: ['详情', '修改']
    };
  },
  computed: {}, // 计算属性
  watch: {}, // 侦听器（扩展的计算属性）
  methods: {
    receviceOpt(opt, row) {
      if (opt == '修改') {
        this.handleViewEdit(row);
      } else if (opt == '详情') {
        this.handleViewDetail(row);
      }
    },
    /**
     * @description: 编辑
     */
    handleViewEdit(row) {
      const vm = this;
      const layer = this.$dgLayer({
        title: `修改`,
        shade: [0.4, '#FFF'],
        content: edit,
        skin: 'auth-earlywarning-plan-edit-layer',
        props: {
          info: row
        },
        on: {
          success() {
            vm.handleSearch();
            layer.close(layer.dialogIndex);
          }
        },
        area: ['900px', '600px']
      });
    },
    /**
     * @description:详情
     */
    handleViewDetail(row) {
      const layer = this.$dgLayer({
        title: `详情`,
        shade: [0.4, '#FFF'],
        content: detail,
        props: {
          info: row
        },
        on: {
          success() {
            layer.close(layer.dialogIndex);
          }
        },
        area: ['900px', '600px']
      });
    }
  }
};
</script>
<style lang="scss" scoped></style>
