<template>
  <div class="cmain">
    <div class="cards">
      <div class="ctop">
        <span class="icon">&#xe646;</span>
        <span class="ctitle">{{ company.companyName }}</span>
        <span class="ckk" @click="op('info')">查看</span>
        <img :src="rz" class="rz" />
        <span class="icon qr" title="点击查看企业二维码" @click="op('qr')">&#xe643;</span>
      </div>
      <div class="desc">账户余额（元）</div>
      <div class="money">{{ company.money }}</div>
    </div>
    <el-form ref="form" :model="form" :rules="rules" label-width="120px">
      <el-form-item label="结算单号" prop="money">
        <el-input type="number" v-model="form.money" 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-item label="应结金额(元)" prop="money">
        <el-input type="number" v-model="form.money" 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>
import rz from '@/assets/images/rz.png';
export default {
  data() {
    return {
      rz: rz,
      company: {},
      form: {},
      rules: {
        money: [{ required: true, message: '充值金额不能为空', trigger: 'blur' }],
        certificate: [{ required: true, message: '充值凭证不能为空', trigger: 'blur' }]
      }
    };
  },
  props: {
    param: {
      type: Object,
      default: () => {
        return {};
      }
    },
    layerid: {
      type: String
    }
  },
  mounted() {
    this.ajax({ url: '/work/company/index' }).then((response) => {
      this.company = response.data;
    });
    this.ajax({ url: '/work/statement/index' }).then((response) => {
      this.company = response.data;
    });
  },
  methods: {
    submitForm() {
      this.$refs['form'].validate((valid) => {
        if (valid) {
          this.ajax({ method: 'post', url: '/work/recharge/add', data: this.form }).then((response) => {
            this.$modal.msgSuccess('提交成功');
            this.$layer.close(this.layerid);
            this.$parent.getList();
          });
        }
      });
    }
  }
};
</script>
