<template>
|
<div class="app-container">
|
<!--工具栏-->
|
<el-row :gutter="15">
|
<el-col :xs="24" :sm="24" :md="8" :lg="8" :xl="7">
|
<el-card class="box-card" shadow="never">
|
<el-tabs v-model="activeName" @tab-click="handleClick" style="height: 200px;">
|
<el-tab-pane label="临期任务(10)" name="first">临期任务</el-tab-pane>
|
</el-tabs>
|
</el-card>
|
</el-col>
|
<el-col :xs="24" :sm="24" :md="16" :lg="16" :xl="17">
|
<el-card class="box-card" shadow="never">
|
<el-tabs v-model="activeName" @tab-click="handleClick" style="height: 200px;">
|
<el-tab-pane label="进行中任务(10)" name="first">进行中任务</el-tab-pane>
|
<el-tab-pane label="未着手任务(10)" name="second">未着手任务</el-tab-pane>
|
<el-tab-pane label="未分配任务(10)" name="third">未分配任务</el-tab-pane>
|
</el-tabs>
|
</el-card>
|
</el-col>
|
</el-row>
|
<el-divider></el-divider>
|
<div class="head-container">
|
<div v-if="crud.props.searchToggle">
|
<!-- 搜索 -->
|
<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>
|
<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="所属项目" style="width: 185px;" class="filter-item" @change="queryProjectChange" @keyup.enter.native="crud.toQuery">
|
<el-option
|
v-for="item in queryProjects"
|
:key="item.id"
|
:label="item.name"
|
:value="item.id"
|
/>
|
</el-select>
|
<el-select v-model="query.taskId" filterable clearable placeholder="所属任务" 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>
|
<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="fillDate">
|
<el-date-picker v-model="form.fillDate" type="date" style="width: 340px;" :disabled="disabledFlagBySettlement" />
|
</el-form-item>
|
<el-form-item label="所属员工" prop="userId">
|
<el-select v-model="form.userId" filterable clearable placeholder="请选择" style="width: 340px;" :disabled="disabledFlagBySettlement || (userRolesLevelMin != roleLevelSuper && userRolesLevelMin != roleLevelGeneral)" @change="formUserChange">
|
<el-option
|
v-for="item in users"
|
:key="item.id"
|
:label="item.nickName"
|
:value="item.id"
|
:disabled="!item.enabled"
|
/>
|
</el-select>
|
</el-form-item>
|
<el-form-item label="所属项目" prop="projectId">
|
<el-select v-model="form.projectId" filterable clearable placeholder="请选择" style="width: 340px;" :disabled="disabledFlagBySettlement || crud.status.edit == crudStatusPrepared" @change="formProjectChange">
|
<el-option
|
v-for="item in formProjects"
|
:key="item.id"
|
:label="item.name"
|
:value="item.id"
|
/>
|
</el-select>
|
</el-form-item>
|
<el-form-item label="所属任务" prop="taskId">
|
<el-select v-model="form.taskId" filterable clearable placeholder="请选择" style="width: 340px;" :disabled="disabledFlagBySettlement" @change="formTaskChange">
|
<el-option
|
v-for="item in formTasks"
|
:key="item.id"
|
:label="item.name"
|
:value="item.id"
|
/>
|
</el-select>
|
</el-form-item>
|
<el-form-item label="消耗工时" prop="consumedHours">
|
<el-input v-model="form.consumedHours" style="width: 340px;" :disabled="disabledFlagBySettlement">
|
<template slot="append">小时</template>
|
</el-input>
|
</el-form-item>
|
<el-form-item>
|
已消耗工时:{{ form.alreadyConsumedHours }} / 任务工时:{{ form.taskHours }}
|
</el-form-item>
|
<el-form-item label="消耗工作量" prop="consumedWorkload">
|
<el-input v-model="form.consumedWorkload" style="width: 340px;" :disabled="disabledFlagBySettlement" />
|
</el-form-item>
|
<el-form-item label="消耗工作量单位">
|
{{ dict.label[standardWorkloadUnit][form.consumedWorkloadUnit] }}
|
</el-form-item>
|
<el-form-item label="任务进度" prop="taskProgress">
|
<el-input v-model="form.taskProgress" style="width: 340px;" :disabled="disabledFlagBySettlement">
|
<template slot="prepend"><i class="i el-icon-search" @click="showInner" /></template>
|
<template slot="append">%</template>
|
</el-input>
|
</el-form-item>
|
<el-form-item v-if="(userRolesLevelMin == roleLevelSuper || userRolesLevelMin == roleLevelGeneral) && crud.status.edit == crudStatusPrepared" label="结算状态" prop="settlementStatus">
|
<el-select v-model="form.settlementStatus" filterable placeholder="请选择" style="width: 340px;" :disabled="disabledFlagBySettlement">
|
<el-option
|
v-for="item in dict[settlementStatus]"
|
:key="item.id"
|
:label="item.label"
|
:value="item.value"
|
/>
|
</el-select>
|
</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="crud.submitCU">确认</el-button>
|
</div>
|
<el-dialog
|
width="30%"
|
title="日报详细"
|
:visible.sync="innerVisible"
|
append-to-body
|
>
|
<el-table ref="tableInner" v-loading="innerLoading" :data="innerData" size="small" style="width: 100%;">
|
<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="taskHours" label="分配工时" min-width="80px" />
|
<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>
|
</el-dialog>
|
</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="consumedHours" label="消耗工时" min-width="80px" />
|
<el-table-column :show-overflow-tooltip="true" prop="consumedWorkload" label="消耗工作量" min-width="80px" />
|
<el-table-column :show-overflow-tooltip="true" prop="taskWorkloadUnit" label="消耗工作量单位" min-width="110px">
|
<template slot-scope="scope">
|
<el-tag v-if="scope.row.taskWorkloadUnit != null && scope.row.taskWorkloadUnit != ''">{{ dict.label[standardWorkloadUnit][scope.row.taskWorkloadUnit] }}</el-tag>
|
</template>
|
</el-table-column>
|
<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 prop="createTime" label="创建时间" min-width="140px" />
|
<el-table-column v-if="checkPer(['admin','taskDaliy:edit','taskDaliy:del'])" label="操作" width="150px" align="center" fixed="right">
|
<template slot-scope="scope">
|
<udOperation
|
v-if="userRolesLevelMin == roleLevelSuper || userRolesLevelMin == roleLevelGeneral || scope.row.userId == user.id"
|
:data="scope.row"
|
:permission="permission"
|
/>
|
</template>
|
</el-table-column>
|
</el-table>
|
<!--分页组件-->
|
<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 crudUser from '@/api/system/user'
|
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, 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' }
|
],
|
userId: [
|
{ required: true, message: '所属员工不能为空', trigger: 'change' }
|
],
|
projectId: [
|
{ required: true, message: '所属项目不能为空', trigger: 'change' }
|
],
|
taskId: [
|
{ required: true, message: '所属任务不能为空', trigger: 'change' }
|
],
|
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: '所属任务' }
|
],
|
// 字典:标准工作量单位
|
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: [],
|
// 检索任务列表
|
queryTasks: [],
|
// 表单项目列表
|
formProjects: [],
|
// 表单任务列表
|
formTasks: [],
|
// 表单禁用标记(结算状态)
|
disabledFlagBySettlement: false,
|
// 内侧弹出框
|
innerVisible: false,
|
// 内侧数据
|
innerData: [],
|
// 内侧数据加载
|
innerLoading: false,
|
// 当前月份
|
currentMonth: new Date(),
|
// 当前TAB
|
activeName: 'first',
|
}
|
},
|
computed: {
|
...mapGetters([
|
'user'
|
])
|
},
|
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.getAll({ 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.getUser()
|
// 获取检索项目
|
this.getQueryProject()
|
return true
|
},
|
handleClick(tab, event) {
|
console.log(tab, event);
|
},
|
// 获取用户
|
getUser() {
|
// 获取用户
|
crudUser.getAll().then(res => {
|
// 用户列表
|
this.users = res
|
})
|
},
|
// 获取检索项目
|
getQueryProject() {
|
// 获取项目
|
crudProject.getRelevant().then(res => {
|
// 检索项目列表
|
this.queryProjects = res
|
})
|
},
|
// 检索项目变更
|
queryProjectChange() {
|
// 检索赋值
|
this.$set(this.query, 'taskId', null)
|
// 判断检索项目是否为空
|
if (this.query.projectId == null || this.query.projectId === '') {
|
// 检索任务列表
|
this.queryTasks = []
|
} else {
|
// 获取任务
|
crudTask.getAll({ projectId: this.query.projectId }).then(res => {
|
// 检索任务列表
|
this.queryTasks = res
|
})
|
}
|
},
|
// 新增与编辑前做的操作
|
[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.beforeToAdd]() {
|
// 判断用户最大角色级别是否是角色级别:超级管理员或角色级别:总经理
|
if (this.userRolesLevelMin !== this.roleLevelSuper && this.userRolesLevelMin !== this.roleLevelGeneral) {
|
// 表单赋值
|
this.form.userId = this.user.id
|
// 表单用户变更
|
this.formUserChange()
|
}
|
},
|
// 钩子:编辑 - 之前
|
[CRUD.HOOK.beforeToEdit]() {
|
// 获取项目
|
crudProject.getPartake({ taskUserId: this.form.userId, approveStatus: constant.APPROVE_STATUS_ACKNOWLEDGED }).then(res => {
|
// 表单项目列表
|
this.formProjects = res
|
})
|
// 获取任务
|
crudTask.getPartake({ taskUserId: this.form.userId, projectId: this.form.projectId }).then(res => {
|
// 表单任务列表
|
this.formTasks = res
|
// 表单任务变更
|
this.formTaskChange()
|
})
|
},
|
// 表单用户变更
|
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() {
|
// 表单赋值
|
this.form.taskId = null
|
// 判断表单项目是否为空
|
if (this.form.projectId == null || this.form.projectId === '') {
|
// 表单任务列表
|
this.formTasks = []
|
} else {
|
// 获取任务
|
crudTask.getPartake({ taskUserId: this.form.userId, projectId: this.form.projectId }).then(res => {
|
// 表单任务列表
|
this.formTasks = res
|
})
|
}
|
},
|
// 表单任务变更
|
formTaskChange() {
|
// 循环表单任务列表
|
for (let i = 0; i < this.formTasks.length; i++) {
|
// 判断是否为选中任务
|
if (this.formTasks[i].id === this.form.taskId) {
|
// 表单赋值
|
this.form.consumedWorkloadUnit = this.formTasks[i].planWorkloadUnit
|
break
|
}
|
// 判断循环是否结束
|
if (i === this.formTasks.length - 1) {
|
// 表单赋值
|
this.form.consumedWorkloadUnit = null
|
}
|
}
|
// 查询任务的总消耗工时
|
crudTaskDaliy.taskTotalConsumedHours({ userId: this.form.userId, projectId: this.form.projectId, taskId: this.form.taskId }).then(res => {
|
// 表单赋值
|
this.form.alreadyConsumedHours = res
|
})
|
// 查询任务分配
|
crudTaskUser.getAll({ userId: this.form.userId, projectId: this.form.projectId, taskId: this.form.taskId }).then(res => {
|
// 表单赋值
|
this.form.taskHours = res[0].taskHours
|
})
|
},
|
showInner() {
|
// 显示内部对话框
|
this.innerVisible = true
|
this.innerLoading = true
|
crudTaskDaliy.getTaskDaliyWithHours({ userId: this.form.userId, projectId: this.form.projectId, taskId: this.form.taskId, page: 0, size: 5, sort: 'fillDate,desc' }).then(res => {
|
this.innerData = res.content
|
this.innerLoading = false
|
})
|
}
|
}
|
}
|
</script>
|
|
<style scoped>
|
|
</style>
|