<template>
|
<div class="app-container">
|
<!--工具栏-->
|
<el-row v-loading="taskLoading" :gutter="15">
|
<el-col :xs="24" :sm="24" :md="8" :lg="8" :xl="7">
|
<el-card class="box-card" shadow="never" style="width: 750px">
|
<el-tabs v-model="tobeOver" style="height: 200px;" @tab-click="handleClickTobeTasked">
|
<el-tab-pane :label="tobeTasked" name="first">
|
<el-table
|
:data="adventTasks"
|
height="180"
|
:show-header="false"
|
>
|
<el-table-column
|
prop="name"
|
:show-overflow-tooltip="true"
|
min-width="180px"
|
/>
|
<el-table-column
|
prop="taskStartDate"
|
:show-overflow-tooltip="true"
|
min-width="180px"
|
/>
|
<el-table-column
|
prop="taskEndDate"
|
:show-overflow-tooltip="true"
|
min-width="180px"
|
/>
|
<el-table-column width="100px" style="align-items: center">
|
<template slot-scope="scope">
|
<el-button type="primary" size="mini" @click="quickFilling(scope.row)">填写日报</el-button>
|
</template>
|
</el-table-column>
|
</el-table>
|
</el-tab-pane>
|
</el-tabs>
|
</el-card>
|
</el-col>
|
<el-col :xs="24" :sm="24" :md="16" :lg="16" :xl="17" style="padding-left: 250px">
|
<el-card class="box-card" shadow="never">
|
<el-tabs v-model="activeName" style="height: 200px;">
|
<el-tab-pane :label="tasking" name="first">
|
<el-table
|
v-if="ongoingTasks.length != 0"
|
:data="ongoingTasks"
|
height="180"
|
:show-header="false"
|
:stripe="true"
|
>
|
<el-table-column
|
prop="name"
|
:show-overflow-tooltip="true"
|
min-width="150px"
|
/>
|
<el-table-column
|
prop="taskStartDate"
|
:show-overflow-tooltip="true"
|
min-width="180px"
|
/>
|
<el-table-column
|
prop="taskEndDate"
|
:show-overflow-tooltip="true"
|
min-width="180px"
|
/>
|
<el-table-column width="100px" style="align-items: center">
|
<template slot-scope="scope">
|
<el-button type="primary" size="mini" @click="quickFilling(scope.row)">填写日报</el-button>
|
</template>
|
</el-table-column>
|
</el-table>
|
<span v-else>暂无任务</span>
|
</el-tab-pane>
|
<el-tab-pane :label="tobeTask" name="second">
|
<el-table
|
v-if="taskNotStarted.length != 0"
|
:data="taskNotStarted"
|
height="180"
|
:show-header="false"
|
>
|
<el-table-column
|
prop="name"
|
:show-overflow-tooltip="true"
|
min-width="180px"
|
/>
|
<el-table-column
|
prop="taskStartDate"
|
:show-overflow-tooltip="true"
|
min-width="180px"
|
/>
|
<el-table-column
|
prop="taskEndDate"
|
:show-overflow-tooltip="true"
|
min-width="180px"
|
/>
|
<el-table-column width="100px" style="align-items: center">
|
<template slot-scope="scope">
|
<el-button type="primary" size="mini" @click="quickFilling(scope.row)">填写日报</el-button>
|
</template>
|
</el-table-column>
|
</el-table>
|
<span v-else>暂无任务</span>
|
</el-tab-pane>
|
<!--<el-tab-pane label="未分配任务" name="third" style=":display: false">未分配任务</el-tab-pane>-->
|
</el-tabs>
|
</el-card>
|
</el-col>
|
</el-row>
|
<el-divider />
|
<div class="head-container">
|
<div v-if="crud.props.searchToggle">
|
<!-- 搜索 -->
|
<el-date-picker
|
v-model="query.fillDates"
|
type="daterange"
|
clearable
|
class="filter-item"
|
value-format="yyyy-MM-dd"
|
placeholder="请选择日报日期"
|
range-separator=" ~ "
|
start-placeholder="开始日期"
|
end-placeholder="结束日期"
|
style="width: 285px;"
|
/>
|
<el-select v-model="query.projectId" filterable clearable placeholder="所属项目" :loading="loadingProject" style="width: 185px;" class="filter-item" @change="queryProjectChange" @keyup.enter.native="crud.toQuery" @clear="clearQueryTasks">
|
<el-option
|
v-for="item in queryProjects"
|
:key="item.id"
|
:label="item.name"
|
:value="item.id"
|
/>
|
</el-select>
|
<el-select v-model="query.taskMongoId" filterable clearable placeholder="所属任务" :loading="loadingTast" style="width: 185px;" class="filter-item" @keyup.enter.native="crud.toQuery">
|
<el-option
|
v-for="item in queryTasks"
|
:key="item.id"
|
:label="item.name"
|
:value="item.id"
|
/>
|
</el-select>
|
<el-input v-model="query.name" filterable clearable placeholder="任务名称" style="width: 185px;" class="filter-item" />
|
<rrOperation :crud="crud" />
|
</div>
|
<!--如果想在工具栏加入更多按钮,可以使用插槽方式, slot = 'left' or 'right'-->
|
<crudOperation :permission="permission" />
|
<!--表单组件-->
|
<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="userNickName">
|
<el-input v-model="form.userNickName" style="width: 340px;" :disabled="true" />
|
</el-form-item>
|
<el-form-item label="所属项目" prop="projectId">
|
<el-select v-if="queryProjects.length > 0" :key="form.projectId" v-model="form.projectId" filterable clearable placeholder="请选择" style="width: 340px;" :disabled="form.flag" @change="formProjectChange">
|
<template v-if="loadingQueryProjectsOne" #prefix>
|
<i class="el-icon-loading" />
|
</template>
|
<template v-if="!loadingQueryProjectsOne">
|
<el-option
|
v-for="item in queryProjects"
|
:key="item.id"
|
:label="item.name"
|
:value="item.id"
|
/>
|
</template>
|
</el-select>
|
<el-select v-else v-model="form" filterable clearable :placeholder="loadingQueryProjectsOne ? '加载中' : '请选择'" style="width: 340px;" :disabled="form.flag" @change="formProjectChange">
|
<template v-if="loadingQueryProjectsOne" #prefix>
|
<i class="el-icon-loading" />
|
</template>
|
<template v-if="!loadingQueryProjectsOne">
|
<el-option
|
v-for="item in queryProjects"
|
:key="item.id"
|
:label="item.name"
|
:value="item.id"
|
/>
|
</template>
|
</el-select>
|
</el-form-item>
|
<el-form-item label="所属任务" prop="taskId">
|
<el-select v-if="formTasks.length > 0" :key="form.taskId" v-model="form.taskId" filterable clearable placeholder="请选择" style="width: 340px;" :disabled="form.flag" @change="formTaskChange">
|
<template v-if="loadingQueryProjects" #prefix>
|
<i class="el-icon-loading" />
|
</template>
|
<template v-if="!loadingQueryProjects">
|
<el-option
|
v-for="item in formTasks"
|
:key="item.id"
|
:label="item.name"
|
:value="item.id"
|
/>
|
</template>
|
</el-select>
|
<el-select v-else v-model="form" filterable clearable :placeholder="loadingQueryProjects ? '加载中' : '请选择'" style="width: 340px;" :disabled="form.flag" @change="formTaskUserChange">
|
<template v-if="loadingQueryProjects" #prefix>
|
<i class="el-icon-loading" />
|
</template>
|
<template v-if="!loadingQueryProjects">
|
<el-option
|
v-for="item in formTasks"
|
:key="item.id"
|
:label="item.name"
|
:value="item.id"
|
/>
|
</template>
|
</el-select>
|
</el-form-item>
|
<el-form-item label="分配任务" prop="taskUserMongo">
|
<el-select v-if="formTaskUserIds.length > 0" :key="form.taskUserMongo.id" v-model="form.taskUserMongo.id" :allow-create="true" filterable clearable placeholder="请选择" style="width: 340px;" :disabled="form.flag" @change="formTaskUserChange">
|
<template v-if="loadingQueryProjectsTwo" #prefix>
|
<i class="el-icon-loading" />
|
</template>
|
<template v-if="!loadingQueryProjects">
|
<el-option
|
v-for="item in formTaskUserIds"
|
:key="item.id"
|
:label="item.name"
|
:value="item.id"
|
/>
|
</template>
|
</el-select>
|
<el-select v-else v-model="form" filterable clearable :placeholder="loadingQueryProjectsTwo ? '加载中' : '请选择'" style="width: 340px;" :disabled="form.flag" @change="formTaskUserChange">
|
<template v-if="loadingQueryProjectsTwo" #prefix>
|
<i class="el-icon-loading" />
|
</template>
|
<template v-if="!loadingQueryProjectsTwo">
|
<el-option
|
v-for="item in formTaskUserIds"
|
:key="item.id"
|
:label="item.name"
|
:value="item.id"
|
/>
|
</template>
|
</el-select>
|
</el-form-item>
|
<el-form-item label="填写日期" prop="fillDate">
|
<el-date-picker v-model="form.fillDate" type="date" style="width: 340px;" :disabled="form.taskUserMongo.id == null" @change="formDateChange" />
|
</el-form-item>
|
<el-form-item label="消耗工时" prop="consumedHours">
|
<el-input v-model="form.consumedHours" style="width: 340px;" :disabled="disabledFlagBySettlement || form.fillDate == null" @input="watchFlagChange">
|
<template slot="append">小时</template>
|
</el-input>
|
</el-form-item>
|
<el-form-item>
|
已消耗工时:{{ form.alreadyConsumedHours }} / 任务工时:{{ form.taskHours }}
|
</el-form-item>
|
<el-form-item label="任务进度" prop="taskProgress">
|
<el-input v-model="form.taskProgress" style="width: 340px;" :disabled="disabledFlagBySettlement">
|
<template slot="append">%</template>
|
</el-input>
|
</el-form-item>
|
<el-form-item label="备注">
|
<el-input v-model="form.remarks" :rows="3" type="textarea" style="width: 340px;" :disabled="disabledFlagBySettlement" />
|
</el-form-item>
|
</el-form>
|
<div slot="footer" class="dialog-footer">
|
<el-button type="text" @click="crud.cancelCU">取消</el-button>
|
<el-button :loading="crud.status.cu === 2" type="primary" @click="checkForm(1)">确认</el-button>
|
</div>
|
</el-dialog>
|
<!--表格渲染-->
|
<el-table ref="table" v-loading="crud.loading" :data="crud.data" size="small" style="width: 100%;" @selection-change="crud.selectionChangeHandler">
|
<el-table-column type="selection" width="55" />
|
<el-table-column :show-overflow-tooltip="true" prop="fillDate" label="填写日期" fixed="left" min-width="100px">
|
<template slot-scope="scope">
|
{{ crud.toDate(scope.row.fillDate) }}
|
</template>
|
</el-table-column>
|
<el-table-column :show-overflow-tooltip="true" prop="userNickName" label="所属员工" fixed="left" min-width="100px">
|
<template slot-scope="scope">
|
<el-tag>{{ scope.row.userNickName }}</el-tag>
|
</template>
|
</el-table-column>
|
<el-table-column :show-overflow-tooltip="true" prop="projectName" label="所属项目" min-width="140px">
|
<template slot-scope="scope">
|
<el-tag>{{ scope.row.projectName }}</el-tag>
|
</template>
|
</el-table-column>
|
<el-table-column :show-overflow-tooltip="true" prop="taskName" label="所属任务" min-width="180px">
|
<template slot-scope="scope">
|
<el-tag>{{ scope.row.taskName }}</el-tag>
|
</template>
|
</el-table-column>
|
<el-table-column :show-overflow-tooltip="true" prop="taskUserMongo.name" label="分配任务" min-width="180px">
|
<template slot-scope="scope">
|
<el-tag>{{ scope.row.taskUserMongo.name }}</el-tag>
|
</template>
|
</el-table-column>
|
<el-table-column :show-overflow-tooltip="true" prop="consumedHours" label="消耗工时" min-width="80px" />
|
<el-table-column :show-overflow-tooltip="true" prop="taskProgress" label="任务进度" min-width="80px">
|
<template slot-scope="scope">
|
{{ scope.row.taskProgress }}%
|
</template>
|
</el-table-column>
|
<el-table-column :show-overflow-tooltip="true" prop="settlementStatus" min-width="80px" label="结算状态">
|
<template slot-scope="scope">
|
<el-tag>{{ dict.label[settlementStatus][scope.row.settlementStatus] }}</el-tag>
|
</template>
|
</el-table-column>
|
<el-table-column prop="remarks" label="备注" min-width="140px" />
|
<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 :data="scope.row" :permission="permission" />
|
</template>
|
</el-table-column>
|
</el-table>
|
|
<el-dialog
|
title="提示"
|
:visible.sync="centerDialogVisibleTaskHours"
|
width="30%"
|
center
|
>
|
<span>本次日报的消耗工时已超过任务工时,确定要继续吗?</span>
|
<span slot="footer" class="dialog-footer">
|
<el-button @click="centerDialogVisibleTaskHours = false">取 消</el-button>
|
<el-button type="primary" @click="submitDialogTaskHours">确 定</el-button>
|
</span>
|
</el-dialog>
|
|
<el-dialog
|
title="提示"
|
:visible.sync="centerDialogVisibleTaskProgress"
|
width="30%"
|
center
|
>
|
<span>本次日报的任务进度比您原本的任务进度要少,确定要继续吗?</span>
|
<span slot="footer" class="dialog-footer">
|
<el-button @click="centerDialogVisibleTaskProgress = false">取 消</el-button>
|
<el-button type="primary" @click="submitDialogTaskProgress">确 定</el-button>
|
</span>
|
</el-dialog>
|
<!--分页组件-->
|
<pagination />
|
</div>
|
</div>
|
</template>
|
|
<script>
|
import crudTaskDaliy from '@/api/task/taskDaliy'
|
import CRUD, { presenter, header, form, crud } from '@crud/crud'
|
import rrOperation from '@crud/RR.operation'
|
import crudOperation from '@crud/CRUD.operation'
|
import udOperation from '@crud/UD.operation'
|
import pagination from '@crud/Pagination'
|
import { mapGetters } from 'vuex'
|
import constant from '../../../utils/constant'
|
import crudProject from '@/api/project/project'
|
import crudTask from '@/api/task/task'
|
import crudTaskUser from '@/api/task/taskUser'
|
|
const defaultForm = { id: null, projectId: null, taskId: null, taskMongoId: null, taskUserMongo: {}, userId: null, fillDate: null, consumedHours: null, alreadyConsumedHours: 0, taskHours: 0, consumedWorkload: null, consumedWorkloadUnit: null, taskProgress: null, settlementStatus: constant.SETTLEMENT_STATUS_UNSETTLED, remarks: null, createBy: null, createTime: null, updateBy: null, updateTime: null }
|
export default {
|
name: 'TaskDaliy',
|
components: { pagination, crudOperation, rrOperation, udOperation },
|
mixins: [presenter(), header(), form(defaultForm), crud()],
|
dicts: [constant.STANDARD_WORKLOAD_UNIT, constant.SETTLEMENT_STATUS],
|
cruds() {
|
return CRUD({ title: '任务日报', url: 'api/taskDaliy', idField: 'id', sort: 'fillDate,desc', crudMethod: { ...crudTaskDaliy }})
|
},
|
data() {
|
// 时长(万内)验证
|
var durationValidate = (rule, value, callback) => {
|
const reg = /^([0-9]|[1-9]\d{1,3})(\.\d{1,2})?$/
|
if (value != null && value !== '' && !reg.test(value)) {
|
callback(new Error('请输入 一万 以内的正整数或两位小数'))
|
} else {
|
callback()
|
}
|
}
|
// 比例(百内)验证
|
var proportionValidate = (rule, value, callback) => {
|
const reg = /^([0-9]|[1-9]\d)(\.\d{1,2})?$|100$/
|
if (value != null && value !== '' && !reg.test(value)) {
|
callback(new Error('请输入 一百 以内的正整数或两位小数'))
|
} else {
|
callback()
|
}
|
}
|
return {
|
permission: {
|
add: ['admin', 'taskDaliy:add'],
|
edit: ['admin', 'taskDaliy:edit'],
|
del: ['admin', 'taskDaliy:del'],
|
download: ['admin', 'taskDaliy:download']
|
},
|
rules: {
|
fillDate: [
|
{ required: true, message: '填写日期不能为空', trigger: 'change' }
|
],
|
userNickName: [
|
{ required: true, message: '所属员工不能为空', trigger: 'change' }
|
],
|
projectId: [
|
{ required: true, message: '所属项目不能为空', trigger: 'blur' }
|
],
|
taskId: [
|
{ required: true, message: '所属任务不能为空', trigger: 'blur' }
|
],
|
taskUserMongo: [
|
{ required: true, message: '分配任务不能为空', trigger: 'blur' }
|
],
|
consumedHours: [
|
{ required: true, message: '消耗工时不能为空', trigger: 'blur' },
|
{ validator: durationValidate, trigger: 'blur' }
|
],
|
consumedWorkload: [
|
{ validator: durationValidate, trigger: 'blur' }
|
],
|
taskProgress: [
|
{ required: true, message: '任务进度不能为空', trigger: 'blur' },
|
{ validator: proportionValidate, trigger: 'blur' }
|
],
|
settlementStatus: [
|
{ required: true, message: '结算状态不能为空', trigger: 'change' }
|
]
|
},
|
queryTypeOptions: [
|
{ key: 'userId', display_name: '所属员工' },
|
{ key: 'projectId', display_name: '所属项目' },
|
{ key: 'taskId', display_name: '所属任务' },
|
{ key: 'taskUserId', display_name: '分配任务' },
|
{ key: 'TaskUserName', display_name: '任务名称' },
|
{ key: 'taskMongoId', display_name: '任务名称' }
|
],
|
// 字典:标准工作量单位
|
standardWorkloadUnit: constant.STANDARD_WORKLOAD_UNIT,
|
// 字典:结算状态
|
settlementStatus: constant.SETTLEMENT_STATUS,
|
// 角色级别:超级管理员
|
roleLevelSuper: constant.ROLE_LEVEL_SUPER,
|
// 角色级别:总经理
|
roleLevelGeneral: constant.ROLE_LEVEL_GENERAL,
|
// CRUD状态
|
crudStatusPrepared: CRUD.STATUS.PREPARED,
|
// 用户最大角色级别
|
userRolesLevelMin: null,
|
// 用户列表
|
users: [],
|
// 检索项目列表
|
queryProjects: [],
|
adventTasks: [],
|
ongoingTasks: [],
|
taskNotStarted: [],
|
// 检索任务列表
|
queryTasks: [],
|
// 表单项目列表
|
formProjects: [],
|
// 表单任务列表
|
formTasks: [],
|
// 三级任务
|
formTaskUserIds: [],
|
// 表单禁用标记(结算状态)
|
disabledFlagBySettlement: false,
|
// 当前月份
|
currentMonth: new Date(),
|
// 当前TAB
|
activeName: 'first',
|
tobeOver: 'first',
|
tasking: '进行中任务',
|
tobeTask: '未着手任务',
|
tobeTasked: '临期任务',
|
currentTask: null,
|
taskLoading: true,
|
centerDialogVisibleTaskHours: false,
|
centerDialogVisibleTaskProgress: false,
|
confirmHours: false,
|
confirmProgress: false,
|
newValue: '',
|
oldValue: '',
|
tempValue: '',
|
resData: true,
|
userIds: [],
|
watchFlg: false,
|
editVar: '',
|
loadingProject: true,
|
loadingTast: false,
|
loadingQueryProjectsOne: false,
|
loadingQueryProjects: false,
|
loadingQueryProjectsTwo: false
|
}
|
},
|
computed: {
|
...mapGetters([
|
'user'
|
])
|
},
|
watch: {
|
'form.consumedHours': function(newVal, oldVal) {
|
if (newVal === 0 && this.userIds.includes(this.form.taskUserMongo.id)) {
|
this.form.alreadyConsumedHours = this.tempValue
|
}
|
if (this.crud.status.edit === 1 && newVal === 0) {
|
this.form.alreadyConsumedHours = this.form.alreadyConsumedHours - (this.editVar - 0)
|
}
|
if (this.watchFlg) {
|
this.form.alreadyConsumedHours = (this.form.alreadyConsumedHours) - (oldVal - 0) + (newVal - 0)
|
this.watchFlg = false
|
}
|
},
|
'confirmProgress': function(newVal) {
|
this.confirmProgress = newVal
|
},
|
'confirmHours': function(newVal) {
|
this.confirmHours = newVal
|
},
|
'crud.status.edit': function() {
|
this.editVar = this.form.consumedHours
|
}
|
},
|
methods: {
|
// 钩子:在获取表格数据之前执行,false 则代表不获取数据
|
[CRUD.HOOK.beforeRefresh]() {
|
// 判断传参是否为空
|
if (this.$route.params.projectId != null && this.$route.params.projectId !== '' && this.crud.query.projectId === undefined) {
|
// 检索条件赋值
|
this.$set(this.crud.query, 'projectId', Number(this.$route.params.projectId))
|
// 获取任务列表
|
crudTask.getAllOfDaily({ projectId: this.query.projectId }).then(res => {
|
// 检索任务列表
|
this.queryTasks = res
|
})
|
}
|
// 判断传参是否为空
|
if (this.$route.params.taskId != null && this.$route.params.taskId !== '' && this.crud.query.taskId === undefined) {
|
// 检索条件赋值
|
this.$set(this.crud.query, 'taskId', Number(this.$route.params.taskId))
|
}
|
// 用户角色级别数组
|
const userRolesLevel = this.user.roles.map(({ level }) => level)
|
// 用户最大角色级别
|
this.userRolesLevelMin = Math.min(...userRolesLevel)
|
// 获取检索项目
|
this.getQueryProject()
|
this.getAdventTasks()
|
this.getOngoingTasks()
|
this.getTaskNotStarted()
|
return true
|
},
|
// 新增与编辑前做的操作
|
[CRUD.HOOK.afterToCU](crud, form) {
|
// 判断表单结算状态
|
if (this.form.settlementStatus === constant.SETTLEMENT_STATUS_SETTLED) {
|
// 表单禁用标记(结算状态)
|
this.disabledFlagBySettlement = true
|
} else {
|
// 表单禁用标记(结算状态)
|
this.disabledFlagBySettlement = false
|
}
|
// 随机数
|
this.random = Math.random()
|
},
|
[CRUD.HOOK.afterSubmit]() {
|
this.form.flag = false
|
this.currentTask = null
|
this.formTasks = []
|
this.formTaskUserIds = []
|
this.form.alreadyConsumedHours = 0
|
this.confirmHours = false
|
this.confirmProgress = false
|
},
|
[CRUD.HOOK.afterEditError]() {
|
this.form.flag = false
|
this.currentTask = null
|
this.formTasks = []
|
this.formTaskUserIds = []
|
this.form.alreadyConsumedHours = 0
|
this.confirmHours = false
|
this.confirmProgress = false
|
},
|
[CRUD.HOOK.afterEditCancel]() {
|
this.form.flag = false
|
this.currentTask = null
|
this.formTasks = []
|
this.formTaskUserIds = []
|
this.form.alreadyConsumedHours = 0
|
this.confirmHours = false
|
this.confirmProgress = false
|
},
|
[CRUD.HOOK.afterAddCancel]() {
|
this.form.flag = false
|
this.currentTask = null
|
this.formTasks = []
|
this.formTaskUserIds = []
|
this.form.alreadyConsumedHours = 0
|
this.confirmHours = false
|
this.confirmProgress = false
|
},
|
[CRUD.HOOK.afterAddError]() {
|
this.form.flag = false
|
this.currentTask = null
|
this.formTasks = []
|
this.formTaskUserIds = []
|
this.form.alreadyConsumedHours = 0
|
this.confirmHours = false
|
this.confirmProgress = false
|
},
|
// 钩子:新建 - 之前
|
[CRUD.HOOK.beforeToAdd]() {
|
this.formTasks = []
|
this.formTaskUserIds = []
|
this.form.taskId = null
|
this.form.taskUserMongo.id = null
|
this.form.userId = this.user.id
|
this.form.userNickName = this.user.nickName
|
// 判断用户最大角色级别是否是角色级别:超级管理员或角色级别:总经理
|
if (this.userRolesLevelMin !== this.roleLevelSuper && this.userRolesLevelMin !== this.roleLevelGeneral) {
|
// 表单赋值
|
this.form.userId = this.user.id
|
this.form.userNickName = this.user.nickName
|
|
// 表单用户变更
|
this.formUserChange()
|
this.formTaskChange()
|
}
|
if (this.currentTask) {
|
this.form.projectId = this.currentTask.projectId
|
this.formProjectChange(() => {
|
this.form.taskId = this.currentTask.taskId
|
this.formTaskChange(() => { this.form.taskUserMongo.id = this.currentTask.id })
|
})
|
this.form.taskHours = this.currentTask.performanceHours
|
this.form.alreadyConsumedHours = this.currentTask.alreadyConsumedHours
|
this.tempValue = this.currentTask.alreadyConsumedHours
|
this.form.flag = true
|
}
|
},
|
// 钩子:编辑 - 之前
|
[CRUD.HOOK.beforeToEdit]() {
|
this.form.userId = this.user.id
|
this.form.userNickName = this.user.nickName
|
this.loadingQueryProjects = true
|
this.loadingQueryProjectsTwo = true
|
crudTask.getAllOfDaily({ projectId: this.form.projectId }).then(res => {
|
// 检索任务列表
|
|
this.formTasks = res
|
this.$nextTick().then(() => {
|
this.loadingQueryProjects = false
|
})
|
})
|
crudTaskUser.getAllTaskUser(this.form.taskUserMongo.id).then(res => {
|
if (res === []) {
|
this.formTaskUserIds = []
|
}
|
this.formTaskUserIds = res
|
this.$nextTick().then(() => {
|
this.loadingQueryProjectsTwo = false
|
})
|
|
for (let i = 0; i < this.formTaskUserIds.length; i++) {
|
this.userIds.push(this.formTaskUserIds[i].id)
|
}
|
|
// 循环表单任务列表
|
for (let i = 0; i < this.formTaskUserIds.length; i++) {
|
// 判断是否为选中任务
|
if (this.formTaskUserIds[i].id === this.form.taskUserMongo.id) {
|
this.form.taskHours = this.formTaskUserIds[i].performanceHours
|
this.form.alreadyConsumedHours = this.formTaskUserIds[i].alreadyConsumedHours
|
this.tempValue = this.formTaskUserIds[i].alreadyConsumedHours
|
}
|
}
|
})
|
},
|
[CRUD.HOOK.afterRefresh]() {
|
this.taskLoading = false
|
},
|
[CRUD.HOOK.beforeSubmit]() {
|
if (!this.userIds.includes(this.form.taskUserMongo.id)) {
|
// 置换一下
|
var taskUserMongoName = this.form.taskUserMongo.id
|
this.form.taskUserMongo.name = taskUserMongoName
|
this.form.taskUserMongo.id = null
|
}
|
},
|
checkForm(flag) {
|
if (this.form.taskUserMongo.id === undefined) {
|
this.$message({
|
showClose: true,
|
message: '分配任务不能为空',
|
type: 'error'
|
})
|
return
|
} else if (this.form.fillDate === undefined) {
|
this.$message({
|
showClose: true,
|
message: '填写日期不能为空',
|
type: 'error'
|
})
|
return
|
} else if (this.form.consumedHours === undefined || this.form.consumedHours === 0) {
|
this.$message({
|
showClose: true,
|
message: '请填写任务时长',
|
type: 'error'
|
})
|
return
|
} else if (this.form.taskProgress === undefined) {
|
this.$message({
|
showClose: true,
|
message: '任务进度不能为空',
|
type: 'error'
|
})
|
return
|
}
|
crudTaskDaliy.checkTaskHours({ 'taskProgress': this.form.taskProgress, 'taskUserId': this.form.taskUserMongo.id, 'fillDate': this.form.fillDate }).then(res => {
|
if (res === false && !this.confirmProgress) {
|
flag++
|
// 为假
|
this.centerDialogVisibleTaskProgress = true
|
if (this.confirmProgress) {
|
// 如果确定了
|
const result = this.form.alreadyConsumedHours
|
if (result > this.form.taskHours && !this.confirmHours) {
|
this.centerDialogVisibleTaskHours = true
|
if (this.confirmHours) {
|
this.crud.submitCU()
|
} else {
|
if (flag > 1) {
|
return
|
} else {
|
this.checkForm()
|
}
|
}
|
} else {
|
this.crud.submitCU()
|
}
|
} else {
|
if (flag > 1) {
|
return
|
} else {
|
// 没确定
|
this.checkForm()
|
}
|
}
|
} else {
|
flag++
|
// 判断时间
|
const result = this.form.alreadyConsumedHours
|
if (result > this.form.taskHours && !this.confirmHours) {
|
this.centerDialogVisibleTaskHours = true
|
if (this.confirmHours) {
|
this.crud.submitCU()
|
} else {
|
if (flag > 1) {
|
return
|
} else {
|
this.checkForm()
|
}
|
}
|
} else {
|
this.crud.submitCU()
|
}
|
}
|
})
|
},
|
watchFlagChange() {
|
this.watchFlg = true
|
},
|
getAdventTasks() {
|
crudTaskUser.getAdventTasks().then(res => {
|
this.adventTasks = res
|
})
|
},
|
getOngoingTasks() {
|
crudTaskUser.getOngoingTasks().then(res => {
|
this.ongoingTasks = res
|
})
|
},
|
getTaskNotStarted() {
|
crudTaskUser.getTaskNotStarted().then(res => {
|
this.taskNotStarted = res
|
})
|
},
|
handleClick(tab, event) {
|
console.log(tab, event)
|
},
|
handleClickTobeTasked(tab, event) {
|
console.log(tab, event)
|
},
|
// 获取检索项目
|
getQueryProject() {
|
this.loadingProject = true
|
this.queryProjects = []
|
this.loadingQueryProjectsOne = true
|
// 获取项目
|
crudProject.getRelevantOfDaily().then(res => {
|
// this.formProjects = res
|
// 检索项目列表
|
this.queryProjects = res
|
this.loadingProject = false
|
this.$nextTick().then(() => {
|
this.loadingQueryProjectsOne = false
|
})
|
})
|
|
// 获取任务列表
|
crudTask.getAllOfDaily({ projectId: this.query.projectId }).then(res => {
|
// 检索任务列表
|
this.queryTasks = res
|
})
|
},
|
// 检索项目变更
|
queryProjectChange() {
|
this.queryTasks = []
|
this.loadingTast = true
|
// 检索赋值
|
this.$set(this.query, 'taskId', null)
|
// 判断检索项目是否为空
|
if (this.query.projectId === null || this.query.projectId === '') {
|
// 检索任务列表
|
this.queryTasks = []
|
} else {
|
// 获取任务
|
crudTask.getAllOfDaily({ projectId: this.query.projectId }).then(res => {
|
// 检索任务列表
|
this.queryTasks = res
|
this.loadingTast = false
|
})
|
}
|
},
|
clearQueryTasks() {
|
this.loadingTast = false
|
},
|
formDateChange() {
|
crudTaskDaliy.getDailyDetail({ taskUserId: this.form.taskUserMongo.id, fillDate: this.form.fillDate }).then(res => {
|
if (res === '') {
|
this.form.alreadyConsumedHours = this.tempValue
|
this.form.consumedHours = 0
|
} else {
|
this.form.alreadyConsumedHours = this.tempValue
|
this.form.consumedHours = res.consumedHours
|
this.form.taskProgress = res.taskProgress
|
}
|
if (!this.userIds.includes(this.form.taskUserMongo.id)) {
|
this.form.consumedHours = 0
|
this.form.taskProgress = 0
|
this.form.alreadyConsumedHours = 0
|
}
|
})
|
},
|
// 表单用户变更
|
formUserChange() {
|
// 表单赋值
|
this.form.projectId = null
|
this.form.taskId = null
|
// 判断表单用户是否为空
|
if (this.form.userId == null || this.form.userId === '') {
|
// 表单项目列表
|
this.formProjects = []
|
// 表单任务列表
|
this.formTasks = []
|
} else {
|
// 获取项目
|
crudProject.getPartake({ taskUserId: this.form.userId, approveStatus: constant.APPROVE_STATUS_ACKNOWLEDGED }).then(res => {
|
// 表单项目列表
|
this.formProjects = res
|
})
|
}
|
},
|
// 表单项目变更
|
formProjectChange(cb) {
|
// 表单赋值
|
this.form.taskId = null
|
this.form.taskUserMongo = {}
|
this.form.taskHours = 0
|
this.form.alreadyConsumedHours = 0
|
this.form.consumedHours = null
|
this.form.taskProgress = null
|
this.form.remarks = null
|
// 判断表单项目是否为空
|
if (this.form.projectId == null || this.form.projectId === '') {
|
// 表单任务列表
|
this.formTasks = []
|
} else {
|
this.loadingQueryProjects = true
|
this.loadingQueryProjectsTwo = true
|
this.formTasks = []
|
this.formTaskUserIds = []
|
this.form.taskId = null
|
this.form.taskUserMongo.id = null
|
// 获取任务
|
crudTask.getAllOfDaily({ projectId: this.form.projectId }).then(res => {
|
// 检索任务列表
|
this.formTasks = res
|
this.$nextTick().then(() => {
|
this.loadingQueryProjects = false
|
})
|
if (cb) {
|
cb()
|
}
|
})
|
}
|
},
|
// 表单任务变更
|
formTaskChange(cb) {
|
this.formTaskUserIds = []
|
this.form.taskUserMongo.id = null
|
this.loadingQueryProjectsTwo = true
|
// 循环表单任务列表
|
for (let i = 0; i < this.formTasks.length; i++) {
|
// 判断是否为选中任务
|
if (this.formTasks[i].id === this.form.taskId) {
|
crudTask.getRelevantTaskUser({ 'taskId': this.form.taskId }).then(res => {
|
if (res === []) {
|
this.formTaskUserIds = []
|
}
|
for (let i = 0; i < res.length; i++) {
|
this.userIds.push(res[i].id)
|
}
|
this.formTaskUserIds = res
|
this.$nextTick().then(() => {
|
this.loadingQueryProjectsTwo = false
|
})
|
this.form.taskProgress = res.taskProgress
|
this.form.consumedHours = res.consumedHours
|
if (cb) {
|
cb()
|
}
|
})
|
}
|
}
|
},
|
formTaskUserChange() {
|
this.form.consumedHours = 0
|
this.form.fillDate = null
|
// this.form.taskProgress = 0
|
this.form.alreadyConsumedHours = 0
|
this.form.taskHours = 0
|
console.log('ddd:' + this.form.taskUserMongo.id)
|
// 循环表单任务列表
|
for (let i = 0; i < this.formTaskUserIds.length; i++) {
|
// 判断是否为选中任务
|
if (this.formTaskUserIds[i].id === this.form.taskUserMongo.id) {
|
this.form.taskHours = this.formTaskUserIds[i].performanceHours
|
this.form.alreadyConsumedHours = this.formTaskUserIds[i].alreadyConsumedHours
|
this.tempValue = this.formTaskUserIds[i].alreadyConsumedHours
|
}
|
}
|
|
this.getTaskProgress(this.form.taskUserMongo.id)
|
},
|
quickFilling(object) {
|
this.currentTask = object
|
this.crud.toAdd()
|
this.getTaskProgress(object.id)
|
},
|
getTaskProgress(id) {
|
// 任务更改查询任务进度
|
crudTaskDaliy.getDailyTaskProgress({ taskUserId: id }).then(res => {
|
if (res !== '') {
|
this.form.taskProgress = res.taskProgress
|
} else {
|
this.form.taskProgress = 0
|
}
|
})
|
},
|
submitDialogTaskHours() {
|
this.centerDialogVisibleTaskHours = false
|
this.confirmHours = true
|
},
|
submitDialogTaskProgress() {
|
this.centerDialogVisibleTaskProgress = false
|
this.confirmProgress = true
|
}
|
}
|
}
|
</script>
|
|
<style scoped>
|
adventTable tr:first-child {
|
display: none;
|
}
|
</style>
|