|
@@ -1,4 +1,4 @@
|
|
-import { replaceDocx, docsToPdf, createZip, uploadFileToOSS } from "../../lib/docs";
|
|
|
|
|
|
+import { replaceDocx, createZip, uploadFileToOSS, docxToPdf } from "../../lib/docs";
|
|
// const Parse = global.Parse;
|
|
// const Parse = global.Parse;
|
|
|
|
|
|
const path = require("path")
|
|
const path = require("path")
|
|
@@ -257,19 +257,20 @@ function renderReportDocsByTextbook(textbook){
|
|
Object.keys(fixData).forEach(key=>{
|
|
Object.keys(fixData).forEach(key=>{
|
|
bookData[key] = fixData[key]
|
|
bookData[key] = fixData[key]
|
|
})
|
|
})
|
|
- console.log(bookData)
|
|
|
|
- console.log(json)
|
|
|
|
|
|
+ // console.log(bookData)
|
|
|
|
+ // console.log(json)
|
|
let bookid = json.code || json?.objectId;
|
|
let bookid = json.code || json?.objectId;
|
|
let tempFileName = path.join(`${bookid}${json.title}.docx`)
|
|
let tempFileName = path.join(`${bookid}${json.title}.docx`)
|
|
return new Promise((resolve)=>{
|
|
return new Promise((resolve)=>{
|
|
replaceDocx(TemplateDocxPath,tempFileName,bookData,{onDocxComplete:async (filePath)=>{
|
|
replaceDocx(TemplateDocxPath,tempFileName,bookData,{onDocxComplete:async (filePath)=>{
|
|
// 需要API支持
|
|
// 需要API支持
|
|
- // docsToPdf(filePath)
|
|
|
|
- let url = (await uploadFileToOSS(filePath))?.url || null
|
|
|
|
|
|
+ let pdfPath = filePath.replaceAll(".docx",".pdf")
|
|
|
|
+ filePath = await docxToPdf(filePath,pdfPath) || filePath // 成功用pdf,失败继续用docx
|
|
|
|
+ let url = (await uploadFileToOSS(pdfPath))?.url || null
|
|
resolve({
|
|
resolve({
|
|
code:bookid,
|
|
code:bookid,
|
|
title:json?.title,
|
|
title:json?.title,
|
|
- filePath,
|
|
|
|
|
|
+ pdfPath,
|
|
url
|
|
url
|
|
})
|
|
})
|
|
}})
|
|
}})
|