<template>
  <el-form ref="ruleForm" label-width="80px" size="mini" :model="ruleForm" :rules="rules">
    <el-form-item label="状态" prop="status">
      <el-select v-model="ruleForm.status" style="width:100%">
        <el-option value="2" label="通过" />
        <el-option value="3" label="驳回" />
      </el-select>
    </el-form-item>

    <el-form-item label="备注" prop="remark">
      <el-input placeholder="备注" v-model="ruleForm.remark" type="textarea" />
    </el-form-item>

    <el-form-item>
      <div class="fr">
        <el-button type="primary" @click="submit">保 存</el-button>
      </div>
    </el-form-item>
  </el-form>
</template>

<script>
export default {
  name: "waitApproval",
  computed: {
    rules() {
      return {
        status: [{ required: true, message: "请选择状态", trigger: "change" }],
        remark: [
          {
            required: this.ruleForm.status === "3",
            message: "请输入备注",
            trigger: "change"
          }
        ]
      };
    }
  },
  data() {
    return {
      ruleForm: {
        status: "2",
        remark: ""
      }
    };
  },
  methods: {
    submit() {
      this.$refs.ruleForm.validate(isValid => {
        if(!isValid) return
        const { status, remark } = this.ruleForm;
        this.$emit("confirm", { status, remark });
      })
    }
  }
};
</script>
