<template>
<el-dialog title="银行信息查询" :visible.sync="visible" width="800px" @close="handleClose">
      <div class="eContainer-params">
        <el-form
          :model="params"
          ref="modelForm"
          label-position="left"
          label-width="150px"
          @submit.native.prevent
          size="small"
        >
          <c-col :span="12">
            <c-col :span="22">
              <el-form-item label="SWIFT编号" prop="swiftNo">
                <c-input size="small" v-model="params.swiftNo" maxlength="11" placeholder="请输入SWIFT编号"></c-input>
              </el-form-item>
            </c-col>

            <c-col :span="22">
              <el-form-item label="银行英文名称" prop="ptyEnName">
                <c-input size="small" v-model="params.ptyEnName" maxlength="200" placeholder="请输入银行英文名称"></c-input>
              </el-form-item>
            </c-col>
          </c-col>

          <c-col :span="12">
            <c-col :span="22">
              <el-form-item label="类型" prop="partInoutCrClrFlag">
                <c-radio v-model="params.partInoutCrClrFlag" label="2">SWIFT</c-radio>
                <c-radio v-model="params.partInoutCrClrFlag" label="1">FMT</c-radio>
              </el-form-item>
            </c-col>

            <c-col :span="22">
              <el-form-item label="银行英文地址" prop="ptyEnAddr">
                <c-input size="small" v-model="params.ptyEnAddr" maxlength="200" placeholder="请输入银行英文地址"></c-input>
              </el-form-item>
            </c-col>
          </c-col>

          <c-col :span="24" style="text-align:center;">
            <el-button size="small" type="primary" icon="el-icon-search" @click="handleSearch">查询</el-button>
            <el-button size="small" type="primary" @click="handleReset">重置</el-button>
          </c-col>
        </el-form>
      </div>

      <div>
        <c-list-page
          ref="cList"
          :columnsConfig="columnsConfig"
          :params="searchParams"
          :pageSize="pageSize"
          :loadDataFirstRender="false"
          @row-click="handleRowClick"
          url="v1/pm/pty/ptys"
        ></c-list-page>
      </div>
    </el-dialog>
</template>

<script>
export default {
  props: {
    visible: {
      type: Boolean,
      default: false
    }
  },
  data: function () {
    return {
      params: {
        swiftNo: '',
        ptyEnName: '',
        swiftNo: "",
        ptyEnName: "",
        ptyEnAddr: "",
        partInoutCrClrFlag: "",
        ptyTpCd: "3",//查询银行类型
        establshTestKeyFlag: "" //是否建立密押关系
      },
      searchParams: {
        swiftNo: "",
        ptyEnName: "",
        ptyEnAddr: "",
        partInoutCrClrFlag: "",
        ptyTpCd: "3",//查询银行类型
        establshTestKeyFlag: "" //是否建立密押关系
      },
      pageSize: 5,
      columnsConfig: [
        {
          prop: "swiftNo",
          label: "SWIFT编号"
        },
        {
          prop: "ptyEnName",
          label: "银行英文名称"
        },
        {
          prop: "ptyEnAddr",
          label: "银行英文地址"
        }
      ]
    };
  },
  methods: {
    handleClose: function () {
      this.$emit('close')
    },
    handleRowClick: function (row) {
      console.log('dialog rowselection')
      let result = {
        BIC: row.swiftNo,
        NAM1: row.ptyEnName
      }
      this.$emit('rowselect', result)
      this.$emit('close')
    }, 
    handleSearch: function () {
      this.searchParams = {...this.params}
    },
    handleReset: function () {
      this.$refs.modelForm.resetFields();
      if (this.testKeyRelatFlag) {
        this.params.establshTestKeyFlag = "Y";
        this.searchParams = {
          ...this.params
        }
      } else {
        this.searchParams = {
          ...this.params
        }
      }
    }
  }
}
</script>

<style>
.m-swf-bank {
  margin-top: -10px;
}
.m-swf-bank .el-form-item{
  margin-bottom: 0;
}
</style>
