portalAction.js 4.48 KB
export default {
  data() {
    return {
      pagination: {
        page: 1,
        pageSize: 30,
        total: 0,
      },
      selectedRows: [],
      pageSizes: [10, 20, 30, 50, 100, 200, 300],
      headerStyle: {
        background: '#fafafa',
      },
    }
  },
  computed: {
    tableHeight() {
      return this.$baseTableHeight(-47)
    },
  },
  mounted() {
    this.$baseEventBus.$on('get-layout-config', () => {
      localStorage.setItem(
        this.columnConfig.id,
        JSON.stringify(this.columnConfig.updateDate)
      )
      if (this.$refs.htPortal) {
        this.$refs.htPortal?.updateColumnLayout()
      }
    })
    this.$baseEventBus.$on('add-column', (layoutId) => {
      if (this.$refs.htPortal) {
        this.$refs.htPortal.addColumn(layoutId)
      }
    })
  },
  methods: {
    handleClickProcess(row, type, tableData) {
      if (['commonProcess', 'processOverview', 'collection'].includes(type)) {
        this.$refs.leaderDialog.handleNewProcessJumps(row)
      } else if (type === 'todo') {
        this.$refs.leaderDialog.handleJumpsTodoPage(
          row,
          {
            isGetApprovalBtn: true,
            type: 'fromTodoList',
            key: tableData.length === 1 ? 'onlyOneTask' : '',
          },
          (url) => {
            this.menuSelect('11')
          }
        )
      } else if (type === 'request') {
        this.handleRequestJump(row)
      } else if (type === 'draft') {
        const path = '/matter/startProcess'
        this.$router.push({
          path,
          query: this.getCurrentQuery(row, type),
        })
      } else if (type === 'done') {
        this.setReaded(row.id)
        const path = '/matter/approvalForm'
        this.$router.push({
          path,
          query: this.getCurrentQuery(row, type),
        })
      } else {
        const path = '/matter/approvalForm'
        this.$router.push({
          path,
          query: this.getCurrentQuery(row, type),
        })
      }
    },

    getColumnLayout(data) {
      this.columnConfig = data
      sessionStorage.setItem('layoutId', data.id)
      //判断管理端是否修改了栏目布局 identifyChange:0.前台未进行拖拽  1.前台更新后,后台未更新 2.前台更新之后,后台进行更新
      if ([1, 2].includes(data.identifyChange)) {
        localStorage.setItem(`isNewLayout_${data.id}`, true)
        this.$baseEventBus.$emit('change-layout', { isNewLayout: true })
      } else {
        localStorage.setItem(`isNewLayout_${data.id}`, false)
        this.$baseEventBus.$emit('change-layout', { isNewLayout: false })
      }
    },
    changeLayout() {
      localStorage.setItem(`isDragColumn_${this.columnConfig.id}`, true)
      this.$baseEventBus.$emit('change-layout', { isDragColumn: true })
    },
    handleRequestJump(row) {
      getMyRequestTask(row.id).then((res) => {
        let task = res.value
        const path = '/matter/approvalForm'
        let query = {
          instId: row.id,
          // 这个参数用于检查是否有撤回流程权限
          type: 'request',
          myApplication: true,
        }
        if (task && task.id) {
          query = {
            ...query,
            taskId: task.id,
            isGetApprovalBtn: true,
          }
        }
        this.$router.push({
          path,
          query,
        })
      })
    },
    setReaded(id) {
      this.$requestConfig.setReaded({ procInstId: id }).then((resp) => {
        console.log(resp)
      })
    },
    getCurrentQuery(row, type) {
      const { id, procInstId, nodeId } = row
      const queryMap = {
        done: {
          type: 'done',
          doneTaskId: row.taskId,
          isDefAuthorize: row.isDefAuthorize,
        },
        draft: {
          defId: row.procDefId,
          name: row.subject,
          instStatus: row.status,
        },
        received: {
          readId: row.id, //为知会任务表的id
          receivedStatus: row.status,
          isRead: row.isRead,
        },
        circulated: {
          readId: row.id,
        },
      }
      let query = {
        instId: ['done', 'request', 'draft'].includes(type) ? id : procInstId,
        nodeId,
        from: type,
      }
      if (['done', 'draft', 'received', 'circulated'].includes(type)) {
        query = {
          ...query,
          ...queryMap[type],
        }
      }
      if (['draft', 'done'].includes(type)) {
        delete query.from
      }
      return query
    },
    menuSelect(index) {
      this.$store.dispatch('app/addVisitedMenus', index)
    },
  },
}