|
|
@@ -339,6 +339,23 @@ module.exports = app => {
|
|
|
});
|
|
|
}
|
|
|
if(newAuditors.length > 0) await transaction.insert(this.tableName, newAuditors);
|
|
|
+ // 同步更新到权限表里
|
|
|
+ const auditList = await this.ctx.service.tenderPermission.getPartsPermission(this.ctx.tender.id, ['safe_inspection']);
|
|
|
+ const insert_members = [];
|
|
|
+ const insert_uids = [];
|
|
|
+ for (const user of newAuditors) {
|
|
|
+ const addAid = this._.find(auditList, { uid: user.aid });
|
|
|
+ if (!addAid) {
|
|
|
+ insert_members.push({
|
|
|
+ uid: user.aid,
|
|
|
+ safe_inspection: ['1'],
|
|
|
+ });
|
|
|
+ insert_uids.push(user.aid);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (insert_members.length > 0) {
|
|
|
+ await this.ctx.service.tenderPermission.saveOnePermission(this.ctx.tender.id, insert_uids, insert_members, ['safe_inspection'], transaction);
|
|
|
+ }
|
|
|
await transaction.commit();
|
|
|
} catch (err) {
|
|
|
await transaction.rollback();
|
|
|
@@ -377,6 +394,15 @@ module.exports = app => {
|
|
|
audit_type: auditType.key.common, audit_order: order,
|
|
|
};
|
|
|
await transaction.insert(this.tableName, newAuditor);
|
|
|
+ const auditList = await this.ctx.service.tenderPermission.getPartsPermission(this.ctx.tender.id, ['safe_inspection']);
|
|
|
+ const addAid = this._.includes(this._.map(auditList, 'uid'), lastId);
|
|
|
+ if (!addAid) {
|
|
|
+ const insert_members = [{
|
|
|
+ uid: lastId,
|
|
|
+ safe_inspection: ['1'],
|
|
|
+ }];
|
|
|
+ await this.ctx.service.tenderPermission.saveOnePermission(this.ctx.tender.id, [lastId], insert_members, ['safe_inspection'], transaction);
|
|
|
+ }
|
|
|
await transaction.commit();
|
|
|
} catch (err) {
|
|
|
await transaction.rollback();
|