mirror of
https://github.com/kuaifan/dootask.git
synced 2025-12-12 11:19:56 +00:00
feat: 优化任务可见性推送逻辑
This commit is contained in:
parent
81c019105c
commit
0666a8f5c2
@ -1991,7 +1991,9 @@ class ProjectController extends AbstractController
|
|||||||
'path' => $file->getRawOriginal('path'),
|
'path' => $file->getRawOriginal('path'),
|
||||||
'thumb' => $file->getRawOriginal('thumb'),
|
'thumb' => $file->getRawOriginal('thumb'),
|
||||||
]);
|
]);
|
||||||
$task->pushMsg('filedelete', $file);
|
$task->pushMsg('filedelete', [
|
||||||
|
'id' => $file->id,
|
||||||
|
]);
|
||||||
$file->delete();
|
$file->delete();
|
||||||
//
|
//
|
||||||
return Base::retSuccess('success', $file);
|
return Base::retSuccess('success', $file);
|
||||||
@ -2840,7 +2842,7 @@ class ProjectController extends AbstractController
|
|||||||
* @apiVersion 1.0.0
|
* @apiVersion 1.0.0
|
||||||
* @apiGroup project
|
* @apiGroup project
|
||||||
* @apiName task__ai_generate
|
* @apiName task__ai_generate
|
||||||
*
|
*
|
||||||
* @apiParam {String} content 用户输入的任务描述(必填)
|
* @apiParam {String} content 用户输入的任务描述(必填)
|
||||||
* @apiParam {String} [current_title] 当前已有的任务标题(用于优化改进)
|
* @apiParam {String} [current_title] 当前已有的任务标题(用于优化改进)
|
||||||
* @apiParam {String} [current_content] 当前已有的任务内容(HTML格式,用于优化改进)
|
* @apiParam {String} [current_content] 当前已有的任务内容(HTML格式,用于优化改进)
|
||||||
@ -2860,13 +2862,13 @@ class ProjectController extends AbstractController
|
|||||||
public function task__ai_generate()
|
public function task__ai_generate()
|
||||||
{
|
{
|
||||||
User::auth();
|
User::auth();
|
||||||
|
|
||||||
// 获取用户输入的任务描述
|
// 获取用户输入的任务描述
|
||||||
$content = Request::input('content');
|
$content = Request::input('content');
|
||||||
if (empty($content)) {
|
if (empty($content)) {
|
||||||
return Base::retError('任务描述不能为空');
|
return Base::retError('任务描述不能为空');
|
||||||
}
|
}
|
||||||
|
|
||||||
// 获取上下文信息
|
// 获取上下文信息
|
||||||
$context = [
|
$context = [
|
||||||
'current_title' => Request::input('current_title', ''),
|
'current_title' => Request::input('current_title', ''),
|
||||||
@ -2877,7 +2879,7 @@ class ProjectController extends AbstractController
|
|||||||
'has_time_plan' => boolval(Request::input('has_time_plan', false)),
|
'has_time_plan' => boolval(Request::input('has_time_plan', false)),
|
||||||
'priority_level' => Request::input('priority_level', ''),
|
'priority_level' => Request::input('priority_level', ''),
|
||||||
];
|
];
|
||||||
|
|
||||||
// 如果当前内容是HTML格式,转换为markdown
|
// 如果当前内容是HTML格式,转换为markdown
|
||||||
if (!empty($context['current_content'])) {
|
if (!empty($context['current_content'])) {
|
||||||
$context['current_content'] = Base::html2markdown($context['current_content']);
|
$context['current_content'] = Base::html2markdown($context['current_content']);
|
||||||
@ -2885,7 +2887,7 @@ class ProjectController extends AbstractController
|
|||||||
if (!empty($context['template_content'])) {
|
if (!empty($context['template_content'])) {
|
||||||
$context['template_content'] = Base::html2markdown($context['template_content']);
|
$context['template_content'] = Base::html2markdown($context['template_content']);
|
||||||
}
|
}
|
||||||
|
|
||||||
$result = AI::generateTask($content, $context);
|
$result = AI::generateTask($content, $context);
|
||||||
if (Base::isError($result)) {
|
if (Base::isError($result)) {
|
||||||
return Base::retError('生成任务失败', $result);
|
return Base::retError('生成任务失败', $result);
|
||||||
|
|||||||
@ -1579,7 +1579,8 @@ class ProjectTask extends AbstractModel
|
|||||||
} elseif ($data instanceof self) {
|
} elseif ($data instanceof self) {
|
||||||
$data = $data->toArray();
|
$data = $data->toArray();
|
||||||
}
|
}
|
||||||
//
|
|
||||||
|
// 获取接收会员
|
||||||
if ($userid === null) {
|
if ($userid === null) {
|
||||||
$userids = $this->project->relationUserids();
|
$userids = $this->project->relationUserids();
|
||||||
} else {
|
} else {
|
||||||
@ -1590,11 +1591,7 @@ class ProjectTask extends AbstractModel
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!Arr::exists($data, 'visibility')) {
|
// 按可见性分组推送
|
||||||
$data['visibility'] = $this->visibility;
|
|
||||||
}
|
|
||||||
|
|
||||||
$visibility = intval($data['visibility']);
|
|
||||||
$taskUser = ProjectTaskUser::select(['userid', 'owner'])->whereTaskId($data['id'])->get();
|
$taskUser = ProjectTaskUser::select(['userid', 'owner'])->whereTaskId($data['id'])->get();
|
||||||
$ownerList = $taskUser->where('owner', 1)->pluck('userid')->toArray();
|
$ownerList = $taskUser->where('owner', 1)->pluck('userid')->toArray();
|
||||||
$assistList = $taskUser->where('owner', 0)->pluck('userid')->toArray();
|
$assistList = $taskUser->where('owner', 0)->pluck('userid')->toArray();
|
||||||
@ -1603,16 +1600,19 @@ class ProjectTask extends AbstractModel
|
|||||||
$assistUsers = array_values(array_diff(array_intersect($userids, $assistList), $ownerUsers));
|
$assistUsers = array_values(array_diff(array_intersect($userids, $assistList), $ownerUsers));
|
||||||
|
|
||||||
$array = [];
|
$array = [];
|
||||||
|
|
||||||
|
// 负责人
|
||||||
if ($ownerUsers) {
|
if ($ownerUsers) {
|
||||||
$array[] = [
|
$array[] = [
|
||||||
'userid' => $ownerUsers,
|
'userid' => $ownerUsers,
|
||||||
'data' => array_merge($data, [
|
'data' => array_merge($data, [
|
||||||
'owner' => 1,
|
'owner' => 1,
|
||||||
'assist' => 1,
|
'assist' => 0,
|
||||||
])
|
])
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 协助人
|
||||||
if ($assistUsers) {
|
if ($assistUsers) {
|
||||||
$array[] = [
|
$array[] = [
|
||||||
'userid' => $assistUsers,
|
'userid' => $assistUsers,
|
||||||
@ -1623,27 +1623,31 @@ class ProjectTask extends AbstractModel
|
|||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 其他人
|
||||||
$otherUsers = [];
|
$otherUsers = [];
|
||||||
switch ($visibility) {
|
switch (intval($data['visibility'])) {
|
||||||
case 1:
|
case 1:
|
||||||
|
// 项目人员:除了负责人、协助人项目其他人
|
||||||
$otherUsers = array_diff($userids, $ownerUsers, $assistUsers);
|
$otherUsers = array_diff($userids, $ownerUsers, $assistUsers);
|
||||||
break;
|
break;
|
||||||
case 2:
|
case 2:
|
||||||
$otherUsers = [];
|
// 任务人员:除了负责人、协助人
|
||||||
|
// $otherUsers = [];
|
||||||
break;
|
break;
|
||||||
case 3:
|
case 3:
|
||||||
|
// 指定成员
|
||||||
$specifys = ProjectTaskVisibilityUser::select(['userid'])->whereTaskId($data['id'])->pluck('userid')->toArray();
|
$specifys = ProjectTaskVisibilityUser::select(['userid'])->whereTaskId($data['id'])->pluck('userid')->toArray();
|
||||||
$otherUsers = array_diff(array_intersect($userids, $specifys), $ownerUsers, $assistUsers);
|
$otherUsers = array_diff(array_intersect($userids, $specifys), $ownerUsers, $assistUsers);
|
||||||
break;
|
break;
|
||||||
default:
|
|
||||||
$otherUsers = array_diff($userids, $ownerUsers, $assistUsers);
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($otherUsers) {
|
if ($otherUsers) {
|
||||||
$array[] = [
|
$array[] = [
|
||||||
'userid' => array_values($otherUsers),
|
'userid' => array_values($otherUsers),
|
||||||
'data' => $data
|
'data' => array_merge($data, [
|
||||||
|
'owner' => 0,
|
||||||
|
'assist' => 0,
|
||||||
|
])
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1651,6 +1655,7 @@ class ProjectTask extends AbstractModel
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 推送
|
||||||
foreach ($array as $item) {
|
foreach ($array as $item) {
|
||||||
$params = [
|
$params = [
|
||||||
'ignoreFd' => $ignoreSelf ? Request::header('fd') : null,
|
'ignoreFd' => $ignoreSelf ? Request::header('fd') : null,
|
||||||
|
|||||||
8
resources/assets/js/store/actions.js
vendored
8
resources/assets/js/store/actions.js
vendored
@ -4609,11 +4609,6 @@ export default {
|
|||||||
case 'recovery': // 恢复(归档)
|
case 'recovery': // 恢复(归档)
|
||||||
dispatch("saveTask", data)
|
dispatch("saveTask", data)
|
||||||
break;
|
break;
|
||||||
case 'relation':
|
|
||||||
if (data?.id) {
|
|
||||||
emitter.emit('taskRelationUpdate', data.id)
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case 'dialog':
|
case 'dialog':
|
||||||
dispatch("saveTask", data)
|
dispatch("saveTask", data)
|
||||||
dispatch("getDialogOne", data.dialog_id).catch(() => {})
|
dispatch("getDialogOne", data.dialog_id).catch(() => {})
|
||||||
@ -4627,6 +4622,9 @@ export default {
|
|||||||
case 'delete':
|
case 'delete':
|
||||||
dispatch("forgetTask", data)
|
dispatch("forgetTask", data)
|
||||||
break;
|
break;
|
||||||
|
case 'relation':
|
||||||
|
emitter.emit('taskRelationUpdate', data.id)
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
})(msgDetail);
|
})(msgDetail);
|
||||||
break;
|
break;
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user