yaozc2021
2025-04-25 c19eda1fb09764cfa1ae134bda39efd9507784aa
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
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
<template>
  <div class="app-container">
    <!--工具栏-->
    <div class="head-container">
      <div>
        <el-select v-model="curProject" value-key="id" filterable placeholder="所属项目" style="width: 400px;" class="filter-item">
          <el-option
            v-for="item in projects"
            :key="item.id"
            :label="item.name"
            :value="item"
          >
            <span style="float: left">{{ item.name }}</span>
          </el-option>
        </el-select>
        <el-select
          v-model="query.userId"
          filterable
          clearable
          placeholder="所属员工"
          style="width: 185px;"
          class="filter-item"
          @keyup.enter.native="crud.toQuery"
        >
          <el-option
            v-for="item in users"
            :key="item.id"
            :label="item.nickName"
            :value="item.id"
          />
        </el-select>
        <rrOperation :crud="crud" />
      </div>
      <!--表格渲染-->
      <el-table
        ref="table"
        v-loading="crud.loading"
        :data="crud.data"
        size="small"
        style="width: 100%;"
        row-key="id"
        :tree-props="{ children: 'children', hasChildren: 'hasChildren' }"
        @selection-change="crud.selectionChangeHandler"
      >
        <el-table-column type="selection" width="55" />
        <el-table-column :show-overflow-tooltip="true" prop="name" label="名称" fixed="left" width="180" />
        <el-table-column :show-overflow-tooltip="true" label="计划工时" width="80">
          <template slot-scope="scope">
            {{ scope.row.sumPlanHours }}
          </template>
        </el-table-column>
        <el-table-column :show-overflow-tooltip="true" prop="planStartTime" label="计划开始时间" width="140" />
        <el-table-column :show-overflow-tooltip="true" prop="planEndTime" label="计划结束时间" width="140" />
        <el-table-column :show-overflow-tooltip="true" prop="taskStatus" label="任务状态" width="80">
          <template slot-scope="scope">
            <el-tag>{{ dict.label[taskStatus][scope.row.taskStatus] }}</el-tag>
          </template>
        </el-table-column>
        <el-table-column :show-overflow-tooltip="true" label="消耗工时" width="80">
          <template slot-scope="scope">
            <el-tag v-if="scope.row.consumedHours > scope.row.sumPlanHours" type="info">{{ scope.row.consumedHours }}</el-tag>
            <el-tag v-else type="error">{{ scope.row.consumedHours }}</el-tag>
          </template>
        </el-table-column>
        <el-table-column :show-overflow-tooltip="true" prop="performanceType" label="绩效类型" width="80">
          <template slot-scope="scope">
            <el-tag>{{ dict.label[performanceType][scope.row.performanceType] }}</el-tag>
          </template>
        </el-table-column>
        <el-table-column :show-overflow-tooltip="true" prop="tagList" label="任务分类" width="240">
          <template slot-scope="scope">
            <template>
              <el-tag v-for="tag in scope.row.tagList" :key="tag">{{ tag }}</el-tag>
            </template>
          </template>
        </el-table-column>
        <el-table-column :show-overflow-tooltip="true" prop="description" label="描述" />
        <el-table-column v-if="checkPer(['admin','task:divide','task:edit','task:del']) && crud.query.flag === true" label="操作" width="180px" align="center" fixed="right">
          <template slot-scope="scope">
            <udOperation :data="scope.row" :permission="permission" />
          </template>
        </el-table-column>
      </el-table>
      <!--分页组件-->
      <pagination />
    </div>
  </div>
</template>
 
<script>
import crudTask from '@/api/task/task'
import CRUD, { presenter, header, form, crud } from '@crud/crud'
import rrOperation from '@crud/RR.operation'
import pagination from '@crud/Pagination'
import constant from '@/utils/constant'
import crudUser from '@/api/system/user'
import crudProject from '@/api/project/project'
 
