|
@@ -206,6 +206,7 @@ module.exports = app => {
|
|
|
const rptId = params.rptId;
|
|
|
const ttlPgs = params.ttlPgs;
|
|
|
const uuid = params.uuid;
|
|
|
+ const removeUuid = params.removeUuid;
|
|
|
const childUuids = params.childUuids;
|
|
|
const splitArcPages = params.splitArcPages;
|
|
|
const reportName = params.reportName;
|
|
@@ -232,7 +233,13 @@ module.exports = app => {
|
|
|
}
|
|
|
}
|
|
|
if (!hasArchive) {
|
|
|
- // 表示有新的要加
|
|
|
+ // 表示有新的要加, 有加有减
|
|
|
+ for (let idx = contentArr.length - 1; idx >= 0; idx--) {
|
|
|
+ if (contentArr[idx].uuid === removeUuid) {
|
|
|
+ contentArr.splice(idx, 1);
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ }
|
|
|
contentArr.push({ rpt_id: rptId, uuid, total_page: ttlPgs, encryption: content, user_id: userId, report_name: reportName, childUuids, splitArcPages });
|
|
|
} else {
|
|
|
//
|
|
@@ -264,6 +271,7 @@ module.exports = app => {
|
|
|
const dtStr = `${updateDate.getFullYear()}-${montStr}-${dateStr} ${hrStr}:${minStr}:${secStr}`;
|
|
|
let rst = null;
|
|
|
const fileName = parentUuidName + '.PDF';
|
|
|
+ let removeUuid = ''; // 因这里把增删功能做在一起,有可能要删除一个旧的uuid,需要返回,给加密处理用
|
|
|
const orgArchiveList = await ctx.service.rptArchive.getPrjStgArchive(prjId, stgId);
|
|
|
if (orgArchiveList.length > 0) {
|
|
|
const contentArr = JSON.parse(orgArchiveList[0].content);
|
|
@@ -290,6 +298,7 @@ module.exports = app => {
|
|
|
|
|
|
if (updateRmIdx >= 0) {
|
|
|
// 删除oss文件
|
|
|
+ removeUuid = item.items[updateRmIdx].uuid;
|
|
|
await ctx.app.signPdfOss.delete(`archive/${item.items[updateRmIdx].uuid}.PDF`);
|
|
|
// 以及删除子oss文件
|
|
|
if (item.items[updateRmIdx].childUuids && item.items[updateRmIdx].childUuids.length > 0) {
|
|
@@ -317,13 +326,13 @@ module.exports = app => {
|
|
|
}
|
|
|
const updatedRst = await ctx.service.rptArchive.updateArchive(orgArchiveList[0].id, prjId, stgId, contentArr);
|
|
|
// console.log(updatedRst);
|
|
|
- rst = { err: 0, msg: parentUuidName, data: { uuid: parentUuidName, childUuids, fileName, updateDate, updatedRst: contentArr } };
|
|
|
+ rst = { err: 0, msg: parentUuidName, data: { uuid: parentUuidName, childUuids, removeUuid, fileName, updateDate, updatedRst: contentArr } };
|
|
|
} else {
|
|
|
// 需要增加
|
|
|
const archiveArr = [];
|
|
|
archiveArr.push({ rpt_id: rptId, items: [{ uuid: parentUuidName, updateDate_time: dtStr, childUuids }] });
|
|
|
const addedRst = await ctx.service.rptArchive.createArchive(prjId, stgId, archiveArr);
|
|
|
- rst = { err: 0, msg: parentUuidName, data: { uuid: parentUuidName, childUuids, fileName, updateDate, updatedRst: archiveArr } };
|
|
|
+ rst = { err: 0, msg: parentUuidName, data: { uuid: parentUuidName, childUuids, removeUuid, fileName, updateDate, updatedRst: archiveArr } };
|
|
|
}
|
|
|
return rst;
|
|
|
}
|