<template>
  <div class="cmain">
    <el-form :model="queryParams" ref="queryForm" :inline="true" @submit.native.prevent v-show="showSearch">
      <el-form-item label="姓名" prop="name">
        <el-input v-model="queryParams.name" placeholder="请输入姓名" @keyup.enter.native="handleQuery" clearable />
      </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">重置</el-button>
      </el-form-item>
      <el-button type="primary" icon="el-icon-download" @click="handleQuery" style="float: right">导出excel</el-button>
    </el-form>
    <el-table :data="response.rows" border>
      <el-table-column type="index" label="序号" align="center" width="80" />
      <el-table-column label="姓名" align="center" prop="name" />
      <el-table-column label="身份证" align="center" prop="idCard" />
      <el-table-column label="手机号" align="center" prop="phone" />
      <el-table-column label="支付宝账号" align="center" prop="alipay" />
      <el-table-column label="状态" align="center" prop="state" />
      <template slot="empty">
        <el-empty></el-empty>
      </template>
    </el-table>
    <pagination v-if="response.total > 0" :total="response.total" :page.sync="queryParams.pageNum" :limit.sync="queryParams.pageSize" @pagination="getList" />
  </div>
</template>

<script>
export default {
  name: 'Packages',
  data() {
    return {
      response: {},
      queryParams: {
        pageNum: 1,
        pageSize: 10,
        projectId: null,
        name: null,
        orderByColumn: 'p.id',
        isAsc: 'desc'
      }
    };
  },
  props: {
    param: {
      type: Object,
      default: () => {
        return {};
      }
    },
    layerid: {
      type: String
    }
  },
  mounted() {
    this.queryParams.projectId = this.param.projectId;
    this.getList();
  },
  methods: {
    getList() {
      this.ajax({ url: '/work/packages/list', data: this.queryParams }).then((response) => {
        this.response = response;
      });
    },
    handleQuery() {
      this.queryParams.pageNum = 1;
      this.getList();
    },
    resetQuery() {
      this.resetForm('queryForm');
      this.handleQuery();
    },
    /** 导出按钮操作 */
    handleExport() {
      this.download('/work/packages/export', { ...this.queryParams }, `caseinfo_${new Date().getTime()}.xlsx`);
    }
  }
};
</script>
