<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.ClassName}}
          </template>
        </div>
        <div class="row" style="align-items: center">
          <span>带班老师</span>
          <q-avatar size="sm" style="margin:0 5px;" v-if="data.ClassInfo&&data.ClassInfo.TeacherIcon">
            <img :src="data.ClassInfo.TeacherIcon" />
          </q-avatar>
          <q-avatar style="margin:0 5px;" size="sm" color="teal-10" text-color="white" v-else>
            <template
              v-if="data.ClassInfo&&data.ClassInfo.TeacherName">{{data.ClassInfo.TeacherName.substring(0,1)}}</template>
          </q-avatar>
          <span v-if="data&& data.ClassInfo" style="color:#2961FE;font-weight: bold">
            {{data.ClassInfo.TeacherName}}
          </span>
        </div>
      </div>
    </div>
    <div class="page-content">
      <orderlist :dataList="dataList" ref="orderL" :authObj="authObj" :cancelList="CancelList"
        @success="refreshClassOrder"></orderlist>
    </div>
  </div>
</template>
<script>
  import {
    quertClassOrderList
  } from '../../api/sale/sale';

  import orderlist from '../../components/sale/orderlist'
  export default {
    components: {
      orderlist
    },
    data() {
      return {
        data: {},
        msg: {
          ClassId: 0
        },
        //正常订单
        dataList: [],
        //取消订单
        CancelList: [],
        //权限判断
        authObj: {
          isShowName: false, //不显示班级名称
          isShowEditSale: true, //显示修改销售按钮
          isShowEducationRemark: true, //显示修改教务备注
          isShowPrincipalRemark: true, //显示校长备注
          isShowManagerRemark: true, //显示总经理备注
          isShowCommissionEdit: true, //显示修改提成按钮
          isShowRewardEdit: true, //显示修改额外提成按钮
        }
      }
    },
    created() {
      if (this.$route.query.ClassId) {
        this.ClassId = this.$route.query.ClassId
        this.msg.ClassId = this.ClassId;
      }
      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>
