<template>
  <div class="app-container">
    <el-form :model="queryParams" ref="queryForm" size="small" :inline="true" v-show="showSearch" label-width="68px">
      <el-form-item label="博主昵称" prop="nickname">
        <el-input
          v-model="queryParams.nickname"
          placeholder="请输入博主昵称"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>

      <el-form-item label="平台名称" prop="platformName">
        <el-input
          v-model="queryParams.platformName"
          placeholder="请输入平台名称"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>

      <el-form-item label="平台昵称" prop="accountName">
        <el-input
          v-model="queryParams.accountName"
          placeholder="请输入账号昵称"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </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-row :gutter="10" class="mb8">
      <el-col :span="1.5">
        <el-button
          type="info"
          plain
          size="mini"
          @click="openHis"
        >审核历史
        </el-button>
      </el-col>
      <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
    </el-row>

    <el-table v-loading="loading" :data="cardList">
      <el-table-column label="博主昵称" align="center" prop="nickname" />
      <el-table-column label="平台名称" align="center" prop="platformName" />
      <el-table-column label="账号id" align="center" prop="accountNumber" />
      <el-table-column label="平台昵称" align="center" prop="accountName" />
      <el-table-column label="粉丝数量" align="center" prop="fansNum" />
      <el-table-column label="联系方式" align="center" prop="tel" />
      <el-table-column label="商单自报价" align="center" prop="price" />
      <el-table-column label="操作" align="center" class-name="small-padding fixed-width">
        <template slot-scope="scope">
          <el-button
            size="mini"
            type="text"
            @click="handleCheck(scope.row.id)"
          >审核</el-button>
        </template>
      </el-table-column>
    </el-table>
    <pagination
      v-show="total>0"
      :total="total"
      :page.sync="queryParams.pageNum"
      :limit.sync="queryParams.pageSize"
      @pagination="getList"
    />
    <BusiCardForm ref="refForm" @success="getList"/>
    <CardCheckHis ref="hisFormRef" @success="getList"/>
  </div>
</template>
<script>
import { listCard, getCard, delCard, addCard, updateCard } from "@/api/member/busiCard";
import BusiCardForm from "@/views/member/busiCard/form/busiCardForm.vue"
import CardCheckHis from "@/views/member/busiCard/form/cardCheckHis.vue"
export default {
  name: "BusiCard",
  components: {
    BusiCardForm,CardCheckHis
  },
  data() {
    return {
      // 遮罩层
      loading: true,
      // 选中数组
      ids: [],
      // 非单个禁用
      single: true,
      // 非多个禁用
      multiple: true,
      // 显示搜索条件
      showSearch: true,
      // 总条数
      total: 0,
      // 博主名片表格数据
      cardList: [],
      // 查询参数
      queryParams: {
        pageNum: 1,
        pageSize: 10,
        nickname: null,
        platformName: null,
        accountName: null,
        approvalStatus: 0,
      },
      // 表单参数
      form: {},
      // 表单校验
      rules: {
      }
    };
  },
  created() {
    this.getList();
  },
  methods: {
    /** 查询博主名片列表 */
    getList() {
      this.loading = true;
      listCard(this.queryParams).then(response => {
        this.cardList = response.data.records;
        this.total = response.data.total;
        this.loading = false;
      });
    },

    /** 跳转审核界面*/
    handleCheck(id){
      this.$refs['refForm'].initDraw(id)
    },

    /** 搜索按钮操作 */
    handleQuery() {
      this.queryParams.pageNum = 1;
      this.getList();
    },
    /** 重置按钮操作 */
    resetQuery() {
      this.resetForm("queryForm");
      this.handleQuery();
    },

    /** 审核历史*/
    openHis(){
      this.$refs["hisFormRef"].initForm()
    },

    /** 导出按钮操作 */
    handleExport() {
      this.download('member/card/export', {
        ...this.queryParams
      }, `card_${new Date().getTime()}.xlsx`)
    }
  }
};
</script>
