Circulate.vue 2.1 KB
<template>
  <!-- 传阅 -->
  <div>
    <ApprovalDialog
      ref="approvalDialog"
      alias="circulate"
      :dialog-title="$t('taskToCopyTo.ProcessCirculation')"
      :user-label="$t('taskToCopyTo.CirculationPersonnel')"
      :opinion-label="$t('taskToCopyTo.CirculationInstructions')"
      :is-show-user-selector="true"
      :is-get-approval-btn="isGetApprovalBtn"
      @submit-form="handleSubmitForm"
    />
  </div>
</template>

<script>
  import ApprovalDialog from './ApprovalDialog'
  import { transToMore } from '@/api/process'
  import { mapState } from 'vuex'
  export default {
    name: 'Circulate',
    components: {
      ApprovalDialog,
    },
    props: {
      taskId: {
        type: String,
        default: '',
      },
      instId: {
        type: String,
        default: '',
      },
      nodeId: {
        type: String,
        default: '',
      },
      noticeId: {
        type: String,
        default: '',
      },
      isGetApprovalBtn: {
        type: Boolean,
        default: false,
      },
    },
    data() {
      return {}
    },
    computed: {
      ...mapState('matter', ['currentShowDialogAlias']),
    },
    watch: {
      currentShowDialogAlias(val) {
        if (val && val !== 'circulate') {
          this.$refs.approvalDialog.handleClose('autoClose')
        }
      },
    },
    methods: {
      handleOpen() {
        this.$refs.approvalDialog.openDialog()
      },
      handleSubmitForm(formData, cb) {
        const { userId, files, opinion } = formData
        const data = {
          copyToType: '0',
          messageType: 'inner',
          files,
          userId,
          opinion,
          taskId: this.taskId,
          instanceId: this.instId,
          selectNodeId: this.nodeId,
          parentId: this.noticeId,
        }
        transToMore(data, (res) => {
          if (res.state) {
            this.$message.success(res.message)
            cb?.()
            this.$emit('submit-after')
          } else {
            this.$message.info(res.message)
            cb?.()
          }
        })
      },
    },
  }
</script>

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