<template>
  <div class="page-body">
    <div class="page-search row items-center">
      <div class="col row wrap q-col-gutter-md">
        <div class="col-3">
          <q-input @input="resetSearch" clearable filled v-model="msg.Description" label="关键字" />
        </div>
      </div>
    </div>
    <div class="page-content">
      <q-table :pagination="msg" :loading="loading" no-data-label="暂无相关数据" flat class="sticky-column-table"
        separator="none" :data="dataList" :columns="columns" row-key="name">
        <template v-slot:top="props">
          <div class="col-2 q-table__title">返佣管理</div>
          <q-space />
          <div class="page-option">

          </div>
        </template>
        <template v-slot:body-cell-ClassName="props">
          <q-td :props="props" style="padding-right: 0px">
            {{props.row.ClassName}} 【{{props.row.ClassNo}}】
          </q-td>
        </template>
        <template v-slot:bottom>
          <q-pagination class="full-width justify-end" v-model="msg.pageIndex" color="primary" :max="pageCount"
            :input="true" @input="changePage" />
        </template>
      </q-table>
    </div>
    <saleForm v-if="isShowTask" :taskOption="taskOption" @close="closeSaleForm" @success="RefreshPage"></saleForm>
  </div>
</template>
<script>
  import {
    GetCustomerBalanceDetailPage
  } from '../../api/sale/peemanagement';
  import saleForm from '../../components/sale/sale-form';
  export default {
    meta: {
      title: "返佣管理"
    },
    components: {
      saleForm
    },
    data() {
      return {
        columns: [{
            name: 'BalanceTypeStr',
            label: '类型',
            field: 'BalanceTypeStr',
            align: 'left'
          },
          {
            name: 'Money',
            label: '变更金额',
            align: 'left',
            field: 'Money'
          },
          {
            name: 'Description',
            label: '变更详情',
            field: 'Description',
            align: 'left',
          },
          {
            name: 'ClassName',
            label: '班级信息',
            field: 'ClassName',
            align: 'left',
          },
          {
            name: 'OrderId',
            label: '订单编号',
            field: 'OrderId',
            align: 'left',
          },
          {
            name: 'PeopleNum',
            label: '订单人数',
            field: 'PeopleNum',
            align: 'left',
          },
          {
            name: 'BalanceStateStr',
            label: '返佣',
            field: 'BalanceStateStr',
            align: 'left',
          },
          {
            name: 'RemitStr',
            label: '提现',
            field: 'RemitStr',
            align: 'left',
          },
          {
            name: 'UpdateTimeStr',
            label: '更新时间',
            field: 'UpdateTimeStr',
            align: 'left',
          },
        ],
        dataList: [],
        loading: true,
        msg: {
          CustomerId: 0,
          pageIndex: 1,
          pageSize: 12,
          rowsPerPage: 12,
          RebateType: 1,
          Description: "",
        },
        pageCount: 0,
        taskOption: null,
        isShowTask: false,
      }
    },
    created() {
      if (this.$route.query && this.$route.query.CustomerId) {
        this.msg.CustomerId = this.$route.query.CustomerId
      }
    },
    mounted() {
      this.getList()
    },
    methods: {
      resetSearch() {
        this.loading = true;
        this.msg.pageIndex = 1;
        this.getList();
      },
      changePage(val) {
        this.msg.pageIndex = val;
        this.loading = true;
        this.getList();
      },
      RefreshPage() {
        this.getList()
      },
      //获取数据
      getList() {
        this.loading = true;
        GetCustomerBalanceDetailPage(this.msg).then(res => {
          this.loading = false;
          if (res.Code == 1) {
            this.dataList = res.Data.PageData;
            this.pageCount = res.Data.PageCount;
          }
        }).catch(() => {
          this.loading = false
        })
      }
    },
  }
</script>

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