<template>
  <div class="cmain">
    <el-form ref="form" :model="form" :rules="rules" label-width="120px">
      <el-form-item label="姓名" prop="name">
        <el-input v-model="form.name" placeholder="请输入姓名" clearable />
      </el-form-item>
      <el-form-item label="身份证号" prop="idCard">
        <el-input v-model="form.idCard" placeholder="请输入身份证号" clearable />
      </el-form-item>
      <el-form-item label="手机号" prop="phone">
        <el-input v-model="form.phone" placeholder="请输入手机号" clearable />
      </el-form-item>
      <el-form-item label="支付宝" prop="alipay">
        <el-input v-model="form.alipay" placeholder="请输入支付宝" clearable />
      </el-form-item>
      <el-form-item label="开户行" prop="bankName">
        <el-input v-model="form.bankName" placeholder="请输入开户行" clearable />
      </el-form-item>
      <el-form-item label="银行卡号" prop="bankAccount">
        <el-input v-model="form.bankAccount" placeholder="请输入银行卡号" clearable />
      </el-form-item>
      <el-form-item label="结算金额(元)" prop="money">
        <el-input type="number" v-model="form.money" placeholder="请输入结算金额" clearable />
      </el-form-item>
    </el-form>
    <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 {
    dicts: ['invoice', 'channel'],
    data() {
      return {
        form: {},
        rules: {
          name: [{ required: true, message: '不能为空', trigger: 'blur' }],
          idCard: [{ required: true, message: '不能为空', trigger: 'blur' }],
          phone: [{ required: true, message: '不能为空', trigger: 'blur' }],
          alipay: [{ required: true, message: '不能为空', trigger: 'blur' }],
          bankName: [{ required: true, message: '不能为空', trigger: 'blur' }],
          bankAccount: [{ required: true, message: '不能为空', trigger: 'blur' }],
          money: [{ required: true, message: '不能为空', trigger: 'blur' }]
        }
      };
    },
    props: {
      param: {
        type: Object,
        default: () => {
          return {};
        }
      },
      layerid: {
        type: String
      }
    },
    mounted() {
      this.form = this.param.form;
    },
    methods: {
      submitForm() {
        this.$refs['form'].validate((valid) => {
          if (valid) {
            this.ajax({ method: 'post', url: '/work/statement/make/statementDetail/edit', data: this.form }).then((response) => {
              this.$modal.msgSuccess('编辑成功');
              this.$layer.close(this.layerid);
              this.$parent.getList();
            });
          }
        });
      }
    }
  };
</script>
