<script>
export default {
  name: 'RejectReasonModal',
  props: {
    value: {
      type: Boolean,
      default: false,
    },
  },
  data() {
    return {
      visible: this.value,
      rejectReason: "",
    };
  },
  watch: {
    value(newVal) {
      this.visible = newVal;
    },
  },
  methods: {
    handleOk() {//改为已处理
      if (!this.rejectReason.trim()) {
        this.$message.error("请填写处理办法！");
        return;
      }
      this.$emit("ok", this.rejectReason);
      this.visible = false;
      this.$emit("input", false);
      this.rejectReason = "";
    },
    handleCancel() {
      this.visible = false;
      this.$emit("input", false);
      this.rejectReason = "";
    },
    handleReject() {//改为驳回
      this.visible = false;
      this.$emit("input", false);
      this.$emit("cancel", this.rejectReason);
      this.rejectReason = "";
    },
  },
}
</script>

<template>
  <a-modal
    v-model="visible"
    title="处理"
    :destroyOnClose="true"
    @cancel="handleCancel"
  >
    <template slot="footer">
      <a-button key="back" type="danger" @click="handleReject">驳回</a-button>
      <a-button key="submit" type="primary" @click="handleOk">
        提交
      </a-button>
    </template>
    <a-textarea
      v-model="rejectReason"
      placeholder="请输入处理意见"
      :rows="4"
    />
  </a-modal>
</template>

<style scoped>

</style>