<template>
  <div class="app-container">
    <el-form :model="search" ref="queryForm" :inline="true" v-show="showSearch" :size="ELsize" label-width="auto">
      <el-form-item label="代理账号">
        <el-input v-model="search.userMobile" placeholder="请输入代理账号" clearable @keyup.enter.native="handleQuery" />
      </el-form-item>
      <el-form-item label="代理昵称">
        <el-input v-model="search.userNickname" placeholder="请输入代理昵称" clearable @keyup.enter.native="handleQuery" />
      </el-form-item>
      <el-form-item label="所属区县">
        <el-cascader v-model="search.areaTreaList" :options="areaTreaList"
          :props="{ expandTrigger: 'hover', checkStrictly: true }" placeholder="请选择省市区县" />
      </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">
      <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="accountCode" width="150">
        <template slot-scope="{row}">
          {{ row.accountCode | TableItemEmpty }}
        </template>
      </el-table-column>
      <el-table-column label="代理账号" align="center" prop="userMobile" width="150">
        <template slot-scope="{row}">
          {{ row.userMobile | TableItemEmpty }}
        </template>
      </el-table-column>
      <el-table-column label="代理昵称" align="center" prop="userNickname">
        <template slot-scope="{row}">
          {{ row.userNickname | TableItemEmpty }}
        </template>
      </el-table-column>
      <el-table-column label="代理层级" align="center" prop="agentLevel" width="120">
        <template slot-scope="{row}">
          {{ row.agentLevel == 1 ? "省级代理" : "区县代理" }}
        </template>
      </el-table-column>
      <el-table-column label="所属区县" align="center" prop="provinceName">
        <template slot-scope="{ row }">
          {{ row.provinceName + (row.cityName || "") + (row.areaName || "") }}
        </template>
      </el-table-column>

      <el-table-column label="状态" align="center" prop="status" width="100">
        <template slot-scope="{row}">
          <!-- {{ row.status | PurposeTypeOptionFilter | TableItemEmpty }} -->
          <StatusTag :status-vo="row.status | PurposeTypeOptionFilter(true)" />
        </template>
      </el-table-column>
      <el-table-column label="发放时间" align="center" prop="createTime" width="180">
        <template slot-scope="{row}">
          {{ row.createTime | TableItemEmpty }}
        </template>
      </el-table-column>
      <el-table-column label="使用时间" align="center" prop="purposeTime" width="180">
        <template slot-scope="{row}">
          {{ row.purposeTime | TableItemEmpty }}
        </template>
      </el-table-column>
      <el-table-column label="注册店铺" align="center" prop="purposeName" show-overflow-tooltip>
        <template slot-scope="{row}">
          <!-- 已下发的不显示店铺 -->
          {{ (row.status === PurposeTypeEnum.DISPATCHED ? "" : row.purposeName) | 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 getListApi from "@/mixins/getListApi";
import { agentAccountCodePage } from "@/api/agentManage";
import { PurposeTypeEnum } from "@/utils/statusEnum";
export default {
  mixins: [getListApi],
  data() {
    return {
      PurposeTypeEnum,
      listURL: agentAccountCodePage,
    };
  },
  created() {
    this.getCnAreaTree();
  },
  methods: {},
};
</script>
<style scoped lang="scss"></style>
