<template>
  <div class="page-body myOrder">
    <div class="row col" style="height: 40px">
      <div class="row col" style="justify-content: space-between;align-items: center;margin-bottom: 10px">
        <div>
          <template v-if="data&& data.ClassInfo">
            {{data.ClassInfo.StudyName}}
          </template>
        </div>
      </div>
    </div>
    <div class="page-content">
      <orderlist :dataList="dataList" ref="orderL" :authObj="authObj" :cancelList="CancelList"
        @success="refreshClassOrder" :modityOrderType="2"></orderlist>
    </div>
  </div>
</template>
<script>
  import {
    quertClassOrderList
  } from '../../api/sale/sale';
  import orderlist from '../../components/sale/orderlist'
  export default {
    meta: {
      title: "留学就业订单中心"
    },
    components: {
      orderlist
    },
    data() {
      return {
        data: {},
        msg: {
          SourceId: 0
        },
        //正常订单
        dataList: [],
        //取消订单
        CancelList: [],
        //权限判断
        authObj: {
          isShowName: true, //不显示班级名称
          isShowEditSale: true, //显示修改销售按钮
          isShowEducationRemark: true, //显示修改教务备注
          isShowPrincipalRemark: true, //显示校长备注
          isShowManagerRemark: true, //显示总经理备注
          isShowCommissionEdit: true, //显示修改提成按钮
          isShowRewardEdit: true, //显示修改额外提成按钮
          isshoworderconfirm:false,//订单确认按钮
        }
      }
    },
    created() {
      if (this.$route.query.SourceId) {
        this.msg.SourceId = this.$route.query.SourceId;
      }
      let userinfo = this.getLocalStorage();
      userinfo.ActionMenuList.map(x=>{//判断权限
        if(x.FunctionCode == "SA_Order_confirm"){//留学和就业订单确认按钮
          this.authObj.isshoworderconfirm = true;
        }
      
      })
      this.getList();
    },
    mounted() {

    },
    methods: {
      //获取菜单分页列表
      getList() {
        this.loading = true;
        quertClassOrderList(this.msg).then(res => {
          this.data = res.Data;
          if (this.data && this.data.OrderList && this.data.OrderList.NorList) {
            this.dataList = this.data.OrderList.NorList;
            let OrderIds = []
            this.dataList.forEach(x => {
              OrderIds.push(x.OrderId)
            })
            if (OrderIds.length > 0) {
              OrderIds = OrderIds.join(',')
              if (this.dataList.length > 0) {
                this.$refs.orderL.getOrderFinanceList(OrderIds, 1)
              }
            }
          }
          if (this.data && this.data.OrderList && this.data.OrderList.CancelList) {
            this.CancelList = this.data.OrderList.CancelList;
            let OrderIds = []
            this.CancelList.forEach(x => {
              OrderIds.push(x.OrderId)
            })
            if (OrderIds.length > 0) {
              OrderIds = OrderIds.join(',')
              if (this.CancelList.length > 0) {
                this.$refs.orderL.getOrderFinanceList(OrderIds, 2)
              }
            }
          }
          this.loading = false
        }).catch(() => {
          this.loading = false
        })
      },
      //刷新页面
      refreshClassOrder() {
        this.getList();
      }
    }
  }

</script>
<style>

</style>
