<template>
  <div>
    <!-- 头部导航栏 -->
    <el-breadcrumb separator-class="el-icon-arrow-right">
      <el-breadcrumb-item>消费分期</el-breadcrumb-item>
      <el-breadcrumb-item>已有数据查询</el-breadcrumb-item>
    </el-breadcrumb>

    <el-card>
      <div class="filter">
        用户状态：
        <el-select
          v-model="userStatus"
          @change="selectUserStatusChange"
          placeholder="请选择用户状态"
        >
          <el-option
            v-for="item in statusOption"
            :key="item.label"
            :label="item.label"
            :value="item.value"
          ></el-option>
        </el-select>
        <el-button
          type="primary"
          style="margin-left: 20px"
          @click="searchVccData"
          >查询数据</el-button
        >
      </div>
      <!-- 数据表格 -->
      <div class="dataTable">
        <el-table :data="dataTable" border style="width: 100%">
          <el-table-column
            prop="phoneNo"
            label="手机号"
            width="150px"
          ></el-table-column>
          <el-table-column
            prop="userId"
            label="userId"
            width="150px"
          ></el-table-column>
          <el-table-column
            prop="uuid"
            label="uuid"
            width="400px"
          ></el-table-column>
          <el-table-column
            prop="registeredFrom"
            label="注册渠道"
            width="150px"
          ></el-table-column>
          <el-table-column
            prop="nextApplyTime"
            label="过期时间"
            width="200px"
          ></el-table-column>
          <el-table-column prop="createdAt" label="创建时间"></el-table-column>
        </el-table>
      </div>
      <!-- 分页 -->
      <el-pagination
        background
        @size-change="handleSizeChange"
        @current-change="handleCurrentChange"
        :current-page.sync="queryInfo.pageNum"
        :page-size="queryInfo.pageSize"
        layout="total, prev, pager, next"
        :total="totalNum"
      ></el-pagination>
    </el-card>
  </div>
</template>

<script>
import {getVccData} from '@/api/getVccData'
export default {
  data() {
    return {
      userStatus: '',
      queryInfo: {
        namespace: window.sessionStorage.getItem('env'),
        status: '',
        pageNum: 1,
        pageSize: 10
      },
      totalNum: 0,
      statusOption: [
        { label: '初始状态', value: 0 },
        { label: '授信成功未开户', value: 1 },
        { label: '授信失败', value: 2 },
        {label: '禁用', value: 3},
        { label: '审核中', value: 4 },
        { label: '冻结', value: 5 },
        { label: '开户成功', value: 6 },
        { label: '开户失败', value: 7 }
      ],
      dataTable: []
    }
  },
  methods: {
    selectUserStatusChange() {
      this.queryInfo.status = this.userStatus
    },
    getVccData() {
      getVccData(this.queryInfo).then((resp) => {
        this.dataTable = resp.data.data.content
        this.totalNum = resp.data.data.totalNum
      })
    },
    // 查询vcc数据
    searchVccData() {
      this.queryInfo.pageNum = 1
      this.queryInfo.pageSize = 10
      this.getVccData()
    },
    handleSizeChange(newSize) {
      this.queryInfo.pageSize = newSize
      this.getVccData()
    },
    handleCurrentChange(newPage) {
      this.queryInfo.pageNum = newPage
      this.getVccData()
    }
  }
}
</script>

<style lang="less" scoped>
.filter {
  margin-bottom: 15px;
  font-size: 14px;
}
</style>
