mirror of
https://github.com/kuaifan/dootask.git
synced 2025-12-15 13:22:49 +00:00
fix: 修复修改删除标签未同步任务标签的问题
This commit is contained in:
parent
a15b29122e
commit
325dc5e2fe
@ -29,6 +29,7 @@ use App\Models\ProjectColumn;
|
|||||||
use App\Models\ProjectInvite;
|
use App\Models\ProjectInvite;
|
||||||
use App\Models\ProjectFlowItem;
|
use App\Models\ProjectFlowItem;
|
||||||
use App\Models\ProjectTaskFile;
|
use App\Models\ProjectTaskFile;
|
||||||
|
use App\Models\ProjectTaskTag;
|
||||||
use App\Models\ProjectTaskUser;
|
use App\Models\ProjectTaskUser;
|
||||||
use App\Models\WebSocketDialog;
|
use App\Models\WebSocketDialog;
|
||||||
use App\Exceptions\ApiException;
|
use App\Exceptions\ApiException;
|
||||||
@ -2991,7 +2992,7 @@ class ProjectController extends AbstractController
|
|||||||
/**
|
/**
|
||||||
* @api {post} api/project/tag/save 51. 保存标签
|
* @api {post} api/project/tag/save 51. 保存标签
|
||||||
*
|
*
|
||||||
* @apiDescription 需要token身份(修改:项目负责人;添加:项目所有成员)
|
* @apiDescription 需要token身份(修改:项目负责人、标签创建者;添加:项目所有成员)
|
||||||
* @apiVersion 1.0.0
|
* @apiVersion 1.0.0
|
||||||
* @apiGroup project
|
* @apiGroup project
|
||||||
* @apiName tag__save
|
* @apiName tag__save
|
||||||
@ -3043,12 +3044,36 @@ class ProjectController extends AbstractController
|
|||||||
if (!$tag) {
|
if (!$tag) {
|
||||||
return Base::retError('标签不存在或已被删除');
|
return Base::retError('标签不存在或已被删除');
|
||||||
}
|
}
|
||||||
$tag->update($data);
|
AbstractModel::transaction(function () use ($data, $tag) {
|
||||||
|
$tagWhere = [
|
||||||
|
'project_id' => $tag->project_id,
|
||||||
|
'name' => $tag->name,
|
||||||
|
];
|
||||||
|
// 获取使用该标签的任务ID
|
||||||
|
$taskIds = ProjectTaskTag::where($tagWhere)->pluck('task_id')->toArray();
|
||||||
|
// 更新任务
|
||||||
|
if (!empty($taskIds)) {
|
||||||
|
ProjectTask::whereIn('id', $taskIds)->update(['updated_at' => Carbon::now()]);
|
||||||
|
}
|
||||||
|
// 更新任务标签
|
||||||
|
ProjectTaskTag::where($tagWhere)->update([
|
||||||
|
'color' => $data['color'],
|
||||||
|
'name' => $data['name'],
|
||||||
|
]);
|
||||||
|
// 更新标签
|
||||||
|
$tag->update($data);
|
||||||
|
});
|
||||||
} else {
|
} else {
|
||||||
$tagCount = ProjectTag::where('project_id', $projectId)->count();
|
$tagCount = ProjectTag::where('project_id', $projectId)->count();
|
||||||
if ($tagCount >= 100) {
|
if ($tagCount >= 100) {
|
||||||
return Base::retError('每个项目最多添加100个标签');
|
return Base::retError('每个项目最多添加100个标签');
|
||||||
}
|
}
|
||||||
|
if (ProjectTag::where([
|
||||||
|
'project_id' => $projectId,
|
||||||
|
'name' => $name,
|
||||||
|
])->exists()) {
|
||||||
|
return Base::retError('标签已存在');
|
||||||
|
}
|
||||||
$tag = ProjectTag::create($data);
|
$tag = ProjectTag::create($data);
|
||||||
$project->addLog("添加标签【" . $tag->name . "】");
|
$project->addLog("添加标签【" . $tag->name . "】");
|
||||||
}
|
}
|
||||||
@ -3058,7 +3083,7 @@ class ProjectController extends AbstractController
|
|||||||
/**
|
/**
|
||||||
* @api {get} api/project/tag/delete 52. 删除标签
|
* @api {get} api/project/tag/delete 52. 删除标签
|
||||||
*
|
*
|
||||||
* @apiDescription 需要token身份(限:项目负责人)
|
* @apiDescription 需要token身份(限:项目负责人、标签创建者)
|
||||||
* @apiVersion 1.0.0
|
* @apiVersion 1.0.0
|
||||||
* @apiGroup project
|
* @apiGroup project
|
||||||
* @apiName tag__delete
|
* @apiName tag__delete
|
||||||
@ -3071,7 +3096,7 @@ class ProjectController extends AbstractController
|
|||||||
*/
|
*/
|
||||||
public function tag__delete()
|
public function tag__delete()
|
||||||
{
|
{
|
||||||
User::auth();
|
$user = User::auth();
|
||||||
//
|
//
|
||||||
$id = intval(Request::input('id'));
|
$id = intval(Request::input('id'));
|
||||||
if (!$id) {
|
if (!$id) {
|
||||||
@ -3081,9 +3106,28 @@ class ProjectController extends AbstractController
|
|||||||
if (!$tag) {
|
if (!$tag) {
|
||||||
return Base::retError('标签不存在或已被删除');
|
return Base::retError('标签不存在或已被删除');
|
||||||
}
|
}
|
||||||
Project::userProject($tag->project_id, true, true);
|
$project = Project::userProject($tag->project_id);
|
||||||
$tag->delete();
|
if (!$project->owner && $tag->userid != $user->userid) {
|
||||||
return Base::retSuccess('删除成功');
|
return Base::retError('没有权限删除标签');
|
||||||
|
}
|
||||||
|
//
|
||||||
|
return AbstractModel::transaction(function () use ($tag) {
|
||||||
|
$tagWhere = [
|
||||||
|
'project_id' => $tag->project_id,
|
||||||
|
'name' => $tag->name,
|
||||||
|
];
|
||||||
|
// 获取使用该标签的任务ID
|
||||||
|
$taskIds = ProjectTaskTag::where($tagWhere)->pluck('task_id')->toArray();
|
||||||
|
// 更新任务
|
||||||
|
if (!empty($taskIds)) {
|
||||||
|
ProjectTask::whereIn('id', $taskIds)->update(['updated_at' => Carbon::now()]);
|
||||||
|
}
|
||||||
|
// 删除任务标签
|
||||||
|
ProjectTaskTag::where($tagWhere)->delete();
|
||||||
|
// 删除标签
|
||||||
|
$tag->delete();
|
||||||
|
return Base::retSuccess('删除成功');
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@ -515,6 +515,7 @@
|
|||||||
<DrawerOverlay
|
<DrawerOverlay
|
||||||
v-model="taskTagShow"
|
v-model="taskTagShow"
|
||||||
placement="right"
|
placement="right"
|
||||||
|
:beforeClose="taskTagBeforeClose"
|
||||||
:size="720">
|
:size="720">
|
||||||
<ProjectTaskTag ref="taskTag" v-if="taskTagShow" :project-id="projectId"/>
|
<ProjectTaskTag ref="taskTag" v-if="taskTagShow" :project-id="projectId"/>
|
||||||
</DrawerOverlay>
|
</DrawerOverlay>
|
||||||
@ -1607,6 +1608,10 @@ export default {
|
|||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
|
async taskTagBeforeClose() {
|
||||||
|
this.$store.dispatch("getTaskForProject", this.projectId).catch(() => {})
|
||||||
|
},
|
||||||
|
|
||||||
workflowBeforeClose() {
|
workflowBeforeClose() {
|
||||||
return new Promise(resolve => {
|
return new Promise(resolve => {
|
||||||
if (!this.$refs.workflow) {
|
if (!this.$refs.workflow) {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user