<template>
  <div class="app-container">
    <!-- 顶部操作区域 -->
    <div class="filter-container">
      <div class="filter-control">
        <span>退款编号:</span>
        <el-input
          v-model="listQuery.productName"
          placeholder="退款编号"
          clearable
          style="width: 180px"
          @keyup.enter.native="getList"
          @clear="getList"
        />
      </div>
      <div class="filter-control">
        <span>订单ID:</span>
        <el-input
          v-model="listQuery.shopName"
          placeholder="订单ID"
          clearable
          style="width: 120px"
          @keyup.enter.native="getList"
          @clear="getList"
        />
      </div>
      <div class="filter-control">
        <span>订单编号:</span>
        <el-input
          v-model="listQuery.shopName"
          placeholder="订单编号"
          clearable
          style="width: 180px"
          @keyup.enter.native="getList"
          @clear="getList"
        />
      </div>
      <div class="filter-control">
        <span>买家：</span>
        <el-input
          v-model="listQuery.shopName"
          placeholder="买家"
          clearable
          style="width: 120px"
          @keyup.enter.native="getList"
          @clear="getList"
        />
      </div>
      <div class="filter-control">
        <span>退款审核状态:</span>
        <el-select v-model="listQuery.status" style="width: 120px" clearable @change="getList">
          <el-option value="" label="所有" />
          <el-option :value="1" label="待审核" />
          <el-option :value="2" label="审核通过" />
          <el-option :value="3" label="审核不通过" />
        </el-select>
      </div>
      <div class="filter-control">
        <span>申请时间:</span>
        <el-date-picker
          v-model="time"
          type="daterange"
          unlink-panels
          value-format="yyyy-MM-dd"
          range-separator="至"
          start-placeholder="开始日期"
          end-placeholder="结束日期"
          :picker-options="pickerOptions"
          @change="handleDatePick"
        />
      </div>
      <div class="filter-control">
        <el-button type="primary" @click="getList"> 查询 </el-button>
      </div>
    </div>
    <!-- 列表 -->
    <el-table v-loading="isLoading" :data="list" border style="width: 100%" height="660">
      <el-table-column prop="id" label="ID" align="center" width="50" />
      <el-table-column prop="productName" label="商品名称" align="center" />
      <el-table-column prop="shopName" label="供应商名称" align="center">
        <template slot-scope="{ row }">
          {{ row.shopName ? row.shopName : '---' }}
        </template>
      </el-table-column>
      <el-table-column prop="price" label="拼团价格" align="center" width="100">
        <template slot-scope="{ row }">
          {{ row.price | amountfilters }}
        </template>
      </el-table-column>
      <el-table-column prop="memberNum" label="拼团人数" align="center" width="50" />
      <el-table-column prop="name" label="已拼人数" align="center" width="50">
        <template slot-scope="{ row }">
          <span v-if="row.status === 2">{{ row.memberNum }}</span>
          <span v-else>{{ row.orderIdList.length }}</span>
        </template>
      </el-table-column>
      <el-table-column prop="orderIdList" label="关联订单" align="center" width="100">
        <template slot-scope="{ row }">
          <template v-if="row.orderIdList">
            <p v-for="item in row.orderIdList" :key="item">
              {{ item ? item : '---' }}
            </p>
          </template>
          <p v-else>---</p>
        </template>
      </el-table-column>
      <el-table-column prop="status" label="小程序状态" align="center" width="100">
        <template slot-scope="{ row }">
          <el-tag v-if="row.status === 1" type="warning" size="small">拼团中</el-tag>
          <el-tag v-if="row.status === 2" type="success" size="small">已拼成</el-tag>
        </template>
      </el-table-column>
      <el-table-column prop="startTime" label="开始时间" align="center" width="100">
        <template slot-scope="{ row }">
          {{ row.startTime ? row.startTime : '---' }}
        </template>
      </el-table-column>
      <el-table-column prop="endTime" label="结束时间" align="center" width="100">
        <template slot-scope="{ row }">
          {{ row.endTime ? row.endTime : '---' }}
        </template>
      </el-table-column>
      <el-table-column prop="completeTime" label="成团时间" align="center" width="100">
        <template slot-scope="{ row }">
          {{ row.completeTime ? row.completeTime : '---' }}
        </template>
      </el-table-column>
      <el-table-column fixed="right" label="操作" align="center">
        <template slot-scope="{ row }">
          <el-button
            v-if="row.status === 1"
            type="primary"
            size="mini"
            style="margin: 2px"
            @click="handleRecordDetail(3, row)"
          >
            一键成团
          </el-button>
          <el-button type="danger" size="mini" style="margin: 2px" @click="handleRecordDetail(3, row)">
            拼团成员
          </el-button>
        </template>
      </el-table-column>
    </el-table>
    <!-- 页码 -->
    <pagination
      :total="total"
      :page-sizes="[10, 20, 30, 100]"
      :page-size="20"
      :page.sync="listQuery.pageNum"
      :limit.sync="listQuery.pageSize"
      @pagination="getHeHeCollageRecord"
    />
  </div>
</template>

<script>
import { getHeHeCollageRecord } from '@/api/stricts/active/active'
import pickerOptions from '@/utils/time-picker.js'
export default {
  name: 'GroupsList',
  filters: {},
  data() {
    return {
      time: '',
      pickerOptions,
      isLoading: true,
      listQuery: {
        id: '',
        productName: '',
        status: '',
        shopName: '',
        pageNum: 1,
        pageSize: 20
      },
      list: [],
      total: 0
    }
  },
  computed: {},
  created() {
    this.getList()
  },
  mounted() {},
  methods: {
    // 获取行为记录列表
    getList() {
      this.list = []
      this.listQuery.pageNum = 1
      this.getHeHeCollageRecord()
    },
    // 获取首页导航列表
    async getHeHeCollageRecord() {
      try {
        this.isLoading = true
        const res = await getHeHeCollageRecord(this.listQuery)
        this.list = res.data.results
        this.total = res.data.totalRecord
        this.isLoading = false
      } catch (error) {
        console.log(error)
      }
    },
    // 菜单排序
    async consultSort(row) {
      try {
        // await consultSort({ id: row.id, sortNumber: row.sortNumber })
        this.getList()
      } catch (error) {
        console.log(error)
      }
    }
  }
}
</script>

<style>
.avatar-uploader .el-upload {
  border: 1px dashed #d9d9d9;
  border-radius: 6px;
  cursor: pointer;
  position: relative;
  overflow: hidden;
  float: left;
}
.uploader-tips {
  position: absolute;
  bottom: 0;
  left: 160px;
  line-height: 28px;
  color: red;
  margin: 0;
}
</style>
