<template>
  <div class="app-container">
    <div class="cmain">
      <el-form ref="form" :model="form" :rules="rules" label-width="120px">
        <div class="bos">
          <div class="lab">
            <div class="bsg"></div>
            <div class="tit">企业充值信息</div>
          </div>
          <el-form-item label="服务公司" prop="serviceCompany">
            <el-input v-model="form.serviceCompany" 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>
        </div>
        <div class="bos">
          <div class="lab">
            <div class="bsg"></div>
            <div class="tit">结算信息</div>
          </div>
          <el-form-item label="综合服务费率" prop="rate">
            <el-input type="number" v-model="form.rate" placeholder="请输入综合服务费率" clearable><template slot="append">%</template></el-input>
          </el-form-item>
        </div>
      </el-form>
      <div class="mfooter">
        <el-button type="primary" @click="submitForm">确 定</el-button>
        <el-button @click="$layer.close(layerid)">取 消</el-button>
      </div>
    </div>
  </div>
</template>

<script>
export default {
  data() {
    return {
      form: {},
      rules: {
        serviceCompany: [{ required: true, message: '服务公司不能为空', trigger: 'blur' }],
        bankName: [{ required: true, message: '开户行不能为空', trigger: 'blur' }],
        bankAccount: [{ required: true, message: '银行卡号不能为空', trigger: 'blur' }],
        rate: [{ required: true, message: '综合服务费率不能为空', trigger: 'blur' }],
      }
    };
  },
  mounted() {
    this.ajax({ url: '/work/platform/detail' }).then((response) => {
      this.form = response.data;
    });
  },
  methods: {
    submitForm() {
      this.$refs['form'].validate((valid) => {
        if (valid) {
          if (this.form.id) {
            this.ajax({ method: 'post', url: '/work/platform/edit', data: this.form }).then((response) => {
              this.$modal.msgSuccess('修改成功');
            });
          }
        }
      });
    }
  }
};
</script>
