<template>
  <div class="app-container">
    <div class="filter-container">

      <el-input v-model="search.keyWord" placeholder="关键字" style="width: 200px;" class="filter-item" />
      <el-date-picker
        v-model="searchTime"
        type="daterange"
        range-separator="-"
        start-placeholder="开始日期"
        end-placeholder="结束日期"
        value-format="yyyy-MM-dd HH:mm:ss"
        :default-time="['00:00:00', '23:59:59']">
      </el-date-picker>
      <el-button class="filter-item" type="primary" icon="el-icon-search" @click="searchData">
        搜索
      </el-button>
      <div class="top-right-btn">
        <el-tooltip class="item" effect="dark" content="刷新" placement="top">
          <el-button size="mini" circle icon="el-icon-refresh" @click="getList" />
        </el-tooltip>
      </div>
    </div>
    <el-table
      :data="tableData"
      v-loading="listLoading"
      style="width: 100%;margin-bottom: 20px;"
      row-key="id"
      show-summary
      sum-text=" "
      border
      default-expand-all>
      <template v-for="(column,index) in columns">
        <el-table-column
          v-if="column.visible"
          :key="index"
        :prop="column.field"
        :label="column.label"
          :align="column.childs.length>0?'center':'left'"
        >
          <template v-for="(columnChild, childIndex) in column.childs">
            <el-table-column
              v-if="column.visible"
              :key="childIndex"
              :prop="columnChild.field"
              :label="columnChild.label"></el-table-column>
          </template>
        </el-table-column>
      </template>
    </el-table>
  </div>
</template>

<script>
import {getPCountProcessStatistics} from "@/api/specialEdition/processStatistics";

export default {
  name: 'ProcessStatistics',
  data() {
    return {
      listLoading: false,
      search: {
        keyWord: '',
        beginTime: '',
        endTime: ''
      },
      searchTime: [],
      tableData: [],
      columns: []
    }
  },
  created() {
    this.getList()
  },
  methods: {
    getList() {
      const _that = this
      if (_that.searchTime == null || _that.searchTime < 0) {
        _that.search.beginTime = ''
        _that.search.endTime = ''
      } else {
        _that.search.beginTime = _that.searchTime[0]
        _that.search.endTime = _that.searchTime[1]
      }
      var params = _that.search
      var data = {
        'params': JSON.stringify(params),
      }
      getPCountProcessStatistics(data).then(res => {
        console.log(res)
        if (res.httpCode == 200) {
          _that.tableData = res.data.processDatas
          _that.columns = res.data.columns
        }
      })
    },

    // 搜索
    searchData() {
      this.getList()
    },
  }
}
</script>

<style lang="scss" scoped>
.app-container{
::v-deep .el-table__footer-wrapper tbody td{
    background-color: #d0d2d6;
  }
}
</style>
