<!--  -->
<template>
  <div class="m-container">
    <h2>
      <div class="squrt"></div>
      推广订单
    </h2>
    <div class="m-core">
      <save-form
        :inline="true"
        :model="searchForm"
        @submit="search"
        @reset="onReSet"
        ref="searchForm"
      >
      <el-form-item prop="courseStatus">

         <el-input  v-model="searchForm.orderNo" placeholder="请输入订单编号"></el-input>
        </el-form-item>
        <el-form-item prop="extensionUserId">
          <remote-search
            ariaPlaceholder="请选择推荐人"
            :commit="'setTeachers'"
            v-model="searchForm.extensionUserId"
            :demissionFlag="true"
            :isForzenWithQueryCondition="true"
          />
        </el-form-item>
        <el-form-item>
          <el-button native-type="submit" type="primary">搜索</el-button>
          <el-button native-type="reset" type="danger">重置</el-button>
        </el-form-item>
      </save-form>
      <div class="tableWrap">
        <el-table
          style="width: 100%"
          :header-cell-style="{ background: '#EDEEF0', color: '#444' }"
          :data="tableList"
        >
          <el-table-column
            align="center"
            prop="orderNo"
            label="订单编号"
          >
          </el-table-column>
          <el-table-column
            align="center"
            prop="orderType"
            label="订单类型"
          >
            <template slot-scope="scope">
             {{getOrderType(scope.row.orderType)}}
            </template>
          </el-table-column>
          <el-table-column
            align="center"
            prop="orderAmount"
            label="订单金额"
          >
            <template slot-scope="scope">
             {{ scope.row.orderAmount|moneyFormat }}元
            </template>
          </el-table-column>
          <el-table-column
            align="center"
            prop="orderAmount"
            label="支付时间"
          >
            <template slot-scope="scope">
             {{ scope.row.payTime }}
            </template>
          </el-table-column>

          <el-table-column
            align="center"
            prop="extensionUser"
            label="推广人员"
          >
            <template slot-scope="scope">
              {{scope.row.extensionUser}}
            </template>
          </el-table-column>
          <el-table-column
            align="center"
            prop="extensionFee"
            label="绩效金额"
          >
            <template slot-scope="scope">
              {{scope.row.extensionFee|moneyFormat}}元
            </template>
          </el-table-column>

        </el-table>
        <pagination
          sync
          :total.sync="pageInfo.total"
          :page.sync="pageInfo.page"
          :limit.sync="pageInfo.limit"
          :page-sizes="pageInfo.page_size"
          @pagination="getList"
        />
      </div>
    </div>
  </div>
</template>

<script>
import axios from "axios";
import { getToken } from "@/utils/auth";
import pagination from "@/components/Pagination/index";
import { getOrderPage } from "@/api/businessManager";
import { getInstrument } from "@/api/buildTeam";
import {  getTimes } from "@/utils";
import load from "@/utils/loading";

const orderType = {
  COURSE_SALE:'课包销售',
  MUSICAL_SALE:'乐器销售',
  REPAIR:'维修订单',
  "":'--'
}
export default {
  components: { pagination },
  data() {
    return {
      searchForm: {
        extensionUserId: null,
        orderNo:'',

      },
      soundLists: [],
      organList: [],
      tableList:[],
      pageInfo: {
        // 分页规则
        limit: 10, // 限制显示条数
        page: 1, // 当前页
        total: 0, // 总条数
        page_size: [10, 20, 40, 50], // 选择限制显示条数
      },
      categoryList:[]
    };
  },
  //生命周期 - 创建完成（可以访问当前this实例）
  created() {},
  //生命周期 - 挂载完成（可以访问DOM元素）
  mounted() {
    // 获取分部
    this.$store.dispatch("setBranchs");
    this.init();
    this.getList()
  },
  methods: {
    init() {
    },
   search() {
      this.pageInfo.page = 1;
      this.getList()
    },
    onReSet() {
      this.pageInfo.page = 1;
    this.searchForm= {
        search: null,
        organId:'',
        teacherIdList:'',
        timer:[],
        courseStatus:'',
        teachMode:''
      }
      this.getList()
    },
    async getList() {
     try{
      const {  timer, ...rest } = this.searchForm;
      let obj = {
        page: this.pageInfo.page,
        rows: this.pageInfo.limit,
        ...rest,
      }
       const res = await getOrderPage(obj)
        this.tableList = res.data.rows
        this.pageInfo.total = res.data.total
     }catch(e){
      console.log(e)
     }
    },
    getOrderType(type){
      return type?orderType[type]:'--'
    }
  },
};
</script>
<style lang='scss' scoped>
</style>
