<template>
  <a-card :bordered="false">
    <!-- 查询区域 -->
    <div class="table-page-search-wrapper">
      <a-form layout="inline" @keyup.enter.native="searchQuery">
        <a-row :gutter="24">
          <a-col :md="8" :sm="24">
            <a-form-item label="事件类别">
              <a-select v-model="queryParam.eventCategory" placeholder="请选择" default-value="VSS">
                <a-select-option value="VSS">VSS</a-select-option>
                <a-select-option value="EPS">EPS</a-select-option>
              </a-select>
            </a-form-item>
          </a-col>
        </a-row>
      </a-form>

    </div>
    <!-- 查询区域-END -->

    <!-- 操作按钮区域 -->
    <span style="float: left;overflow: hidden;" class="table-page-search-submitButtons">
               <a-col :md="6" :sm="24">
                  <a-button type="primary" @click="searchQuery">查询</a-button>
               </a-col>
            </span>
    <!--    <div class="table-operator">-->
    <!--&lt;!&ndash;      <a-button @click="handleAdd" type="primary" icon="plus">新增</a-button>&ndash;&gt;-->
    <!--&lt;!&ndash;      <a-button type="primary" icon="download" @click="handleExportXls('pm_event_info')">导出</a-button>&ndash;&gt;-->
    <!--&lt;!&ndash;      <a-upload name="file" :showUploadList="false" :multiple="false" :headers="tokenHeader" :action="importExcelUrl" @change="handleImportExcel">&ndash;&gt;-->
    <!--&lt;!&ndash;&lt;!&ndash;        <a-button type="primary" icon="import">导入</a-button>&ndash;&gt;&ndash;&gt;-->
    <!--&lt;!&ndash;      </a-upload>&ndash;&gt;-->
    <!--      &lt;!&ndash; 高级查询区域 &ndash;&gt;-->
    <!--&lt;!&ndash;      <j-super-query :fieldList="superFieldList" ref="superQueryModal" @handleSuperQuery="handleSuperQuery"></j-super-query>&ndash;&gt;-->
    <!--&lt;!&ndash;              <a-button style="margin-left: 8px"> 批量操作 <a-icon type="down" /></a-button>&ndash;&gt;-->
    <!--            <a-button @click="handleAdd" type="primary" icon="plus">新增</a-button>-->


    <!--      &lt;!&ndash;      <a-dropdown v-if="selectedRowKeys.length > 0">&ndash;&gt;-->
    <!--&lt;!&ndash;        <a-menu slot="overlay">&ndash;&gt;-->
    <!--          <a-menu-item key="1" @click="batchDel"><a-icon type="delete"/>删除</a-menu-item>-->
    <!--&lt;!&ndash;        </a-menu>&ndash;&gt;-->
    <!--&lt;!&ndash;        <a-button style="margin-left: 8px"> 批量操作 <a-icon type="down" /></a-button>&ndash;&gt;-->
    <!--&lt;!&ndash;      </a-dropdown>&ndash;&gt;-->
    <!--    </div>-->

    <!-- table区域-begin -->
    <!--    <div>-->
    <!--      <div class="ant-alert ant-alert-info" style="margin-bottom: 16px;">-->
    <!--        <i class="anticon anticon-info-circle ant-alert-icon"></i> 已选择 <a style="font-weight: 600">{{ selectedRowKeys.length }}</a>项-->
    <!--        <a style="margin-left: 24px" @click="onClearSelected">清空</a>-->
    <!--      </div>-->

    <a-table
      ref="table"
      size="middle"
      :scroll="{x:true}"
      bordered
      rowKey="id"
      :columns="columns"
      :dataSource="dataSource"
      :pagination="ipagination"
      :loading="loading"
      :rowSelection="{selectedRowKeys: selectedRowKeys, onChange: onSelectChange}"
      class="j-table-force-nowrap"
      @change="handleTableChange">

      <template slot="htmlSlot" slot-scope="text">
        <div v-html="text"></div>
      </template>
      <template slot="imgSlot" slot-scope="text">
        <span v-if="!text" style="font-size: 12px;font-style: italic;">无图片</span>
        <img v-else :src="getImgView(text)" height="25px" alt=""
             style="max-width:80px;font-size: 12px;font-style: italic;"/>
      </template>
      <template slot="fileSlot" slot-scope="text">
        <span v-if="!text" style="font-size: 12px;font-style: italic;">无文件</span>
        <a-button
          v-else
          :ghost="true"
          type="primary"
          icon="download"
          size="small"
          @click="downloadFile(text)">
          下载
        </a-button>
      </template>

      <!--        <span slot="action" slot-scope="text, record">-->
      <!--          <a @click="handleEdit(record)">编辑</a>-->

      <!--          <a-divider type="vertical" />-->
      <!--          <a-dropdown>-->
      <!--            <a class="ant-dropdown-link">更多 <a-icon type="down" /></a>-->
      <!--            <a-menu slot="overlay">-->
      <!--              <a-menu-item>-->
      <!--                <a @click="handleDetail(record)">详情</a>-->
      <!--              </a-menu-item>-->
      <!--              <a-menu-item>-->
      <!--                <a-popconfirm title="确定删除吗?" @confirm="() => handleDelete(record.id)">-->
      <!--                  <a>删除</a>-->
      <!--                </a-popconfirm>-->
      <!--              </a-menu-item>-->
      <!--            </a-menu>-->
      <!--          </a-dropdown>-->
      <!--        </span>-->

    </a-table>
    <!--    </div>-->

    <pm-event-info-modal ref="modalForm" @ok="modalFormOk"></pm-event-info-modal>
  </a-card>
