<template>
  <div v-loading="loading">
    <div class="white-box">
      <div class="leo-filter" v-loading="loading">
        <div :class="`filter-item filter-date-range-picker`">
          <el-input v-model="filterModel.userName" placeholder="请输入会员编号" @change="handleChkUser">
            <template slot="append">【{{realName}}】</template>
          </el-input>
        </div>
        <el-button class="filter-item filter-filter-btn" type="primary" @click="handleFilter">筛选</el-button>
      </div>
      <h3>当周实时新增业绩</h3>
      <el-table class="table-box" :data="weekData" stripe style="width: 100%;">
        <el-table-column label="个人业绩" prop="PV_PCS"></el-table-column>
        <el-table-column label="一市场业绩" prop="PV_1L"></el-table-column>
        <el-table-column label="二市场业绩" prop="PV_2L"></el-table-column>
        <el-table-column label="三市场业绩" prop="PV_3L"></el-table-column>
        <el-table-column label="团队业绩" prop="PV_PSS"></el-table-column>
      </el-table>
      <h3>当月实时新增业绩</h3>
      <el-table class="table-box" :data="monthData" stripe style="width: 100%;">
        <el-table-column label="个人业绩" prop="PV_PCS"></el-table-column>
        <el-table-column label="一市场业绩" prop="PV_1L"></el-table-column>
        <el-table-column label="二市场业绩" prop="PV_2L"></el-table-column>
        <el-table-column label="三市场业绩" prop="PV_3L"></el-table-column>
        <el-table-column label="团队业绩" prop="PV_PSS"></el-table-column>
      </el-table>
      <h3>上月累计业绩</h3>
      <el-table class="table-box" :data="lastData" stripe style="width: 100%;">
        <el-table-column label="个人业绩" prop="PV_PCS"></el-table-column>
        <el-table-column label="一市场业绩" prop="PV_1L"></el-table-column>
        <el-table-column label="二市场业绩" prop="PV_2L"></el-table-column>
        <el-table-column label="三市场业绩" prop="PV_3L"></el-table-column>
        <el-table-column label="团队业绩" prop="PV_PSS"></el-table-column>
        <el-table-column label="团队累计业绩" prop="PV_PSS_TOTAL"></el-table-column>
      </el-table>
    </div>
  </div>
</template>

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

  export default {
    name: 'bonus_real-time-perf',
    components: {},
    mounted() {
      this.loading = false
    },
    data() {
      return {
        filterModel: {
          userName: '',
        },
        realName: '-',
        weekData: null,
        monthData: null,
        lastData: null,
        loading: true,
        tool: tool,
        bigLocation: null,
      }
    },
    methods: {
      handleChkUser() {
        if (this.filterModel.userName) {
          this.loading = true
          network.getData('user/full-info', {userName: this.filterModel.userName}).then(response => {
            this.realName = response.REAL_NAME
            this.loading = false
          }).catch(response => {
            this.loading = false
          })
        }
      },
      chkBig(big, loc) {
        big = Number(big)
        loc = Number(loc)
        return (loc === big) ? 'text-danger' : ''
      },
      handleFilter() {
        if (this.filterModel.userName === '') {
          this.$message({
            message: '请填写会员编号',
            type: 'warning'
          })
          return false
        }
        this.getData()
      },
      getData() {
        let vueObj = this
        vueObj.loading = true
        network.getData('bonus/real-time-perf', {userName: vueObj.filterModel.userName}).then(response => {
          vueObj.weekData = response.weekData
          vueObj.monthData = response.monthData
          vueObj.lastData = response.lastData
          vueObj.bigLocation = response.bigLocation
          vueObj.loading = false
        }).catch(response => {
          vueObj.loading = false
        })
      },
    }
  }

</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;
    }
  }
</style>
