Merge branch 'zhaoss' of http://192.168.1.110:5678/r/pms-upgrade into master
10 files added
7 files modified
| | |
| | | public static final String PRIORITY_MIDDLE = "priority_middle"; |
| | | // 优先度:高 |
| | | public static final String PRIORITY_HIGH = "priority_high"; |
| | | |
| | | // 任务状态 |
| | | public static final String TASK_STATUS = "task_status"; |
| | | // 任务状态:未开始 |
| | | public static final String TASK_STATUS_NOT_STARTED = "task_status_not_started"; |
| | | // 任务状态:进行中 |
| | | public static final String TASK_STATUS_IN_HAND = "task_status_in_hand"; |
| | | // 任务状态:已完成 |
| | | public static final String TASK_STATUS_COMPLETED = "task_status_completed"; |
| | | } |
| New file |
| | |
| | | /* |
| | | * Copyright 2019-2020 Zheng Jie |
| | | * |
| | | * Licensed under the Apache License, Version 2.0 (the "License"); |
| | | * you may not use this file except in compliance with the License. |
| | | * You may obtain a copy of the License at |
| | | * |
| | | * http://www.apache.org/licenses/LICENSE-2.0 |
| | | * |
| | | * Unless required by applicable law or agreed to in writing, software |
| | | * distributed under the License is distributed on an "AS IS" BASIS, |
| | | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| | | * See the License for the specific language governing permissions and |
| | | * limitations under the License. |
| | | */ |
| | | package me.zhengjie.modules.task.domain; |
| | | |
| | | import lombok.Data; |
| | | import cn.hutool.core.bean.BeanUtil; |
| | | import io.swagger.annotations.ApiModelProperty; |
| | | import cn.hutool.core.bean.copier.CopyOptions; |
| | | import me.zhengjie.base.BaseEntity; |
| | | |
| | | import javax.persistence.*; |
| | | import javax.validation.constraints.*; |
| | | import java.sql.Timestamp; |
| | | import java.io.Serializable; |
| | | |
| | | /** |
| | | * @website https://eladmin.vip |
| | | * @description / |
| | | * @author 赵士淞 |
| | | * @date 2022-12-28 |
| | | **/ |
| | | @Entity |
| | | @Data |
| | | @Table(name="task_user") |
| | | public class TaskUser extends BaseEntity implements Serializable { |
| | | |
| | | @Id |
| | | @GeneratedValue(strategy = GenerationType.IDENTITY) |
| | | @Column(name = "`id`") |
| | | @ApiModelProperty(value = "ID") |
| | | private Long id; |
| | | |
| | | @Column(name = "`project_id`",nullable = false) |
| | | @NotNull |
| | | @ApiModelProperty(value = "项目ID") |
| | | private Long projectId; |
| | | |
| | | @Column(name = "`task_id`",nullable = false) |
| | | @NotNull |
| | | @ApiModelProperty(value = "任务ID") |
| | | private Long taskId; |
| | | |
| | | @Column(name = "`user_id`",nullable = false) |
| | | @NotNull |
| | | @ApiModelProperty(value = "用户ID") |
| | | private Long userId; |
| | | |
| | | @Column(name = "`task_start_date`",nullable = false) |
| | | @NotNull |
| | | @ApiModelProperty(value = "任务开始时间") |
| | | private Timestamp taskStartDate; |
| | | |
| | | @Column(name = "`task_end_date`",nullable = false) |
| | | @NotNull |
| | | @ApiModelProperty(value = "任务结束时间") |
| | | private Timestamp taskEndDate; |
| | | |
| | | @Column(name = "`task_hours`",nullable = false) |
| | | @NotNull |
| | | @ApiModelProperty(value = "任务工时") |
| | | private Double taskHours; |
| | | |
| | | @Column(name = "`task_workload`") |
| | | @ApiModelProperty(value = "任务工作量") |
| | | private Double taskWorkload; |
| | | |
| | | @Column(name = "`task_workload_unit`") |
| | | @ApiModelProperty(value = "任务工作量单位") |
| | | private String taskWorkloadUnit; |
| | | |
| | | @Column(name = "`task_status`",nullable = false) |
| | | @NotBlank |
| | | @ApiModelProperty(value = "任务状态") |
| | | private String taskStatus; |
| | | |
| | | @Column(name = "`remarks`") |
| | | @ApiModelProperty(value = "备注") |
| | | private String remarks; |
| | | |
| | | public void copy(TaskUser source){ |
| | | BeanUtil.copyProperties(source,this, CopyOptions.create().setIgnoreNullValue(true)); |
| | | } |
| | | } |
| New file |
| | |
| | | /* |
| | | * Copyright 2019-2020 Zheng Jie |
| | | * |
| | | * Licensed under the Apache License, Version 2.0 (the "License"); |
| | | * you may not use this file except in compliance with the License. |
| | | * You may obtain a copy of the License at |
| | | * |
| | | * http://www.apache.org/licenses/LICENSE-2.0 |
| | | * |
| | | * Unless required by applicable law or agreed to in writing, software |
| | | * distributed under the License is distributed on an "AS IS" BASIS, |
| | | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| | | * See the License for the specific language governing permissions and |
| | | * limitations under the License. |
| | | */ |
| | | package me.zhengjie.modules.task.repository; |
| | | |
| | | import me.zhengjie.modules.task.domain.TaskUser; |
| | | import org.springframework.data.jpa.repository.JpaRepository; |
| | | import org.springframework.data.jpa.repository.JpaSpecificationExecutor; |
| | | import org.springframework.data.jpa.repository.Query; |
| | | |
| | | import java.util.List; |
| | | |
| | | /** |
| | | * @website https://eladmin.vip |
| | | * @author 赵士淞 |
| | | * @date 2022-12-28 |
| | | **/ |
| | | public interface TaskUserRepository extends JpaRepository<TaskUser, Long>, JpaSpecificationExecutor<TaskUser> { |
| | | |
| | | /** |
| | | * 根据任务ID查询任务工时总和 |
| | | * @param taskId / |
| | | * @return / |
| | | */ |
| | | @Query(value = "SELECT COALESCE(SUM(task_hours),0) FROM task_user WHERE task_id = ?1", nativeQuery = true) |
| | | Double sumTaskHoursByTaskId(Long taskId); |
| | | |
| | | /** |
| | | * 根据任务ID查询任务工作量总和 |
| | | * @param taskId / |
| | | * @return / |
| | | */ |
| | | @Query(value = "SELECT COALESCE(SUM(task_workload),0) FROM task_user WHERE task_id = ?1", nativeQuery = true) |
| | | Double sumTaskWorkloadByTaskId(Long taskId); |
| | | |
| | | /** |
| | | * 根据任务ID查询所属用户 |
| | | * @param taskId / |
| | | * @return / |
| | | */ |
| | | @Query(value = "SELECT user_id FROM task_user WHERE task_id = ?1", nativeQuery = true) |
| | | List<Long> findUserIdByTaskId(Long taskId); |
| | | } |
| | |
| | | import me.zhengjie.annotation.Log; |
| | | import me.zhengjie.modules.task.domain.Task; |
| | | import me.zhengjie.modules.task.service.TaskService; |
| | | import me.zhengjie.modules.task.service.TaskUserService; |
| | | import me.zhengjie.modules.task.service.dto.TaskQueryCriteria; |
| | | import me.zhengjie.modules.task.service.dto.TaskUserDto; |
| | | import org.springframework.data.domain.Pageable; |
| | | import lombok.RequiredArgsConstructor; |
| | | import org.springframework.http.HttpStatus; |
| | |
| | | public class TaskController { |
| | | |
| | | private final TaskService taskService; |
| | | private final TaskUserService taskUserService; |
| | | |
| | | @Log("导出数据") |
| | | @ApiOperation("导出数据") |
| | |
| | | taskService.deleteAll(ids); |
| | | return new ResponseEntity<>(HttpStatus.OK); |
| | | } |
| | | |
| | | @PostMapping(value = "/divide") |
| | | @Log("分配任务") |
| | | @ApiOperation("分配任务") |
| | | @PreAuthorize("@el.check('task:divide')") |
| | | public ResponseEntity<Object> divideTask(@Validated @RequestBody TaskUserDto resources){ |
| | | taskUserService.divide(resources); |
| | | return new ResponseEntity<>(HttpStatus.NO_CONTENT); |
| | | } |
| | | } |
| New file |
| | |
| | | /* |
| | | * Copyright 2019-2020 Zheng Jie |
| | | * |
| | | * Licensed under the Apache License, Version 2.0 (the "License"); |
| | | * you may not use this file except in compliance with the License. |
| | | * You may obtain a copy of the License at |
| | | * |
| | | * http://www.apache.org/licenses/LICENSE-2.0 |
| | | * |
| | | * Unless required by applicable law or agreed to in writing, software |
| | | * distributed under the License is distributed on an "AS IS" BASIS, |
| | | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| | | * See the License for the specific language governing permissions and |
| | | * limitations under the License. |
| | | */ |
| | | package me.zhengjie.modules.task.rest; |
| | | |
| | | import me.zhengjie.annotation.Log; |
| | | import me.zhengjie.modules.task.domain.TaskUser; |
| | | import me.zhengjie.modules.task.service.TaskUserService; |
| | | import me.zhengjie.modules.task.service.dto.TaskUserQueryCriteria; |
| | | import org.springframework.data.domain.Pageable; |
| | | import lombok.RequiredArgsConstructor; |
| | | import org.springframework.http.HttpStatus; |
| | | import org.springframework.http.ResponseEntity; |
| | | import org.springframework.security.access.prepost.PreAuthorize; |
| | | import org.springframework.validation.annotation.Validated; |
| | | import org.springframework.web.bind.annotation.*; |
| | | import io.swagger.annotations.*; |
| | | import java.io.IOException; |
| | | import javax.servlet.http.HttpServletResponse; |
| | | |
| | | /** |
| | | * @website https://eladmin.vip |
| | | * @author 赵士淞 |
| | | * @date 2022-12-28 |
| | | **/ |
| | | @RestController |
| | | @RequiredArgsConstructor |
| | | @Api(tags = "任务分配管理") |
| | | @RequestMapping("/api/taskUser") |
| | | public class TaskUserController { |
| | | |
| | | private final TaskUserService taskUserService; |
| | | |
| | | @Log("导出数据") |
| | | @ApiOperation("导出数据") |
| | | @GetMapping(value = "/download") |
| | | @PreAuthorize("@el.check('taskUser:download')") |
| | | public void exportTaskUser(HttpServletResponse response, TaskUserQueryCriteria criteria) throws IOException { |
| | | taskUserService.download(taskUserService.queryAll(criteria), response); |
| | | } |
| | | |
| | | @GetMapping |
| | | @Log("查询任务分配") |
| | | @ApiOperation("查询任务分配") |
| | | @PreAuthorize("@el.check('taskUser:list')") |
| | | public ResponseEntity<Object> queryTaskUser(TaskUserQueryCriteria criteria, Pageable pageable){ |
| | | return new ResponseEntity<>(taskUserService.queryAll(criteria,pageable),HttpStatus.OK); |
| | | } |
| | | |
| | | @GetMapping(value = "/all") |
| | | @Log("查询任务分配") |
| | | @ApiOperation("查询任务分配") |
| | | @PreAuthorize("@el.check('taskUser:list')") |
| | | public ResponseEntity<Object> queryTaskUser(TaskUserQueryCriteria criteria){ |
| | | return new ResponseEntity<>(taskUserService.queryAll(criteria),HttpStatus.OK); |
| | | } |
| | | |
| | | @PostMapping |
| | | @Log("新增任务分配") |
| | | @ApiOperation("新增任务分配") |
| | | @PreAuthorize("@el.check('taskUser:add')") |
| | | public ResponseEntity<Object> createTaskUser(@Validated @RequestBody TaskUser resources){ |
| | | return new ResponseEntity<>(taskUserService.create(resources),HttpStatus.CREATED); |
| | | } |
| | | |
| | | @PutMapping |
| | | @Log("修改任务分配") |
| | | @ApiOperation("修改任务分配") |
| | | @PreAuthorize("@el.check('taskUser:edit')") |
| | | public ResponseEntity<Object> updateTaskUser(@Validated @RequestBody TaskUser resources){ |
| | | taskUserService.update(resources); |
| | | return new ResponseEntity<>(HttpStatus.NO_CONTENT); |
| | | } |
| | | |
| | | @DeleteMapping |
| | | @Log("删除任务分配") |
| | | @ApiOperation("删除任务分配") |
| | | @PreAuthorize("@el.check('taskUser:del')") |
| | | public ResponseEntity<Object> deleteTaskUser(@RequestBody Long[] ids) { |
| | | taskUserService.deleteAll(ids); |
| | | return new ResponseEntity<>(HttpStatus.OK); |
| | | } |
| | | } |
| New file |
| | |
| | | /* |
| | | * Copyright 2019-2020 Zheng Jie |
| | | * |
| | | * Licensed under the Apache License, Version 2.0 (the "License"); |
| | | * you may not use this file except in compliance with the License. |
| | | * You may obtain a copy of the License at |
| | | * |
| | | * http://www.apache.org/licenses/LICENSE-2.0 |
| | | * |
| | | * Unless required by applicable law or agreed to in writing, software |
| | | * distributed under the License is distributed on an "AS IS" BASIS, |
| | | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| | | * See the License for the specific language governing permissions and |
| | | * limitations under the License. |
| | | */ |
| | | package me.zhengjie.modules.task.service; |
| | | |
| | | import me.zhengjie.modules.task.domain.TaskUser; |
| | | import me.zhengjie.modules.task.service.dto.TaskUserDto; |
| | | import me.zhengjie.modules.task.service.dto.TaskUserQueryCriteria; |
| | | import org.springframework.data.domain.Pageable; |
| | | import java.util.Map; |
| | | import java.util.List; |
| | | import java.io.IOException; |
| | | import javax.servlet.http.HttpServletResponse; |
| | | |
| | | /** |
| | | * @website https://eladmin.vip |
| | | * @description 服务接口 |
| | | * @author 赵士淞 |
| | | * @date 2022-12-28 |
| | | **/ |
| | | public interface TaskUserService { |
| | | |
| | | /** |
| | | * 查询数据分页 |
| | | * @param criteria 条件 |
| | | * @param pageable 分页参数 |
| | | * @return Map<String,Object> |
| | | */ |
| | | Map<String,Object> queryAll(TaskUserQueryCriteria criteria, Pageable pageable); |
| | | |
| | | /** |
| | | * 查询所有数据不分页 |
| | | * @param criteria 条件参数 |
| | | * @return List<TaskUserDto> |
| | | */ |
| | | List<TaskUserDto> queryAll(TaskUserQueryCriteria criteria); |
| | | |
| | | /** |
| | | * 根据ID查询 |
| | | * @param id ID |
| | | * @return TaskUserDto |
| | | */ |
| | | TaskUserDto findById(Long id); |
| | | |
| | | /** |
| | | * 创建 |
| | | * @param resources / |
| | | * @return TaskUserDto |
| | | */ |
| | | TaskUserDto create(TaskUser resources); |
| | | |
| | | /** |
| | | * 编辑 |
| | | * @param resources / |
| | | */ |
| | | void update(TaskUser resources); |
| | | |
| | | /** |
| | | * 多选删除 |
| | | * @param ids / |
| | | */ |
| | | void deleteAll(Long[] ids); |
| | | |
| | | /** |
| | | * 导出数据 |
| | | * @param all 待导出的数据 |
| | | * @param response / |
| | | * @throws IOException / |
| | | */ |
| | | void download(List<TaskUserDto> all, HttpServletResponse response) throws IOException; |
| | | |
| | | /** |
| | | * 分配 |
| | | * @param resources / |
| | | * @return TaskUserDto |
| | | */ |
| | | void divide(TaskUserDto resources); |
| | | } |
| | |
| | | |
| | | import java.sql.Timestamp; |
| | | import java.io.Serializable; |
| | | import java.util.List; |
| | | |
| | | /** |
| | | * @website https://eladmin.vip |
| | |
| | | |
| | | /** 是否有子级 */ |
| | | private Boolean hasChildren; |
| | | |
| | | /** 已分配工时 */ |
| | | private Double divideHours; |
| | | |
| | | /** 已分配工作量 */ |
| | | private Double divideWorkload; |
| | | |
| | | /** 已分配用户 */ |
| | | private List<Long> divideUserIds; |
| | | } |
| New file |
| | |
| | | /* |
| | | * Copyright 2019-2020 Zheng Jie |
| | | * |
| | | * Licensed under the Apache License, Version 2.0 (the "License"); |
| | | * you may not use this file except in compliance with the License. |
| | | * You may obtain a copy of the License at |
| | | * |
| | | * http://www.apache.org/licenses/LICENSE-2.0 |
| | | * |
| | | * Unless required by applicable law or agreed to in writing, software |
| | | * distributed under the License is distributed on an "AS IS" BASIS, |
| | | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| | | * See the License for the specific language governing permissions and |
| | | * limitations under the License. |
| | | */ |
| | | package me.zhengjie.modules.task.service.dto; |
| | | |
| | | import lombok.Data; |
| | | import me.zhengjie.base.BaseDTO; |
| | | |
| | | import java.sql.Timestamp; |
| | | import java.io.Serializable; |
| | | import java.util.List; |
| | | |
| | | /** |
| | | * @website https://eladmin.vip |
| | | * @description / |
| | | * @author 赵士淞 |
| | | * @date 2022-12-28 |
| | | **/ |
| | | @Data |
| | | public class TaskUserDto extends BaseDTO implements Serializable { |
| | | |
| | | /** ID */ |
| | | private Long id; |
| | | |
| | | /** 项目ID */ |
| | | private Long projectId; |
| | | |
| | | /** 任务ID */ |
| | | private Long taskId; |
| | | |
| | | /** 用户ID */ |
| | | private Long userId; |
| | | |
| | | /** 任务开始时间 */ |
| | | private Timestamp taskStartDate; |
| | | |
| | | /** 任务结束时间 */ |
| | | private Timestamp taskEndDate; |
| | | |
| | | /** 任务工时 */ |
| | | private Double taskHours; |
| | | |
| | | /** 任务工作量 */ |
| | | private Double taskWorkload; |
| | | |
| | | /** 任务工作量单位 */ |
| | | private String taskWorkloadUnit; |
| | | |
| | | /** 任务状态 */ |
| | | private String taskStatus; |
| | | |
| | | /** 备注 */ |
| | | private String remarks; |
| | | |
| | | /** 项目名称 */ |
| | | private String projectName; |
| | | |
| | | /** 任务名称 */ |
| | | private String taskName; |
| | | |
| | | /** 用户昵称 */ |
| | | private String userNickName; |
| | | |
| | | /** 多用户ID */ |
| | | private List<Long> userIds; |
| | | } |
| New file |
| | |
| | | /* |
| | | * Copyright 2019-2020 Zheng Jie |
| | | * |
| | | * Licensed under the Apache License, Version 2.0 (the "License"); |
| | | * you may not use this file except in compliance with the License. |
| | | * You may obtain a copy of the License at |
| | | * |
| | | * http://www.apache.org/licenses/LICENSE-2.0 |
| | | * |
| | | * Unless required by applicable law or agreed to in writing, software |
| | | * distributed under the License is distributed on an "AS IS" BASIS, |
| | | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| | | * See the License for the specific language governing permissions and |
| | | * limitations under the License. |
| | | */ |
| | | package me.zhengjie.modules.task.service.dto; |
| | | |
| | | import lombok.Data; |
| | | import java.util.List; |
| | | import me.zhengjie.annotation.Query; |
| | | |
| | | /** |
| | | * @website https://eladmin.vip |
| | | * @author 赵士淞 |
| | | * @date 2022-12-28 |
| | | **/ |
| | | @Data |
| | | public class TaskUserQueryCriteria{ |
| | | |
| | | /** 精确 */ |
| | | @Query |
| | | private Long projectId; |
| | | |
| | | /** 精确 */ |
| | | @Query |
| | | private Long taskId; |
| | | |
| | | /** 精确 */ |
| | | @Query |
| | | private Long userId; |
| | | |
| | | /** 精确 */ |
| | | @Query |
| | | private String taskStatus; |
| | | } |
| | |
| | | import me.zhengjie.modules.project.repository.ProjectRepository; |
| | | import me.zhengjie.modules.system.repository.DictDetailRepository; |
| | | import me.zhengjie.modules.task.domain.Task; |
| | | import me.zhengjie.modules.task.repository.TaskUserRepository; |
| | | import me.zhengjie.utils.ValidationUtil; |
| | | import me.zhengjie.utils.FileUtil; |
| | | import lombok.RequiredArgsConstructor; |
| | |
| | | private final TaskMapper taskMapper; |
| | | private final ProjectRepository projectRepository; |
| | | private final DictDetailRepository dictDetailRepository; |
| | | private final TaskUserRepository taskUserRepository; |
| | | |
| | | @Override |
| | | public Map<String,Object> queryAll(TaskQueryCriteria criteria, Pageable pageable){ |
| | |
| | | public TaskDto apply(Task t) { |
| | | // 将实体类转换成DTO |
| | | TaskDto taskDto = taskMapper.toDto(t); |
| | | // 根据项目ID查询项目信息 |
| | | Project project = projectRepository.findById(taskDto.getProjectId()).orElseGet(Project::new); |
| | | ValidationUtil.isNull(project.getId(),"Project","id",taskDto.getProjectId()); |
| | | // 项目名称 |
| | | taskDto.setProjectName(project.getName()); |
| | | // 判断父级任务ID是否为空 |
| | | if (taskDto.getPid() != null) { |
| | | // 根据父级任务ID查询任务信息 |
| | | Task task = taskRepository.findById(taskDto.getPid()).orElseGet(Task::new); |
| | | ValidationUtil.isNull(task.getId(),"Task","id",taskDto.getPid()); |
| | | // 项目名称 |
| | | taskDto.setPidName(task.getName()); |
| | | } |
| | | // 根据父级任务ID查询 |
| | | List<Task> childrenTaskList = taskRepository.findByPid(taskDto.getId()); |
| | | // 判断子级数量 |
| | | if (childrenTaskList.size() > 0) { |
| | | // 是否有子级 |
| | | taskDto.setHasChildren(true); |
| | | } else { |
| | | // 是否有子级 |
| | | taskDto.setHasChildren(false); |
| | | } |
| | | // 自定义处理 |
| | | taskDto = customHandle(taskDto); |
| | | // 返回处理好的DTO |
| | | return taskDto; |
| | | } |
| | | }; |
| | | return PageUtil.toPage(page.map(func)); |
| | | } |
| | | |
| | | private TaskDto customHandle(TaskDto taskDto) { |
| | | // 根据项目ID查询项目信息 |
| | | Project project = projectRepository.findById(taskDto.getProjectId()).orElseGet(Project::new); |
| | | ValidationUtil.isNull(project.getId(),"Project","id",taskDto.getProjectId()); |
| | | // 项目名称 |
| | | taskDto.setProjectName(project.getName()); |
| | | // 判断父级任务ID是否为空 |
| | | if (taskDto.getPid() != null) { |
| | | // 根据父级任务ID查询任务信息 |
| | | Task task = taskRepository.findById(taskDto.getPid()).orElseGet(Task::new); |
| | | ValidationUtil.isNull(task.getId(),"Task","id",taskDto.getPid()); |
| | | // 父级任务名称 |
| | | taskDto.setPidName(task.getName()); |
| | | } |
| | | // 根据父级任务ID查询 |
| | | List<Task> childrenTaskList = taskRepository.findByPid(taskDto.getId()); |
| | | // 判断子级数量 |
| | | if (childrenTaskList.size() > 0) { |
| | | // 是否有子级 |
| | | taskDto.setHasChildren(true); |
| | | } else { |
| | | // 是否有子级 |
| | | taskDto.setHasChildren(false); |
| | | } |
| | | // 据任务ID查询任务工时总和 |
| | | Double sumTaskHours = taskUserRepository.sumTaskHoursByTaskId(taskDto.getId()); |
| | | // 已分配工时 |
| | | taskDto.setDivideHours(sumTaskHours); |
| | | // 据任务ID查询任务工作量总和 |
| | | Double sumTaskWorkload = taskUserRepository.sumTaskWorkloadByTaskId(taskDto.getId()); |
| | | // 已分配工作量 |
| | | taskDto.setDivideWorkload(sumTaskWorkload); |
| | | // 根据任务ID查询所属用户 |
| | | List<Long> userIdList = taskUserRepository.findUserIdByTaskId(taskDto.getId()); |
| | | // 已分配用户 |
| | | taskDto.setDivideUserIds(userIdList); |
| | | // 返回 |
| | | return taskDto; |
| | | } |
| | | |
| | | @Override |
| | |
| | | List<TaskDto> childrenTaskDtoList = taskMapper.toDto(taskRepository.findByPid(criteria.getId())); |
| | | // 循环子级任务列表 |
| | | for (int i = 0; i < childrenTaskDtoList.size(); i ++) { |
| | | // 根据项目ID查询项目信息 |
| | | Project project = projectRepository.findById(childrenTaskDtoList.get(i).getProjectId()).orElseGet(Project::new); |
| | | ValidationUtil.isNull(project.getId(),"Project","id",childrenTaskDtoList.get(i).getProjectId()); |
| | | // 项目名称 |
| | | childrenTaskDtoList.get(i).setProjectName(project.getName()); |
| | | // 判断父级任务ID是否为空 |
| | | if (childrenTaskDtoList.get(i).getPid() != null) { |
| | | // 根据父级任务ID查询任务信息 |
| | | Task task = taskRepository.findById(childrenTaskDtoList.get(i).getPid()).orElseGet(Task::new); |
| | | ValidationUtil.isNull(task.getId(),"Task","id",childrenTaskDtoList.get(i).getPid()); |
| | | // 项目名称 |
| | | childrenTaskDtoList.get(i).setPidName(task.getName()); |
| | | } |
| | | // 根据父级任务ID查询 |
| | | List<Task> childrenTaskList = taskRepository.findByPid(childrenTaskDtoList.get(i).getId()); |
| | | // 判断子级数量 |
| | | if (childrenTaskList.size() > 0) { |
| | | // 是否有子级 |
| | | childrenTaskDtoList.get(i).setHasChildren(true); |
| | | } else { |
| | | // 是否有子级 |
| | | childrenTaskDtoList.get(i).setHasChildren(false); |
| | | } |
| | | // 自定义处理 |
| | | childrenTaskDtoList.set(i, customHandle(childrenTaskDtoList.get(i))); |
| | | } |
| | | return childrenTaskDtoList; |
| | | } |
| New file |
| | |
| | | /* |
| | | * Copyright 2019-2020 Zheng Jie |
| | | * |
| | | * Licensed under the Apache License, Version 2.0 (the "License"); |
| | | * you may not use this file except in compliance with the License. |
| | | * You may obtain a copy of the License at |
| | | * |
| | | * http://www.apache.org/licenses/LICENSE-2.0 |
| | | * |
| | | * Unless required by applicable law or agreed to in writing, software |
| | | * distributed under the License is distributed on an "AS IS" BASIS, |
| | | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| | | * See the License for the specific language governing permissions and |
| | | * limitations under the License. |
| | | */ |
| | | package me.zhengjie.modules.task.service.impl; |
| | | |
| | | import me.zhengjie.modules.constant.Constant; |
| | | import me.zhengjie.modules.project.domain.Project; |
| | | import me.zhengjie.modules.project.repository.ProjectRepository; |
| | | import me.zhengjie.modules.system.domain.User; |
| | | import me.zhengjie.modules.system.repository.DictDetailRepository; |
| | | import me.zhengjie.modules.system.repository.UserRepository; |
| | | import me.zhengjie.modules.task.domain.Task; |
| | | import me.zhengjie.modules.task.domain.TaskUser; |
| | | import me.zhengjie.modules.task.repository.TaskRepository; |
| | | import me.zhengjie.utils.ValidationUtil; |
| | | import me.zhengjie.utils.FileUtil; |
| | | import lombok.RequiredArgsConstructor; |
| | | import me.zhengjie.modules.task.repository.TaskUserRepository; |
| | | import me.zhengjie.modules.task.service.TaskUserService; |
| | | import me.zhengjie.modules.task.service.dto.TaskUserDto; |
| | | import me.zhengjie.modules.task.service.dto.TaskUserQueryCriteria; |
| | | import me.zhengjie.modules.task.service.mapstruct.TaskUserMapper; |
| | | import org.springframework.stereotype.Service; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | | import org.springframework.data.domain.Page; |
| | | import org.springframework.data.domain.Pageable; |
| | | import me.zhengjie.utils.PageUtil; |
| | | import me.zhengjie.utils.QueryHelp; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | import java.io.IOException; |
| | | import javax.servlet.http.HttpServletResponse; |
| | | import java.util.ArrayList; |
| | | import java.util.LinkedHashMap; |
| | | import java.util.function.Function; |
| | | |
| | | /** |
| | | * @website https://eladmin.vip |
| | | * @description 服务实现 |
| | | * @author 赵士淞 |
| | | * @date 2022-12-28 |
| | | **/ |
| | | @Service |
| | | @RequiredArgsConstructor |
| | | public class TaskUserServiceImpl implements TaskUserService { |
| | | |
| | | private final TaskUserRepository taskUserRepository; |
| | | private final TaskUserMapper taskUserMapper; |
| | | private final ProjectRepository projectRepository; |
| | | private final TaskRepository taskRepository; |
| | | private final UserRepository userRepository; |
| | | private final DictDetailRepository dictDetailRepository; |
| | | |
| | | @Override |
| | | public Map<String,Object> queryAll(TaskUserQueryCriteria criteria, Pageable pageable){ |
| | | Page<TaskUser> page = taskUserRepository.findAll((root, criteriaQuery, criteriaBuilder) -> QueryHelp.getPredicate(root,criteria,criteriaBuilder),pageable); |
| | | // 将实体类转换为DTO(重写) |
| | | Function<TaskUser, TaskUserDto> func = new Function<TaskUser, TaskUserDto>(){ |
| | | @Override |
| | | public TaskUserDto apply(TaskUser t) { |
| | | // 将实体类转换成DTO |
| | | TaskUserDto taskUserDto = taskUserMapper.toDto(t); |
| | | // 根据项目ID查询项目信息 |
| | | Project project = projectRepository.findById(taskUserDto.getProjectId()).orElseGet(Project::new); |
| | | ValidationUtil.isNull(project.getId(),"Project","id",taskUserDto.getProjectId()); |
| | | // 项目名称 |
| | | taskUserDto.setProjectName(project.getName()); |
| | | // 根据任务ID查询任务信息 |
| | | Task task = taskRepository.findById(taskUserDto.getTaskId()).orElseGet(Task::new); |
| | | ValidationUtil.isNull(task.getId(),"Task","id",taskUserDto.getTaskId()); |
| | | // 任务名称 |
| | | taskUserDto.setTaskName(task.getName()); |
| | | // 根据用户ID查询用户信息 |
| | | User user = userRepository.findById(taskUserDto.getUserId()).orElseGet(User::new); |
| | | ValidationUtil.isNull(user.getId(),"User","id",taskUserDto.getUserId()); |
| | | // 用户昵称 |
| | | taskUserDto.setUserNickName(user.getNickName()); |
| | | // 返回处理好的DTO |
| | | return taskUserDto; |
| | | } |
| | | }; |
| | | return PageUtil.toPage(page.map(func)); |
| | | } |
| | | |
| | | @Override |
| | | public List<TaskUserDto> queryAll(TaskUserQueryCriteria criteria){ |
| | | return taskUserMapper.toDto(taskUserRepository.findAll((root, criteriaQuery, criteriaBuilder) -> QueryHelp.getPredicate(root,criteria,criteriaBuilder))); |
| | | } |
| | | |
| | | @Override |
| | | @Transactional |
| | | public TaskUserDto findById(Long id) { |
| | | TaskUser taskUser = taskUserRepository.findById(id).orElseGet(TaskUser::new); |
| | | ValidationUtil.isNull(taskUser.getId(),"TaskUser","id",id); |
| | | return taskUserMapper.toDto(taskUser); |
| | | } |
| | | |
| | | @Override |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public TaskUserDto create(TaskUser resources) { |
| | | return taskUserMapper.toDto(taskUserRepository.save(resources)); |
| | | } |
| | | |
| | | @Override |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public void update(TaskUser resources) { |
| | | TaskUser taskUser = taskUserRepository.findById(resources.getId()).orElseGet(TaskUser::new); |
| | | ValidationUtil.isNull( taskUser.getId(),"TaskUser","id",resources.getId()); |
| | | taskUser.copy(resources); |
| | | taskUserRepository.save(taskUser); |
| | | } |
| | | |
| | | @Override |
| | | public void deleteAll(Long[] ids) { |
| | | for (Long id : ids) { |
| | | taskUserRepository.deleteById(id); |
| | | } |
| | | } |
| | | |
| | | @Override |
| | | public void download(List<TaskUserDto> all, HttpServletResponse response) throws IOException { |
| | | List<Map<String, Object>> list = new ArrayList<>(); |
| | | for (TaskUserDto taskUser : all) { |
| | | String projectName = taskUser.getProjectId() != null ? projectRepository.findById(taskUser.getProjectId()).orElseGet(Project::new).getName() : ""; |
| | | String taskName = taskUser.getTaskId() != null ? taskRepository.findById(taskUser.getTaskId()).orElseGet(Task::new).getName() : ""; |
| | | String userNickName = taskUser.getUserId() != null ? userRepository.findById(taskUser.getUserId()).orElseGet(User::new).getNickName() : ""; |
| | | String taskStatus = taskUser.getTaskStatus() != null ? dictDetailRepository.findByDictNameAndValue(Constant.TASK_STATUS, taskUser.getTaskStatus()).getLabel() : ""; |
| | | String taskWorkloadUnit = taskUser.getTaskWorkloadUnit() != null ? dictDetailRepository.findByDictNameAndValue(Constant.STANDARD_WORKLOAD_UNIT, taskUser.getTaskWorkloadUnit()).getLabel() : ""; |
| | | Map<String,Object> map = new LinkedHashMap<>(); |
| | | map.put("项目名称", projectName); |
| | | map.put("任务名称", taskName); |
| | | map.put("用户姓名", userNickName); |
| | | map.put("任务开始时间", taskUser.getTaskStartDate()); |
| | | map.put("任务结束时间", taskUser.getTaskEndDate()); |
| | | map.put("任务工时", taskUser.getTaskHours()); |
| | | map.put("任务工作量", taskUser.getTaskWorkload()); |
| | | map.put("任务工作量单位", taskWorkloadUnit); |
| | | map.put("任务状态", taskStatus); |
| | | map.put("备注", taskUser.getRemarks()); |
| | | map.put("创建者", taskUser.getCreateBy()); |
| | | map.put("创建时间", taskUser.getCreateTime()); |
| | | map.put("更新者", taskUser.getUpdateBy()); |
| | | map.put("更新时间", taskUser.getUpdateTime()); |
| | | list.add(map); |
| | | } |
| | | FileUtil.downloadExcel(list, response); |
| | | } |
| | | |
| | | @Override |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public void divide(TaskUserDto resources) { |
| | | // 循环多用户ID |
| | | for (int i = 0; i < resources.getUserIds().size(); i ++) { |
| | | // 任务分配实体类 |
| | | TaskUser taskUser = new TaskUser(); |
| | | taskUser.setProjectId(resources.getProjectId()); |
| | | taskUser.setTaskId(resources.getTaskId()); |
| | | taskUser.setUserId(resources.getUserIds().get(i)); |
| | | taskUser.setTaskStartDate(resources.getTaskStartDate()); |
| | | taskUser.setTaskEndDate(resources.getTaskEndDate()); |
| | | taskUser.setTaskHours(resources.getTaskHours()); |
| | | taskUser.setTaskWorkload(resources.getTaskWorkload()); |
| | | taskUser.setTaskWorkloadUnit(resources.getTaskWorkloadUnit()); |
| | | taskUser.setTaskStatus(resources.getTaskStatus()); |
| | | // 保存 |
| | | taskUserRepository.save(taskUser); |
| | | } |
| | | } |
| | | } |
| New file |
| | |
| | | /* |
| | | * Copyright 2019-2020 Zheng Jie |
| | | * |
| | | * Licensed under the Apache License, Version 2.0 (the "License"); |
| | | * you may not use this file except in compliance with the License. |
| | | * You may obtain a copy of the License at |
| | | * |
| | | * http://www.apache.org/licenses/LICENSE-2.0 |
| | | * |
| | | * Unless required by applicable law or agreed to in writing, software |
| | | * distributed under the License is distributed on an "AS IS" BASIS, |
| | | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| | | * See the License for the specific language governing permissions and |
| | | * limitations under the License. |
| | | */ |
| | | package me.zhengjie.modules.task.service.mapstruct; |
| | | |
| | | import me.zhengjie.base.BaseMapper; |
| | | import me.zhengjie.modules.task.domain.TaskUser; |
| | | import me.zhengjie.modules.task.service.dto.TaskUserDto; |
| | | import org.mapstruct.Mapper; |
| | | import org.mapstruct.ReportingPolicy; |
| | | |
| | | /** |
| | | * @website https://eladmin.vip |
| | | * @author 赵士淞 |
| | | * @date 2022-12-28 |
| | | **/ |
| | | @Mapper(componentModel = "spring", unmappedTargetPolicy = ReportingPolicy.IGNORE) |
| | | public interface TaskUserMapper extends BaseMapper<TaskUserDto, TaskUser> { |
| | | |
| | | } |
| | |
| | | }) |
| | | } |
| | | |
| | | export default { getAll, getChildren, add, edit, del } |
| | | export function divide(data) { |
| | | return request({ |
| | | url: 'api/task/divide', |
| | | method: 'post', |
| | | data |
| | | }) |
| | | } |
| | | |
| | | export default { getAll, getChildren, add, edit, del, divide } |
| New file |
| | |
| | | import request from '@/utils/request' |
| | | |
| | | export function getAll(params) { |
| | | return request({ |
| | | url: 'api/taskUser/all', |
| | | method: 'get', |
| | | params |
| | | }) |
| | | } |
| | | |
| | | export function add(data) { |
| | | return request({ |
| | | url: 'api/taskUser', |
| | | method: 'post', |
| | | data |
| | | }) |
| | | } |
| | | |
| | | export function del(ids) { |
| | | return request({ |
| | | url: 'api/taskUser/', |
| | | method: 'delete', |
| | | data: ids |
| | | }) |
| | | } |
| | | |
| | | export function edit(data) { |
| | | return request({ |
| | | url: 'api/taskUser', |
| | | method: 'put', |
| | | data |
| | | }) |
| | | } |
| | | |
| | | export default { getAll, add, edit, del } |
| | |
| | | // 优先度:高 |
| | | export const PRIORITY_HIGH = 'priority_high' |
| | | |
| | | // 任务状态 |
| | | export const TASK_STATUS = 'task_status' |
| | | // 任务状态:未开始 |
| | | export const TASK_STATUS_NOT_STARTED = 'task_status_not_started' |
| | | // 任务状态:进行中 |
| | | export const TASK_STATUS_IN_HAND = 'task_status_in_hand' |
| | | // 任务状态:已完成 |
| | | export const TASK_STATUS_COMPLETED = 'task_status_completed' |
| | | |
| | | export default { |
| | | CONFIG_PROPORTION_BASIC_WAGE, |
| | | CONFIG_PROPORTION_MERIT_WAGE, |
| | |
| | | PRIORITY, |
| | | PRIORITY_LOW, |
| | | PRIORITY_MIDDLE, |
| | | PRIORITY_HIGH |
| | | PRIORITY_HIGH, |
| | | TASK_STATUS, |
| | | TASK_STATUS_NOT_STARTED, |
| | | TASK_STATUS_IN_HAND, |
| | | TASK_STATUS_COMPLETED |
| | | } |
| | |
| | | <div class="head-container"> |
| | | <div v-if="crud.props.searchToggle"> |
| | | <!-- 搜索 --> |
| | | <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-option |
| | | v-for="item in projects" |
| | |
| | | :value="item.id" |
| | | /> |
| | | </el-select> |
| | | <el-input v-model="query.name" clearable placeholder="名称" style="width: 185px;" class="filter-item" @keyup.enter.native="crud.toQuery" /> |
| | | <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]" |
| | |
| | | <rrOperation :crud="crud" /> |
| | | </div> |
| | | <!--如果想在工具栏加入更多按钮,可以使用插槽方式, slot = 'left' or 'right'--> |
| | | <crudOperation :permission="permission" /> |
| | | <crudOperation :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> |
| | | </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;" @change="projectChange"> |
| | | <el-option |
| | |
| | | :value="item.id" |
| | | /> |
| | | </el-select> |
| | | </el-form-item> |
| | | <el-form-item label="名称" prop="name"> |
| | | <el-input v-model="form.name" style="width: 340px;" /> |
| | | </el-form-item> |
| | | <el-form-item label="父级任务"> |
| | | <el-select v-model="form.pid" filterable clearable placeholder="请选择" style="width: 340px;"> |
| | |
| | | <!--表格渲染--> |
| | | <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-column type="selection" width="55" /> |
| | | <el-table-column :show-overflow-tooltip="true" prop="projectName" label="所属项目" fixed="left" width="180"> |
| | | <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"> |
| | | <template slot-scope="scope"> |
| | | <el-tag>{{ scope.row.projectName }}</el-tag> |
| | | </template> |
| | | </el-table-column> |
| | | <el-table-column :show-overflow-tooltip="true" prop="name" label="名称" fixed="left" width="180" /> |
| | | <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> |
| | |
| | | <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" prop="planHours" label="计划工时" width="80" /> |
| | | <el-table-column :show-overflow-tooltip="true" prop="planWorkload" label="计划工作量" width="80" /> |
| | | <el-table-column :show-overflow-tooltip="true" label="已分配 / 计划工时" width="120"> |
| | | <template slot-scope="scope"> |
| | | {{ scope.row.divideHours }} / {{ scope.row.planHours }} |
| | | </template> |
| | | </el-table-column> |
| | | <el-table-column :show-overflow-tooltip="true" label="已分配 / 计划工作量" width="130"> |
| | | <template slot-scope="scope"> |
| | | <span> |
| | | {{ 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> |
| | |
| | | </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:edit','task:del'])" label="操作" width="150px" align="center" fixed="right"> |
| | | <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" |
| | | /> |
| | | > |
| | | <el-button |
| | | slot="left" |
| | | v-permission="permission.divide" |
| | | size="mini" |
| | | type="primary" |
| | | icon="el-icon-share" |
| | | @click="toDivide(scope.row)" |
| | | /> |
| | | </udOperation> |
| | | </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;" /> |
| | | </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> |
| | |
| | | import pagination from '@crud/Pagination' |
| | | import constant from '../../../utils/constant' |
| | | import crudProject from '@/api/project/project' |
| | | import crudUser from '@/api/system/user' |
| | | |
| | | const defaultForm = { id: null, projectId: null, pid: null, name: null, priority: null, taskClassification: null, description: null, planStartTime: null, planEndTime: null, planHours: null, planWorkload: null, planWorkloadUnit: 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, description: null, planStartTime: null, planEndTime: null, planHours: null, planWorkload: null, planWorkloadUnit: null, remarks: null, createBy: null, createTime: null, updateBy: null, updateTime: null } |
| | | export default { |
| | | name: 'Task', |
| | | components: { pagination, crudOperation, rrOperation, udOperation }, |
| | |
| | | add: ['admin', 'task:add'], |
| | | edit: ['admin', 'task:edit'], |
| | | del: ['admin', 'task:del'], |
| | | download: ['admin', 'task:download'] |
| | | download: ['admin', 'task:download'], |
| | | divide: ['admin', 'task:divide'] |
| | | }, |
| | | rules: { |
| | | projectId: [ |
| | | { required: true, message: '所属项目不能为空', trigger: 'change' } |
| | | ], |
| | | name: [ |
| | | { required: true, message: '名称不能为空', trigger: 'blur' }, |
| | | { max: 100, message: '最大长度 100 个字符', trigger: 'blur' } |
| | | ], |
| | | projectId: [ |
| | | { required: true, message: '所属项目不能为空', trigger: 'change' } |
| | | ], |
| | | priority: [ |
| | | { required: true, message: '优先度不能为空', trigger: 'change' } |
| | |
| | | ] |
| | | }, |
| | | queryTypeOptions: [ |
| | | { key: 'projectId', display_name: '所属项目' }, |
| | | { key: 'name', display_name: '名称' }, |
| | | { key: 'projectId', display_name: '所属项目' }, |
| | | { key: 'priority', display_name: '优先度' }, |
| | | { key: 'taskClassification', display_name: '任务分类' } |
| | | ], |
| | |
| | | // 项目列表 |
| | | projects: [], |
| | | // 父级任务列表 |
| | | pidTasks: [] |
| | | pidTasks: [], |
| | | // 分配表单状态 |
| | | divideStatus: false, |
| | | // 分配表单加载 |
| | | divideLoading: false, |
| | | // 分配表单数据 |
| | | divideForm: { projectId: null, projectName: null, taskId: null, taskname: null, userIds: [], divideUserIds: [], taskStartDate: null, taskEndDate: null, taskHours: null, taskWorkload: null, taskWorkloadUnit: 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() > _this.divideForm.taskEndDate.getTime() : false |
| | | } |
| | | }, |
| | | // 任务结束时间选项 |
| | | taskEndDatePickerOptions: { |
| | | // 禁用日期 |
| | | disabledDate(time) { |
| | | return _this.divideForm.taskStartDate != null && _this.divideForm.taskStartDate !== '' ? time.getTime() < _this.divideForm.taskStartDate.getTime() - (86400000 - 1) : false |
| | | } |
| | | }, |
| | | // 用户列表 |
| | | users: [] |
| | | } |
| | | }, |
| | | methods: { |
| | |
| | | [CRUD.HOOK.beforeRefresh]() { |
| | | // 获取项目 |
| | | this.getProject() |
| | | // 获取用户 |
| | | this.getUser() |
| | | return true |
| | | }, |
| | | // 获取项目 |
| | |
| | | crudProject.getAll({ approveStatus: constant.APPROVE_STATUS_ACKNOWLEDGED }).then(res => { |
| | | // 项目列表 |
| | | this.projects = res |
| | | }) |
| | | }, |
| | | // 获取用户 |
| | | getUser() { |
| | | // 获取用户 |
| | | crudUser.getAll().then(res => { |
| | | // 用户列表 |
| | | this.users = res |
| | | }) |
| | | }, |
| | | // 树形表数据加载 |
| | | load(tree, treeNode, resolve) { |
| | | // 获取子级任务 |
| | | crudTask.getChildren({ id: tree.id }).then(res => { |
| | | // 添加 |
| | | resolve(res) |
| | | }) |
| | | }, |
| | | // 钩子:新建 - 之前 |
| | |
| | | projectChange() { |
| | | // 表单赋值 |
| | | this.form.pid = null |
| | | // 父级任务列表 |
| | | this.pidTasks = [] |
| | | // 获取父级任务 |
| | | crudTask.getAll({ projectId: this.form.projectId }).then(res => { |
| | | // 判断表单项目是否为空 |
| | | if (this.form.projectId == null || this.form.projectId === '') { |
| | | // 父级任务列表 |
| | | this.pidTasks = res |
| | | this.pidTasks = [] |
| | | } else { |
| | | // 获取父级任务 |
| | | crudTask.getAll({ projectId: this.form.projectId }).then(res => { |
| | | // 父级任务列表 |
| | | this.pidTasks = res |
| | | }) |
| | | } |
| | | }, |
| | | // 任务分配 |
| | | 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 |
| | | }, |
| | | // 分配表单关闭 |
| | | 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, taskWorkloadUnit: null, taskStatus: null } |
| | | // 清除表单验证 |
| | | this.$nextTick(() => { |
| | | this.$refs['divideForm'].clearValidate() |
| | | }) |
| | | }, |
| | | // 树形表数据加载 |
| | | load(tree, treeNode, resolve) { |
| | | // 获取子级任务 |
| | | crudTask.getChildren({ id: tree.id }).then(res => { |
| | | // 添加 |
| | | resolve(res) |
| | | // 分配表单提交 |
| | | 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 |
| | | } |
| | | }) |
| | | } |
| | | } |
| New file |
| | |
| | | <template> |
| | | <div class="app-container"> |
| | | <!--工具栏--> |
| | | <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-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 projects" |
| | | :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> |
| | | <el-select v-model="query.taskStatus" filterable clearable placeholder="任务状态" style="width: 185px;" class="filter-item" @keyup.enter.native="crud.toQuery"> |
| | | <el-option |
| | | v-for="item in dict[taskStatus]" |
| | | :key="item.id" |
| | | :label="item.label" |
| | | :value="item.value" |
| | | /> |
| | | </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="userId"> |
| | | <el-select v-model="form.userId" filterable clearable placeholder="请选择" style="width: 340px;"> |
| | | <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;" @change="formProjectChange"> |
| | | <el-option |
| | | v-for="item in projects" |
| | | :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;"> |
| | | <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="taskStartDate"> |
| | | <el-date-picker v-model="form.taskStartDate" type="datetime" :picker-options="taskStartDatePickerOptions" :disabled="crud.status.edit == crudStatusPrepared" style="width: 340px;" /> |
| | | </el-form-item> |
| | | <el-form-item label="任务结束时间" prop="taskEndDate"> |
| | | <el-date-picker v-model="form.taskEndDate" type="datetime" :picker-options="taskEndDatePickerOptions" style="width: 340px;" /> |
| | | </el-form-item> |
| | | <el-form-item label="任务工时" prop="taskHours"> |
| | | <el-input v-model="form.taskHours" style="width: 340px;" /> |
| | | </el-form-item> |
| | | <el-form-item label="任务工作量" prop="taskWorkload"> |
| | | <el-input v-model="form.taskWorkload" style="width: 340px;" /> |
| | | </el-form-item> |
| | | <el-form-item label="任务工作量单位" prop="taskWorkloadUnit"> |
| | | <el-select v-model="form.taskWorkloadUnit" filterable placeholder="请选择" style="width: 340px;"> |
| | | <el-option |
| | | v-for="item in dict[standardWorkloadUnit]" |
| | | :key="item.id" |
| | | :label="item.label" |
| | | :value="item.value" |
| | | /> |
| | | </el-select> |
| | | </el-form-item> |
| | | <el-form-item label="任务状态" prop="taskStatus"> |
| | | <el-select v-model="form.taskStatus" filterable placeholder="请选择" style="width: 340px;"> |
| | | <el-option |
| | | v-for="item in dict[taskStatus]" |
| | | :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;" /> |
| | | </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> |
| | | <!--表格渲染--> |
| | | <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="userNickName" label="所属用户" fixed="left" width="100"> |
| | | <template slot-scope="scope"> |
| | | <el-tag>{{ scope.row.userNickName }}</el-tag> |
| | | </template> |
| | | </el-table-column> |
| | | <el-table-column :show-overflow-tooltip="true" prop="taskName" label="所属任务" fixed="left" width="180"> |
| | | <template slot-scope="scope"> |
| | | <el-tag>{{ scope.row.taskName }}</el-tag> |
| | | </template> |
| | | </el-table-column> |
| | | <el-table-column :show-overflow-tooltip="true" prop="projectName" label="所属项目" width="140"> |
| | | <template slot-scope="scope"> |
| | | <el-tag>{{ scope.row.projectName }}</el-tag> |
| | | </template> |
| | | </el-table-column> |
| | | <el-table-column :show-overflow-tooltip="true" prop="taskStartDate" label="任务开始时间" width="140" /> |
| | | <el-table-column :show-overflow-tooltip="true" prop="taskEndDate" label="任务结束时间" width="140" /> |
| | | <el-table-column :show-overflow-tooltip="true" prop="taskHours" label="任务工时" width="80" /> |
| | | <el-table-column :show-overflow-tooltip="true" prop="taskWorkload" label="任务工作量" width="80" /> |
| | | <el-table-column :show-overflow-tooltip="true" prop="taskWorkloadUnit" label="任务工作量单位" width="110"> |
| | | <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="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','taskUser:edit','taskUser:del'])" label="操作" width="150px" align="center" fixed="right"> |
| | | <template slot-scope="scope"> |
| | | <udOperation |
| | | :data="scope.row" |
| | | :permission="permission" |
| | | /> |
| | | </template> |
| | | </el-table-column> |
| | | </el-table> |
| | | <!--分页组件--> |
| | | <pagination /> |
| | | </div> |
| | | </div> |
| | | </template> |
| | | |
| | | <script> |
| | | 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 udOperation from '@crud/UD.operation' |
| | | import pagination from '@crud/Pagination' |
| | | import constant from '../../../utils/constant' |
| | | import crudProject from '@/api/project/project' |
| | | import crudTask from '@/api/task/task' |
| | | import crudUser from '@/api/system/user' |
| | | |
| | | const defaultForm = { id: null, userId: null, projectId: null, taskId: null, taskStartDate: null, taskEndDate: null, taskHours: null, taskWorkload: null, taskWorkloadUnit: null, taskStatus: null, remarks: null, createBy: null, createTime: null, updateBy: null, updateTime: null } |
| | | export default { |
| | | name: 'TaskUser', |
| | | components: { pagination, crudOperation, rrOperation, udOperation }, |
| | | mixins: [presenter(), header(), form(defaultForm), crud()], |
| | | dicts: [constant.TASK_STATUS, constant.STANDARD_WORKLOAD_UNIT], |
| | | cruds() { |
| | | return CRUD({ title: '任务分配', url: 'api/taskUser', idField: 'id', sort: 'id,desc', crudMethod: { ...crudTaskUser }}) |
| | | }, |
| | | data() { |
| | | // 指针重指向 |
| | | const _this = this |
| | | // 时长(千内)验证 |
| | | var durationValidate = (rule, value, callback) => { |
| | | const reg = /^([0-9]|[1-9]\d{1,2})(\.\d{1,2})?$|1000$/ |
| | | if (value != null && value !== '' && !reg.test(value)) { |
| | | callback(new Error('请输入 一千 以内的正整数或两位小数')) |
| | | } else { |
| | | callback() |
| | | } |
| | | } |
| | | return { |
| | | permission: { |
| | | add: ['admin', 'taskUser:add'], |
| | | edit: ['admin', 'taskUser:edit'], |
| | | del: ['admin', 'taskUser:del'], |
| | | download: ['admin', 'taskUser:download'] |
| | | }, |
| | | rules: { |
| | | userId: [ |
| | | { required: true, message: '所属用户不能为空', trigger: 'change' } |
| | | ], |
| | | projectId: [ |
| | | { required: true, message: '所属项目不能为空', trigger: 'change' } |
| | | ], |
| | | taskId: [ |
| | | { 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' } |
| | | ], |
| | | taskStatus: [ |
| | | { required: true, message: '任务状态不能为空', trigger: 'change' } |
| | | ] |
| | | }, |
| | | queryTypeOptions: [ |
| | | { key: 'userId', display_name: '所属用户' }, |
| | | { key: 'projectId', display_name: '所属项目' }, |
| | | { key: 'taskId', display_name: '所属任务' }, |
| | | { key: 'taskStatus', display_name: '任务状态' } |
| | | ], |
| | | // 任务开始时间选项 |
| | | taskStartDatePickerOptions: { |
| | | // 禁用日期 |
| | | disabledDate(time) { |
| | | return _this.form.taskEndDate != null && _this.form.taskEndDate !== '' ? time.getTime() > _this.form.taskEndDate : false |
| | | } |
| | | }, |
| | | // 任务结束时间选项 |
| | | taskEndDatePickerOptions: { |
| | | // 禁用日期 |
| | | disabledDate(time) { |
| | | return _this.form.taskStartDate != null && _this.form.taskStartDate !== '' ? time.getTime() < _this.form.taskStartDate - (86400000 - 1) : false |
| | | } |
| | | }, |
| | | // 字典:任务状态 |
| | | taskStatus: constant.TASK_STATUS, |
| | | // 字典:标准工作量单位 |
| | | standardWorkloadUnit: constant.STANDARD_WORKLOAD_UNIT, |
| | | // CRUD状态 |
| | | crudStatusPrepared: CRUD.STATUS.PREPARED, |
| | | // 项目列表 |
| | | projects: [], |
| | | // 检索任务列表 |
| | | queryTasks: [], |
| | | // 表单任务列表 |
| | | formTasks: [], |
| | | // 用户列表 |
| | | users: [] |
| | | } |
| | | }, |
| | | methods: { |
| | | // 钩子:在获取表格数据之前执行,false 则代表不获取数据 |
| | | [CRUD.HOOK.beforeRefresh]() { |
| | | // 获取项目 |
| | | this.getProject() |
| | | // 获取用户 |
| | | this.getUser() |
| | | return true |
| | | }, |
| | | // 获取项目 |
| | | getProject() { |
| | | // 获取项目 |
| | | crudProject.getAll({ approveStatus: constant.APPROVE_STATUS_ACKNOWLEDGED }).then(res => { |
| | | // 项目列表 |
| | | this.projects = res |
| | | }) |
| | | }, |
| | | // 获取用户 |
| | | getUser() { |
| | | // 获取用户 |
| | | crudUser.getAll().then(res => { |
| | | // 用户列表 |
| | | this.users = 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 |
| | | }) |
| | | } |
| | | }, |
| | | // 表单项目变更 |
| | | formProjectChange() { |
| | | // 表单赋值 |
| | | this.form.taskId = null |
| | | // 判断表单项目是否为空 |
| | | if (this.form.projectId == null || this.form.projectId === '') { |
| | | // 表单任务列表 |
| | | this.formTasks = [] |
| | | } else { |
| | | // 获取父级任务 |
| | | crudTask.getAll({ projectId: this.form.projectId }).then(res => { |
| | | // 表单任务列表 |
| | | this.formTasks = res |
| | | }) |
| | | } |
| | | } |
| | | } |
| | | } |
| | | </script> |
| | | |
| | | <style scoped> |
| | | |
| | | </style> |