<template>
  <div>
    <el-form
      :model="queryParams"
      ref="queryForm"
      :inline="true"
      label-width="88px"
    >
     
      <!-- <el-form-item label="是否使用" prop="couponIsUsed">
        <el-select
          v-model="queryParams.couponIsUsed"
          placeholder="油品名称"
          clearable
          size="small"
        >
          <el-option
            v-for="dict in oilNameOptions"
            :key="dict.dictLabel"
            :label="dict.dictLabel"
            :value="dict.dictLabel"
          />
        </el-select>
      </el-form-item> -->
       <el-form-item label="使用状态" prop="couponIsUsed">
        <el-select
          v-model="queryParams.couponIsUsed"
          clearable
          placeholder="请选择"
        >
          <el-option label="已使用" value="1" ></el-option>
          <el-option label="未使用" value="0" ></el-option>
         
        </el-select>
      </el-form-item>
    <el-form-item label="核销手机号"  prop="verificationUserPhone">
        <el-input
          v-model="queryParams.verificationUserPhone"
          placeholder="请输入手机号"
         
          clearable
          size="small"
          
        />
       </el-form-item>
      <el-form-item label="领取时间" prop="getCouponTime">
        <el-date-picker
          style="width: 350px"
          v-model="dateRangeCreatedDate"
          size="mini"
          value-format="yyyy-MM-dd HH:mm:ss"
          type="datetimerange"
          range-separator="至"
          start-placeholder="开始日期"
          end-placeholder="结束日期"
        >
        </el-date-picker>
      </el-form-item>
      <el-form-item>
        <el-button
          type="cyan"
          icon="el-icon-search"
          size="mini"
          @click="handleQuery"
          >搜索</el-button
        >
        <el-button
          type="info"
          icon="el-icon-refresh"
          size="mini"
          @click="resetQuery"
          >重置</el-button
        >
        <!-- <el-button
          type="warning"
          icon="el-icon-download"
          size="mini"
          @click="handleExport"
          >导出</el-button
        > -->
      </el-form-item>
    </el-form>
    <el-table :data="couponUserList">
      <af-table-column label="油站名" align="center" prop="id" v-if="jiBie==0||jiBie==1"/>
      <af-table-column
        v-if="false"
        label="优惠券id"
        align="center"
        prop="id"
      />
      <af-table-column label="用户ID" align="center" prop="unionId" v-if="false" />
      <af-table-column label="油站ID" align="center" prop="stationId" v-if="false" />
      <af-table-column label="发放方式ID" align="center" prop="issueId" v-if="false" />
      <af-table-column label="发放方式标识" align="left" prop="issueRemark" />
       <af-table-column label="活动名称" align="left" prop="issueName" />
      
      <af-table-column label="优惠券ID" align="center" prop="couponId"  v-if="false"/>
      <af-table-column
          label="优惠券标识"
          align="left"
          prop="couponRemark"
          fixed="left"
        />
        <af-table-column label="卡片类型" align="left">
          <template slot-scope="scope">
            {{
              scope.row.couponType == 1
                ? "现金劵" + "--面值：" + scope.row.couponAmt + "元"
                : ""
            }}
            {{
              scope.row.couponType == 2
                ? "折扣券" + "--折扣：" + scope.row.couponAmt + "% "
                : ""
            }}
            {{
              scope.row.couponType == 3
                ? "兑换券" + "--商品：" + scope.row.couponName
                : ""
            }}
          </template>
        </af-table-column>
      <af-table-column label="使用状态" 
      align="center"
       >
           <template slot-scope="scope">
            {{ scope.row.couponIsUsed == "0" ? "未使用" : "" }}
            {{ scope.row.couponIsUsed == "1" ? "已使用" : "" }}
            {{ scope.row.couponIsUsed == "2" ? "已核销" : "" }}
          </template>
      </af-table-column>
      <af-table-column label="有效状态"
       align="center"
      >
       <template slot-scope="scope">
            {{ scope.row.couponIsEffective == "0" ? "无效" : "" }}
            {{ scope.row.couponIsEffective == "1" ? "有效" : "" }}
          </template>
      </af-table-column>
      <af-table-column label="用户保存id" align="center" prop="userId" v-if="false" />
      <af-table-column label="用户手机号" align="center" prop="mobilePhone" />
      <af-table-column label="用户名" align="center" prop="blogNickName" />
       <af-table-column label="核销员手机号" align="center" prop="verificationUserPhone" />
      <af-table-column label="优惠券获取时间" align="center" prop="getCouponTime">
        <template slot-scope="scope">
          <span>{{
            parseTime(scope.row.getCouponTime, "{y}-{m}-{d} {h}:{i}:{s}")
          }}</span>
        </template>
      </af-table-column>
      <af-table-column label="优惠券截止时间" align="center" prop="couponEffectiveTime">
        <template slot-scope="scope">
          <span>{{
            parseTime(scope.row.couponEffectiveTime, "{y}-{m}-{d} {h}:{i}:{s}")
          }}</span>
        </template>
      </af-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 { listOrder, exportOrder,printOrderInfo } from "@/api/station/order";
import { stationinfo } from "@/api/station/gun";
import { listPrice, getPrice } from "@/api/station/price";
import {queryCouponUserList} from "@/api/coupon";
import {
  listManage
} from "@/api/station/manage";

export default {
  name: "coupon_user",
  data() {
    return {
      //创建订单时间间隔
      dateRangeCreatedDate: [],
      // 总条数
      total: 0,
      // 优惠券的信息
      couponUserList: [],
      oilNameOptions: [],
      // 字典
      payTypeOptions: [],
      // 下拉油站
      stationOptions: [],
      // 弹出层标题
      title: "",
      // 是否显示弹出层
      open: false,
      // 查询参数
      queryParams: {
        levelId:this.levelId,
        pageNum: 1,
        pageSize: 10,
        issueId: null,
        couponId: null,
        stationId: null,
        couponIsUsed: null,
        couponIsEffective: null,
        getCouponTime: null,
        verificationUserPhone:null
      },
      // 表单校验
      rules: {},
      reprint:false,
    };
  },
  created() {
    this.getList();
  },

  methods: {
 
    /** 查询订单支付列表 */
    getList() {
      this.queryParams.levelId = this.levelId
      queryCouponUserList(
        this.addDateRange(this.queryParams, this.dateRangeCreatedDate)
      ).then((response) => {
        this.couponUserList = response.rows;
        this.total = response.total;
      });
    },
    /** 搜索按钮操作 */
    handleQuery() {
      this.queryParams.pageNum = 1;
      this.getList();
    },
    /** 重置按钮操作 */
    resetQuery() {
      this.dateRangeCreatedDate = [];
      this.resetForm("queryForm");
      this.handleQuery();
    },
   
    /** 导出按钮操作 */
    handleExport() {
      const queryParams = this.queryParams;
      this.$confirm("是否确认导出所有订单支付数据项?", "警告", {
        confirmButtonText: "确定",
        cancelButtonText: "取消",
        type: "warning",
      })
        .then(function () {
          return exportOrder(queryParams);
        })
        .then((response) => {
          this.download(response.msg);
        });
    },
  },
};
</script>