</template>

<script>

import '@/assets/less/TableExpand.less'
import {mixinDevice} from '@/utils/mixin'
import {JeecgListMixin} from '@/mixins/JeecgListMixin'
import PmEventInfoModal from './modules/PmEventInfoModal'

export default {
  name: 'PmEventInfoList',
  mixins: [JeecgListMixin, mixinDevice],
  components: {
    PmEventInfoModal
  },
  data() {
    return {
      description: 'pm_event_info管理页面',
      // 表头
      columns: [
        // {
        //   title: '#',
        //   dataIndex: '',
        //   key:'rowIndex',
        //   width:60,
        //   align:"center",
        //   customRender:function (t,r,index) {
        //     return parseInt(index)+1;
        //   }
        // },
        {
          title: '类别',
          align: "center",
          dataIndex: 'eventCategory'
        },
        {
          title: '源名称',
          align: "center",
          dataIndex: 'sourceName'
        },
        {
          title: '日志ID',
          align: "center",
          dataIndex: 'logId'
        },
        {
          title: '状态',
          align: "center",
          dataIndex: 'eventState'
        },
        {
          title: '等级',
          align: "center",
          dataIndex: 'eventLevel'
        },
        {
          title: '控制中心编号',
          align: "center",
          dataIndex: 'unitIdx'
        },
        {
          title: '类型',
          align: "center",
          dataIndex: 'eventType'
        },
        {
          title: '类型名称',
          align: "center",
          dataIndex: 'eventTypeName'
        },
        // {
        //   title:'事件所属子系统类型."废弃，事件整改，没有子系统属性"',
        //   align:"center",
        //   dataIndex: 'subSysType'
        // },
        {
          title: '名称',
          align: "center",
          dataIndex: 'eventName'
        },
        {
          title: '开始时间',
          align: "center",
          dataIndex: 'startTime',
          customRender: function (text) {
            return !text ? "" : (text.length > 10 ? text.substr(0, 20) : text)
          }
        },
        {
          title: '结束时间',
          align: "center",
          dataIndex: 'stopTime',
          customRender: function (text) {
            return !text ? "" : (text.length > 10 ? text.substr(0, 20) : text)
          }
        },
        {
          title: '源编号',
          align: "center",
          dataIndex: 'sourceIdx'
        },
        {
          title: '源类型',
          align: "center",
          dataIndex: 'sourceType'
        },
        {
          title: '描述信息',
          align: "center",
          dataIndex: 'logTxt'
        },
        {
          title: '区域编号',
          align: "center",
          dataIndex: 'regionIdx'
        },

        // {
        //   title:'事件拓展信息:各个子系统根据子系统的消息结构体定义解析,下文主要介绍事件中此字段含义',
        //   align:"center",
        //   dataIndex: 'extInfo'
        // },
        // {
        //   title:'事件处理结果:当 event_state 为更新时使用',
        //   align:"center",
        //   dataIndex: 'rsltMsg'
        // },
        // {
        //   title:'联动信息:目前包含客户端联动、预案',
        //   align:"center",
        //   dataIndex: 'trigInfo'
        // },
        // {
        //   title: '操作',
        //   dataIndex: 'action',
        //   align:"center",
        //   fixed:"right",
        //   width:147,
        //   scopedSlots: { customRender: 'action' }
        // }
      ],
      url: {
        list: "/pm/pmEventInfo/list",
        delete: "/pm/pmEventInfo/delete",
        deleteBatch: "/pm/pmEventInfo/deleteBatch",
        exportXlsUrl: "/pm/pmEventInfo/exportXls",
        importExcelUrl: "pm/pmEventInfo/importExcel",

      },
      dictOptions: {},
      superFieldList: [],
    }
  },
  created() {
    this.getSuperFieldList();
  },
  computed: {
    importExcelUrl: function () {
      return `${window._CONFIG['domianURL']}/${this.url.importExcelUrl}`;
    },
  },
  methods: {
    initDictConfig() {
    },
    getSuperFieldList() {
      let fieldList = [];
      fieldList.push({type: 'string', value: 'logId', text: '唯一标识一次发生的事件'})
      fieldList.push({type: 'string', value: 'eventCategory', text: '事件类别'})
      fieldList.push({
        type: 'int',
        value: 'eventState',
        text: '0：瞬时事件，保存；1：事件开始，保存；2：事件结束，更新结束时间； 3：事件脉冲，客户端和服务器使用，CMS 不用；4：事件更新，联动结果更新'
      })
      fieldList.push({type: 'int', value: 'eventLevel', text: '0：普通事件；1：低级报警；2：中级报警；3：高级报警'})
      fieldList.push({type: 'string', value: 'unitIdx', text: '控制中心编号'})
      fieldList.push({type: 'int', value: 'eventType', text: '事件类型'})
      fieldList.push({type: 'string', value: 'eventTypeName', text: '事件类型名称'})
      fieldList.push({type: 'int', value: 'subSysType', text: '事件所属子系统类型."废弃，事件整改，没有子系统属性"'})
      fieldList.push({type: 'string', value: 'eventName', text: '事件名称'})
      fieldList.push({type: 'string', value: 'startTime', text: '事件开始时间'})
      fieldList.push({type: 'string', value: 'stopTime', text: '事件结束时间'})
      fieldList.push({type: 'string', value: 'sourceIdx', text: '事件源编号'})
      fieldList.push({type: 'int', value: 'sourceType', text: '事件源类型'})
      fieldList.push({type: 'string', value: 'sourceName', text: '事件源名称'})
      fieldList.push({type: 'string', value: 'logTxt', text: '事件描述信息'})
      fieldList.push({type: 'string', value: 'regionIdx', text: '事件源区域编号'})
      fieldList.push({type: 'string', value: 'extInfo', text: '事件拓展信息:各个子系统根据子系统的消息结构体定义解析,下文主要介绍事件中此字段含义'})
      fieldList.push({type: 'string', value: 'rsltMsg', text: '事件处理结果:当 event_state 为更新时使用'})
      fieldList.push({type: 'string', value: 'trigInfo', text: '联动信息:目前包含客户端联动、预案'})
      this.superFieldList = fieldList
    }
  }
}
</script>
<style scoped>
@import '~@assets/less/common.less';
</style>