|
@@ -1,4 +1,4 @@
|
|
|
-import { replaceDocx, createZip, uploadFileToOSS, docxToPdf, renderDocx, toBarCode } from "../../lib/docs";
|
|
|
+import { replaceDocx, createZip, uploadFileToOSS, docxToPdf, renderDocx, toBarCode, downloadUrl } from "../../lib/docs";
|
|
|
// const Parse = global.Parse;
|
|
|
|
|
|
const path = require("path")
|
|
@@ -202,8 +202,9 @@ export async function exportProcessReportDocs(processId,bookList) {
|
|
|
plist.push(renderReportDocsByTextbook(textbook)); // 立即执行并返回 Promise
|
|
|
}
|
|
|
let presults = await Promise.all(plist);
|
|
|
+ console.log(presults)
|
|
|
presults.forEach(result=>{
|
|
|
- if(result?.filePath){
|
|
|
+ if(result?.filePath || result?.pdfPath){
|
|
|
docsList.push(result)
|
|
|
}
|
|
|
})
|
|
@@ -418,13 +419,30 @@ function pushDistinctItem(list,item){
|
|
|
return list
|
|
|
}
|
|
|
function renderReportDocsByTextbook(textbook){
|
|
|
+
|
|
|
console.log("renderReportDocsByTextbook")
|
|
|
return new Promise(async (resolve)=>{
|
|
|
+
|
|
|
let json = textbook.toJSON();
|
|
|
json.hasNoSign = false; // 未上传作者签名
|
|
|
json.hasNoUnit = false; // 未上传单位资料
|
|
|
json.hasNoNine = false; // 无需添加滞后九
|
|
|
- let bookid = json.code || json?.objectId;
|
|
|
+ let bookid = json.code || json?.objectId;
|
|
|
+
|
|
|
+ let exportPDF = textbook.get("exportPDF");
|
|
|
+ if(exportPDF){
|
|
|
+ // console.log(exportPDF)
|
|
|
+ let exportPath = await downloadUrl(exportPDF,{tempDir:path.join(tempDir,textbook.id),keepFileName:true});
|
|
|
+ // console.log(exportPath)
|
|
|
+ resolve({
|
|
|
+ code:bookid,
|
|
|
+ objectId:textbook.id,
|
|
|
+ title:json?.title,
|
|
|
+ pdfPath:exportPath,
|
|
|
+ urlPdf:exportPDF,
|
|
|
+ })
|
|
|
+ return
|
|
|
+ }
|
|
|
|
|
|
// 默认单册为第一分册
|
|
|
let book1Data = json?.childrens?.[0]
|
|
@@ -672,6 +690,10 @@ function renderReportDocsByTextbook(textbook){
|
|
|
console.log("PDF CREATED:",filePath)
|
|
|
if(pdfPath){
|
|
|
urlPdf = (await uploadFileToOSS(pdfPath,json?.objectId))?.url || null
|
|
|
+ if(urlPdf){
|
|
|
+ textbook.set("exportPDF",urlPdf);
|
|
|
+ textbook.save();
|
|
|
+ }
|
|
|
}
|
|
|
}catch(err){
|
|
|
console.error(err)
|