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

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

  export default {
    name: 'CommunicateFeedbackButton',
    components: {
      ApprovalDialog,
    },
    mixins: [approvalButton],
    props: {
      readId: {
        type: String,
        default: '',
      },
    },
    methods: {
      handleCommunicateFeedback() {
        this.$refs.approvalDialog.openDialog()
      },
      handleSubmitForm(dialogFormData, cb) {
        const zfiles = ''
        const params = {
          instId: '', //实例id
          taskId: this.readId,
          zfiles,
          ...dialogFormData,
        }
        savaCommunicateFeedback(params)
          .then((res) => {
            if (!res.state) return this.$message.warning(res.message)
            this.$router.go(-1)
          })
          .finally(() => {
            cb()
          })
      },
    },
  }
</script>

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