|
@@ -185,6 +185,7 @@ export async function exportProcessReportDocs(processId,bookList) {
|
|
|
query.equalTo("eduProcess",processId);
|
|
|
textbookList = await query.find();
|
|
|
}
|
|
|
+ console.log(bookList)
|
|
|
if(bookList?.length){ // 直接导出教材列表
|
|
|
let query = new Parse.Query("EduTextbook")
|
|
|
query.include("childrens","department")
|
|
@@ -383,6 +384,9 @@ 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;
|
|
|
|
|
|
// 默认单册为第一分册
|
|
@@ -497,7 +501,7 @@ function renderReportDocsByTextbook(textbook){
|
|
|
console.log(json?.approval)
|
|
|
let isNotImpt = (json?.approval?.indexOf("101计划")==-1) && (json?.approval?.indexOf("中央")==-1) && (json?.approval?.indexOf("四新")==-1) && (json?.approval?.indexOf("建设")==-1);
|
|
|
|
|
|
-
|
|
|
+
|
|
|
let fixData = {
|
|
|
volumeList:volumeList,
|
|
|
// 图片信息
|
|
@@ -568,6 +572,21 @@ function renderReportDocsByTextbook(textbook){
|
|
|
// console.log(json)
|
|
|
let tempFileName = path.join(`${bookid}_${json.title}_申报书及附件.docx`)
|
|
|
|
|
|
+
|
|
|
+ // mergeFiles 处理七八九是否签名或后置问题
|
|
|
+ let lastPageList = []
|
|
|
+ let docx7 = await getPageDocx(bookid,"七",bookData);
|
|
|
+ let docx8 = await getPageDocx(bookid,"八",bookData);
|
|
|
+ let docx9 = await getPageDocx(bookid,"九",bookData);
|
|
|
+ lastPageList.push(json?.authorSignPDF?.url||docx7);
|
|
|
+ lastPageList.push(json?.unitMaterial?.url||docx8);
|
|
|
+ lastPageList.push(docx9);
|
|
|
+ let lastPageFileName = path.join(tempDir,`${bookid}_${bookData.title}_申报书及附件_789.pdf`)
|
|
|
+ let lastPagePdf = await docxToPdf(null,lastPageFileName,{mergeFiles:lastPageList}) // 成功用pdf,失败继续用docx
|
|
|
+ // mergeFiles = [...lastPageList,...mergeFiles]
|
|
|
+ mergeFiles = [lastPagePdf,...mergeFiles]
|
|
|
+
|
|
|
+
|
|
|
// 开始文件合并导出
|
|
|
let filePath,pdfPath,urlDocx,urlPdf
|
|
|
let TemplateDocxPath
|
|
@@ -604,21 +623,22 @@ function renderReportDocsByTextbook(textbook){
|
|
|
urlPdf,
|
|
|
})
|
|
|
return
|
|
|
- replaceDocx(TemplateDocxPath,tempFileName,bookData,{onDocxComplete:async (filePath)=>{
|
|
|
- // 需要API支持
|
|
|
- let pdfPath = filePath.replaceAll(".docx",".pdf")
|
|
|
- filePath = await docxToPdf(filePath,pdfPath) || filePath // 成功用pdf,失败继续用docx
|
|
|
- let url = (await uploadFileToOSS(pdfPath))?.url || null
|
|
|
- resolve({
|
|
|
- code:bookid,
|
|
|
- title:json?.title,
|
|
|
- filePath,
|
|
|
- url
|
|
|
- })
|
|
|
- }})
|
|
|
})
|
|
|
}
|
|
|
|
|
|
+async function getPageDocx(bookid,pageName,bookData){
|
|
|
+ let tplPath = path.join(TemplateDocxDir,`模板-本科教材申报书-${pageName}.docx`);
|
|
|
+ let tempFileName = path.join(`${bookid}_${bookData.title}_申报书及附件_${pageName}.docx`);
|
|
|
+ let filePath = renderDocx(tplPath,tempFileName,bookData);
|
|
|
+ return filePath;
|
|
|
+ // 转pdf
|
|
|
+ // let pdfPath = filePath.replaceAll(".docx",".pdf")
|
|
|
+ // let options = {}
|
|
|
+ // pdfPath = await docxToPdf(null,pdfPath,options) || filePath // 成功用pdf,失败继续用docx
|
|
|
+ // return pdfPath
|
|
|
+
|
|
|
+}
|
|
|
+
|
|
|
function toYearMonth(date){
|
|
|
// console.log("toYearMonth",date)
|
|
|
if(typeof date == "string" && (date?.indexOf("年")>-1 || date?.indexOf("-")>-1)) return date
|