<template>
  <div class="cmain">
    <companyInfo></companyInfo>
    <el-table :data="[param.row]" border style="margin-top: 13px; margin-bottom: 13px">
      <el-table-column label="结算单号" align="center" prop="num" />
      <el-table-column label="应发人数" align="center" prop="peoples" />
      <el-table-column label="应结金额(元)" align="center" prop="money" />
    </el-table>
    <div class="bos">
      <div class="lab">
        <div class="bsg"></div>
        <div class="tit">发放操作</div>
      </div>
      <el-form ref="form" :model="form" :rules="rules" label-width="120px">
        <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-row>
          <el-col :span="12">
            <el-form-item label="手机号码">
              <sms v-model="user.phone" url="/work/statement/give/sms"></sms>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="短信验证码" prop="code">
              <el-input type="number" v-model="form.code" />
            </el-form-item>
          </el-col>
        </el-row>
      </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,
      form: {},
      rules: {
        code: [{ required: true, message: '短信验证码不能为空', trigger: 'blur' }]
      }
    };
  },
  props: {
    param: {
      type: Object,
      default: () => {
        return {};
      }
    },
    layerid: {
      type: String
    }
  },
  methods: {
    submitForm() {
      this.$refs['form'].validate((valid) => {
        if (valid) {
          this.ajax({ method: 'post', url: '/work/statement/give/send', data: { id: this.param.id, code: this.form.code } }).then((response) => {
            this.$modal.msgSuccess('发放成功');
            this.$layer.close(this.layerid);
            this.$parent.getList();
          });
        }
      });
    }
  }
};
</script>
