// 传阅

<template>
  <div>
    <allSimilarDialog
      :title="'传阅'"
      ref="allSimilarDialog"
      :task-id="taskId"
      :inst-id="instId"
      :node-id="nodeId"
      :notice-id="noticeId"
      @onClickRight="onClickRight"
    ></allSimilarDialog>
  </div>
</template>

<script>
  import matterButton from '@/mixins/matterButton.js'

  import { transToMore } from '@/api/process'
  import allSimilarDialog from '@/views/matter/components/allSimilarDialog.vue'
  export default {
    name: 'CirculatedButton',
    mixins: [matterButton],
    components: { allSimilarDialog },
    props: {
      userSelectorIsSingle: {
        type: Boolean,
        default: false,
      },
      taskId: {
        type: String,
        default: '',
      },
      instId: {
        type: String,
        default: '',
      },
      nodeId: {
        type: String,
        default: '',
      },
      defId: {
        type: String,
        default: '',
      },
      noticeId: {
        type: String,
        default: '',
      },
    },
    data() {
      return {
        showRejectMethod: false,
        showOften: false,
      }
    },
    methods: {
      showDialog() {
        this.$refs.allSimilarDialog.showDialog()
      },

      onClickRight(val, cb) {
        const { userId, files, opinion } = val
        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.$toast.success(res.message)
            cb?.()
            this.$emit('closePop')
            this.$emit('submit-after')
          } else {
            this.$toast.fail(res.message)
          }
        })
      },
    },
  }
</script>

<style lang="scss" scoped>
  @import '@/styles/matterButton.scss';
</style>
