<template>
  <div class="app-container">
    <el-form :model="queryParams" ref="queryForm" size="small" :inline="true" label-width="68px">
      <!--代理商 -->
      <el-form-item label="代理商" prop="agentId">
        <el-select v-model="queryParams.agentId" placeholder="请选择代理商" filterable clearable size="small">
          <el-option v-for="item in agentList" :key="item.agentId" :label="item.name" :value="item.agentId"></el-option>
        </el-select>
      </el-form-item>
      <!--开卡时间-->
      <el-form-item label="开卡时间" prop="date">
        <el-date-picker clearable v-model="dataRange" style="width:220px" value-format="yyyy-MM-dd" type="daterange" range-separator="-" placeholder="请选择缴费时间" />
      </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>
    <el-table v-loading="loading" :data="rows">
      <!--代理商	已开卡	已缴费	未缴费	已退费	已激活	未激活-->
      <el-table-column label="代理商" align="center" prop="agentName" />
      <el-table-column label="已开卡" align="center" prop="opened" />
      <el-table-column label="已缴费" align="center" prop="payed" />
      <el-table-column label="未缴费" align="center" prop="nopay" />
      <el-table-column label="已退费" align="center" prop="refund" />
      <el-table-column label="已激活" align="center" prop="active" />
      <el-table-column label="未激活" align="center" prop="inactive" />
    </el-table>
  </div>
</template>

<script>
import { staticByAgent } from "@/api/voluntary/busiCards";
import { getAllAgents } from "@/api/voluntary/busiAgents";
export default {
  data() {
    return {
      loading: false,
      agentList: [],
      dataRange: [],
      queryParams: { agentId: null },
      rows: []
    }
  },
  created() {
    let vm = this;
    getAllAgents().then(res => {
      vm.agentList = res.rows || [];
    })
    this.getList();
  },
  methods: {

    handleQuery() {
      this.getList();
    },
    resetQuery() {
      this.dataRange = [];
      this.queryParams.agentId = null;
    },
    getList() {
      let vm = this;
      this.addDateRange(this.queryParams, this.dataRange, 'DistributeTime')
      staticByAgent(this.queryParams).then(res => {
        vm.rows = res.data;
      })
    }
  },
};
</script>
