<template>
  <div v-loading="loading">
    <div class="white-box">
      <div class="leo-filter" v-loading="loading">
        <div :class="`filter-item`">
          <el-select v-model="periodNum" placeholder="请选择日期">
            <el-option v-for="(item,key) in periodNums" :label="`${tool.formatDate(item.END_TIME,false)}`" :value="item.PERIOD_NUM" :key="key"></el-option>
          </el-select>
        </div>
        <el-button class="filter-item filter-filter-btn" type="primary" @click="handleFilter">筛选</el-button>
      </div>
      <el-table class="table-box" ref="multipleTable" :data="tableData" stripe show-summary style="width: 100%;">
        <el-table-column label="补助类型" prop="BT_TYPE_NAME" width="110"></el-table-column>
        <el-table-column label="订单编号" width="150">
          <template slot-scope="scope">
            {{scope.row.FROM_ORDER_SN}}
          </template>
        </el-table-column>
        <el-table-column label="订货时间" width="200">
          <template slot-scope="scope">
            {{tool.formatDate(scope.row.ORDER_TIME)}}
          </template>
        </el-table-column>
        <el-table-column label="订货积分">
          <template slot-scope="scope">
            {{scope.row.PAY_PV}}
          </template>
        </el-table-column>
        <el-table-column label="发货时间" width="200">
          <template slot-scope="scope">
            {{tool.formatDate(scope.row.DELIVERY_AT)}}
          </template>
        </el-table-column>
        <el-table-column label="转账金额">
          <template slot-scope="scope">
            {{scope.row.TRANSFER_AMOUNT}}
          </template>
        </el-table-column>
        <el-table-column label="转账时间" width="200">
          <template slot-scope="scope">
            {{tool.formatDate(scope.row.TRANSFER_AT)}}
          </template>
        </el-table-column>
        <el-table-column label="店补金额" prop="AMOUNT"></el-table-column>
      </el-table>
      <div class="white-box-footer">
        <pagination :total="totalCount" :page_size="pageSize" @size-change="handleSizeChange" @current-change="handleCurrentChange"></pagination>
      </div>
    </div>
  </div>
</template>

<script>
  import network from '@/utils/network'
  import tool from '@/utils/tool'
  import Pagination from '@/components/Pagination'

  export default {
    name: 'bonus_flow-bt',
    components: {Pagination},
    mounted() {
      this.loading = false
      this.getPeriodNum()
    },
    data() {
      return {
        tableData: [],
        loading: true,
        multipleSelection: [],
        currentPage: 1,
        totalPages: 1,
        totalCount: 1,
        pageSize: 20,
        tool: tool,
        filterData: null,
        filterStatus: 'ALL',
        periodNum: null,
        periodNums: null,
        allType:{ORDER:'订货店补',TRANS:'转账店补',PROD:'产品补贴',TOOL:'工具流补贴'}
      }
    },
    methods: {
      getPeriodNum(){
        let vueObj = this
        vueObj.loading = true
        network.getData('bonus/dec-period').then(response => {
          vueObj.periodNums = response
          vueObj.loading = false
        }).catch(response => {
          vueObj.loading = false
        })
      },
      getBtTypeName(type){
        console.log(type)
        return this.allType[type]
      },
      handleFilterStatusClick(tab, event) {
        this.filterData.filterStatus =this.filterStatus!=='ALL'?this.filterStatus:null
        this.getData()
      },
      handleCurrentChange(page) {
        this.getData(page, this.pageSize)
      },
      handleSizeChange(pageSize) {
        this.getData(this.currentPage, pageSize)
      },
      handleFilter() {
        this.getData(1, this.pageSize)
      },
      getData(page, pageSize) {
        let vueObj = this
        network.getPageData(this, 'bonus/flow-bt', page, pageSize, {periodNum:vueObj.periodNum}, function (response) {
          vueObj.tableData = response.list
        })
      },
    }
  }

</script>

<style scoped>
  .leo-filter {
    padding: 0 0 15px 0;
  }

  .leo-filter .filter-hidden {
    display: none;
  }

  .filter-item {
    margin-right: 10px;
  }

  @media (min-width: 768px) {
    .leo-filter {
    }

    .leo-filter .filter-item {
      display: inline-block;
      max-width: 200px;
    }

    .leo-filter .filter-item.filter-date-month-picker {
      display: inline-block;
      max-width: 220px;
    }

    .leo-filter .filter-item.filter-date-range-picker {
      display: inline-block;
      max-width: 380px;
    }

    .leo-filter .filter-item.filter-filter-btn {
      height: 38px;
      width: 80px;
    }

    .leo-filter .filter-hidden {
      display: none;
    }
  }

  .table-box .el-form-item__label {
    width: 100px;
    color: #99a9bf;
  }

  .table-box .el-form-item {
    width: 30%;
    margin-right: 0;
    margin-bottom: 0;
  }
</style>