fix: 其他人员添加任务会临时出现在自己的列表中
This commit is contained in:
parent
674c5a11c1
commit
9d9500ba1b
@ -1134,10 +1134,11 @@ class ProjectController extends AbstractController
|
|||||||
'project_id' => $project->id,
|
'project_id' => $project->id,
|
||||||
'column_id' => $column->id,
|
'column_id' => $column->id,
|
||||||
]));
|
]));
|
||||||
$data = [
|
$data = ProjectTask::oneTask($task->id);
|
||||||
'new_column' => $newColumn,
|
if ($newColumn) {
|
||||||
'task' => ProjectTask::oneTask($task->id),
|
$data = $data->toArray();
|
||||||
];
|
$data['new_column'] = $newColumn;
|
||||||
|
}
|
||||||
$task->pushMsg('add', $data);
|
$task->pushMsg('add', $data);
|
||||||
return Base::retSuccess('添加成功', $data);
|
return Base::retSuccess('添加成功', $data);
|
||||||
}
|
}
|
||||||
@ -1174,10 +1175,7 @@ class ProjectController extends AbstractController
|
|||||||
'times' => [$task->start_at, $task->end_at],
|
'times' => [$task->start_at, $task->end_at],
|
||||||
'owner' => [User::userid()]
|
'owner' => [User::userid()]
|
||||||
]);
|
]);
|
||||||
$data = [
|
$data = ProjectTask::oneTask($task->id);
|
||||||
'new_column' => null,
|
|
||||||
'task' => ProjectTask::oneTask($task->id),
|
|
||||||
];
|
|
||||||
$task->pushMsg('add', $data);
|
$task->pushMsg('add', $data);
|
||||||
return Base::retSuccess('添加成功', $data);
|
return Base::retSuccess('添加成功', $data);
|
||||||
}
|
}
|
||||||
|
@ -304,28 +304,45 @@ class Project extends AbstractModel
|
|||||||
/**
|
/**
|
||||||
* 推送消息
|
* 推送消息
|
||||||
* @param string $action
|
* @param string $action
|
||||||
* @param array $data 发送内容,默认为[id=>项目ID]
|
* @param array|self $data 发送内容,默认为[id=>项目ID]
|
||||||
* @param array $userid 指定会员,默认为项目所有成员
|
* @param array $userid 指定会员,默认为项目所有成员
|
||||||
*/
|
*/
|
||||||
public function pushMsg($action, $data = null, $userid = null)
|
public function pushMsg($action, $data = null, $userid = null)
|
||||||
{
|
{
|
||||||
if ($data === null) {
|
if ($data === null) {
|
||||||
$data = ['id' => $this->id];
|
$data = ['id' => $this->id];
|
||||||
|
} elseif ($data instanceof self) {
|
||||||
|
$data = $data->toArray();
|
||||||
}
|
}
|
||||||
|
//
|
||||||
|
$array = [$userid, []];
|
||||||
if ($userid === null) {
|
if ($userid === null) {
|
||||||
$userid = $this->relationUserids();
|
$array[0] = $this->relationUserids();
|
||||||
|
} elseif (!is_array($userid)) {
|
||||||
|
$array[0] = [$userid];
|
||||||
|
}
|
||||||
|
//
|
||||||
|
if (isset($data['owner'])) {
|
||||||
|
$owners = ProjectUser::whereProjectId($data['id'])->whereOwner(1)->pluck('userid')->toArray();
|
||||||
|
$array = [array_intersect($array[0], $owners), array_diff($array[0], $owners)];
|
||||||
|
}
|
||||||
|
//
|
||||||
|
foreach ($array as $index => $item) {
|
||||||
|
if ($index > 0) {
|
||||||
|
$data['owner'] = 0;
|
||||||
|
}
|
||||||
|
$params = [
|
||||||
|
'ignoreFd' => Request::header('fd'),
|
||||||
|
'userid' => array_values($item),
|
||||||
|
'msg' => [
|
||||||
|
'type' => 'project',
|
||||||
|
'action' => $action,
|
||||||
|
'data' => $data,
|
||||||
|
]
|
||||||
|
];
|
||||||
|
$task = new PushTask($params, false);
|
||||||
|
Task::deliver($task);
|
||||||
}
|
}
|
||||||
$params = [
|
|
||||||
'ignoreFd' => Request::header('fd'),
|
|
||||||
'userid' => $userid,
|
|
||||||
'msg' => [
|
|
||||||
'type' => 'project',
|
|
||||||
'action' => $action,
|
|
||||||
'data' => $data,
|
|
||||||
]
|
|
||||||
];
|
|
||||||
$task = new PushTask($params, false);
|
|
||||||
Task::deliver($task);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -799,10 +799,7 @@ class ProjectTask extends AbstractModel
|
|||||||
$this->archived_userid = User::userid();
|
$this->archived_userid = User::userid();
|
||||||
$this->archived_follow = 0;
|
$this->archived_follow = 0;
|
||||||
$this->addLog("任务取消归档:" . $this->name);
|
$this->addLog("任务取消归档:" . $this->name);
|
||||||
$this->pushMsg('add', [
|
$this->pushMsg('add', ProjectTask::oneTask($this->id));
|
||||||
'new_column' => null,
|
|
||||||
'task' => ProjectTask::oneTask($this->id),
|
|
||||||
]);
|
|
||||||
} else {
|
} else {
|
||||||
// 归档任务
|
// 归档任务
|
||||||
if ($isAuto === true) {
|
if ($isAuto === true) {
|
||||||
@ -873,8 +870,8 @@ class ProjectTask extends AbstractModel
|
|||||||
/**
|
/**
|
||||||
* 推送消息
|
* 推送消息
|
||||||
* @param string $action
|
* @param string $action
|
||||||
* @param array $data 发送内容,默认为[id, parent_id, project_id, column_id, dialog_id]
|
* @param array|self $data 发送内容,默认为[id, parent_id, project_id, column_id, dialog_id]
|
||||||
* @param array $userid 指定会员,默认为项目所有成员
|
* @param array $userid 指定会员,默认为项目所有成员
|
||||||
*/
|
*/
|
||||||
public function pushMsg($action, $data = null, $userid = null)
|
public function pushMsg($action, $data = null, $userid = null)
|
||||||
{
|
{
|
||||||
@ -889,21 +886,37 @@ class ProjectTask extends AbstractModel
|
|||||||
'column_id' => $this->column_id,
|
'column_id' => $this->column_id,
|
||||||
'dialog_id' => $this->dialog_id,
|
'dialog_id' => $this->dialog_id,
|
||||||
];
|
];
|
||||||
|
} elseif ($data instanceof self) {
|
||||||
|
$data = $data->toArray();
|
||||||
}
|
}
|
||||||
|
//
|
||||||
|
$array = [$userid, []];
|
||||||
if ($userid === null) {
|
if ($userid === null) {
|
||||||
$userid = $this->project->relationUserids();
|
$array[0] = $this->project->relationUserids();
|
||||||
|
} elseif (!is_array($userid)) {
|
||||||
|
$array[0] = [$userid];
|
||||||
|
}
|
||||||
|
//
|
||||||
|
if (isset($data['owner'])) {
|
||||||
|
$owners = ProjectTaskUser::whereTaskId($data['id'])->whereOwner(1)->pluck('userid')->toArray();
|
||||||
|
$array = [array_intersect($array[0], $owners), array_diff($array[0], $owners)];
|
||||||
|
}
|
||||||
|
foreach ($array as $index => $item) {
|
||||||
|
if ($index > 0) {
|
||||||
|
$data['owner'] = 0;
|
||||||
|
}
|
||||||
|
$params = [
|
||||||
|
'ignoreFd' => Request::header('fd'),
|
||||||
|
'userid' => array_values($item),
|
||||||
|
'msg' => [
|
||||||
|
'type' => 'projectTask',
|
||||||
|
'action' => $action,
|
||||||
|
'data' => $data,
|
||||||
|
]
|
||||||
|
];
|
||||||
|
$task = new PushTask($params, false);
|
||||||
|
Task::deliver($task);
|
||||||
}
|
}
|
||||||
$params = [
|
|
||||||
'ignoreFd' => Request::header('fd'),
|
|
||||||
'userid' => $userid,
|
|
||||||
'msg' => [
|
|
||||||
'type' => 'projectTask',
|
|
||||||
'action' => $action,
|
|
||||||
'data' => $data,
|
|
||||||
]
|
|
||||||
];
|
|
||||||
$task = new PushTask($params, false);
|
|
||||||
Task::deliver($task);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
16
resources/assets/js/store/actions.js
vendored
16
resources/assets/js/store/actions.js
vendored
@ -1353,19 +1353,15 @@ export default {
|
|||||||
/**
|
/**
|
||||||
* 添加任务成功
|
* 添加任务成功
|
||||||
* @param dispatch
|
* @param dispatch
|
||||||
* @param data
|
* @param task
|
||||||
*/
|
*/
|
||||||
addTaskSuccess({dispatch}, data) {
|
addTaskSuccess({dispatch}, task) {
|
||||||
const {new_column, task} = data;
|
if (typeof task.new_column !== "undefined") {
|
||||||
if (new_column) {
|
dispatch("saveColumn", task.new_column)
|
||||||
dispatch("saveColumn", new_column)
|
delete task.new_column
|
||||||
}
|
}
|
||||||
dispatch("saveTask", task)
|
dispatch("saveTask", task)
|
||||||
if (task.parent_id) {
|
dispatch("getProjectOne", task.project_id);
|
||||||
dispatch("getTaskOne", task.parent_id);
|
|
||||||
} else {
|
|
||||||
dispatch("getProjectOne", task.project_id);
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
Loading…
x
Reference in New Issue
Block a user