<template>
  <div class="app-container" style="overflow-y: auto;">
    <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="director">
            <el-input v-model="form.director" 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="address">
            <el-input v-model="form.address" placeholder="请输入通讯地址" clearable />
          </el-form-item>
          <el-form-item label="平台邮箱" prop="email">
            <el-input v-model="form.email" 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="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>
        <div class="bos">
          <div class="lab">
            <div class="bsg"></div>
            <div class="tit">协议</div>
          </div>
          <el-form-item label="用户协议" prop="privacy">
            <editor v-model="form.agreement" placeholder="请输入内容"></editor>
          </el-form-item>
          <el-form-item label="隐私政策" prop="privacy">
            <editor v-model="form.privacy" placeholder="请输入内容"></editor>
          </el-form-item>
        </div>
      </el-form>
      <div>
        <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' }],
        director: [{ required: true, message: '不能为空', trigger: 'blur' }],
        phone: [{ required: true, message: '不能为空', trigger: 'blur' }],
        email: [{ 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>
