<template>
  <div class="table-box">
    <div class="modal-title">
      <el-form :model="form" :inline="true" ref="modalSearch">
        <el-form-item label="银行名称" prop="bankname">
          <el-input
            v-model="form.bankname"
            style="width: 170px; margin-right: 2px"
            placeholder="请输入银行名称"
            clearable
          />
        </el-form-item>
      </el-form>
      <el-button type="primary" @click="onSubmit">查询</el-button>
    </div>
    <el-table
      ref="multipleTable"
      v-loading="loding"
      :data="tableData"
      element-loading-text="加载中..."
      border
      fit
      highlight-current-row
      max-height="400"
      @row-dblclick="rowClick"
    >
      <template slot="empty">
        <img src="" alt />
        <p>暂无数据</p>
      </template>
      <el-table-column
        fixed="left"
        align="center"
        type="index"
        label="序号"
        width="50"
      />

      <el-table-column align="center" label="银行行别代码" prop="bankTypeCode">
      </el-table-column>
      <el-table-column align="center" label="银行名称" prop="bankname">
      </el-table-column>
      <el-table-column
        align="center"
        label="操作"
        #default="{ row }"
        fixed="right"
      >
        <span class="operate-btn" @click.stop="selectRowData(row)">选择</span>
      </el-table-column>
    </el-table>
    <div class="block">
      <el-pagination
        @size-change="handleSizeChange"
        @current-change="handleCurrentChange"
        :current-page="crutPage"
        :page-sizes="[10, 20, 30, 40]"
        :page-size="pageSize"
        layout="total, sizes, prev, pager, next, jumper"
        :total="total"
      >
      </el-pagination>
    </div>
  </div>
</template>
<script>
import { dialogTableClumn, dislogTableData } from "./form";
import { querySupBankCode } from "@/api/bank-manage/index";
import moment from "moment";
const pagaData = { current: 1, size: 10 };
export default {
  name: "tableView",
  components: {},
  data() {
    return {
      loding: false, // 表格数据加载loding
      tableData: [], // 表格数据
      clumnData: dialogTableClumn, // 表格头数据
      total: 0,
      pageSize: 10,
      crutPage: 1,
      searchData: {},
      form: {
        bankname: "",
      },
    };
  },
  props: {
    getTableData: {
      type: Object,
      default: {},
    },
    getsearchData: {
      type: Object,
      default: {},
    },
  },
  created() {
    this.getData({ ...pagaData });
  },
  mounted() {},
  methods: {
    //查询按钮触发
    onSubmit() {
      this.$refs["modalSearch"].validate((valid) => {
        if (valid) {
          this.getData();
        }
      });
    },
    getData(data) {
      querySupBankCode({ ...data, ...this.form }).then((res) => {
        if (res.success == true) {
          this.tableData = res.data.records;
          this.total = res.data.total;
          this.pageSize = res.data.size;
        }
      });
    },
    //选择某一条数据
    selectRowData(row) {
      this.$emit("selectRowList", row);
    },
    //每页几条数据
    handleSizeChange(val) {
      this.pageSize = val;
      this.crutPage = 1;
      let tablePam = { size: val, current: 1 };
      this.getData({ ...tablePam });
    },
    // 当前在第几页
    handleCurrentChange(val) {
      this.crutPage = val;
      let tablePam = { size: this.pageSize, current: val };
      this.getData({ ...tablePam });
    },
  },
  watch: {
    //表格数据发生改变时重新渲染
  },
};
</script>
<style scoped lang="scss">
.table-box {
  padding: 1px;
  position: relative;
  padding-bottom: 50px;
  .block {
    position: absolute;
    right: 10px;
    bottom: 10px;
  }
  .modal-title {
    width: 100%;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: space-between;
  }
  .operate-btn {
    color: #3789ea;
    cursor: pointer;
    margin-left: 10px;
  }
}
</style>
