<template>
  <div class="review-approvalt">
    <el-form ref="ruleForm" :model="ruleForm" :rules="rules" label-width="150px" label-position="top" class="rule-form-orange">
      <el-form-item label="授信决议" prop="approvalConclusion">
        <el-radio-group v-model="ruleForm.approvalConclusion" :disabled="isView">
          <el-radio label="pass">通过</el-radio>
          <el-radio label="back">退回</el-radio>
        </el-radio-group>
      </el-form-item>
      <el-form-item
        label="审批意见："
        style="width: 100%;"
        class="textarea-content"
        prop="approvalComments"
        :rules="[
          { required: ruleForm.approvalConclusion === 'back', message: '请输入审批意见', trigger: 'blur' }
        ]"
      >
        <el-input v-model="ruleForm.approvalComments" type="textarea" style="width: 100%;" rows="3" clearable :disabled="isView" />
      </el-form-item>
    </el-form>
  </div>
</template>

<script>
module.exports = {
  name: 'ReviewApproval',
  props: ["info"],
  data() {
    return {
      ruleForm: {
        approvalConclusion: 'pass',
        approvalComments: ''
      },
      rules: {
        approvalConclusion: [
          { required: true, message: '请选择授信决议', trigger: 'change' }
        ]
      }
    }
  },
  props: ["info", "isView"],
  methods: {
    confirm() {
      return new Promise((res, rej) => {
        this.$refs.ruleForm.validate(flag => {
          if(flag) {
            res({ creditResolutionApproval: {
              conclusion: this.ruleForm.approvalConclusion,
              suggestion: this.ruleForm.approvalComments
            }})
          } else {
            rej()
          }
        })
      })
    }
  },
  watch: {
    'info.id': {
      handler: function(val) {
        if(val) {
          this.ruleForm.approvalConclusion = this.info.creditResolutionApproval?.conclusion
          this.ruleForm.approvalComments = this.info.creditResolutionApproval?.suggestion
        }
      },
      immediate: true
    }
  }
}
</script>

<style  scoped>

</style>
