feat(task): 增加解除任务关联功能

支持用户在任务详情中解除误关联的任务,权限与修改任务一致(项目负责人、任务负责人、任务协助人)。

- 新增 ProjectTaskRelation::deleteRelation() 删除双向关联并推送 WebSocket
- 新增 API POST /api/project/task/related/delete 接口
- 前端关联任务列表 hover 显示删除按钮,点击确认后解除关联

Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
kuaifan
2026-03-09 06:38:13 +00:00
parent 4068966700
commit 04708cedb6
5 changed files with 128 additions and 0 deletions

View File

@@ -1987,6 +1987,44 @@ class ProjectController extends AbstractController
]);
}
/**
* @api {post} api/project/task/related/delete 删除任务关联
*
* @apiDescription 需要token身份项目、任务负责人
* @apiVersion 1.0.0
* @apiGroup project
* @apiName task__related__delete
*
* @apiParam {Number} task_id 任务ID
* @apiParam {Number} related_task_id 关联任务ID
*
* @apiSuccess {Number} ret 返回状态码1正确、0错误
* @apiSuccess {String} msg 返回信息(错误描述)
* @apiSuccess {Object} data 返回数据
*/
public function task__related__delete()
{
User::auth();
//
$task_id = intval(Request::input('task_id'));
$related_task_id = intval(Request::input('related_task_id'));
if ($task_id <= 0 || $related_task_id <= 0) {
return Base::retError('参数错误');
}
//
$task = ProjectTask::userTask($task_id);
//
$project = Project::userProject($task->project_id);
ProjectPermission::userTaskPermission($project, ProjectPermission::TASK_UPDATE, $task);
//
$success = ProjectTaskRelation::deleteRelation($task_id, $related_task_id);
if (!$success) {
return Base::retError('关联不存在');
}
//
return Base::retSuccess('操作成功');
}
/**
* @api {get} api/project/task/content 获取任务详细描述
*