<template>
  <div class="right_con">
    <div class="news_info_fgx fl"></div>
    <p class="date_earning fl">组员业绩总览</p>
    <Poptip word-wrap width="380" placement="bottom-start" trigger="hover" class="hover_contents" style="marign-top:3px">
          <div slot="content">
            <p><span>注册数：</span> 当日新注册玩家数，包含全部站点内的新用户</p>
            <p><span>独立注册IP：</span>当日新注册玩家数（排除重复注册IP）</p>
            <p><span>达标用户：</span>当日游戏角色达标用户数，含新老用户</p>
            <p><span>推广奖金：</span>当日得到的推广人数奖金</p>
            <p><span>充值用户：</span>当日游戏内消费过的玩家数，统计所有消费方式</p>
            <p><span>注：</span>数据每1小时更新1次，整点更新</p>
          </div>
          <img src="../../../static/image/why.png" alt class="title_why">
        </Poptip>
    <div class="fr mar_T_15">
      <div class="search">
        <Input v-model="search.name" placeholder="员工名称" class="wid_120 fl mar_L_5 mar_T_3"></Input>
        <Button type="primary" class="mar_L_5" @click="getDataEarning()">搜索</Button>
        <Button class="clear_btn" @click="removeSearch">清空</Button>
      </div>
    </div>
    <Table :columns="earningList" :data="earningData" border class="tables clear" ></Table>
  </div>
</template>
<script>
import { removeSearch } from "@/assets/js/common";
import { timeFormatter } from "@/utils/utils"
export default {
  name: "data_earning",
  data() {
    return {
      inputlist:[],
      allTeamList:[],
      search:{
        name:'',
        date:timeFormatter(new Date(),'{y}-{m}-{d}')
      },
      titlePlaceholder:'',
      earningList: [
        {
          title: "日期",
          render:(h,params)=>{
            let today=new Date()
            return h('span',today.getFullYear()+'-'+Number(today.getMonth()+1)+'-'+today.getDate())
          }
        },
        {
          title: "员工",
          key:'manager_name',
        },
        {
          title: "注册数",
          key:'register_num',
          sortable: true
        },
        {
          title: "独立IP数",
          key:'ip_num',
          sortable: true
        },
        {
          title: "充值人数",
          key:'recharge_count',
          sortable: true
        },
        {
          title: "充值统计",
          key:'recharge_pay_sum',
          sortable: true
        },
      ],
      earningData: []
    };
  },
  watch: {},
  methods: {
    getDataEarning(){
      this.$store.commit('changeloading',true)
      this.$api.getDataEarning({...this.search}).then(data=>{
        if(data.code==200){
            this.earningData=[]
            data.data.forEach((item,index) => {
             this.earningData.push({
               manager_name:item.manager_name,
               register_num:item.register_count||0,
               effective_reister:item.recharge_pay_sum||0,
               ip_num:item.register_ip_count||0,
               recharge_count:item.recharge_count||0,
               recharge_pay_sum:(item.recharge_pay_sum).toFixed(2) ||0.00,
             })
           });
           this.$store.commit('changeloading',false)
        }else{
          this.$Message.info(data.msg)
          this.$store.commit('changeloading',false)
        }
      })
    },
    removeSearch() {
      this.search = { ...removeSearch({ ...this.search }) };
    },
  },
  created() {
    this.getDataEarning()
  },
};
</script>
<style>
.date_earning{
  margin-top: 15px;
  font-size: 15px;
  margin-left: 5px
}
</style>


