fix: 主任务被删除或归档时子任务应该也同步
This commit is contained in:
parent
c930e4dd92
commit
24287c0857
@ -799,6 +799,11 @@ class ProjectTask extends AbstractModel
|
|||||||
$this->addLog($logText, $userid);
|
$this->addLog($logText, $userid);
|
||||||
$this->pushMsg('archived');
|
$this->pushMsg('archived');
|
||||||
}
|
}
|
||||||
|
self::whereParentId($this->id)->update([
|
||||||
|
'archived_at' => $this->archived_at,
|
||||||
|
'archived_userid' => $this->archived_userid,
|
||||||
|
'archived_follow' => $this->archived_follow,
|
||||||
|
]);
|
||||||
$this->save();
|
$this->save();
|
||||||
});
|
});
|
||||||
return true;
|
return true;
|
||||||
@ -814,12 +819,11 @@ class ProjectTask extends AbstractModel
|
|||||||
AbstractModel::transaction(function () {
|
AbstractModel::transaction(function () {
|
||||||
if ($this->dialog_id) {
|
if ($this->dialog_id) {
|
||||||
$dialog = WebSocketDialog::find($this->dialog_id);
|
$dialog = WebSocketDialog::find($this->dialog_id);
|
||||||
if ($dialog) {
|
$dialog?->deleteDialog();
|
||||||
$dialog->deleteDialog();
|
|
||||||
}
|
}
|
||||||
}
|
self::whereParentId($this->id)->delete();
|
||||||
$this->delete();
|
|
||||||
$this->addLog("删除{任务}:" . $this->name);
|
$this->addLog("删除{任务}:" . $this->name);
|
||||||
|
$this->delete();
|
||||||
});
|
});
|
||||||
if ($pushMsg) {
|
if ($pushMsg) {
|
||||||
$this->pushMsg('delete');
|
$this->pushMsg('delete');
|
||||||
|
@ -6,7 +6,7 @@ use Illuminate\Database\Migrations\Migration;
|
|||||||
class ProjectTasksUpdateSubtaskTime extends Migration
|
class ProjectTasksUpdateSubtaskTime extends Migration
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* Run the migrations.
|
* 子任务同步主任务(任务时间)
|
||||||
*
|
*
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
|
@ -0,0 +1,51 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
use App\Models\ProjectTask;
|
||||||
|
use Illuminate\Database\Migrations\Migration;
|
||||||
|
|
||||||
|
class ProjectTasksUpdateSubtaskArchivedDelete extends Migration
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* 子任务同步主任务(归档、删除)
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function up()
|
||||||
|
{
|
||||||
|
// 归档
|
||||||
|
ProjectTask::whereParentId(0)
|
||||||
|
->whereNotNull('archived_at')
|
||||||
|
->chunkById(100, function ($lists) {
|
||||||
|
/** @var ProjectTask $task */
|
||||||
|
foreach ($lists as $task) {
|
||||||
|
ProjectTask::whereParentId($task->id)->update([
|
||||||
|
'archived_at' => $task->archived_at,
|
||||||
|
'archived_userid' => $task->archived_userid,
|
||||||
|
'archived_follow' => $task->archived_follow,
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
// 删除
|
||||||
|
ProjectTask::onlyTrashed()
|
||||||
|
->whereParentId(0)
|
||||||
|
->chunkById(100, function ($lists) {
|
||||||
|
/** @var ProjectTask $task */
|
||||||
|
foreach ($lists as $task) {
|
||||||
|
ProjectTask::whereParentId($task->id)->update([
|
||||||
|
'deleted_at' => $task->deleted_at,
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Reverse the migrations.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function down()
|
||||||
|
{
|
||||||
|
//
|
||||||
|
}
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user