<template>
  <div>
    <el-card>
    <el-form
        :model="queryParams"
        ref="queryForm"
        size="small"
        :inline="true"
        label-width="120px"
        style="margin-bottom: 10px;"
    >
      <el-form-item label="申请用户姓名" prop="search">
        <el-input
            v-model="queryParams.a7"
            placeholder="请输入申请用户姓名"
            clearable
            style="width: 240px"
            @keyup.enter.native="getList"
        />
      </el-form-item>
      <el-form-item label="申请用户手机号" prop="vip">
        <el-input
            v-model="queryParams.a6"
            placeholder="请输入申请用户手机号"
            clearable
            style="width: 240px"
            @keyup.enter.native="getList"
        />
        </el-form-item>
      </el-form>
      <el-button type="primary" @click="getList">查询</el-button>
      <el-button type="primary" @click="reset">重置</el-button>
    </el-card>
    <el-table
      v-loading="loading"
      :data="userList"
    >
    <el-table-column label="申请用户姓名" align="center" key="a7" prop="a7" />
    <el-table-column label="申请用户手机号" align="center" key="a6" prop="a6" />
    <el-table-column label="是否已经审核" align="center" key="a1" prop="a1">
      <template slot-scope="scope">
        {{scope.row.a1 == 0 ? '审核中' :scope.row.a1 == 1 ? '已通过' : '未提交'}}
      </template>
    </el-table-column>
    <el-table-column label="申请类型" align="center" key="a3" prop="a3" >
      <template slot-scope="scope">
        {{scope.row.a3 == 3 ? '3人' :scope.row.a3 == 10 ? '10人' :scope.row.a3 == 20 ? '20人' :scope.row.a3 == 50 ? '50人' :scope.row.a3 == 100 ? '100人' : ''}}
      </template>
    </el-table-column>
    <el-table-column label="赠送产品编号" align="center" key="a4" prop="a4" />
    <el-table-column label="操作" align="center" width="200px">
      <template slot-scope="scope">
        <div v-if="scope.row.a1 == 0" style="display: flex; justify-content: space-between;">
          <el-button size="mini" type="primary" @click="handleEdit(scope.row)">审核通过</el-button>
          <el-button size="mini" type="danger" @click="handledelete(scope.row)">审核不通过</el-button>
        </div>
      </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 request from '@/utils/request'
export default {
  name: "jiangli",
  data() {
    return {
      userList: [],
      total: 0,
      loading: false,
      queryParams: {
        pageNum: 1,
        pageSize: 10,
        a7: '',
        a6: '',
      },
    };
  },
  mounted() {
    this.getList();
  },
  methods: {
    reset(){
      this.queryParams = {
        pageNum: 1,
        pageSize: 10,
        a7: '',
        a6: '',
      };
      this.getList();
    },
    getList() {
      this.loading = true;
      request({
        url: '/yw6/listAll',
        method: 'get',
        params: this.queryParams,
        }).then(res => {
          this.userList = res.rows;
          this.total = res.total;
          this.loading = false;
          console.log(this.userList)
      })
    },
    handleEdit(item){
      request({
        url:"/yw6/editTg",
        method:"put",
        data:{
          a2:item.a2,
        }
      }).then(res => {
        this.$message.success("操作成功");
        this.getList();
      })
    },
    handledelete(item){
      request({
        url:`/yw6/remove/${item.a2}`,
        method:"delete",
      }).then(res => {
        this.$message.success("操作成功");
        this.getList();
      })
    }
  },  
};
</script>