<template>
  <el-dialog :visible="visible" width="500px" @close="handleClose" center :close-on-click-modal="false" title="供应商对公付款设置">
    <el-form ref="ruleForm" :model="ruleForm" :rules="rules" label-width="100px">
      <el-form-item label="银行名称" prop="bankName">
        <el-input placeholder="银行名称" />
      </el-form-item>

      <el-form-item label="银行卡号" prop="bankNumber">
        <el-input placeholder="银行卡号" />
      </el-form-item>

      <el-form-item class="flex-end">
        <el-button size="mini" type="primary" @click="onSubmit">提交</el-button>
      </el-form-item>
    </el-form>
  </el-dialog>
</template>

<script>
export default {
  props:['visible'],
  computed:{
    _visible:{
      get(){
        return this.visible
      },
      set(newVal){
        this.$emit("update:visible", newVal)
      }
    }
  },
  data(){
    return {
      ruleForm:{
        bankName:"",
        bankNumber:""
      },
      rules:{
        bankName:[
          {
            required:true,
            trigger:'change',
            message:'请输入银行名称'
          }
        ],
        bankNumber:[
          {
            required:true,
            trigger:'change',
            message:'请输入银行卡号'
          }
        ]
      }
    }
  },
  methods:{
    handleClose(){
      this._visible = false
      this.ruleForm = {
        bankName:"",
        bankNumber:""
      }
    },
    async onSubmit(){
      try{
        await this.$refs.ruleForm.validate()

        this.handleClose()
        this.$emit('refresh')
      }catch(e){
        console.log(e)
      }
    }
  }
}
</script>
