From d0c51ac702c57f2cae84a8d879a5b605f2dab630 Mon Sep 17 00:00:00 2001
From: weicd <weicd@yhzhg.cn>
Date: Thu, 28 Sep 2023 09:50:45 +0000
Subject: [PATCH] 修改
---
eladmin-web-master/src/views/task/task/index.vue | 910 +++++++++++++++++++++++++++++++++++---------------------
1 files changed, 565 insertions(+), 345 deletions(-)
diff --git a/eladmin-web-master/src/views/task/task/index.vue b/eladmin-web-master/src/views/task/task/index.vue
index 3ab560e..0d92017 100644
--- a/eladmin-web-master/src/views/task/task/index.vue
+++ b/eladmin-web-master/src/views/task/task/index.vue
@@ -2,34 +2,38 @@
<div class="app-container">
<!--工具栏-->
<div class="head-container">
- <div v-if="crud.props.searchToggle">
+ <div>
<!-- 搜索 -->
- <el-input v-model="query.name" clearable placeholder="名称" style="width: 185px;" class="filter-item" @keyup.enter.native="crud.toQuery" />
- <el-select v-model="query.projectId" filterable clearable placeholder="所属项目" style="width: 185px;" class="filter-item" @keyup.enter.native="crud.toQuery">
+ <el-select v-model="curProject" value-key="id" filterable placeholder="所属项目" style="width: 400px;" class="filter-item" @change="queryByProjectId">
<el-option
v-for="item in projects"
:key="item.id"
:label="item.name"
- :value="item.id"
- />
+ :value="item"
+ >
+ <span style="float: left">{{ item.name }}</span>
+ </el-option>
</el-select>
- <el-select v-model="query.priority" filterable clearable placeholder="优先度" style="width: 185px;" class="filter-item" @keyup.enter.native="crud.toQuery">
- <el-option
- v-for="item in dict[priority]"
- :key="item.id"
- :label="item.label"
- :value="item.value"
- />
- </el-select>
- <el-select v-model="query.taskClassification" filterable clearable placeholder="任务分类" style="width: 185px;" class="filter-item" @keyup.enter.native="crud.toQuery">
- <el-option
- v-for="item in dict[taskClassification]"
- :key="item.id"
- :label="item.label"
- :value="item.value"
- />
- </el-select>
- <el-select v-model="query.taskStatus" filterable clearable placeholder="任务状态" style="width: 185px;" class="filter-item" @keyup.enter.native="crud.toQuery">
+ </div>
+ <div style="margin-bottom: 20px;">
+ <el-card class="box-card">
+ <el-descriptions title="项目信息" :column="3">
+ <el-descriptions-item label="项目开始时间">{{ curProject === null ? '' : curProject.planStartDate }}</el-descriptions-item>
+ <el-descriptions-item label="项目结束时间">{{ curProject === null ? '' : curProject.planEndDate }}</el-descriptions-item>
+ <el-descriptions-item label="剩余天数">{{ curProject === null ? '0' : '0' }}</el-descriptions-item>
+ <el-descriptions-item label="总任务数">{{ curProject === null ? '0' : curProject.totalTask }}</el-descriptions-item>
+ <el-descriptions-item label="完成任务数">{{ curProject === null ? '0' : curProject.completeTask }}</el-descriptions-item>
+ <el-descriptions-item label="任务完成比">{{ isNaN(curProject === null ? '0%' : (parseFloat((curProject.completeTask / curProject.totalTask) * 100)).toFixed(2)) ? 0 : curProject === null ? '0%' : (parseFloat((curProject.completeTask / curProject.totalTask) * 100)).toFixed(2) + '%' }}</el-descriptions-item>
+ <el-descriptions-item label="总工时数">{{ curProject === null ? '0.0' : curProject.totalHours }}</el-descriptions-item>
+ <el-descriptions-item label="完成工时数">{{ curProject === null ? '0.0' : curProject.completeHours }}</el-descriptions-item>
+ <el-descriptions-item label="工时完成比">{{ isNaN(curProject === null ? '0%' : (parseFloat((curProject.completeHours / curProject.totalHours) * 100)).toFixed(2)) ? 0 : curProject === null ? '0%' : (parseFloat((curProject.completeHours / curProject.totalHours) * 100)).toFixed(2) + '%' }}</el-descriptions-item>
+ </el-descriptions>
+ </el-card>
+ </div>
+ <div>
+ <!-- 搜索 -->
+ <el-autocomplete v-model="query.name" class="filter-item" :fetch-suggestions="querySearch" placeholder="名称" style="width: 185px;" />
+ <el-select v-model="query.taskStatuses" multiple collapse-tags filterable clearable placeholder="任务状态" style="width: 185px;" class="filter-item">
<el-option
v-for="item in dict[taskStatus]"
:key="item.id"
@@ -37,57 +41,61 @@
:value="item.value"
/>
</el-select>
+ <el-select v-model="query.performanceType" filterable clearable placeholder="绩效类型" style="width: 185px;" class="filter-item">
+ <el-option
+ v-for="item in dict[performanceType]"
+ :key="item.id"
+ :label="item.label"
+ :value="item.value"
+ />
+ </el-select>
+ <el-select v-model="query.tagList" multiple collapse-tags filterable clearable placeholder="任务分类" style="width: 185px;" class="filter-item">
+ <el-option
+ v-for="item in tags"
+ :key="item"
+ :label="item"
+ :value="item"
+ />
+ </el-select>
+ <div class="block">
+ <el-cascader
+ v-model="query.userIds"
+ :options="options"
+ clearable
+ placeholder="任务负责人"
+ :show-all-levels="false"
+ style="width: 185px;"
+ />
+ </div>
<rrOperation :crud="crud" />
</div>
+
+ <el-dialog
+ title="任务详情"
+ :visible.sync="dialogVisible"
+ width="800px"
+ @closed="calendarLoading = true"
+ @opened="monthClick('')"
+ >
+ <FullCalendar ref="fullCalendar" v-loading="calendarLoading" :options="calendarOptions" />
+ </el-dialog>
+
<!--如果想在工具栏加入更多按钮,可以使用插槽方式, slot = 'left' or 'right'-->
- <crudOperation :permission="permission">
+ <crudOperation v-if="this.crud.query.flag" :permission="permission">
<el-button
slot="right"
- v-permission="permission.divide"
class="filter-item"
size="mini"
type="primary"
- icon="el-icon-share"
- :disabled="crud.selections.length !== 1"
- @click="toDivide(crud.selections[0])"
- >
- 分配
- </el-button>
- <el-button
- slot="right"
- v-permission="permission.seeDivide"
- class="filter-item"
- size="mini"
- type="primary"
- icon="el-icon-share"
- :disabled="crud.selections.length !== 1"
- style="margin-left: 4px !important;"
- @click="toSeeDivide(crud.selections[0])"
- >
- 查看分配
- </el-button>
- <el-button
- slot="right"
- v-permission="permission.seeDaliy"
- class="filter-item"
- size="mini"
- type="primary"
- icon="el-icon-share"
- :disabled="crud.selections.length !== 1"
- style="margin-left: 4px !important;"
- @click="toSeeDaliy(crud.selections[0])"
- >
- 查看日报
- </el-button>
+ :disabled="taskDetailDisabled"
+ @click="draw"
+ >任务详情</el-button>
</crudOperation>
<!--表单组件-->
<el-dialog :close-on-click-modal="false" :before-close="crud.cancelCU" :visible.sync="crud.status.cu > 0" :title="crud.status.title" width="500px">
<el-form ref="form" :model="form" :rules="rules" size="small" label-width="110px">
- <el-form-item label="名称" prop="name">
- <el-input v-model="form.name" style="width: 340px;" />
- </el-form-item>
<el-form-item label="所属项目" prop="projectId">
- <el-select v-model="form.projectId" filterable clearable placeholder="请选择" style="width: 340px;" :disabled="crud.status.edit == crudStatusPrepared" @change="projectChange">
+ <el-select v-model="form.projectId" disabled placeholder="请选择" style="width: 340px;">
<el-option
v-for="item in projects"
:key="item.id"
@@ -96,31 +104,44 @@
/>
</el-select>
</el-form-item>
- <el-form-item label="父级任务">
- <el-select v-model="form.pid" filterable clearable placeholder="请选择" style="width: 340px;">
+ <el-form-item label="名称" prop="name">
+ <el-input v-model="form.name" style="width: 340px;" />
+ </el-form-item>
+ <el-form-item label="任务分类" prop="taskClassification" placeholder="请选择">
+ <el-tag
+ v-for="(tag, id) in form.tagList"
+ :key="id"
+ closable
+ :disable-transitions="false"
+ @close="handleClose(id)"
+ >
+ {{ tag }}
+ </el-tag>
+ <el-select
+ v-if="inputVisible"
+ ref="saveTagInput"
+ v-model="inputValue"
+ class="input-new-tag"
+ filterable
+ clearable
+ allow-create
+ default-first-option
+ @keyup.enter.native="handleInputConfirm"
+ @change="handleInputConfirm"
+ >
<el-option
- v-for="item in pidTasks"
- :key="item.id"
- :label="item.name"
- :value="item.id"
- :disabled="item.id == form.id"
+ v-for="(item, id) in tags"
+ :key="id"
+ :label="item"
+ :value="item"
/>
</el-select>
+ <el-button v-else class="button-new-tag" size="small" @click="showInput">请选择标签</el-button>
</el-form-item>
- <el-form-item label="优先度" prop="priority">
- <el-select v-model="form.priority" filterable clearable placeholder="请选择" style="width: 340px;">
+ <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[priority]"
- :key="item.id"
- :label="item.label"
- :value="item.value"
- />
- </el-select>
- </el-form-item>
- <el-form-item label="任务分类" prop="taskClassification">
- <el-select v-model="form.taskClassification" filterable clearable placeholder="请选择" style="width: 340px;">
- <el-option
- v-for="item in dict[taskClassification]"
+ v-for="item in dict[performanceType]"
:key="item.id"
:label="item.label"
:value="item.value"
@@ -130,42 +151,46 @@
<el-form-item label="描述">
<el-input v-model="form.description" :rows="3" type="textarea" style="width: 340px;" />
</el-form-item>
- <el-form-item label="计划开始时间">
- <el-date-picker v-model="form.planStartTime" type="datetime" :picker-options="planStartTimePickerOptions" style="width: 340px;" />
+ <el-form-item label="计划开始时间" prop="planStartTime">
+ <el-date-picker v-model="form.planStartTime" type="datetime" value-format="yyyy-MM-dd HH:mm:ss" :default-time="$store.state.user.user.sysRostering.workStartTime + ':00'" :picker-options="planStartTimePickerOptions" style="width: 340px;" />
</el-form-item>
- <el-form-item label="计划结束时间">
- <el-date-picker v-model="form.planEndTime" type="datetime" :picker-options="planEndTimePickerOptions" style="width: 340px;" />
+ <el-form-item label="计划结束时间" prop="planEndTime">
+ <el-date-picker v-model="form.planEndTime" type="datetime" value-format="yyyy-MM-dd HH:mm:ss" :default-time="$store.state.user.user.sysRostering.workEndTime + ':00'" :picker-options="planEndTimePickerOptions" style="width: 340px;" />
</el-form-item>
<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="planWorkload">
- <el-input v-model="form.planWorkload" style="width: 340px;" />
- </el-form-item>
- <el-form-item label="计划工作量单位">
- <el-select v-model="form.planWorkloadUnit" filterable clearable placeholder="请选择" style="width: 340px;">
- <el-option
- v-for="item in dict[standardWorkloadUnit]"
- :key="item.id"
- :label="item.label"
- :value="item.value"
+ <el-form-item label="任务成员" prop="containUserList">
+ <div class="block">
+ <el-cascader
+ v-model="selectedValue"
+ :filterable="true"
+ :options="options"
+ :props="props"
+ clearable
+ placeholder="任务成员"
+ :show-all-levels="false"
+ style="width: 340px;"
/>
- </el-select>
+ </div>
</el-form-item>
- <el-form-item label="任务状态" prop="taskStatus">
- <el-select v-model="form.taskStatus" filterable placeholder="请选择" style="width: 340px;">
+ <el-form-item label="任务负责人" prop="userId">
+ <el-select v-if="form.containUserList" v-model="form.userIdList" :no-data-text=" '没有任务成员' " multiple filterable clearable placeholder="请选择" style="width: 340px;">
<el-option
- v-for="item in dict[taskStatus]"
+ v-for="item in users"
+ v-show="form.containUserList != undefined && form.containUserList.some(animal => animal === item.id)"
:key="item.id"
- :label="item.label"
- :value="item.value"
- />
+ :label="item.nickName"
+ :value="item.id"
+ :show-all-levels="false"
+ >
+ <span style="float: left">{{ item.nickName }}</span>
+ <span style="float: right; color: #8492a6; font-size: 13px">{{ item.levelName }}</span>
+ </el-option>
</el-select>
- </el-form-item>
- <el-form-item label="备注">
- <el-input v-model="form.remarks" :rows="3" type="textarea" style="width: 340px;" />
+ <el-select v-else v-model="form.userIdList" :no-data-text=" '没有任务成员' " multiple filterable clearable placeholder="请选择" style="width: 340px;" />
</el-form-item>
</el-form>
<div slot="footer" class="dialog-footer">
@@ -174,116 +199,56 @@
</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
+ 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"
+ @row-click="getTaskUser"
+ >
<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">
+ <el-table-column :show-overflow-tooltip="true" label="计划工时" width="80">
<template slot-scope="scope">
- <el-tag>{{ scope.row.projectName }}</el-tag>
+ {{ scope.row.sumPlanHours }}
</template>
</el-table-column>
- <el-table-column :show-overflow-tooltip="true" prop="priority" label="优先度" width="80">
- <template slot-scope="scope">
- <el-tag>{{ dict.label[priority][scope.row.priority] }}</el-tag>
- </template>
- </el-table-column>
- <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="description" label="描述" width="140" />
<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" label="已完成 / 已分配 / 计划工时" width="160">
- <template slot-scope="scope">
- {{ scope.row.completedHours }} / {{ scope.row.divideHours }} / {{ scope.row.planHours }}
- </template>
- </el-table-column>
- <el-table-column :show-overflow-tooltip="true" label="已完成 / 已分配 / 计划工作量" width="180">
- <template slot-scope="scope">
- <span>
- {{ scope.row.completedWorkload }} / {{ scope.row.divideWorkload }} / {{ scope.row.planWorkload == null || scope.row.planWorkload == '' ? 0 : scope.row.planWorkload }}
- </span>
- </template>
- </el-table-column>
- <el-table-column :show-overflow-tooltip="true" prop="planWorkloadUnit" label="计划工作量单位" width="110">
- <template slot-scope="scope">
- <el-tag v-if="scope.row.planWorkloadUnit != null && scope.row.planWorkloadUnit != ''">{{ dict.label[standardWorkloadUnit][scope.row.planWorkloadUnit] }}</el-tag>
- </template>
- </el-table-column>
<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" prop="remarks" label="备注" width="140" />
- <el-table-column :show-overflow-tooltip="true" prop="createTime" label="创建时间" width="140" />
- <el-table-column v-if="checkPer(['admin','task:divide','task:edit','task:del'])" label="操作" width="180px" align="center" fixed="right">
+ <el-table-column :show-overflow-tooltip="true" prop="performanceType" label="绩效类型" width="80">
<template slot-scope="scope">
- <udOperation
- :data="scope.row"
- :permission="permission"
- >
- <el-button
- slot="left"
- v-permission="permission.divide"
- size="mini"
- type="primary"
- icon="el-icon-share"
- @click="toDivide(scope.row)"
- />
- </udOperation>
+ <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="tagList" label="任务负责人" width="240">
+ <template slot-scope="scope">
+ <el-tag v-for="userId in scope.row.userIdList" :key="userId">{{ getUserNameById(userId) }}</el-tag>
+ </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']) && this.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 />
- <!--表单组件(分配)-->
- <el-dialog :close-on-click-modal="false" :before-close="divideClose" :visible.sync="divideStatus" title="任务分配" width="500px">
- <el-form ref="divideForm" :model="divideForm" :rules="divideRules" size="small" label-width="110px">
- <el-form-item label="项目名称" prop="projectName">
- {{ divideForm.projectName }}
- </el-form-item>
- <el-form-item label="任务名称" prop="taskName">
- {{ divideForm.taskName }}
- </el-form-item>
- <el-form-item label="分配用户" prop="userIds">
- <el-select v-model="divideForm.userIds" filterable clearable multiple placeholder="请选择" style="width: 340px;">
- <el-option
- v-for="item in users"
- :key="item.id"
- :label="item.nickName"
- :value="item.id"
- :disabled="!item.enabled || divideForm.divideUserIds.includes(item.id)"
- />
- </el-select>
- </el-form-item>
- <el-form-item label="任务开始时间" prop="taskStartDate">
- <el-date-picker v-model="divideForm.taskStartDate" type="datetime" :picker-options="taskStartDatePickerOptions" style="width: 340px;" />
- </el-form-item>
- <el-form-item label="任务结束时间" prop="taskEndDate">
- <el-date-picker v-model="divideForm.taskEndDate" type="datetime" :picker-options="taskEndDatePickerOptions" style="width: 340px;" />
- </el-form-item>
- <el-form-item label="任务工时" prop="taskHours">
- <el-input v-model="divideForm.taskHours" style="width: 340px;">
- <template slot="append">小时</template>
- </el-input>
- </el-form-item>
- <el-form-item label="任务工作量" prop="taskWorkload">
- <el-input v-model="divideForm.taskWorkload" style="width: 340px;" />
- </el-form-item>
- <el-form-item label="任务工作量单位" prop="taskWorkloadUnit">
- <span v-if="divideForm.taskWorkloadUnit != null && divideForm.taskWorkloadUnit != ''">
- {{ dict.label[standardWorkloadUnit][divideForm.taskWorkloadUnit] }}
- </span>
- </el-form-item>
- </el-form>
- <div slot="footer" class="dialog-footer">
- <el-button type="text" @click="divideClose">取消</el-button>
- <el-button :loading="divideLoading" type="primary" @click="divideSubmit">确认</el-button>
- </div>
- </el-dialog>
</div>
</div>
</template>
@@ -295,32 +260,37 @@
import crudOperation from '@crud/CRUD.operation'
import udOperation from '@crud/UD.operation'
import pagination from '@crud/Pagination'
-import constant from '../../../utils/constant'
-import crudProject from '@/api/project/project'
+import constant from '@/utils/constant'
import crudUser from '@/api/system/user'
+import crudProject from '@/api/project/project'
+import '@fullcalendar/core/vdom'
+import FullCalendar from '@fullcalendar/vue'
+import dayGridPlugin from '@fullcalendar/daygrid'
+import moment from 'moment'
-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, 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: 'Task',
- components: { pagination, crudOperation, rrOperation, udOperation },
+ components: { pagination, crudOperation, rrOperation, udOperation, FullCalendar },
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 }})
},
data() {
// 指针重指向
const _this = this
- // 时长(千内)验证
+ // 时长(万内)验证
var durationValidate = (rule, value, callback) => {
- const reg = /^([0-9]|[1-9]\d{1,2})(\.\d{1,2})?$|1000$/
+ const reg = /^([0-9]|[1-9]\d{1,3})(\.\d{1,2})?$/
if (value != null && value !== '' && !reg.test(value)) {
- callback(new Error('请输入 一千 以内的正整数或两位小数'))
+ callback(new Error('请输入 一万 以内的正整数或两位小数'))
} else {
callback()
}
}
return {
+ props: { multiple: true },
permission: {
add: ['admin', 'task:add'],
edit: ['admin', 'task:edit'],
@@ -338,11 +308,17 @@
projectId: [
{ required: true, message: '所属项目不能为空', trigger: 'change' }
],
- priority: [
- { required: true, message: '优先度不能为空', trigger: 'change' }
+ performanceType: [
+ { required: true, message: '绩效类型不能为空', trigger: 'change' }
],
- taskClassification: [
- { required: true, message: '任务分类不能为空', trigger: 'change' }
+ pieceRate: [
+ { validator: durationValidate, trigger: 'blur' }
+ ],
+ planStartTime: [
+ { required: true, message: '计划开始时间不能为空', trigger: 'change' }
+ ],
+ planEndTime: [
+ { required: true, message: '计划结束时间不能为空', trigger: 'change' }
],
planHours: [
{ required: true, message: '计划工时不能为空', trigger: 'blur' },
@@ -355,11 +331,93 @@
{ required: true, message: '任务状态不能为空', trigger: 'change' }
]
},
+ calendarOptions: {
+ // 引入的插件
+ plugins: [dayGridPlugin],
+ // 日历头部按钮位置
+ headerToolbar: {
+ left: '',
+ center: 'title',
+ right: 'prev,today,next'
+ },
+ // 日历头部按钮中文转换
+ buttonText: {
+ today: '今天',
+ month: '月',
+ week: '周',
+ day: '天'
+ },
+ initialView: 'dayGridMonth',
+ locale: 'zh-ch',
+ firstDay: '1',
+ weekNumberCalculation: 'ISO',
+ eventColor: '#3d8eec',
+ timeGridEventMinHeight: '20',
+ aspectRatio: '1.5',
+ displayEventTime: false,
+ validRange: {},
+ allDaySlot: false,
+ eventLimit: true,
+ fixedWeekCount: false,
+ // eslint-disable-next-line no-dupe-keys
+ eventTimeFormat: {
+ hour: 'numeric',
+ minute: '2-digit',
+ hour12: false
+ },
+ slotLabelFormat: {
+ hour: '2-digit',
+ minute: '2-digit',
+ meridiem: false,
+ hour12: false
+ },
+ businessHours: {
+ dow: [1, 2, 3, 4, 5],
+ start: '0:00',
+ end: '24:00'
+ },
+ events: [],
+ // 事件
+ editable: false,
+ eventStartEditable: false,
+ eventDurationEditable: false,
+ selectable: false,
+ selectMirror: true,
+ selectMinDistance: 0,
+ weekends: true,
+ navLinks: true,
+ selectHelper: false,
+ selectEventOverlap: false,
+ dayMaxEvents: true,
+ // dateClick: this.handleDateClick, // 点击日期触发
+ // eventsSet: this.handleEvents,
+ // eventClick: this.handleEventClick, // 点击日程触发
+ // eventDrop: this.handleEventDrop,
+ eventResize: this.eventResize,
+ height: 'auto',
+ customButtons: {
+ prev: {
+ click: () => {
+ this.monthClick('prev')
+ }
+ },
+ today: {
+ text: '今天',
+ click: () => {
+ this.monthClick('')
+ }
+ },
+ next: {
+ click: () => {
+ this.monthClick('next')
+ }
+ }
+ }
+ },
queryTypeOptions: [
{ key: 'name', display_name: '名称' },
{ key: 'projectId', display_name: '所属项目' },
{ key: 'priority', display_name: '优先度' },
- { key: 'taskClassification', display_name: '任务分类' },
{ key: 'taskStatus', display_name: '任务状态' }
],
// 计划开始时间选项
@@ -380,74 +438,243 @@
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: [],
+ // 当前项目
+ curProject: null,
// 父级任务列表
pidTasks: [],
- // 分配表单状态
- divideStatus: false,
- // 分配表单加载
- divideLoading: false,
- // 分配表单数据
- divideForm: { projectId: null, projectName: null, taskId: null, taskname: null, userIds: [], divideUserIds: [], taskStartDate: null, taskEndDate: null, taskHours: null, taskWorkload: null, taskStatus: null },
- // 分配表单验证
- divideRules: {
- userIds: [
- { required: true, message: '分配用户不能为空', trigger: 'change' }
- ],
- taskStartDate: [
- { required: true, message: '任务开始时间不能为空', trigger: 'change' }
- ],
- taskEndDate: [
- { required: true, message: '任务结束时间不能为空', trigger: 'change' }
- ],
- taskHours: [
- { required: true, message: '任务工时不能为空', trigger: 'blur' },
- { validator: durationValidate, trigger: 'blur' }
- ],
- taskWorkload: [
- { validator: durationValidate, trigger: 'blur' }
- ]
- },
- // 任务开始时间选项
- taskStartDatePickerOptions: {
- // 禁用日期
- disabledDate(time) {
- return _this.divideForm.taskEndDate != null && _this.divideForm.taskEndDate !== '' ? time.getTime() > new Date(_this.divideForm.taskEndDate).getTime() : false
- }
- },
- // 任务结束时间选项
- taskEndDatePickerOptions: {
- // 禁用日期
- disabledDate(time) {
- return _this.divideForm.taskStartDate != null && _this.divideForm.taskStartDate !== '' ? time.getTime() < new Date(_this.divideForm.taskStartDate).getTime() - (86400000 - 1) : false
- }
- },
+ // 员工列表
+ users: [],
// 用户列表
- users: []
+ tags: [],
+ // tag标签
+ inputVisible: false,
+ inputValue: null,
+ containUserList: [],
+ userList: [],
+ options: [],
+ selectedValue: [],
+ queryUser: [],
+ dialogVisible: false,
+ taskDetailDisabled: true,
+ calendarLoading: true
}
},
+ watch: {
+ 'selectedValue': function(newVal) {
+ this.form.containUserList = []
+ for (let i = 0; i < newVal.length; i++) {
+ var temp = []
+ temp = newVal[i]
+ if (!this.form.containUserList.includes(temp[newVal[i].length - 1])) {
+ // 如果不在
+ this.form.containUserList.push(temp[newVal[i].length - 1])
+ }
+ }
+ },
+ 'crud.selections': function(newVal) {
+ this.taskDetailDisabled = true
+ if (newVal.length === undefined) {
+ this.taskDetailDisabled = false
+ }
+ if (newVal.length > 1) {
+ this.taskDetailDisabled = true
+ }
+ if (newVal.length === 1) {
+ this.taskDetailDisabled = false
+ }
+ },
+ 'queryUser': function(newVal) {
+ // this.query.userId = newVal[newVal.length - 1]
+ }
+ },
+ created() {
+ this.crud.optShow.reset = false
+ },
+ mounted() {
+ // 获取项目
+ this.getProject()
+ // 获取员工
+ this.getUser()
+ this.getTags()
+ },
methods: {
+ [CRUD.HOOK.afterSubmit]() {
+ this.form.containUserList = []
+ this.selectedValue = null
+ },
+ [CRUD.HOOK.afterEditError]() {
+ this.form.containUserList = []
+ this.selectedValue = null
+ },
+ [CRUD.HOOK.afterEditCancel]() {
+ this.form.containUserList = []
+ this.selectedValue = null
+ },
+ [CRUD.HOOK.afterAddCancel]() {
+ this.form.containUserList = []
+ this.selectedValue = null
+ },
+ [CRUD.HOOK.afterAddError]() {
+ this.form.containUserList = []
+ this.selectedValue = null
+ },
+ getContainUserList(e) {
+ this.form.containUserList = e
+ },
+ getTags() {
+ crudTask.getTags().then(res => {
+ this.tags = res
+ })
+ },
// 钩子:在获取表格数据之前执行,false 则代表不获取数据
[CRUD.HOOK.beforeRefresh]() {
- // 获取项目
- this.getProject()
- // 获取用户
- this.getUser()
+ 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
},
- // 获取项目
- getProject() {
- // 获取项目
- crudProject.getRelevant().then(res => {
- // 项目列表
- this.projects = res
+ [CRUD.HOOK.beforeToEdit]() {
+ crudUser.getUserPidDept(this.form.containUserList).then(res => {
+ this.selectedValue = res
+ })
+ },
+ [CRUD.HOOK.beforeSubmit]() {
+ if (!this.form.taskStatus) {
+ this.form.taskStatus = 'task_status_not_started'
+ }
+ if (this.inputValue !== null) {
+ this.form.tagList.push(this.inputValue)
+ }
+ return true
+ },
+ [CRUD.HOOK.afterSubmit]() {
+ this.inputValue = null
+ this.getTags()
+ },
+ // 钩子:新建 - 之前
+ [CRUD.HOOK.beforeToCU]() {
+ this.form.projectId = this.crud.query.projectId
+ // 父级任务列表
+ this.pidTasks = []
+ crudTask.getAll({ projectId: this.form.projectId }).then(res => {
+ // 父级任务列表
+ this.pidTasks = res
+ })
+ },
+ // 日期点击
+ handleDateClick(selectInfo) {
+ console.log('handleDateClick.info:', selectInfo)
+ },
+ handleEventClick(info) {
+ if (info.event._def.extendedProps.type === 1) {
+ this.$router.push({
+ path: '/attendance/attendance',
+ query: { date: info.event._def.extendedProps.date1 }
+ })
+ } else {
+ this.$router.push({ path: '/task/taskDaliy', query: { date: info.event._def.extendedProps.date1 }})
+ }
+ },
+ // 箭头点击事件
+ monthClick(type) {
+ if (this.crud.selections[0].id !== null) {
+ crudTask.getTaskValidRange(this.crud.selections[0].id).then(res => {
+ this.calendarOptions.validRange = res
+
+ const calendarApi = this.$refs['fullCalendar'].getApi()
+ if (type === 'prev') {
+ calendarApi.prev()
+ } else if (type === 'next') {
+ calendarApi.next()
+ } else {
+ calendarApi.gotoDate(res.start)
+ }
+ this.getTaskCalendarInfo(moment(calendarApi.view.currentStart).format('YYYY-MM-DD').toString())
+ this.calendarLoading = false
+ })
+ }
+ },
+ // 获取任务信息
+ getTaskCalendarInfo(month) {
+ crudTask.getTaskCalendarInfo(month, this.crud.selections[0].id).then(res => {
+ this.calendarOptions.events = res.map(function(obj) {
+ return obj
+ })
+ setTimeout(() => {
+ console.log(this.calendarOptions.events)
+ }, 1000)
+ })
+ },
+ queryByProjectId(project) {
+ this.crud.resetQuery(false)
+ this.crud.query.projectId = project.id
+ this.crud.query.flag = project.flag
+ this.crud.toQuery()
+ this.getProjectTotal()
+ },
+ getTaskUser(even) {
+ this.containUserList = []
+ var containList = even.containUserList
+ for (var i = 0; i < this.users.length; i++) {
+ for (var j = 0; j < containList.length; j++) {
+ if (containList[j] === this.users[i].id) {
+ this.containUserList.push(this.users[i])
+ }
+ }
+ }
+ },
+ handleClose(id) {
+ this.form.tagList.splice(id, 1)
+ },
+ showInput() {
+ this.inputVisible = true
+ this.$nextTick(_ => {
+ this.$refs.saveTagInput.focus() // .$refs.input
+ })
+ },
+ handleInputConfirm() {
+ const inputValue = this.inputValue
+ console.log(inputValue)
+ if (inputValue !== '' && inputValue !== null && inputValue !== ' ') {
+ this.form.tagList.push(inputValue)
+ }
+ this.inputVisible = false
+ this.inputValue = null
+ },
+ handleSelect(item) {
+ this.inputValue = item.value
+ this.$refs.saveTagInput.$refs.input.focus()
+ },
+ querySearchAsync(queryString, cb) {
+ crudTask.getTags(queryString ? { tagName: queryString } : {}).then(res => {
+ const tagMap = []
+ res.forEach(tag => {
+ tagMap.push({ value: tag })
+ })
+ cb(tagMap)
})
},
// 获取用户
@@ -457,32 +684,58 @@
// 用户列表
this.users = res
})
+
+ crudUser.getUserDept().then(res => {
+ this.options = res
+ })
+ },
+ getUserNameById(userId) {
+ const userList = this.users.filter(user => user.id === userId)
+ return userList.length === 0 ? '' : userList[0].nickName
+ },
+ // 获取项目
+ getProject() {
+ // 获取项目
+ crudProject.getRelevant({
+ 'projectStatusIn': ['project_status_not_started', 'project_status_under_way'],
+ 'approve_status': 'approve_status_acknowledged'
+ }).then(res => {
+ // 项目列表
+ this.projects = res
+ })
},
// 树形表数据加载
load(tree, treeNode, resolve) {
- // 获取子级任务
- crudTask.getChildren({ id: tree.id }).then(res => {
- // 添加
- resolve(res)
- })
+ resolve(tree.children)
},
- // 钩子:新建 - 之前
- [CRUD.HOOK.beforeToAdd]() {
- // 父级任务列表
- this.pidTasks = []
- },
- // 钩子:编辑 - 之前
- [CRUD.HOOK.beforeToEdit]() {
- // 获取父级任务
- crudTask.getAll({ projectId: this.form.projectId }).then(res => {
- // 父级任务列表
- this.pidTasks = res
+ getProjectTotal() {
+ this.curProject.totalTask = 0
+ this.curProject.totalHours = 0.0
+ this.curProject.completeTask = 0
+ this.curProject.completeHours = 0.0
+ crudTask.getProjectTotal({ 'projectId': this.crud.query.projectId }).then(res => {
+ let totalTask = 0
+ let totalHours = 0.0
+ let completeTask = 0
+ let completeHours = 0.0
+ res.forEach(item => {
+ totalTask += item.count
+ totalHours += item.planHours
+ if (item._id === 'task_status_completed') {
+ completeTask += item.count
+ completeHours += item.planHours
+ }
+ })
+ this.curProject.totalTask = totalTask
+ this.curProject.totalHours = totalHours
+ this.curProject.completeTask = completeTask
+ this.curProject.completeHours = completeHours
})
},
// 项目变更
projectChange() {
// 表单赋值
- this.form.pid = null
+ this.form.parent.id = null
// 判断表单项目是否为空
if (this.form.projectId == null || this.form.projectId === '') {
// 父级任务列表
@@ -495,81 +748,48 @@
})
}
},
- // 任务分配
- toDivide(data) {
- // 分配表单数据
- this.divideForm.projectId = data.projectId
- this.divideForm.projectName = data.projectName
- this.divideForm.taskId = data.id
- this.divideForm.taskName = data.name
- this.divideForm.divideUserIds = data.divideUserIds
- this.divideForm.taskWorkloadUnit = data.planWorkloadUnit
- this.divideForm.taskStatus = constant.TASK_STATUS_NOT_STARTED
- // 分配表单状态
- this.divideStatus = true
+ // 输入框获取焦点时调用的方法
+ async querySearch(queryString, cb) {
+ let results = []
+ if (queryString === null || queryString === '') {
+ cb(results)
+ } else {
+ results = await crudTask.getNames({ projectId: this.crud.query.projectId, name: queryString })
+ cb(results)
+ }
},
- // 查看任务分配
- toSeeDivide(data) {
- // 跳转页面
- this.$router.push({
- name: 'TaskUser',
- params: {
- projectId: data.projectId,
- taskId: data.id
- }
- })
- },
- // 查看任务日报
- toSeeDaliy(data) {
- // 跳转页面
- this.$router.push({
- name: 'TaskDaliy',
- params: {
- projectId: data.projectId,
- taskId: data.id
- }
- })
- },
- // 分配表单关闭
- divideClose() {
- // 分配表单状态
- this.divideStatus = false
- // 分配表单加载
- this.divideLoading = false
- // 分配表单数据
- this.divideForm = { projectId: null, projectName: null, taskId: null, taskname: null, userIds: [], divideUserIds: [], taskStartDate: null, taskEndDate: null, taskHours: null, taskWorkload: null, taskStatus: null }
- // 清除表单验证
- this.$nextTick(() => {
- this.$refs['divideForm'].clearValidate()
- })
- },
- // 分配表单提交
- divideSubmit() {
- // 分配表单加载
- this.divideLoading = true
- // 表单验证
- this.$refs['divideForm'].validate((valid) => {
- if (valid) {
- // 分配任务
- crudTask.divide(this.divideForm).then(res => {
- // 分配表单关闭
- this.divideClose()
- // 消息提示
- this.crud.notify('任务分配成功', CRUD.NOTIFICATION_TYPE.SUCCESS)
- // 刷新页面
- this.crud.refresh()
- })
- } else {
- // 分配表单加载
- this.divideLoading = false
- return false
- }
- })
+ draw() {
+ this.dialogVisible = true
}
}
}
</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>
--
Gitblit v1.9.3