<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>
      <el-table class="table-box" :data="ycPerfList" stripe style="width: 100%;">
        <el-table-column label="用户名" prop="USER_NAME"></el-table-column>
        <el-table-column label="真实姓名" prop="REAL_NAME"></el-table-column>
        <el-table-column label="个人累计业绩" prop="PV_PCS"></el-table-column>
        <el-table-column label="团队总业绩" prop="PV_PSS_TOTAL"></el-table-column>
        <el-table-column label="最大部门累计业绩" prop="MAX_DEPART_PERF"></el-table-column>
        <el-table-column label="去最大部门累计业绩" prop="OTHER_DEPART_PERF"></el-table-column>
        <el-table-column label="个人和团队总业绩" prop="PV_PSS_SUM_TOTAL"></el-table-column>
      </el-table>
    </div>
  </div>
</template>

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

  export default {
    name: 'bonus_yc-perf',
    components: {},
    mounted() {
      this.loading = false
    },
    data() {
      return {
        filterModel: {
          userName: '',
        },
        realName: '-',
        ycPerfList: null,
        loading: true,
        tool: tool,
      }
    },
    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
          })
        }
      },
      handleFilter() {
        if (this.filterModel.userName === '') {
          this.$message({
            message: '请填写会员编号',
            type: 'warning'
          })
          return false
        }
        this.getData()
      },
      getData() {
        let vueObj = this
        vueObj.loading = true
        network.getData('bonus/yc-perf', {userName: vueObj.filterModel.userName}).then(response => {
          vueObj.ycPerfList = response.ycPerfList
          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>
