<style>
    .baseSet_Title {
      width: 120px !important;
      padding: 18px 0 0 16px;
      text-align: right;
    }
  
    .userCommissionDetails .border-bottom {
      /* border-bottom: 1px dashed #EEE; */
      padding-bottom: 5px;
      margin-bottom: 5px;
    }
  
    .userCommissionDetails .text-bottom {
      height: 32px;
      line-height: 32px;
      margin-bottom: 10px;
    }
  
    .userCommissionDetails ._icon_btn i.icon-sousuo {
      background-color: #47BF8C;
    }
  
    .userCommissionDetails ._icon_btn i {
      width: 30px;
      height: 30px;
      display: inline-block;
      color: white !important;
      border-radius: 50%;
      text-align: center;
      line-height: 30px;
      margin-right: 10px;
      cursor: pointer;
      outline: none;
    }
  
    .userCommissionDetails .el-table td,
    .el-table th {
      padding: 5px 0;
    }
  
  </style>
  <template>
    <div class="page-body userCommissionDetails">
      <div class="page-search row items-center">
        <div style="margin-right: 10px;">
          <q-btn color="primary"  size="11px"  label="返回"  @click="goreturn"  style="margin-left:10px" />
        </div>
        
    
      </div>
      <template>
        <el-table ref="filterTable" :data="tableData" v-loading='loading'
          :header-cell-style="{backgroundColor:'#f5f6f7', color: '#a8a8b3'}" border style="width: 100%">
          <el-table-column prop="SchoolName" width='150' label="校区"></el-table-column>
          <el-table-column prop="DeptName" label="部门"></el-table-column>
          <el-table-column prop="UserName" label="销售"> </el-table-column>
         
          <el-table-column prop="OrderId" label="订单号">
            <template slot-scope="scope">
              <div v-if="scope.row.OrderId" style="cursor: pointer;text-decoration: underline;" @click="goUrlorderList('/sale/orderStatistics',scope.row)">
                {{scope.row.OrderId}} 
              </div>
            </template>
          </el-table-column>
          <el-table-column  prop="ActivityName" label="活动名称"></el-table-column>
          <el-table-column  prop="ActivityTime" label="活动日期"></el-table-column>
          <el-table-column prop="DSUserName" label="报名用户" >
            <template slot-scope="scope">
              <div v-if="scope.row.DSUserName">
                {{scope.row.DSUserName}} <span>({{scope.row.DSUserId}})</span>
              </div>
            </template>
          </el-table-column>
          <el-table-column prop="CommissionMoney" label="提成金额" >
            <template slot-scope="scope">
                <div style="color: rgb(233, 82, 82);">{{scope.row.CommissionMoney}}</div>
              </template>
          </el-table-column>
          <el-table-column width='90' prop="Periods" label="期数"> </el-table-column>
          <el-table-column prop="Remark" width='160' label="备注"> </el-table-column>
        </el-table>
      </template>
  
    </div>
  </template>
  <script>
    import {
      GetClassTypePageList,
    } from '../../../api/system/index';
    import {
       getActivityCommissionForOrderList,
    } from '../../../api/finance/index'
    import {
      getClassDropDownList,
    } from "../../../api/school/index";
    export default {
      meta: {
        title: "订单活动提成明细"
      },
      props: {},
      components: {},
      data() {
        return {
          loading: false,
          //列表数据参数
          msg: {
            ActivityId: 0,
            OrderId:0,
          },
          pageCount: 0,
          persistent: false,
          listData: {},
          tableData: [],
          company: [],
          department: [],
          ClassList: [],
          allClassList: [],
        }
      },
      created() {},
      mounted() {
        if (this.$route.query && this.$route.query.ActivityId) {
          this.msg.ActivityId = this.$route.query.ActivityId
        }
        if (this.$route.query && this.$route.query.OrderId) {
          this.msg.OrderId = this.$route.query.OrderId
        }
        this.getList()
      },
      methods: {
  
        getList() {
          if (this.msg)
            this.loading = true;
            getActivityCommissionForOrderList(this.msg).then(res => {
            if (res.Code == 1) {
              this.loading = false;
              this.tableData = res.Data
              if (this.tableData.length > 0) {
                this.getAskfor()
  
              }
            }
          })
        },
        getAskfor() { //求值
          let obj = {
            SchoolName: '合计',
            CommissionMoney: 0,
          }
          this.tableData.forEach((x) => {
            if (x.CommissionMoney) {
              obj.CommissionMoney = this.accAdd(x.CommissionMoney, obj.CommissionMoney)
            };
           
  
          })
          this.tableData.push(obj)
  
        },
        accAdd(arg1, arg2) { //js 加法精确计算
          var r1, r2, m;
          try {
            r1 = arg1.toString().split(".")[1].length;
  
          } catch (e) {
            r1 = 0;
          }
  
          try {
            r2 = arg2.toString().split(".")[1].length;
  
          } catch (e) {
            r2 = 0;
  
          }
          m = Math.pow(10, Math.max(r1, r2));
          return (arg1 * m + arg2 * m) / m;
  
        },
       
        goreturn() {
          this.$router.go(-1);
        },
        goUrlorderList(path,row){//订单跳转
          this.OpenNewUrl('/sale/activeOrderStatistics', {
            OrderId: row.OrderId,
            // EnterID:row.UserId
          });
        },
      },
    }
  </script>
  <style lang="sass">
    @import url('~assets/css/table.sass')
  
  </style>
  