From c752e33fe402e2179e7e6795f567d41c044ca3c6 Mon Sep 17 00:00:00 2001
From: yaozc <yaozc@yhzhg.cn>
Date: Fri, 07 Jul 2023 08:39:58 +0000
Subject: [PATCH] Merge branch 'yaozc_new' of http://192.168.1.110:5678/r/pms-upgrade
---
eladmin-web-master/src/views/task/task/index.vue | 187 ++++++++++++++++++++++++++++++++++++++++++++++
1 files changed, 184 insertions(+), 3 deletions(-)
diff --git a/eladmin-web-master/src/views/task/task/index.vue b/eladmin-web-master/src/views/task/task/index.vue
index f4ac44f..b0cb18f 100644
--- a/eladmin-web-master/src/views/task/task/index.vue
+++ b/eladmin-web-master/src/views/task/task/index.vue
@@ -128,6 +128,16 @@
/>
</el-select>
</el-form-item>
+ <el-form-item label="绩效类型" prop="performanceType">
+ <el-select v-model="form.performanceType" filterable clearable placeholder="请选择" style="width: 340px;">
+ <el-option
+ v-for="item in dict[performanceType]"
+ :key="item.id"
+ :label="item.label"
+ :value="item.value"
+ />
+ </el-select>
+ </el-form-item>
<el-form-item label="描述">
<el-input v-model="form.description" :rows="3" type="textarea" style="width: 340px;" />
</el-form-item>
@@ -140,6 +150,11 @@
<el-form-item label="计划工时" prop="planHours">
<el-input v-model="form.planHours" style="width: 340px;">
<template slot="append">小时</template>
+ </el-input>
+ </el-form-item>
+ <el-form-item label="计件单金" prop="pieceRate">
+ <el-input v-model="form.pieceRate" style="width: 340px;">
+ <template slot="append">元</template>
</el-input>
</el-form-item>
<el-form-item label="计划工作量" prop="planWorkload">
@@ -175,7 +190,20 @@
</div>
</el-dialog>
<!--表格渲染-->
- <el-table ref="table" v-loading="crud.loading" :data="crud.data" size="small" style="width: 100%;" row-key="id" lazy :load="load" :tree-props="{children: 'children', hasChildren: 'hasChildren'}" @selection-change="crud.selectionChangeHandler">
+ <el-table
+ ref="table"
+ v-loading="crud.loading"
+ :data="crud.data"
+ size="small"
+ style="width: 100%;"
+ row-key="id"
+ lazy
+ :load="load"
+ :tree-props="{children: 'children', hasChildren: 'hasChildren'}"
+ :summary-method="getSummaries"
+ show-summary
+ @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" prop="projectName" label="所属项目" width="140">
@@ -191,6 +219,11 @@
<el-table-column :show-overflow-tooltip="true" prop="taskClassification" label="任务分类" width="80">
<template slot-scope="scope">
<el-tag>{{ dict.label[taskClassification][scope.row.taskClassification] }}</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="description" label="描述" width="140" />
@@ -223,6 +256,7 @@
<el-table-column v-if="checkPer(['admin','task:divide','task:edit','task:del'])" label="操作" width="180px" align="center" fixed="right">
<template slot-scope="scope">
<udOperation
+ v-if="userRolesLevelMin == roleLevelSuper || userRolesLevelMin == roleLevelGeneral || scope.row.projectLiableUserIdList.indexOf($store.state.user.user.id) != -1"
:data="scope.row"
:permission="permission"
>
@@ -304,12 +338,12 @@
import crudProject from '@/api/project/project'
import crudUser from '@/api/system/user'
-const defaultForm = { id: null, name: null, projectId: null, pid: null, priority: null, taskClassification: null, description: null, planStartTime: null, planEndTime: null, planHours: null, planWorkload: null, planWorkloadUnit: null, taskStatus: null, remarks: null, createBy: null, createTime: null, updateBy: null, updateTime: null }
+const defaultForm = { id: null, name: null, projectId: null, pid: null, priority: null, taskClassification: null, performanceType: null, description: null, planStartTime: null, planEndTime: null, planHours: null, pieceRate: 0, planWorkload: 0, planWorkloadUnit: null, taskStatus: null, remarks: null, createBy: null, createTime: null, updateBy: null, updateTime: null }
export default {
name: 'Task',
components: { pagination, crudOperation, rrOperation, udOperation },
mixins: [presenter(), header(), form(defaultForm), crud()],
- dicts: [constant.PRIORITY, constant.TAST_CLASSIFICATION, constant.STANDARD_WORKLOAD_UNIT, constant.TASK_STATUS],
+ dicts: [constant.PRIORITY, constant.TAST_CLASSIFICATION, constant.PERFORMANCE_TYPE, constant.STANDARD_WORKLOAD_UNIT, constant.TASK_STATUS],
cruds() {
return CRUD({ title: '任务', url: 'api/task', idField: 'id', sort: 'id,desc', crudMethod: { ...crudTask }})
},
@@ -349,6 +383,12 @@
taskClassification: [
{ required: true, message: '任务分类不能为空', trigger: 'change' }
],
+ performanceType: [
+ { required: true, message: '绩效类型不能为空', trigger: 'change' }
+ ],
+ pieceRate: [
+ { validator: durationValidate, trigger: 'blur' }
+ ],
planHours: [
{ required: true, message: '计划工时不能为空', trigger: 'blur' },
{ validator: durationValidate, trigger: 'blur' }
@@ -385,14 +425,22 @@
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: [],
// 父级任务列表
@@ -443,6 +491,10 @@
methods: {
// 钩子:在获取表格数据之前执行,false 则代表不获取数据
[CRUD.HOOK.beforeRefresh]() {
+ // 用户角色级别数组
+ const userRolesLevel = this.$store.state.user.user.roles.map(({ level }) => level)
+ // 用户最大角色级别
+ this.userRolesLevelMin = Math.min(...userRolesLevel)
// 获取项目
this.getProject()
// 获取用户
@@ -480,6 +532,100 @@
// 添加
resolve(res)
})
+ },
+ // 表格统计
+ getSummaries(param) {
+ const { columns, data } = param
+ const sums = []
+ columns.forEach((column, index) => {
+ // 9号单元格
+ if (index === 9) {
+ // 已完成工时
+ let completedHours = 0
+ const completedHoursValues = data.map(item => Number(item['completedHours']))
+ if (!completedHoursValues.every(value => isNaN(value))) {
+ completedHours = completedHoursValues.reduce((prev, curr) => {
+ const value = Number(curr)
+ if (!isNaN(value)) {
+ return prev + curr
+ } else {
+ return prev
+ }
+ }, 0)
+ }
+ // 已分配工时
+ let divideHours = 0
+ const divideHoursValues = data.map(item => Number(item['divideHours']))
+ if (!divideHoursValues.every(value => isNaN(value))) {
+ divideHours = divideHoursValues.reduce((prev, curr) => {
+ const value = Number(curr)
+ if (!isNaN(value)) {
+ return prev + curr
+ } else {
+ return prev
+ }
+ }, 0)
+ }
+ // 计划工时
+ let planHours = 0
+ const planHoursValues = data.map(item => Number(item['planHours']))
+ if (!planHoursValues.every(value => isNaN(value))) {
+ planHours = planHoursValues.reduce((prev, curr) => {
+ const value = Number(curr)
+ if (!isNaN(value)) {
+ return prev + curr
+ } else {
+ return prev
+ }
+ }, 0)
+ }
+ sums[index] = completedHours + ' / ' + divideHours + ' / ' + planHours
+ }
+ // 10号单元格
+ if (index === 10) {
+ // 已完成工作量
+ let completedWorkload = 0
+ const completedWorkloadValues = data.map(item => Number(item['completedWorkload']))
+ if (!completedWorkloadValues.every(value => isNaN(value))) {
+ completedWorkload = completedWorkloadValues.reduce((prev, curr) => {
+ const value = Number(curr)
+ if (!isNaN(value)) {
+ return prev + curr
+ } else {
+ return prev
+ }
+ }, 0)
+ }
+ // 已分配工作量
+ let divideWorkload = 0
+ const divideWorkloadValues = data.map(item => Number(item['divideWorkload']))
+ if (!divideWorkloadValues.every(value => isNaN(value))) {
+ divideWorkload = divideWorkloadValues.reduce((prev, curr) => {
+ const value = Number(curr)
+ if (!isNaN(value)) {
+ return prev + curr
+ } else {
+ return prev
+ }
+ }, 0)
+ }
+ // 计划工作量
+ let planWorkload = 0
+ const planWorkloadValues = data.map(item => Number(item['planWorkload']))
+ if (!planWorkloadValues.every(value => isNaN(value))) {
+ planWorkload = planWorkloadValues.reduce((prev, curr) => {
+ const value = Number(curr)
+ if (!isNaN(value)) {
+ return prev + curr
+ } else {
+ return prev
+ }
+ }, 0)
+ }
+ sums[index] = completedWorkload + ' / ' + divideWorkload + ' / ' + planWorkload
+ }
+ })
+ return sums
},
// 钩子:新建 - 之前
[CRUD.HOOK.beforeToAdd]() {
@@ -572,6 +718,21 @@
// 表单验证
this.$refs['divideForm'].validate((valid) => {
if (valid) {
+ // 判断用户角色
+ if (this.userRolesLevelMin !== this.roleLevelSuper && this.userRolesLevelMin !== this.roleLevelGeneral) {
+ // 检索选中项目信息
+ const chooseProject = this.projects.filter((item) => {
+ return item.id === this.divideForm.projectId
+ })
+ // 判断是否是项目责任人
+ if (chooseProject.length !== 1 || chooseProject[0].liableUserIdList.indexOf(this.$store.state.user.user.id) === -1) {
+ // 消息提示
+ this.crud.notify('您不是当前项目责任人,无法进行任务分配操作', CRUD.NOTIFICATION_TYPE.WARNING)
+ // 分配表单加载
+ this.divideLoading = false
+ return false
+ }
+ }
// 分配任务
crudTask.divide(this.divideForm).then(res => {
// 分配表单关闭
@@ -587,6 +748,26 @@
return false
}
})
+ },
+ // 钩子:提交 - 之前
+ [CRUD.HOOK.beforeSubmit]() {
+ // 判断用户角色
+ if (this.userRolesLevelMin === this.roleLevelSuper || this.userRolesLevelMin === this.roleLevelGeneral) {
+ return true
+ } else {
+ // 检索选中项目信息
+ const chooseProject = this.projects.filter((item) => {
+ return item.id === this.form.projectId
+ })
+ // 判断是否是项目责任人
+ if (chooseProject.length === 1 && chooseProject[0].liableUserIdList.indexOf(this.$store.state.user.user.id) !== -1) {
+ return true
+ } else {
+ // 消息提示
+ this.crud.notify('您不是当前项目责任人,无法添加/修改任务详情', CRUD.NOTIFICATION_TYPE.WARNING)
+ return false
+ }
+ }
}
}
}
--
Gitblit v1.9.3