matter.js 3.07 KB
import { STATUS, STATUS_DOT_CLASS_NAME_MAP } from '@/views/matter/myTask/const'
import moment from 'moment'

import clipboard from '@/utils/clipboard'

export default {
  componentName: 'MatterComponent',
  data() {
    return {
      status: STATUS,
      pageResult: {
        page: 1,
        pageSize: 20,
        total: 0,
      },
      nodeId: '',
      defId: '',
      pageSizes: [20, 40, 60, 100, 200, 300],
      instanceId: '',
      bpmnInstId: '',
      statusDotClassName: STATUS_DOT_CLASS_NAME_MAP,
      matterClassifyId: null,
      baseSearchQuery: {
        orgName: '',
        orgId: '',
      },
    }
  },
  created() {
    this.$on('matter-classify-update', (nodeId) => {
      this.matterClassifyId = nodeId
    })
  },
  methods: {
    handleShowFlowChart(row) {
      this.instanceId = row.procInstId || row.id
      this.bpmnInstId = row.bpmnInstId
      this.nodeId = row.nodeId
      this.defId = row.procDefId
      this.$nextTick(() => {
        // this.$refs.flowChart.handleOpen()
        this.$refs.processForecast &&
          this.$refs.processForecast.handleOpen(
            row.procInstId || row.ID_ || row.id,
            row,
            row.nodeId,
            false,
            'flowChart'
          )
        this.$refs?.htTable.$refs.htTable.toggleRowSelection(row)
      })
    },
    getCurrentQuery(param, property) {
      let query = param?.querys || []
      if (this.matterClassifyId) {
        const typeIdQuery = query.find(
          (q) => q.group == 'typeId' && q.property == property
        )
        if (typeIdQuery) {
          typeIdQuery['value'] = this.matterClassifyId
        } else {
          query.push({
            property: property,
            value: this.matterClassifyId,
            group: 'typeId',
            operation: 'IN',
            relation: 'AND',
          })
        }
      }
      return query
    },
    calcExpireTime(deadline) {
      if (deadline) {
        const duration = moment(deadline).diff(new Date())
        if (duration > 0) return deadline
        const hour = moment(new Date()).diff(deadline, 'hours')
        const minute = moment(new Date()).diff(deadline, 'minutes') % 60
        return `已到期${hour}时${minute}分`
      }
    },
    currentDateClassName(deadline) {
      const duration = moment(deadline).diff(new Date())
      const overThreeDay = moment(new Date()).diff(deadline, 'day') >= 3
      if (duration > 0) {
        return 'green-color'
      } else if (overThreeDay) {
        return 'orange-color'
      } else {
        return 'red-color'
      }
    },
    rowClassName({ row }) {
      let className = ''
      const statusList = [
        'revoke',
        'revokeToStart',
        'back',
        'backToStart',
        'BACK',
        'BACKSHARE',
      ]
      if (
        statusList.includes(row.instStatus) ||
        statusList.includes(row.status)
      ) {
        className = 'red-row'
        //row.priority === 60 指延后处理任务
      } else if (row.priority === 60) {
        className = 'gray-row'
      }
      return className
    },
    //复制文本方法
    clipboard,
  },
}