<template>
  <div class="cmain">
    <el-form :model="queryParams" ref="queryForm" :inline="true" @submit.native.prevent>
      <el-form-item label="姓名" prop="name">
        <el-input v-model="queryParams.name" placeholder="请输入姓名" @keyup.enter.native="handleQuery" class="inp" clearable />
      </el-form-item>
      <el-form-item label="手机号" prop="phone">
        <el-input v-model="queryParams.phone" placeholder="请输入手机号" @keyup.enter.native="handleQuery" class="inp" clearable />
      </el-form-item>
      <el-form-item label="身份证号" prop="idCard">
        <el-input v-model="queryParams.idCard" 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-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="bankName"/>
      <el-table-column label="银行卡号" align="center" prop="bankAccount"/>
      <el-table-column label="结算金额(元)" align="center" prop="money"/>
      <el-table-column label="操作" align="center" width="160" fixed="right" v-if="!param.detail">
        <template slot-scope="scope">
          <el-button size="mini" type="text" icon="el-icon-edit" @click="op('edit', scope.row)">编辑</el-button>
          <el-button size="mini" type="text" icon="el-icon-delete" @click="del(scope.row)">删除</el-button>
        </template>
      </el-table-column>
      <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>
  import edit from './recordEdit.vue';
  export default {
    data() {
      return {
        response: {},
        queryParams: {
          pageNum: 1,
          pageSize: 10,
          name: null,
          phone: null,
          idCard: null,
          orderByColumn: 'id',
          isAsc: 'desc'
        }
      };
    },
    props: {
      param: {
        type: Object,
        default: () => {
          return {};
        }
      },
      layerid: {
        type: String
      }
    },
    created() {
      this.queryParams.statementId = this.param.form.id;
      this.getList();
    },
    methods: {
      getList() {
        this.ajax({ url: '/work/statement/detailList', data: this.queryParams }).then((response) => {
          this.response = response;
        });
      },
      handleQuery() {
        this.queryParams.pageNum = 1;
        this.getList();
      },
      resetQuery() {
        this.resetForm('queryForm');
        this.handleQuery();
      },
      op(tag, row) {
        if (tag == 'edit') {
          this.iframe({ obj: edit, param: { form: row }, title: '编辑结算单', width: '35%', height: '55%' });
        }
      },
      del(row) {
        this.$confirm('是否确认删除选中数据?', '警告', { type: 'warning' }).then(() => {
          this.get({ url: '/work/statement/make/statementDetail/remove/' + row.id }).then((response) => {
            this.$modal.msgSuccess('删除成功');
            this.getList();
          });
        });
      }
    }
  };
</script>
