<template>
  <div class="approval-button-item circulation-reply-button">
    <el-button
      type="primary"
      :size="btnSize"
      :disabled="disabled"
      @click="handleCirculationReply"
    >
      {{ $t('common.reply') }}
    </el-button>
    <approval-dialog
      ref="approvalDialog"
      alias="reply"
      :dialog-title="$t('common.reply')"
      @submit-form="handleSubmitForm"
    ></approval-dialog>
  </div>
</template>

<script>
  import ApprovalDialog from './ApprovalDialog'
  import { savaCirculationReply } from '@/api/process'

  import approvalButton from '@/mixins/approvalButton'
  export default {
    name: 'CirculationReplyButton',
    components: {
      ApprovalDialog,
    },
    mixins: [approvalButton],
    methods: {
      handleCirculationReply() {
        this.$refs.approvalDialog.openDialog()
      },
      handleSubmitForm(dialogFormData, cb) {
        const zfiles = ''
        const params = {
          instId: this.$route.query.instId, //实例id
          taskId: this.$route.query.readId,
          zfiles,
          ...dialogFormData,
        }
        savaCirculationReply(params)
          .then((res) => {
            if (!res.state) return this.$message.warning(res.message)
            this.$router.go(-1)
          })
          .finally(() => {
            cb()
          })
      },
    },
  }
</script>

<style lang="scss" scoped></style>
