<template>
  <div class="app-container live-page">
        <div class="live-page__header">
      <h2 class="live-page__title">直播收益</h2>
    </div>

<div class="live-panel" v-show="showSearch">
<el-form class="live-search-form" :model="queryParams" ref="queryForm" :inline="true" label-width="100px">
      <el-form-item label="订单号" prop="orderCode">
        <el-input
          v-model="queryParams.orderCode"
          placeholder="请输入订单号"
          clearable
          size="small"
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="用户名称" prop="userName">
        <el-input
          v-model="queryParams.userName"
          placeholder="请输入用户名称"
          clearable
          size="small"
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="销售名称" prop="companyUserName">
        <el-input
          v-model="queryParams.companyUserName"
          placeholder="请输入销售名称"
          clearable
          size="small"
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="公司名称" prop="companyName">
        <el-input
          v-model="queryParams.companyName"
          placeholder="请输入公司名称"
          clearable
          size="small"
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item>
        <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
        <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
      </el-form-item>
    </el-form>
    </div>

    <div class="live-panel live-panel--table">
<el-row :gutter="10" class="mb8">
      <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
    </el-row>

    <el-table border v-loading="loading" :data="dataList" class="live-table">
      <el-table-column label="订单ID" align="center" prop="orderId" />
      <el-table-column label="订单号" align="center" prop="orderCode" />
      <el-table-column label="用户名称" align="center" prop="userName" />
      <el-table-column label="用户电话" align="center" prop="userPhone" />
      <el-table-column label="总价格" align="center" prop="totalPrice" />
      <el-table-column label="支付价格" align="center" prop="payPrice" />
      <el-table-column label="是否支付" align="center" prop="isPay">
        <template slot-scope="scope">
          <el-tag v-if="scope.row.isPay == 1">已支付</el-tag>
          <el-tag v-else>未支付</el-tag>
        </template>
      </el-table-column>
      <el-table-column label="订单状态" align="center" prop="status">
        <template slot-scope="scope">
          <el-tag v-if="scope.row.status == -1">申请退款</el-tag>
          <el-tag v-else-if="scope.row.status == -2">退货成功</el-tag>
          <el-tag v-else-if="scope.row.status == 0">已取消</el-tag>
          <el-tag v-else-if="scope.row.status == 1">待支付</el-tag>
          <el-tag v-else-if="scope.row.status == 2">待发货</el-tag>
          <el-tag v-else-if="scope.row.status == 3">待收货</el-tag>
          <el-tag v-else-if="scope.row.status == 4">待评价</el-tag>
          <el-tag v-else-if="scope.row.status == 5">已完成</el-tag>
          <el-tag v-else>---</el-tag>
        </template>
      </el-table-column>
      <el-table-column label="销售ID" align="center" prop="companyUserId" />
      <el-table-column label="销售名称" align="center" prop="companyUserName" />
      <el-table-column label="公司名称" align="center" prop="companyName" />
    </el-table>
    </div>

    <pagination
      v-show="total > 0"
      :total="total"
      :page.sync="queryParams.pageNum"
      :limit.sync="queryParams.pageSize"
      @pagination="getList"
    />
  </div>
</template>

<script>
import { liveProfitList } from '@/api/live/liveProfit'

export default {
  name: "LiveProfit",
  data() {
    return {
      loading: true,
      showSearch: true,
      total: 0,
      dataList: [],
      queryParams: {
        pageNum: 1,
        pageSize: 10,
        orderCode: null,
        userName: null,
        companyUserName: null,
        companyName: null,
      }
    }
  },
  created() {
    this.getList()
  },
  methods: {
    /** 查询销售端直播数据列表 */
    getList() {
      this.loading = true
      liveProfitList(this.queryParams).then(response => {
        this.dataList = response.rows
        this.total = response.total
        this.loading = false
      })
    },
    /** 搜索按钮操作 */
    handleQuery() {
      this.queryParams.pageNum = 1
      this.getList()
    },
    /** 重置按钮操作 */
    resetQuery() {
      this.queryParams = {
        pageNum: 1,
        pageSize: 10,
        orderCode: null,
        userName: null,
        companyUserName: null,
        companyName: null,
      }
      this.handleQuery()
    }
  }
}
</script>

<style scoped>
</style>

