<template>
  <div class="form-wrap">
    <el-form
      class="search-box"
      ref="form"
      :model="form"
      :inline="true"
      label-width="140px">
      <div class="block-title">
        查询条件
      </div>
      <el-form-item
        label="通道名称"
        prop="keyWords1">
        <el-input v-model="form.keyWords1"></el-input>
      </el-form-item>
      <el-form-item
        label="通道组名称"
        prop="keyWords2">
        <el-select v-model="form.keyWords2">
          <el-option
            label="全部"
            value="">
          </el-option>
          <el-option
            v-for="(item, index) in channelGroupList"
            :key="index"
            :label="item.name"
            :value="item.name"
          ></el-option>
        </el-select>
      </el-form-item>
      <el-form-item
        label="起始时间"
        prop="startDate">
        <el-date-picker
          v-model="form.startDate"
          type="datetime"
          placeholder="选择日期时间">
        </el-date-picker>
      </el-form-item>
      <el-form-item
        label="截止时间"
        prop="endDate">
        <el-date-picker
          default-time="23:59:59"
          v-model="form.endDate"
          type="datetime"
          placeholder="选择日期时间">
        </el-date-picker>
      </el-form-item>
      <div class="btn-wrap">
        <el-button
          @click="reset">
          重置
        </el-button>
        <el-button
          type="primary"
          @click="getList">
          搜索
        </el-button>
      </div>
    </el-form>

    <div class="table-box">
      <!-- <div class="block-title">
        统计信息
      </div> -->
      <el-table
        border
        stripe
        :data="tableData">
        <el-table-column
          type="index"
          width="50px"
          label="#">
        </el-table-column>
        <el-table-column
          prop="checker_channel_name"
          label="通道名称">
        </el-table-column>
        <el-table-column
          prop="checker_channel_group_name"
          label="通道组">
        </el-table-column>
        <el-table-column
          width="80"
          label="进"
          prop="sum_enter">
        </el-table-column>
        <el-table-column
          width="80"
          label="出"
          prop="sum_exit">
        </el-table-column>
      </el-table>
    </div>
  </div>
</template>

<script>
import { getCheckerChannelTrafficRecord, apiChannelGroup } from '@/api/checker'
import moment from 'moment'
export default {
  data () {
    return {
      channelGroupList: [],
      form: {
        'startDate': new Date(moment().startOf('day').format('YYYY-MM-DD HH:mm:ss')),
        'endDate': new Date(moment().endOf('day').format('YYYY-MM-DD HH:mm:ss')),
        'keyWords1': '', // 通道名称
        'keyWords2': '' // 通道组名称
      },
      tableData: [],
      total: 0
    }
  },
  created () {
    this.getChannelGroup()
    this.getList()
  },
  methods: {
    reset () {
      this.$refs.form.resetFields()
    },
    getChannelGroup () {
      apiChannelGroup('getCheckerChannelGroupList', { pageNum: 1, pageSize: 10000 }).then(res => {
        this.channelGroupList = res.list
      })
    },
    // 获取数据
    getList () {
      getCheckerChannelTrafficRecord(this.form).then(res => {
        this.total = res.total
        this.tableData = res.data
      })
    }
  }
}
</script>

<style scoped>

</style>
