<template>
  <div>
    <el-button size="mini" type="text" @click="onShow">编 辑</el-button>
    <el-drawer
        title=" 新建银行卡信息"
        :visible.sync="dialogFormVisible"
        size="600px"
        direction="rtl"
        :show-close="false"
        append-to-body
        @close="onClose">
      <div class="drawer__panel">
        <el-row :gutter="20">
          <el-form :model="form" :rules="rules"  ref="form"  size="mini" label-position="right" label-width="85px">
            <el-col :span="24">
              <el-form-item  label="银行名称:" prop="bank">
                <el-input  v-model="form.bank" placeholder="请输入银行名称"></el-input>
              </el-form-item>
            </el-col>
            <el-col :span="24">
              <el-form-item  label="卡号:" prop="bankcardno">
                <el-input   v-model="form.bankcardno" placeholder="请输入卡号"></el-input>
              </el-form-item>
            </el-col>
            <el-col :span="24">
              <el-form-item  label="开户人:" prop="name">
                <el-input   v-model="form.name" placeholder="请输入开户人"></el-input>
              </el-form-item>
            </el-col>
            <el-col :span="24">
              <el-form-item  label="手机号码:" prop="phonenumber">
                <el-input   v-model="form.phonenumber" placeholder="请输入手机号码"></el-input>
              </el-form-item>
            </el-col>
          </el-form>
        </el-row>
      </div>
      <div class="fixed__btn__panel">
        <el-button size="small" @click="onClose" class="normal-btn-width">取 消</el-button>
        <el-button size="small" type="primary" @click="onSubmit" class="normal-btn-width">确 定</el-button>
      </div>
    </el-drawer>
  </div>
</template>

<script>
export default {
  name: "edit",
  props:["data"],
  data(){
    return {
      dialogFormVisible:false,
      form:{
        "sys_enterprise_bankid": 0,
        "bank": "",
        "bankcardno": "",
        "name": "",
        "phonenumber": "",
        "sys_enterpriseid":1//不传，插入当前账号
      },
      rules:{
        bank: [
          { required: true, message: '银行名称不能为空', trigger: 'blur' },
        ],
        bankcardno: [
          { required: true, message: '卡号不嫩为空', trigger: 'blur' },
        ],
        name: [
          { required: true, message: '开户人不能为空', trigger: 'blur' },
        ],
      },
    }
  },
  methods:{
    onShow(){
      this.dialogFormVisible = true
      this.form = Object.assign({},this.form,this.data)
    },
    onClose(){
      this.dialogFormVisible = false
      this.$refs.form.resetFields()
    },
    onSubmit(){
      this.$refs.form.validate(async (valid) => {
        if (!valid) return false
        this.form.sys_enterpriseid = this.data.sys_enterpriseid
        const res = await this.$api.requested({
          "id": 20221022165703,
          "content": this.form
        })
        this.tool.showMessage(res,()=>{
          this.dialogFormVisible = false
          this.$refs.form.resetFields()
          this.$emit('updateSuccess')
        })
      })
    }
  }
}
</script>

<style scoped>

</style>