<template>
  <div class="ele-body">
    <el-card shadow="never" v-loading="loading">
      <message-search @search="reload"> </message-search>
      <!-- 数据表格 -->
      <ele-pro-table
        ref="table"
        :columns="columns"
        :datasource="datasource"
        cache-key="systemRoleTable"
      >
<!--        <template v-slot:code="{ row }">
          <el-link type="primary" :underline="false">
            {{ row.code }}
          </el-link>
        </template> -->
      </ele-pro-table>
    </el-card>

  </div>
</template>

<script>
  import MessageSearch from './components/message-search.vue';
  import { planConfigPage, removeRule } from '@/api/ruleManagement/plan';
  import dictMixins from '@/mixins/dictMixins';
  export default {
    mixins: [dictMixins],
    components: {
      MessageSearch
    },
    data () {
      return {
        // 表格列配置
        columns: [
          {
            columnKey: 'index',
            label: '序号',
            type: 'index',
            width: 55,
            align: 'center',
            showOverflowTooltip: true,
            fixed: 'left'
          },
          {
            prop: 'code',
            label: '告警级别',
            align: 'center',
            showOverflowTooltip: true,
            minWidth: 110,
            slot: 'code'
          },
          {
            prop: 'name',
            label: '告警设备分类',
            align: 'center',
            showOverflowTooltip: true,
            minWidth: 110
          },
          {
            prop: 'groupName',
            label: '设备编号',
            align: 'center',
            showOverflowTooltip: true,
            minWidth: 110
          },
          {
            prop: 'categoryName',
            label: '设备名称',
            align: 'center',
            showOverflowTooltip: true,
            minWidth: 110
          },
          {
            prop: 'ruleName',
            label: '告警内容',
            align: 'center',
            showOverflowTooltip: true,
            minWidth: 110
          },
          {
            prop: 'autoOrder',
            label: '告警方式',
            align: 'center',
            showOverflowTooltip: true,
            minWidth: 110,
            formatter: (_row, _column, cellValue) => {
              let autoOrder =
                _row.autoOrder == 1 ? '是' : _row.autoOrder == 0 ? '否' : '-';
              return autoOrder;
            }
          },
          {
            prop: 'createTime',
            label: '告警时间',
            align: 'center',
            showOverflowTooltip: true,
            minWidth: 110,
            formatter: (_row, _column, cellValue) => {
              return this.$util.toDateString(cellValue);
            }
          }
        ],
        // 加载状态
        loading: false,
      };
    },
    computed: {},
    created () {
      this.requestDict('规则状态');
    },
    methods: {
      /* 表格数据源 */
      datasource ({ page, limit, where, order }) {
        return planConfigPage({
          pageNum: page,
          size: limit,
          ...where,
          ruleType: 2
        });
      },

      /* 刷新表格 */
      reload (where) {
        this.$refs.table.reload({ page: 1, where, ruleType: 2 });
      }
    }
  };
</script>

<style lang="scss" scoped></style>
