<template>
  <div v-loading="loading">
    <div class="white-box">
      <leo-filter
        :filter="handleFilter"
        :dateRangePickerDisplay="false"
        :userNameDisplay="true"
      ></leo-filter>
      <el-table class="table-box" ref="multipleTable" :data="tableData" stripe style="width: 100%;"
                @row-click="handleExpand" :height="tool.getTableHeight()">
        <el-table-column type="expand">
          <template slot-scope="scope">
            <el-form label-position="left" inline class="demo-table-expand">
              <el-form-item label="区域津贴">
                <span>{{tool.formatPrice(scope.row.BONUS_QY)}}</span>
              </el-form-item>
              <el-form-item label="育成津贴">
                <span>{{tool.formatPrice(scope.row.BONUS_YC)}}</span>
              </el-form-item>
              <el-form-item label="复销奖">
                <span>{{tool.formatPrice(scope.row.BONUS_FX)}}</span>
              </el-form-item>
              <el-form-item label="零售奖">
                <span>{{tool.formatPrice(scope.row.BONUS_LS)}}</span>
              </el-form-item>
              <el-form-item label="车房补贴">
                <span>{{tool.formatPrice(scope.row.BONUS_CF)}}</span>
              </el-form-item>
              <el-form-item label="领袖分红">
                <span>{{tool.formatPrice(scope.row.BONUS_LX)}}</span>
              </el-form-item>
              <el-form-item label="返利">
                <span>{{tool.formatPrice(scope.row.BONUS_FL)}}</span>
              </el-form-item>
              <el-form-item label="补贴">
                <span>{{tool.formatPrice(scope.row.BONUS_BT)}}</span>
              </el-form-item>
              <el-form-item label="健康管理服务费">
                <span>{{tool.formatPrice(scope.row.BONUS_FW)}}</span>
              </el-form-item>
              <el-form-item label="货补">
                <span>{{tool.formatPrice(scope.row.ADD_HB)}}</span>
              </el-form-item>
              <el-form-item label="责任扣除">
                <span>{{tool.formatPrice(scope.row.DEDUCT_ZR)}}</span>
              </el-form-item>
            </el-form>
          </template>
        </el-table-column>
        <el-table-column label="会员编号" prop="USER_NAME"></el-table-column>
        <el-table-column label="期数" prop="PERIOD_NUM"></el-table-column>
        <el-table-column label="是否发放">
          <template slot-scope="scope">
            <span v-if="scope.row.IS_SENT === '1'">是</span>
            <span v-else>否</span>
          </template>
        </el-table-column>
        <el-table-column label="结算时间" width="200">
          <template slot-scope="scope">
            {{tool.formatDate(scope.row.CALCULATED_AT)}}
          </template>
        </el-table-column>
        <el-table-column label="发放时间" width="200">
          <template slot-scope="scope">
            {{tool.formatDate(scope.row.SENT_AT)}}
          </template>
        </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 Vue from 'vue'
import network from '@/utils/network'
import tool from '@/utils/tool'
import LeoFilter from '@/components/Filter'
import Pagination from '@/components/Pagination'

export default {
  name: 'bonus_period-detail',
  components: {LeoFilter,Pagination},
  mounted () {
    this.getData()
  },
  data () {
    return {
      tableData: null,
      loading: true,
      multipleSelection: [],
      currentPage: 1,
      totalPages: 1,
      totalCount: 1,
      pageSize: 20,
      tool: tool,
      filterData: null,
    }
  },
  methods: {
    handleExpand (row, event, column) {
      this.$refs.multipleTable.toggleRowExpansion(row)
    },
    handleCurrentChange (page) {
      this.getData(page, this.pageSize)
    },
    handleSizeChange (pageSize) {
      this.getData(this.currentPage, pageSize)
    },
    handleFilter (model) {
      this.filterData = model
      this.getData(1, this.pageSize)
    },
    getData (page, pageSize) {
      let vueObj = this
      network.getPageData(this, `bonus/period-detail/${this.$route.params.periodNum}`, page, pageSize, this.filterData, function (response) {
        vueObj.tableData = response.list
      })
    },
  }
}

</script>

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

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