<template>
  <div class="cmain">
    <div class="bos">
      <el-steps :active="1" align-center class="cg">
        <el-step title="提现信息"></el-step>
        <el-step title="平台确认"></el-step>
        <el-step title="提现到账"></el-step>
      </el-steps>
      <el-form ref="company" :model="company" label-width="100px">
        <el-form-item label="开户行">
          <el-input v-model="company.bankName" disabled />
        </el-form-item>
        <el-form-item label="银行账户">
          <el-input v-model="company.bankAccount" disabled />
        </el-form-item>
      </el-form>
      <el-form ref="form" :model="form" :rules="rules" label-width="100px">
        <el-form-item label="提现金额" prop="money">
          <el-input type="number" v-model="form.money" placeholder="提现金额不能大于账户余额" clearable />
        </el-form-item>
        <el-form-item label="手机号码">
          <sms v-model="user.phone" url="/work/out/sms"></sms>
        </el-form-item>
        <el-form-item label="短信验证码" prop="code">
          <el-input type="number" v-model="form.code" placeholder="输入6位验证码" />
        </el-form-item>
      </el-form>
    </div>
    <div class="mfooter">
      <el-button type="primary" @click="submitForm">确 定</el-button>
      <el-button @click="$layer.close(layerid)">取 消</el-button>
    </div>
  </div>
</template>

<script>
export default {
  data() {
    return {
      user: this.$store.state.user,
      company: {},
      form: {},
      rules: {
        money: [{ required: true, message: '提现金额不能为空', trigger: 'blur' }],
        code: [{ required: true, message: '验证码不能为空', trigger: 'blur' }]
      }
    };
  },
  props: {
    param: {
      type: Object,
      default: () => {
        return {};
      }
    },
    layerid: {
      type: String
    }
  },
  mounted() {
    this.company = this.param.company;
  },
  methods: {
    submitForm() {
      this.$refs['form'].validate((valid) => {
        if (valid) {
          this.ajax({ method: 'post', url: '/work/out/add', data: this.form }).then((response) => {
            this.$modal.msgSuccess('申请成功');
            this.$layer.close(this.layerid);
            this.$parent.getList();
          });
        }
      });
    }
  }
};
</script>
