delete(); } else { WorkorderProcess::where($fk, $ownerId)->delete(); } if ($rows instanceof \think\Collection) { $rows = $rows->toArray(); } if (!is_array($rows)) { return; } $seq = 1; foreach ($rows as $row) { if ($row instanceof \think\Model) { $row = $row->toArray(); } if (!is_array($row) || trim((string)($row['name'] ?? '')) === '') { continue; } $data = [ $fk => $ownerId, 'seq' => isset($row['seq']) && $row['seq'] !== '' ? (int)$row['seq'] : $seq, 'code' => isset($row['code']) ? trim((string)$row['code']) : '', 'name' => trim((string)$row['name']), 'workstation' => isset($row['workstation']) ? (string)$row['workstation'] : '', 'standard_time' => isset($row['standard_time']) ? (string)$row['standard_time'] : '', 'params' => isset($row['params']) ? (string)$row['params'] : '', 'qc_points' => isset($row['qc_points']) ? (string)$row['qc_points'] : '', 'remark' => isset($row['remark']) ? (string)$row['remark'] : '', ]; if ($isProduct) { (new ProductProcess())->allowField(true)->save($data); } else { (new WorkorderProcess())->allowField(true)->save($data); } $seq++; } } }