<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="goUrlZD(195)" value="签证制单"/>
            <input type="button" class="normalBtn" @click="goUrlZD(196)" value="地接制单"/>
        </li>
      </ul>
    </div> -->
    <table class="singeRowTable" border="0" cellspacing="0" cellpadding="0" v-loading="loading">
      <tr>
        <th>期数</th>
        <th>提成总金额</th>
        <th>{{$t('admin.admin_czPerson')}}</th>
        <th>日期</th>
        <th>{{$t('system.table_operation')}}</th>
      </tr>
      <tr v-for="(item,index) in dataList" :key="index">
        <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 @click="YijianZD(item)" type="danger" class="CM_look" icon="iconfont icon-mui-icon-add" circle></el-button>
          </el-tooltip>
          <el-tooltip class="item" effect="dark" content="手动制单" placement="top">
            <el-button type="primary" class="CM_look" @click="goUrlZD" icon="iconfont icon-danju1" circle></el-button>
          </el-tooltip>    
          <el-tooltip class="item" effect="dark" content="查看" placement="top">
            <el-button type="primary" class="CM_look" @click="goUrl('DjCommissionDetail',item.ID)" icon="iconfont icon-chakan" circle></el-button>
          </el-tooltip>
        </td>
      </tr>
      <tr v-if="dataList.length==0">
        <td colspan="5" align="center">暂无数据</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: {
      goUrlZD(){
        let orderObj = {
          OrderID: 0,
          OrderSource: 8,
          Obj: {},
          SourceID: 0,
          CostType: 112,
          SelectState:true,
        }
        let id=[29,31];
        this.$router.push({
            name: 'ChoiceAddFinancialDocuments',
            query: {
              Type: 2,
              templateID: JSON.stringify(id),
              'blank': 'y',
              'orderObj': JSON.stringify(orderObj)
            }
          })
      },
      YijianZD(item){
        this.$confirm('提成金额是否正确?', '提示', {
          confirmButtonText: '确定',
          cancelButtonText: '取消',
          type: 'warning'
        }).then(() => {
          this.loading=true;
          this.apipost(
            "Financial_post_SetDiJieCommissionBetchImport",
            {PeriodsId:item.ID},
            res => {
              if(res.data.resultCode==1){
                this.Success(res.data.message)
                this.getList();
              }else{
                this.loading=false;
                this.Error(res.data.message)
              }
            },
            null
          );
        }).catch(() => {
          
        });
      },
      // goUrlZD(num){
      //   let orderObj = {
      //     OrderID: 0,
      //     OrderSource: 8,
      //     Obj: {},
      //     SourceID: 0,
      //     CostType: num,
      //     SelectState:true,
      //   }
      //   let id=[29,31];
      //   this.$router.push({
      //       name: 'ChoiceAddFinancialDocuments',
      //       query: {
      //         Type: 2,
      //         templateID: JSON.stringify(id),
      //         'blank': 'y',
      //         'orderObj': JSON.stringify(orderObj)
      //       }
      //     })
      // },
      handleCurrentChange(val) {
        this.msg.PageIndex = val;
        this.getList();
      },
      goUrl(path,id) {
        this.$router.push({
          path: path,
          query: {
            ID:id,
            blank: 'y',
            tab: '详情'
          }
        });
      },
      //获取数据
      getList() {
        this.loading = true;
        this.apipost(
          "OPCommission_GetPeriodsPageList",
          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>