<!--
 * @Author: Fly
 * @Date: 2025-12-10 10:06:13
 * @LastEditTime: 2025-12-20 09:13:33
 * @Description: 
-->
<template>
  <div class="app-container">
    <el-form :model="queryParams" ref="queryForm" :inline="true" v-show="showSearch" :size="ELsize" label-width="auto">
      <el-form-item label="店铺名称" prop="businessName">
        <el-input v-model="queryParams.businessName" placeholder="请输入店铺名称" clearable
          @keyup.enter.native="handleQuery" />
      </el-form-item>
      <el-form-item label="店铺分类" prop="businessType">
        <el-select v-model="queryParams.businessType" placeholder="请输入店铺分类" clearable>
          <el-option v-for="item in ShopTypeOption" :key="item.value" :label="item.label" :value="item.value" />
        </el-select>
      </el-form-item>
      <el-form-item label="统计时间段" prop="time">
        <el-date-picker v-model="queryParams.time" value-format="yyyy-MM-dd" type="daterange" range-separator="-"
          start-placeholder="开始日期" end-placeholder="结束日期"></el-date-picker>
      </el-form-item>
      <el-form-item>
        <el-button type="primary" icon="el-icon-search" @click="handleQuery">搜索</el-button>
        <el-button icon="el-icon-refresh" @click="resetQuery('queryForm')">重置</el-button>
      </el-form-item>
    </el-form>
    <el-row :gutter="10" class="mb8">
      <el-col :span="1.5">
        <el-button type="warning" plain icon="el-icon-download" :size="ELsize" @click="handleExport">导出</el-button>
      </el-col>
      <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
    </el-row>
    <el-table :border="TableBorder" :size="ELTableSize" v-loading="loading" :data="dataList">
      <el-table-column type="index" width="55" label="序号" align="center">
        <template slot-scope="{$index}">
          {{ $getTableIndex(queryParams, $index + 1) }}
        </template>
      </el-table-column>
      <el-table-column label="店铺名称" align="center" prop="businessName">
        <template slot-scope="{row}">
          {{ row.businessName | TableItemEmpty }}
        </template>
      </el-table-column>
      <el-table-column label="店铺类型" align="center">
        <template slot-scope="{row}">
          {{ row.businessType | ShopTypeOptionFilter | TableItemEmpty }}
        </template>
      </el-table-column>
      <el-table-column label="累计发放积分" align="center" prop="totalGrantIntegral">
        <template slot-scope="{row}">
          {{ row.totalGrantIntegral | TableItemEmpty }}
        </template>
      </el-table-column>
      <el-table-column label="已使用积分" align="center" prop="usedIntegral">
        <template slot-scope="{row}">
          {{ row.usedIntegral | TableItemEmpty }}
        </template>
      </el-table-column>
      <el-table-column label="待使用积分" align="center" prop="waitUseIntegral">
        <template slot-scope="{row}">
          {{ row.waitUseIntegral | TableItemEmpty }}
        </template>
      </el-table-column>
    </el-table>

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

  </div>
</template>

<script>
import { businessPage, exportIntegralApi } from '@/api/integral'
import { ShopTypeOption } from "@/utils/statusEnum"
import getListApi from "@/mixins/getListApi";
export default {
  mixins: [getListApi],
  data() {
    return {
      ShopTypeOption,
      listURL: businessPage,
      queryParams: {
        businessName: undefined,
        businessType: undefined,
        time: undefined,
      },
      // 日期范围字段映射配置
      dateRangeMapping: {
        // 日期范围字段名: { start: 开始时间字段名, end: 结束时间字段名 }
        time: { start: 'startTime', end: 'endTime' },
      },
      exportObj: {
        url: exportIntegralApi,
        name: '积分管理'
      },

    }
  },
}
</script>
