<style>
  .baseSet_Title {
    width: 120px !important;
    padding: 18px 0 0 16px;
    text-align: right;
  }

  .cycleOrderList .border-bottom {
    /* border-bottom: 1px dashed #EEE; */
    padding-bottom: 5px;
    margin-bottom: 5px;
  }

  .cycleOrderList .text-bottom {
    height: 32px;
    line-height: 32px;
    margin-bottom: 10px;
  }

  .cycleOrderList ._icon_btn i.icon-sousuo {
    background-color: #47BF8C;
  }

  .cycleOrderList ._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;
  }

  .cycleOrderList .el-table td,
  .el-table th {
    padding: 5px 0;
  }

</style>
<template>
  <div class="page-body cycleOrderList">
    <div class="page-search row items-center">
      <div class="col row wrap q-mr-lg q-col-gutter-md">
        <div class="col-3">
          <q-btn  color="primary"  size="11px"  label="返回"  @click="goreturn"  style="margin-left:10px" />
        </div>
      </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" label="校区" :filters='SchoolNamelist' :filter-method="filterHandler">
        </el-table-column>
        <el-table-column prop="DeptName" label="部门" :filters='DeptNamelist' :filter-method="filterHandler">
        </el-table-column>
        <el-table-column prop="UserName" label="销售" :filters='UserNamelist' :filter-method="filterHandler">
        </el-table-column>
        <el-table-column width='170' prop="ClassName" label="班级信息">
          <template slot-scope="scope">
            <div>{{scope.row.ClassName}} {{scope.row.ClassTypeName}}<span style="color: #409EFF;"
                v-if='scope.row.IsContinueClass==1'>(续)</span></div>
            <div>学生数量:{{scope.row.StudentCount}}人</div>
          </template>
        </el-table-column>
        <el-table-column prop="OrderId" label="订单号">
          <template slot-scope="scope">
            <div style="cursor: pointer;">{{scope.row.OrderId}} </div>

          </template>
        </el-table-column>
        <el-table-column width='130' prop="TotalCommissionMoney" label="订单发放信息">
          <template slot-scope="scope">
            <div style="color: rgb(255, 156, 0);">应发:{{scope.row.TotalCommissionMoney}}</div>
            <div>额外奖励:{{scope.row.OtherMoney}}</div>
            <div>额外扣除:{{scope.row.BackMoney}}</div>
            <div>累计已发:{{scope.row.GiveOutMoney}}</div>
          </template>

        </el-table-column>
        <el-table-column prop="IsFirstCommission" label="首次发放">
          <template slot-scope="scope">
            <div>{{scope.row.IsFirstCommission==1?'是':'否'}}</div>
          </template>
        </el-table-column>
        <el-table-column prop="TotalHours" label="总课时"> </el-table-column>
        <el-table-column width='110' prop="TotalLearn" label="已学习课时"> </el-table-column>
        <el-table-column width='110' prop="CurrentHours" label="当期消费课时">
          <template slot-scope="scope">
            <div>{{scope.row.CurrentHours>=0 ?scope.row.CurrentHours:'-'}}</div>
          </template>
        </el-table-column>
        <el-table-column width='160' prop="CurrentPeriodMoney" label="当期发放信息">
          <template slot-scope="scope">
            <div style="color: rgb(255, 156, 0);">应发:{{scope.row.CurrentPeriodMoney}}</div>
            <div>额外奖励:{{scope.row.CurrentExtraMoney}}</div>
            <div>抵扣:{{scope.row.DeductionMoney}}</div>
            <div>奖励抵扣:{{scope.row.DeductionExtraMoney}}</div>
          </template>
        </el-table-column>

        <el-table-column prop="YFMoney" label="最终发放">
          <template slot-scope="scope">
            <div style="color: rgb(233, 82, 82);">{{scope.row.YFMoney}}</div>

          </template>

        </el-table-column>
        <el-table-column width='85' 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 {
    getSellCommissionForOrderList,
  } from '../../api/finance/index'
  import {
    getClassDropDownList,
  } from "../../api/school/index";
  export default {
    meta: {
      title: "订单提成查询"
    },
    props: {},
    components: {},
    data() {
      return {
        loading: false,
        //列表数据参数
        msg: {
          PeriodId: 0,
          UserId: 0,
          ClassId: 0,
          OrderId: '',
        },
        pageCount: 0,
        persistent: false,
        listData: {},
        tableData: [],
        company: [],
        department: [],
        ClassList: [],
        allClassList: [],

        SchoolNamelist: [],
        DeptNamelist: [],
        UserNamelist: [],
        see_tcdetailed: false,

      }
    },
    created() {
      let userinfo = this.getLocalStorage();
      userinfo.ActionMenuList.map(x => { //判断权限
        if (x.FunctionCode == "see_tcdetailed") { //判断是否可以查看其他明细
          this.see_tcdetailed = true;
        }
      })
      if (this.see_tcdetailed == false) {
        this.msg.UserId = userinfo.Id
      }
    },
    mounted() {
      if (this.$route.query && this.$route.query.OrderId) {
        this.msg.OrderId = this.$route.query.OrderId
      }

      this.getList()
      // this.setClass()
    },
    methods: {

      getList() {
        if (this.msg)
          this.loading = true;
        getSellCommissionForOrderList(this.msg).then(res => {
          if (res.Code == 1) {
            this.loading = false;

            this.tableData = res.Data
            this.SchoolNamelist = [];
            this.DeptNamelist = [];
            this.UserNamelist = [];
            this.tableData.forEach(x => {
              let obj = {
                text: x.SchoolName,
                value: x.SchoolName
              }
              let obj2 = {
                text: x.DeptName,
                value: x.DeptName
              }
              let obj3 = {
                text: x.UserName,
                value: x.UserName
              }
              this.SchoolNamelist.push(obj)
              this.DeptNamelist.push(obj2)
              this.UserNamelist.push(obj3)
            })
            this.SchoolNamelist = this.unique(this.SchoolNamelist)
            this.DeptNamelist = this.unique(this.DeptNamelist)
            this.UserNamelist = this.unique(this.UserNamelist)
          }
        })
      },
      unique(arr, Name) { //数组去重
        const res = new Map();
        return arr.filter(
          (list) => !res.has(list.text) && res.set(list.text, 1)
        );
      },
      //选择班级
      setClass(item) {
        this.isShowClass = true;
        getClassDropDownList({
          CourseId: 0,
          IsAddDefault: 1, //添加默认选项
        }).then(res => {
          if (res.Code == 1) {
            var jsonData = res.Data;
            if (jsonData && jsonData.length > 0) {
              this.ClassList = JSON.parse(JSON.stringify(jsonData));
              this.allClassList = JSON.parse(JSON.stringify(jsonData));;
            }
          }
        });
      },
      //筛选员工
      filterFn(val, update) {
        update(() => {
          if (val === '') {
            this.ClassList = JSON.parse(JSON.stringify(this.allClassList))
          } else {
            const needle = val.toLowerCase()
            this.ClassList = this.allClassList.filter(v => v.ClassName.toLowerCase().indexOf(needle) > -1)
          }
        })
      },

      goUrl(path, id) {
        this.$router.push({
          path: '/financial/' + path,
          query: {
            "id": id,
            blank: 'y',
            tab: '单据详情'
          }
        })
      },
      filterHandler(value, row, column) {
        const property = column['property'];
        return row[property] === value;
      },
      StudentCount(a, b) {
        return a.StudentCount - b.StudentCount;
      },
      goreturn() {
        this.$router.go(-1);
      }



    },
  }

</script>
<style lang="sass">
  @import url('~assets/css/table.sass')

</style>
