| | |
| | | :key="item.id" |
| | | :label="item.name" |
| | | :value="item.id" |
| | | :disabled="item.approveStatus == approveStatusUnrecognized" |
| | | /> |
| | | </el-select> |
| | | </el-form-item> |
| | |
| | | /> |
| | | </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> |
| | |
| | | <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"> |
| | |
| | | </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"> |
| | |
| | | <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" /> |
| | | <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 }} |
| | | {{ crud.toMaxTwoDecimalPlaces(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 }} |
| | | {{ crud.toMaxTwoDecimalPlaces(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 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" |
| | | > |
| | |
| | | <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-form-item label="分配员工" prop="userIds"> |
| | | <el-select v-model="divideForm.userIds" filterable clearable multiple placeholder="请选择" style="width: 340px;" @change="calcHour"> |
| | | <el-option |
| | | v-for="item in users" |
| | | :key="item.id" |
| | | :label="item.nickName" |
| | | :value="item.id" |
| | | :disabled="!item.enabled || divideForm.divideUserIds.includes(item.id)" |
| | | /> |
| | | > |
| | | <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="任务开始时间" prop="taskStartDate"> |
| | | <el-date-picker v-model="divideForm.taskStartDate" type="datetime" value-format="yyyy-MM-dd HH:mm:ss" :default-time="$store.state.user.user.sysRostering.workStartTime + ':00'" :picker-options="taskStartDatePickerOptions" style="width: 340px;" /> |
| | | <el-date-picker v-model="divideForm.taskStartDate" type="datetime" value-format="yyyy-MM-dd HH:mm:ss" :default-time="$store.state.user.user.sysRostering.workStartTime + ':00'" :picker-options="taskStartDatePickerOptions" style="width: 340px;" @change="calcHour" /> |
| | | </el-form-item> |
| | | <el-form-item label="任务结束时间" prop="taskEndDate"> |
| | | <el-date-picker v-model="divideForm.taskEndDate" type="datetime" value-format="yyyy-MM-dd HH:mm:ss" :default-time="$store.state.user.user.sysRostering.workEndTime + ':00'" :picker-options="taskEndDatePickerOptions" style="width: 340px;" /> |
| | | <el-date-picker v-model="divideForm.taskEndDate" type="datetime" value-format="yyyy-MM-dd HH:mm:ss" :default-time="$store.state.user.user.sysRostering.workEndTime + ':00'" :picker-options="taskEndDatePickerOptions" style="width: 340px;" @change="calcHour" /> |
| | | </el-form-item> |
| | | <el-form-item label="任务工时" prop="taskHours"> |
| | | <el-input v-model="divideForm.taskHours" style="width: 340px;"> |
| | |
| | | |
| | | <script> |
| | | import crudTask from '@/api/task/task' |
| | | import crudTaskUser from '@/api/task/taskUser' |
| | | import CRUD, { presenter, header, form, crud } from '@crud/crud' |
| | | import rrOperation from '@crud/RR.operation' |
| | | import crudOperation from '@crud/CRUD.operation' |
| | |
| | | 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 }}) |
| | | }, |
| | | 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() |
| | | } |
| | |
| | | ], |
| | | taskClassification: [ |
| | | { required: true, message: '任务分类不能为空', trigger: 'change' } |
| | | ], |
| | | performanceType: [ |
| | | { required: true, message: '绩效类型不能为空', trigger: 'change' } |
| | | ], |
| | | pieceRate: [ |
| | | { validator: durationValidate, trigger: 'blur' } |
| | | ], |
| | | planHours: [ |
| | | { required: true, message: '计划工时不能为空', trigger: 'blur' }, |
| | |
| | | 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: [], |
| | | // 父级任务列表 |
| | |
| | | // 分配表单加载 |
| | | divideLoading: false, |
| | | // 分配表单数据 |
| | | divideForm: { projectId: null, projectName: null, taskId: null, taskname: null, userIds: [], divideUserIds: [], taskStartDate: null, taskEndDate: null, taskHours: null, taskWorkload: null, taskStatus: null }, |
| | | 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' } |
| | | { required: true, message: '分配员工不能为空', trigger: 'change' } |
| | | ], |
| | | taskStartDate: [ |
| | | { required: true, message: '任务开始时间不能为空', trigger: 'change' } |
| | |
| | | methods: { |
| | | // 钩子:在获取表格数据之前执行,false 则代表不获取数据 |
| | | [CRUD.HOOK.beforeRefresh]() { |
| | | // 用户角色级别数组 |
| | | const userRolesLevel = this.$store.state.user.user.roles.map(({ level }) => level) |
| | | // 用户最大角色级别 |
| | | this.userRolesLevelMin = Math.min(...userRolesLevel) |
| | | // 获取项目 |
| | | this.getProject() |
| | | // 获取用户 |
| | |
| | | // 项目列表 |
| | | this.projects = res |
| | | }) |
| | | }, |
| | | // 自动计算工时 |
| | | calcHour() { |
| | | if (this.divideForm.taskEndDate && this.divideForm.taskStartDate && this.divideForm.userIds && this.divideForm.userIds.length > 0 && !this.divideForm.taskHours) { |
| | | crudTaskUser.calcHours({ userId: this.divideForm.userIds[0], taskStartDate: this.divideForm.taskStartDate, taskEndDate: this.divideForm.taskEndDate }).then(res => { |
| | | this.divideForm.taskHours = res |
| | | }) |
| | | } |
| | | }, |
| | | // 获取用户 |
| | | getUser() { |
| | |
| | | // 添加 |
| | | 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]() { |
| | |
| | | // 分配表单加载 |
| | | 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.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() |
| | |
| | | // 表单验证 |
| | | 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 => { |
| | | // 分配表单关闭 |
| | |
| | | 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 |
| | | } |
| | | } |
| | | } |
| | | } |
| | | } |