|
@@ -48,8 +48,11 @@ module.exports = app => {
|
|
|
const params = JSON.parse(ctx.request.body.params);
|
|
|
// console.log(params);
|
|
|
const rst = await ctx.service.roleRptRel.updateRoleRelationship(params.id, params.tender_id, params.rpt_id, params.stage_id, params.rel_content);
|
|
|
+ const roleRel = await ctx.service.roleRptRel.getRoleRptRelByDetailIds(params.tender_id, params.rpt_id, params.stage_id);
|
|
|
+ // const roleRel = params.rel_content;
|
|
|
+ await encodeSignatureDataUri(roleRel, this.app.baseDir);
|
|
|
// console.log(rst);
|
|
|
- ctx.body = { data: rst };
|
|
|
+ ctx.body = { data: rst, signatureRelInfo: roleRel };
|
|
|
// ctx.body = { data: { msg: 'test the network' } };
|
|
|
ctx.status = 201;
|
|
|
}
|
|
@@ -109,3 +112,36 @@ module.exports = app => {
|
|
|
|
|
|
return ReportController;
|
|
|
};
|
|
|
+
|
|
|
+async function encodeSignatureDataUri(roleRel, baseDir) {
|
|
|
+ if (roleRel) {
|
|
|
+ for (const singleRoleRel of roleRel) {
|
|
|
+ if (singleRoleRel.rel_content !== null && singleRoleRel.rel_content !== undefined && singleRoleRel.rel_content !== '') {
|
|
|
+ const roleRelContent = JSON.parse(singleRoleRel.rel_content);
|
|
|
+ for (const role of roleRelContent) {
|
|
|
+ // console.log(role);
|
|
|
+ if (role.sign_path !== '') {
|
|
|
+ const filePath = baseDir + '/app' + role.sign_path;
|
|
|
+ try {
|
|
|
+ const res = await isFileExisted(filePath);
|
|
|
+ if (res) {
|
|
|
+ const bData = fs.readFileSync(filePath);
|
|
|
+ const base64Str = bData.toString('base64');
|
|
|
+ const datauri = 'data:image/png;base64,' + base64Str;
|
|
|
+ role.sign_pic = datauri;
|
|
|
+ } else {
|
|
|
+ console.log('文件不存在:' + filePath);
|
|
|
+ }
|
|
|
+ } catch (err) {
|
|
|
+ console.error(err);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ singleRoleRel.rel_content = JSON.stringify(roleRelContent);
|
|
|
+ } else {
|
|
|
+ singleRoleRel.rel_content = [];
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+}
|
|
|
+
|