Blame view

frontend/front/src/views/matter/myTask/index.vue 2.85 KB
8d73e917   陈威   初始化提交
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
<template>
  <content-layout
    :tab-pane-list="currentShowTab"
    @tab-click="handleTabClick"
    @node-click="handleNodeClick"
  >
    <keep-alive :include="keepaliveComponents">
      <component
        :is="currentViews[currentActiveTab]"
        :ref="`${currentActiveTab}Table`"
        v-loading="loading"
      ></component>
    </keep-alive>
  </content-layout>
</template>

<script>
  import { TAB_LIST, COMPONENTS_LIST } from './const'

  import processClassify from '@/mixins/processClassify.js'
  import fromModule from '@/mixins/fromModule'

  import { getCurrentAccountLeader, checkHasSecretary } from '@/api/process'
  import { mapState } from 'vuex'

  export default {
    name: 'MyTask',
    components: {
      ContentLayout: () => import('@/views/matter/components/ContentLayout'),
      Todo: () => import('./Todo'),
      LeaderTodo: () => import('./LeaderTodo'),
      Done: () => import('./Done'),
      LeaderDone: () => import('./LeaderDone'),
      MyDelegate: () => import('./MyDelegate'),
    },
    mixins: [processClassify, fromModule],
    data() {
      return {
        leaderList: [],
        hasLeader: false,
        currentActiveTab: 'todo',
        isKeepalive: false,
      }
    },
    computed: {
      ...mapState('user', ['account']),
      currentViews() {
        const currentComponentMap = {}
        Object.keys(COMPONENTS_LIST)
          .filter((key) => this.notIncludesLeader(key))
          .map((key) => {
            currentComponentMap[key] = COMPONENTS_LIST[key]
          })
        return this.hasLeader ? COMPONENTS_LIST : currentComponentMap
      },
      currentTabPaneList() {
        const currentTabList = TAB_LIST.filter((item) =>
          this.notIncludesLeader(item.name)
        )
        return this.hasLeader ? TAB_LIST : currentTabList
      },
      keepaliveComponents() {
        return this.isKeepalive ? Object.values(COMPONENTS_LIST) : []
      },
    },
    activated() {
      this.currentActiveTab = this.$route.query.tabActiveName || 'todo'
    },
    created() {
      if (localStorage.getItem(`keepalive_${this.account}`)) {
        const keepaliveRouteList = JSON.parse(
          localStorage.getItem(`keepalive_${this.account}`)
        )
        if (keepaliveRouteList && keepaliveRouteList.length) {
          this.isKeepalive = keepaliveRouteList
            .map((item) => item.name)
            .includes('MyTask')
        }
      }
    },
    mounted() {
      this.currentActiveTab = this.$route.query.tabActiveName || 'todo'
      this.checkHasSecretary()
    },
    methods: {
      checkHasSecretary() {
        checkHasSecretary().then((res) => {
          this.hasLeader = res.value
        })
      },
      notIncludesLeader(key) {
        return !['leaderTodo', 'leaderDone'].includes(key)
      },
    },
  }
</script>
<style lang="scss" scoped>
  ::v-deep.el-table__fixed-right {
    height: 100%;
  }
</style>