<template>
  <div class="full-height">
    <div class="row items-center">
      <q-avatar size="40px" font-size="20px" color="primary" class="q-mr-md" text-color="white" rounded
        :icon="`iconfont ${node.icon}`" />
      <div class="pingfang text-subtitle1">{{ node.name }}</div>
    </div>
    <div class="q-my-md row">
      <q-input standout v-model="msg.KeyWords" dense type="text" style="width:250px;" label="关键字（名称/微信/手机号）"
        class="q-mr-md" />
      <q-btn color="primary" class="q-px-md" label="查询" unelevated dense @click="searchKeyHandler" />
      <div class="col text-right text-grey-6 f12">
        TIPS：创建订单后，请及时完成订单款项的入账动作，收款单据点击“修改-选择学员-制单”完成此项任务。
      </div>
    </div>
    <div style="height:calc(100% - 158px);overflow-y:auto;">
      <orderlist :dataList="stus" @success="refreshPage" :loading="loading" :authObj="authObj"></orderlist>
    </div>
    <div class="row" style="justify-content: flex-end;padding: 5px 20px">
      <q-pagination v-model="msg.PageIndex" :max="pageCount" @input="changePage" class="full-width justify-end"
        color="primary" :input="true">
      </q-pagination>
    </div>
  </div>
</template>

<script>
  import orderlist from "../sale/orderlist.vue";
  import {
    getMyOrderNotBalance
  } from "../../api/stuMan/index";
  export default {
    components: {
      orderlist
    },
    props: ["node"],
    data() {
      return {
        stus: [],
        loading: false,
        isJudgeTrans: 1,
        pageCount: 0,
        msg: {
          PageIndex: 1,
          pageSize: 10,
          KeyWords: ""
        },
        //权限判断
        authObj: {
          isShowGuestBtn: 1, //显示新增学员名单按钮
          isShowFinanceBtn: true, //显示财务单据按钮
          isShowTransOrder: true, //显示转交订单按钮
          isShowSaleRemark: true, //显示修改销售备注
          isShowBackClass: true, //显示退课按钮
          isShowRenewClass: true, //显示续课按钮
          isShowTransClassOrder: true, //现在转班按钮
          isShowSeparater: true //显示分拆按钮
        }
      };
    },
    mounted() {
      this.getStudent();
    },
    methods: {
      getStudent() {
        if (this.loading) return;
        this.loading = true;
        getMyOrderNotBalance(this.msg)
          .then(r => {
            this.stus = r.Data.PageData;
            this.pageCount = r.Data.PageCount;
            setTimeout(() => {
              this.loading = false;
            }, 1000);
          })
          .catch(e => {
            this.loading = false;
          });
      },
      refreshPage() {
        this.getStudent();
        this.$root.$emit("updateTodoList");
      },
      changePage() {
        this.getStudent();
      },
      searchKeyHandler() {
        this.msg.PageIndex = 1;
        this.getStudent();
      }
    }
  };
</script>
<style>
</style>