fix: error productId
This commit is contained in:
parent
865497bf29
commit
5a33c129c1
1 changed files with 21 additions and 9 deletions
|
|
@ -178,6 +178,26 @@ export class ServiceController extends Controller {
|
|||
update: { value: { increment: 1 } },
|
||||
});
|
||||
|
||||
const workList = await Promise.all(
|
||||
(work || []).map(async (w, wIdx) =>
|
||||
tx.work.create({
|
||||
data: {
|
||||
name: w.name,
|
||||
order: wIdx + 1,
|
||||
attributes: w.attributes,
|
||||
productOnWork: {
|
||||
createMany: {
|
||||
data: w.productId.map((p, pIdx) => ({
|
||||
productId: p,
|
||||
order: pIdx + 1,
|
||||
})),
|
||||
},
|
||||
},
|
||||
},
|
||||
}),
|
||||
),
|
||||
);
|
||||
|
||||
return tx.service.create({
|
||||
include: {
|
||||
work: {
|
||||
|
|
@ -194,15 +214,7 @@ export class ServiceController extends Controller {
|
|||
data: {
|
||||
...payload,
|
||||
code: `${body.code.toLocaleUpperCase()}${last.value.toString().padStart(3, "0")}`,
|
||||
work: {
|
||||
createMany: {
|
||||
data:
|
||||
work?.map((v, i) => ({
|
||||
...v,
|
||||
order: i + 1,
|
||||
})) || [],
|
||||
},
|
||||
},
|
||||
work: { connect: workList.map((v) => ({ id: v.id })) },
|
||||
createdBy: req.user.name,
|
||||
updateBy: req.user.name,
|
||||
},
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue