改进 工单删除

This commit is contained in:
iVampireSP.com 2023-02-01 14:22:30 +08:00
parent 2d466026ab
commit 7e76bb574b
No known key found for this signature in database
GPG Key ID: 2F7B001CA27A8132
2 changed files with 9 additions and 6 deletions

View File

@ -47,17 +47,17 @@ public function handle(): void
if ($this->type == 'post') { if ($this->type == 'post') {
$response = $this->workOrder->module->http()->post('work-orders', $this->workOrder->toArray()); $response = $this->workOrder->module->http()->post('work-orders', $this->workOrder->toArray());
} elseif ($this->type == 'put') { } else if ($this->type == 'put') {
$response = $this->workOrder->module->http()->put('work-orders/'.$this->workOrder->id, $this->workOrder->toArray()); $response = $this->workOrder->module->http()->put('work-orders/' . $this->workOrder->id, $this->workOrder->toArray());
} else { } else {
$response = $this->workOrder->module->http()->delete('work-orders/'.$this->workOrder->id); $response = $this->workOrder->module->http()->delete('work-orders/' . $this->workOrder->id);
if ($response->successful()) { if ($response->successful()) {
$this->workOrder->delete(); $this->workOrder->delete();
} }
} }
if (! $response->successful()) { if (!$response->successful()) {
Log::debug('WorkOrder push failed', [ Log::debug('WorkOrder push failed', [
'type' => $this->type, 'type' => $this->type,
'response' => $response->json(), 'response' => $response->json(),

View File

@ -150,8 +150,11 @@ public function safeDelete(): bool
throw new CommonException('工单状态是 pending无法删除'); throw new CommonException('工单状态是 pending无法删除');
} }
dispatch(new WorkOrderJob($this, 'delete')); if ($this->isPlatform()) {
$this->delete();
} else {
dispatch(new WorkOrderJob($this, 'delete'));
}
return true; return true;
} }