From 22391c10c29ee854091702b82b734fbf55eccc9d Mon Sep 17 00:00:00 2001 From: lyx <2027667395@qq.com> Date: Fri, 15 Mar 2024 12:28:32 +0800 Subject: [PATCH 1/2] fix: record direct problem --- .../src/server/services/record-service.ts | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/packages/plugins/@hera/plugin-rental/src/server/services/record-service.ts b/packages/plugins/@hera/plugin-rental/src/server/services/record-service.ts index 0bb62bd96..12b123916 100644 --- a/packages/plugins/@hera/plugin-rental/src/server/services/record-service.ts +++ b/packages/plugins/@hera/plugin-rental/src/server/services/record-service.ts @@ -9,15 +9,15 @@ export class RecordService { private db: Database; async load() { - // 新版订单页面需要完善订单中项目数据 - this.db.on('records.afterSave', this.setProject.bind(this)); - // 处理直发单,生成对应租赁/购销,出入库单 || 订单创建绑定project字段关系 + // 1. 创建项目/更新项目( 直发单,生成对应租赁/购销,出入库单数据, 并且设置订单多对多project字段关系) this.db.on('records.afterCreate', this.afterCreateDirectRecord.bind(this)); this.db.on('records.afterUpdate', this.afterUpdateDirectRecord.bind(this)); + // 2. 订单新建更新后(根据合同确定出入库字段) + this.db.on('records.afterSave', this.setProject.bind(this)); // 订单发生变化时更新对应结算单的状态(需要重新计算) this.db.on('records.afterSave', this.updateSettlementStatus.bind(this)); // 老系统导入信息系统数据,record_import存储数据,并根据record_import数据创建对应的单子 - // this.db.on('record_import.afterCreate', this.importRecord.bind(this)); + this.db.on('record_import.afterCreate', this.importRecord.bind(this)); } /** * 处理直发单生成单 @@ -38,6 +38,7 @@ export class RecordService { return; } if (values.record_category === RecordTypes.purchaseDirect || values.record_category === RecordTypes.rentDirect) { + const deleteDatas = await this.db.getRepository('records').find({ where: { direct_record_id: model.id } }); // 删除订单多对多项目表数据 const records = await this.db.getRepository('records').find({ where: { direct_record_id: model.id } }); await this.deleteReocrdProject( @@ -45,7 +46,6 @@ export class RecordService { transaction, true, ); - const deleteDatas = await this.db.getRepository('records').find({ where: { direct_record_id: model.id } }); // 删除新建时创建的订单 await this.db.sequelize.query( ` @@ -648,6 +648,7 @@ export class RecordService { async createRecord(model, values, transaction, context, updateData) { delete values.number; delete values.id; + values.vehicles.forEach((item) => delete item.record_vehicles); //采购直发单 if (values.record_category === RecordTypes.purchaseDirect && values.category === RecordCategory.purchase2lease) { const inProject = await this.db.getModel('project').findOne({ @@ -733,7 +734,7 @@ export class RecordService { leaseInData['record_category'] = RecordTypes.rentInStock; leaseInData['movement'] = Movement.in; leaseInData['category'] = RecordCategory.lease; - leaseInData['contract'] = values.in_contract; + leaseInData['contract'] = values.out_contract; leaseInData['out_stock'] = outProject.dataValues; leaseInData['in_stock'] = baseProject.dataValues; if (updateData) { From a64f3b9e46526018ee408f8b4de88dc77c2c9da2 Mon Sep 17 00:00:00 2001 From: lyx <2027667395@qq.com> Date: Fri, 15 Mar 2024 12:30:16 +0800 Subject: [PATCH 2/2] =?UTF-8?q?feat:=20=E5=85=B3=E9=97=AD=E5=A4=B1?= =?UTF-8?q?=E8=AF=AF=E6=89=93=E5=BC=80=E7=9A=84=E6=B3=A8=E9=87=8A?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../@hera/plugin-rental/src/server/services/record-service.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/plugins/@hera/plugin-rental/src/server/services/record-service.ts b/packages/plugins/@hera/plugin-rental/src/server/services/record-service.ts index 12b123916..91d451e40 100644 --- a/packages/plugins/@hera/plugin-rental/src/server/services/record-service.ts +++ b/packages/plugins/@hera/plugin-rental/src/server/services/record-service.ts @@ -17,7 +17,7 @@ export class RecordService { // 订单发生变化时更新对应结算单的状态(需要重新计算) this.db.on('records.afterSave', this.updateSettlementStatus.bind(this)); // 老系统导入信息系统数据,record_import存储数据,并根据record_import数据创建对应的单子 - this.db.on('record_import.afterCreate', this.importRecord.bind(this)); + // this.db.on('record_import.afterCreate', this.importRecord.bind(this)); } /** * 处理直发单生成单