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

<script>
  import ApprovalDialog from './ApprovalDialog'
  import { savaInquiryReply } from '@/api/process'
  import approvalButton from '@/mixins/approvalButton'
  export default {
    name: 'InquiryReplyButton',
    components: {
      ApprovalDialog,
    },
    mixins: [approvalButton],
    methods: {
      handleInquiryReply() {
        this.$refs.approvalDialog.openDialog()
      },
      handleSubmitForm(dialogFormData, cb) {
        const zfiles = ''
        const params = {
          procDefId: this.bpmTask.procDefId, //定义id
          procInstId: this.bpmTask.procInstId, //实例id
          taskId: this.taskId,
          status: 'inqu_reply',
          formData: JSON.stringify(this.data),
          zfiles,
          ...dialogFormData,
        }
        savaInquiryReply(params)
          .then((res) => {
            if (!res.state) return this.$message.warning(res.message)
            this.$message.success(res.message)
            this.dialogModeApprovalCompletionToPre('inquiryReply')
          })
          .finally(() => {
            cb()
          })
      },
    },
  }
</script>

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