<template>
  <div class="approval-button-item countersign-feedback-button">
    <el-button
      :size="btnSize"
      :disabled="disabled"
      type="primary"
      @click="handleCountersignFeedback"
    >
      {{ $t('common.user_add_sign_back') }}
    </el-button>
    <approval-dialog
      ref="approvalDialog"
      alias="countersignFeedbackButton"
      :dialog-title="$t('common.user_add_sign_back')"
      :is-get-approval-btn="isGetApprovalBtn"
      @submit-form="handleSubmitForm"
    ></approval-dialog>
  </div>
</template>

<script>
  import approvalButton from '@/mixins/approvalButton'
  import ApprovalDialog from './ApprovalDialog'
  import { savaCountersignFeedback } from '@/api/process'

  export default {
    name: 'CountersignFeedbackButton',
    components: {
      ApprovalDialog,
    },
    mixins: [approvalButton],
    methods: {
      handleCountersignFeedback() {
        this.$refs.approvalDialog.openDialog()
      },
      handleSubmitForm(dialogFormData, cb) {
        const params = {
          procDefId: this.bpmTask.procDefId, //定义id
          procInstId: this.bpmTask.procInstId, //实例id
          taskId: this.taskId,
          status: 'inqu_reply',
          zfiles: '',
          ...dialogFormData,
        }
        savaCountersignFeedback(params)
          .then((res) => {
            if (!res.state) return this.$message.error(res.message)
            this.$message.success(res.message)
            this.dialogModeApprovalCompletionToPre('feedback')
          })
          .finally(() => {
            cb()
          })
      },
    },
  }
</script>

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