Skip to content

Commit

Permalink
feat: 修复移动任务中选完成进行移动没有设置完成时间的bug
Browse files Browse the repository at this point in the history
  • Loading branch information
weifashi committed Apr 29, 2024
1 parent 2bd8199 commit d7d8ee4
Showing 1 changed file with 18 additions and 11 deletions.
29 changes: 18 additions & 11 deletions app/Models/ProjectTask.php
Original file line number Diff line number Diff line change
Expand Up @@ -1717,41 +1717,48 @@ public function taskPush($userids, int $type, string $suffix = "")
*/
public function moveTask(int $projectId, int $columnId,int $flowItemId = 0,array $owner = [], array $assist = [])
{
AbstractModel::transaction(function () use($projectId, $columnId, $flowItemId, $owner, $assist) {
AbstractModel::transaction(function () use ($projectId, $columnId, $flowItemId, $owner, $assist) {
$newTaskUser = array_merge($owner, $assist);
//
$this->project_id = $projectId;
$this->column_id = $columnId;
$this->flow_item_id = $flowItemId;
// 任务内容
if($this->content){
if ($this->content) {
$this->content->project_id = $projectId;
$this->content->save();
}
// 任务文件
foreach ($this->taskFile as $taskFile){
foreach ($this->taskFile as $taskFile) {
$taskFile->project_id = $projectId;
$taskFile->save();
}
// 任务标签
foreach ($this->taskTag as $taskTag){
foreach ($this->taskTag as $taskTag) {
$taskTag->project_id = $projectId;
$taskTag->save();
}
// 任务用户
$this->updateTask(['owner' => $owner]);
$this->updateTask(['assist' => $assist]);
foreach ($this->taskUser as $taskUser){
if( in_array($taskUser->id, $newTaskUser) ){
$this->updateTask([
'owner' => $owner,
'assist' => $assist
]);
foreach ($this->taskUser as $taskUser) {
if (in_array($taskUser->id, $newTaskUser)) {
$taskUser->project_id = $projectId;
$taskUser->save();
}
}
//
if($flowItemId){
if ($flowItemId) {
$flowItem = projectFlowItem::whereProjectId($projectId)->whereId($flowItemId)->first();
$this->flow_item_id = $flowItemId;
$this->flow_item_name = $flowItem->status . "|" . $flowItem->name;
}else{
if ($flowItem->status == 'end') {
$this->completeTask(Carbon::now(), $flowItem->name);
} else {
$this->completeTask(null);
}
} else {
$this->flow_item_name = '';
}
//
Expand Down

0 comments on commit d7d8ee4

Please sign in to comment.