fix refferl hospital create use order number

This commit is contained in:
avicenan
2026-05-27 12:33:04 +09:00
parent ab692e83f1
commit 6f3cdc925a

View File

@ -134,7 +134,7 @@ export class RefferalHospitalController {
var query = await RefferalHospitalModel.list(filter);
const data = await query.getMany();
const filename = "refferal_hospital.csv";
res.setHeader('Content-Type', 'text/csv');
@ -201,8 +201,16 @@ export class RefferalHospitalController {
const param: any = await schema.validateAsync(req.body);
const lastRow = await OrmHelper.DB.getRepository(RefferalHospital).findOne({
order: {
order_number: "DESC"
},
where: {}
});
const data = new RefferalHospital()
data.refferal_hospital_name = param.refferal_hospital_name
data.order_number = lastRow && lastRow.order_number ? String(Number(lastRow.order_number) + 1) : "1";
data.created_by = req.auth.data.name;
await OrmHelper.DB.manager.save(data);