const defaultForm = { id: null, name: null, projectId: null, userIdList: [], parent: { id: null }, priority: null, tagList: [], performanceType: null, description: null, planStartTime: null, planEndTime: null, planHours: null, pieceRate: 0, planWorkload: 0, planWorkloadUnit: null, taskStatus: null, remarks: null, version: null }
export default {
  name: 'UserStatistics',
  components: { pagination, rrOperation },
  mixins: [presenter(), header(), form(defaultForm), crud()],
  dicts: [constant.TASK_STATUS],
  cruds() {
    return CRUD({ title: '任务', url: 'api/taskDaliy', idField: 'id', sort: 'id,desc', crudMethod: { ...crudTask }})
  },
  data() {
    return {
      props: { multiple: true },
      queryTypeOptions: [
        { key: 'name', display_name: '名称' },
        { key: 'projectId', display_name: '所属项目' },
        { key: 'priority', display_name: '优先度' },
        { key: 'taskStatus', display_name: '任务状态' }
      ],
      // // 字典:优先度
      // priority: constant.PRIORITY,
      // // 字典:任务分类
      // taskClassification: constant.TAST_CLASSIFICATION,
      // // 字典: 绩效类型
      // performanceType: constant.PERFORMANCE_TYPE,
      // // 字典:标准工作量单位
      // standardWorkloadUnit: constant.STANDARD_WORKLOAD_UNIT,
      // // 字典:任务状态
      // taskStatus: constant.TASK_STATUS,
      // // 字典:批准状态-未承认
      // approveStatusUnrecognized: constant.APPROVE_STATUS_UNRECOGNIZED,
      // // 角色级别:超级管理员
      // roleLevelSuper: constant.ROLE_LEVEL_SUPER,
      // // 角色级别:总经理
      // roleLevelGeneral: constant.ROLE_LEVEL_GENERAL,
      // CRUD状态
      crudStatusPrepared: CRUD.STATUS.PREPARED,
      // 用户最大角色级别
      userRolesLevelMin: null,
      // 项目列表
      projects: [],
      // 父级任务列表
      pidTasks: [],
      // 员工列表
      users: [],
      // 用户列表
      tags: [],
      // tag标签
      inputVisible: false,
      inputValue: null,
      containUserList: [],
      userList: [],
      options: [],
      selectedValue: [],
      queryUser: [],
      dialogVisible: false,
      taskDetailDisabled: true,
      calendarLoading: true,
      isShow: false
    }
  },
  created() {
    this.crud.optShow.reset = false
  },
  mounted() {
    // 获取项目
    this.getProject()
    // 获取员工
    this.getUser()
    this.getTags()
  },
  methods: {
    getContainUserList(e) {
      this.form.containUserList = e
    },
    getTags() {
      crudTask.getTags().then(res => {
        this.tags = res
      })
    },
    // 钩子:在获取表格数据之前执行,false 则代表不获取数据
    [CRUD.HOOK.beforeRefresh]() {
      if (!this.crud.query.projectId) {
        return false
      }
      // 用户角色级别数组
      const userRolesLevel = this.$store.state.user.user.roles.map(({ level }) => level)
      // 用户最大角色级别
      this.userRolesLevelMin = Math.min(...userRolesLevel)
 
      return true
    },
    // 获取用户
    getUser() {
      // 获取用户
      crudUser.getAll().then(res => {
        // 用户列表
        this.users = res
      })
 
      crudUser.getUserDept().then(res => {
        this.options = res
      })
    },
    // 获取项目
    getProject() {
      // 获取项目
      crudProject.getRelevant({
        'projectStatusIn': ['project_status_not_started', 'project_status_under_way'],
        'approve_status': 'approve_status_acknowledged'
      }).then(res => {
        // 项目列表
        this.projects = res
      })
    }
  }
}
</script>
 
<style scoped>
  .el-tag + .el-tag {
    margin-left: 10px;
  }
  .button-new-tag {
    margin-left: 10px;
    height: 32px;
    line-height: 30px;
    padding-top: 0;
    padding-bottom: 0;
  }
  .input-new-tag {
    width: 90px;
    margin-left: 10px;
    vertical-align: bottom;
  }
 
  .block{
    display: inline-block;
    vertical-align: middle;
    margin: 0 3px 10px 0;
 
      input {
      height: 30.5px;
      line-height: 30.5px;
      }
    }
</style>