<style>
  .CM_look{
      padding:4px!important;
      position: relative;
      top:1px;
  }
</style>
<template>
  <div class="flexOne">
    <!-- <div class="query-box">
      <ul>
        <li>
            <input type="button" class="normalBtn" @click="generateTable" value="生成提成报表"/>
        </li>
      </ul>
    </div> -->
    <table class="singeRowTable" border="0" cellspacing="0" cellpadding="0">
      <tr>
        <th>期数</th>
        <th>提成总金额</th>
        <th>{{$t('admin.admin_czPerson')}}</th>
        <th>日期</th>
        <th>{{$t('system.table_operation')}}</th>
      </tr>
      <tr v-for="item in dataList">
        <td>{{item.periods}}</td>
        <td>{{item.sumPrice}}</td>
        <td>{{item.createByStr}}</td>
        <td>{{item.createStr}}</td>
        <td>
          <!-- <el-tooltip class="item" effect="dark" content="取消" placement="top">
            <el-button type="danger" icon="el-icon-delete" circle></el-button>
          </el-tooltip> -->
          <el-tooltip class="item" effect="dark" content="查看" placement="top">
            <el-button type="primary" class="CM_look" @click="goUrl('CommissionDetail',item.id)" icon="iconfont icon-chakan" circle></el-button>
          </el-tooltip>
        </td>
      </tr>
    </table>
    <!-- 分页 -->
    <el-pagination background @current-change="handleCurrentChange" :current-page.sync="currentPage"
          layout="total,prev, pager, next, jumper" :page-size='msg.PageSize' :total='total'>
    </el-pagination>
  </div>
</template>

<script>
  export default {
    data() {
      return {
        msg: {
          PageIndex: 1,
          PageSize: 20
        },
        loading:false,
        //数据源
        dataList:[],
        total:0,
        currentPage: 1,
      }
    },
    mounted() {
      this.getList();
    },
    methods: {
      handleCurrentChange(val) {
        this.msg.PageIndex = val;
        this.getList();
      },
      goUrl(path,id) {
        this.$router.push({
          path: path,
          query: {
            ParentId:id,
            blank: 'y',
            tab: '报价详情'
          }
        });
      },
      //获取数据
      getList() {
        this.loading = true;
        this.apipost(
          "sellcommission_GetPageList",
          this.msg,
          res => {
            this.loading = false;
            if(res.data.resultCode==1){
              this.dataList = res.data.data.pageData;
              this.total = res.data.data.count;
            }else{
              this.Error(res.data.message);
            }
          },
          null
        );
      },
      //生成提成报表
      generateTable(){
       let msg = {
          UserId: 0
        }
        this.apipost(
            "sellcommission_SetGenerateCommission",msg,
            res => {
              if(res.data.resultCode==1){
                this.getList();
                this.Success('报表生成成功')
              }else{
                this.Error(res.data.message);
              }
            },
            null
          );
        }
    }
  }
</script>
