<template>
    <div class="page-selectAccounting"> 
       <EMSTable action="query" :server="server" :stripe="false" ref="configTable" :columns="propsColumns" :params = "searchForm" :highlight-row="true" :onSelectionChange="onSelectRow">
          <Form :model="searchForm" ref="searchForm" slot="search-bar" label-position="top" class="ivu-form-no-margin-bottom" inline>
             <Form-item prop="compName" label="收款单位名称">
                  <Input type="text" v-model="searchForm.compName" clearable/>
              </Form-item>
          </Form> 
          <div slot="handle-bar">
              <Button @click.native="search()" type="warning" icon="search">查询</Button>
              <Button @click.native="reset" type="info" icon="loop">重置</Button>
          </div>
      </EMSTable>
    </div>
</template>
<script>
import { EMSTable } from "ems-components";
import Server from "./server.js";
const server = new Server();
export default {
  name: "SelectCompCodeList",
  components: {
    EMSTable
  },
  props: {
    title: {
      type: String,
      default: "公司查询"
    }
  },
  data() {
    return {
      server: server,
      //搜索表单的属性
      searchForm: {
        bankAccountName: "",
        bankAccountNum: "",
        compName: ""
      },
      propsColumns: [
        {
          type: "selection",
          align: "center",
          width: 40,
          fixed: "left"
        },
        {
          title: "收款单位名称",
          key: "compName",
          render: (h, params) => {
            let val = params.row.compName;
            return h(
              "div",
              {
                attrs: {
                  class: "ivu-table-cell ivu-table-cell-ellipsis",
                  title: val
                }
              },
              val
            );
          }
        }
      ]
    };
  },
  created() {
    this.$emit("SetTitle", this.title);
    // this.$emit('SetPageSize',800);
  },
  mounted() {},
  methods: {
    //点击表格行 触发该事件
    onSelectRow(selected) {
      if (selected.length == 0) {
        return;
      }
      if (selected.length > 1) {
        this.$Message.warning({
          content: `只能选择一条数据`,
          duration: 5
        });
        return;
      }
      this.$emit("Close", selected[0]);
    },
    search(page = 1) {
      //搜索数据
      this.$refs["configTable"].load(this.searchForm, page);
    },
    reset() {
      this.$refs["searchForm"].resetFields();
      this.search(1);
    }
  }
};
</script>
<style>
.page-selectAccounting .ivu-form-item-content {
  display: block;
}
</style>