<template>
  <div class="app-container">
      <div class="app-content">
        <div class="title" style="display: flex; justify-content: center; align-items: center;">推广员佣金统计</div>
        <el-form class="search-form" :inline="true" label-width="90px">
                <el-form-item   label="统计">
                  <el-select v-model="queryParams.type" placeholder="请选择日期" size="small">
                    <el-option
                      v-for="item in options"
                      :key="item.value"
                      :label="item.label"
                      :value="item.value">
                    </el-option>
                  </el-select>
                </el-form-item>
                <el-form-item>
                   <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
                   <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
                </el-form-item>
              </el-form>
              </div>
              <el-button class="export" size="small"  @click="handleExport" style="float: right; margin-bottom: 15px; margin-right: 40px;" >导出</el-button>
              <div class="table-box" style="margin-left: 40px; margin-right: 40px;">
                <el-table
                :data="list"
                border
                show-summary
                style="width: 100%;" class="centered-table">

                <el-table-column
                  prop="nickname"
                  label="昵称">
                </el-table-column>
               <el-table-column
                 prop="phone"
                 label="手机号">
               </el-table-column>
                <el-table-column
                  prop="tuiMoney"
                  label="金额">
                </el-table-column>


              </el-table>
          </div>
  </div>
</template>

<script>
import { userTuiMoney,exportUserTuiMoney } from "@/api/company/statistics";
export default {
  data() {
    return {
      exportLoading: false,
      queryParams:{
        type: "9",
        storeId: null,
      },
      options: [{
         value: '1',
         label: '今天'
       }, {
         value: '2',
         label: '昨天'
       }, {
         value: '3',
         label: '本周'
       }, {
         value: '4',
         label: '上周'
       }, {
         value: '5',
         label: '本月'
       }
       , {
         value: '6',
         label: '上月'
       },
       {
         value: '7',
         label: '本季度'
       },
       {
         value: '8',
         label: '上季度'
       }
       , {
         value: '9',
         label: '本年'
       }
       , {
         value: '10',
         label: '去年'
       }],
      list:[],
      storeOPtions:[],
      chart: null,
      data: [
      ],
    };
  },
  created() {
    userTuiMoney(this.queryParams).then(response => {
      this.list = response.list;
    });
  },

  methods: {

 /** 导出按钮操作 */
    handleExport() {
      const queryParams = this.queryParams;
      this.$confirm('是否确认导出所有数据?', "警告", {
          confirmButtonText: "确定",
          cancelButtonText: "取消",
          type: "warning"
        }).then(() => {
            this.exportLoading = true;
          return exportUserTuiMoney(queryParams);
        }).then(response => {
          this.download(response.msg);
          this.exportLoading = false;
        }).catch(() => {});
    },

    handleQuery(){
      userTuiMoney(this.queryParams).then(response => {
        this.list = response.list;
      });
    },
 /** 重置按钮操作 */
    resetQuery() {
     this.queryParams={
       type: null,
       storeId: null,
     }
     this.getorderChartData()
    },

  },
};
</script>
<style>
  .title{
    padding: 20px 30px 0px 30px;
    font-size: 18px;
    font-weight: bold;
    color: black;

  }
  .search-form{
    margin: 20px 30px 0px 30px;
  }
  .echart-box{
    margin: 0 auto;
    text-align: center;
  }
  .el-select{
    margin: 5px 10px;
  }
  .table-box{
    margin-top: 15px;
    .export{
      float: right;
      margin: 10px 0px;
    }
  }
.app-container{
    border: 1px solid #e6e6e6;
    padding: 12px;


}
 .app-content{
      background-color: white;



    }
    .data-box{
      padding: 30px;
      background-color:  rgb(255, 255, 255);
      height: 100%;


    }


    .centered-table .cell {
      text-align: center;
    }
</style>
