<style>
</style>
<template>
  <div class="page-body">
    <div class="page-search row items-center">
      <div class="col row wrap q-mr-lg q-col-gutter-md">
        <div class="col-3">
          <q-input @change="resetSearch" clearable standout="bg-primary text-white" v-model="msg.QOrderId" label="订单编号"
            @clear="resetSearch" maxlength="30" />
        </div>
        <div class="col-3">
          <q-select @input="resetSearch" standout="bg-primary text-white" v-model="msg.AuditStatus"
            :options="StatusOpts" option-value="Id" option-label="Name" label="状态" emit-value map-options />
        </div>
        <div class="col-3">
          <q-input @change="resetSearch" clearable standout="bg-primary text-white" v-model="msg.ProtocolNum"
            label="协议编号" @clear="resetSearch" maxlength="30" />
        </div>
        <div class="col-3">
          <q-input @change="resetSearch" clearable standout="bg-primary text-white" v-model="msg.PartyAName"
            label="学生姓名" @clear="resetSearch" maxlength="30" />
        </div>
        <div class="col-3">
          <q-select @input="resetSearch" standout="bg-primary text-white" option-value="Id" option-label="EmployeeName"
            v-model="msg.QCreateBy" :options="EmployeeList" emit-value map-options label="业务员" use-input
            @filter="filterFn2" clearable />
        </div>
      </div>
    </div>
    <courserefund-form :loading="loading" :dataList="dataList" @success="getList"></courserefund-form>
    <q-pagination class="full-width justify-end" v-model="msg.pageIndex" color="primary" :max="pageCount" :input="true"
      @input="changePage" />
  </div>
</template>
<script>
  import {
    GetBackClassProtocolPage
  } from "../../api/sale/contract";
  import {
    queryEmployee
  } from '../../api/users/user';
  import courserefundForm from "../../components/course/courserefund-form"
  export default {
    meta: {
      title: "退课协议管理",
    },
    components: {
      courserefundForm
    },
    data() {
      return {
        loading: true,
        msg: {
          pageIndex: 1,
          pageSize: 12,
          PartyAName: '',
          AuditStatus: -1,
          QOrderId: '',
          ProtocolNum: '',
          IsQueryAll: 1,
          QCreateBy: "", //业务员
          Id: "", //退课协议编号
        },
        pageCount: 0,
        dataList: [],
        //状态下拉
        StatusOpts: [{
            Id: -1,
            Name: "不限",
          },
          {
            Id: 1,
            Name: "审核中",
          },
          {
            Id: 2,
            Name: "审核通过",
          },
          {
            Id: 3,
            Name: "驳回",
          },
          {
            Id: 4,
            Name: "待签字",
          },
          {
            Id: 5,
            Name: "待确认",
          },
          {
            Id: 6,
            Name: "生效",
          },
        ],
        EmployeeList: [], //业务员
        AllemployeeList: [],
      };
    },
    created() {
      if (this.$route.query.Id) {
        this.msg.Id = this.$route.query.Id;
      }
      this.getEmployee()
    },
    mounted() {
      this.getList();
    },
    methods: {
      //业务员
      getEmployee() {
        var qMsg = {
          Dept_Id: 0
        }
        queryEmployee(qMsg).then(res => {
          if (res.Code == 1) {
            this.EmployeeList = res.Data;
            this.AllemployeeList = JSON.parse(JSON.stringify(this.EmployeeList));
          }
        }).catch(() => {

        })
      },
      //筛选业务员
      filterFn2(val, update) {
        update(() => {
          if (val === '') {
            this.EmployeeList = JSON.parse(JSON.stringify(this.AllemployeeList))
          } else {
            const needle = val.toLowerCase()
            this.EmployeeList = this.AllemployeeList.filter(v => v.EmployeeName.toLowerCase().indexOf(needle) > -1)
          }
        })
      },
      //获取校区列表
      getList() {
        this.loading = true;
        GetBackClassProtocolPage(this.msg).then((res) => {
          this.loading = false;
          if (res.Code == 1) {
            this.dataList = res.Data.PageData;
            this.pageCount = res.Data.PageCount;
          }
        });
      },
      //重新查询
      resetSearch() {
        this.msg.pageIndex = 1;
        this.getList();
      },
      //分页改变
      changePage(val) {
        this.msg.pageIndex = val;
        this.getList();
      }
    },
  };

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

</style>
