|
@@ -175,7 +175,8 @@ const squareCheck = [`□`,String.fromCharCode(0xFE)];
|
|
|
* docsList
|
|
|
* zipUrl
|
|
|
*/
|
|
|
-export async function exportProcessReportDocs(processId,bookList) {
|
|
|
+export async function exportProcessReportDocs(processId,bookList,isNew) {
|
|
|
+ isNew = isNew || false;
|
|
|
if(!processId && !bookList?.length) return {}
|
|
|
|
|
|
let textbookList
|
|
@@ -200,7 +201,7 @@ export async function exportProcessReportDocs(processId,bookList) {
|
|
|
let textbook = textbookList[index];
|
|
|
console.log("textbook",index)
|
|
|
// 直接将异步调用的 Promise 添加到 plist
|
|
|
- plist.push(renderReportDocsByTextbook(textbook)); // 立即执行并返回 Promise
|
|
|
+ plist.push(renderReportDocsByTextbook(textbook,isNew)); // 立即执行并返回 Promise
|
|
|
}
|
|
|
let presults = await Promise.all(plist);
|
|
|
console.log(presults)
|
|
@@ -251,7 +252,7 @@ function fixVolumeData(json,volumeData,index,totalJson,isChildren){
|
|
|
let majorCode4 = volumeData?.majorPoniter?.code?.slice(0,4) || json?.majorPoniter?.code?.slice(0,4) || ""
|
|
|
let majorName4 = volumeData?.majorPoniter?.name || json?.majorPoniter?.name || ""
|
|
|
// 专业代码:前六位 major
|
|
|
- let majorCode6 = volumeData?.major?.code?.slice(0,6) || json?.major?.code?.slice(0,6) || ""
|
|
|
+ let majorCode6 = volumeData?.major?.code?.slice(0) || json?.major?.code?.slice(0) || ""
|
|
|
let majorName6 = volumeData?.major?.name || json?.major?.name || ""
|
|
|
|
|
|
|
|
@@ -347,6 +348,10 @@ function fixVolumeData(json,volumeData,index,totalJson,isChildren){
|
|
|
// console.log(volumeData?.authorList)
|
|
|
for (let index = 0; index < 6; index++) { // 补充空值
|
|
|
if(!volumeData?.authorList?.[index]){
|
|
|
+ if(!volumeData?.authorList){
|
|
|
+ // console.log(volumeData)
|
|
|
+ // volumeData.authorList = []
|
|
|
+ }
|
|
|
volumeData.authorList.push({name:"",unit:"",birth:"",nationality:"",job:"",title:"",mobile:"",email:"",work:""})
|
|
|
}
|
|
|
}
|
|
@@ -419,18 +424,20 @@ function pushDistinctItem(list,item){
|
|
|
}
|
|
|
return list
|
|
|
}
|
|
|
-function renderReportDocsByTextbook(textbook){
|
|
|
-
|
|
|
- console.log("renderReportDocsByTextbook")
|
|
|
+function renderReportDocsByTextbook(textbook,isNew){
|
|
|
+ let TID = textbook?.id;
|
|
|
+ console.log("renderReportDocsByTextbook",textbook?.id)
|
|
|
return new Promise(async (resolve)=>{
|
|
|
|
|
|
let json = textbook.toJSON();
|
|
|
+ json.TID = TID;
|
|
|
json.hasNoSign = false; // 未上传作者签名
|
|
|
json.hasNoUnit = false; // 未上传单位资料
|
|
|
json.hasNoNine = false; // 无需添加滞后九
|
|
|
let bookid = json.code || json?.objectId;
|
|
|
|
|
|
let exportPDF = textbook.get("exportPDF");
|
|
|
+ if(isNew) exportPDF = null;
|
|
|
if(exportPDF){
|
|
|
// console.log(exportPDF)
|
|
|
let exportPath = await downloadUrl(exportPDF,{tempDir:path.join(tempDir,textbook.id),keepFileName:true});
|
|
@@ -447,6 +454,7 @@ function renderReportDocsByTextbook(textbook){
|
|
|
|
|
|
// 默认单册为第一分册
|
|
|
let book1Data = json?.childrens?.[0]
|
|
|
+ // console.log(json,book1Data)
|
|
|
if(book1Data){
|
|
|
Object.keys(book1Data).forEach(key=>{
|
|
|
json[key] = book1Data[key] || json[key] || ""
|
|
@@ -556,7 +564,7 @@ function renderReportDocsByTextbook(textbook){
|
|
|
}
|
|
|
|
|
|
|
|
|
- let bookTempDir = path.join(tempDir,json?.objectId)
|
|
|
+ let bookTempDir = path.join(tempDir,json?.TID)
|
|
|
if(!fs.existsSync(bookTempDir)) fs.mkdirSync(bookTempDir)
|
|
|
|
|
|
|
|
@@ -651,9 +659,9 @@ function renderReportDocsByTextbook(textbook){
|
|
|
|
|
|
// mergeFiles 处理七八九是否签名或后置问题
|
|
|
let lastPageList = []
|
|
|
- let docx7 = await getPageDocx(json?.objectId,bookid,"七",bookData);
|
|
|
- let docx8 = await getPageDocx(json?.objectId,bookid,"八",bookData);
|
|
|
- let docx9 = await getPageDocx(json?.objectId,bookid,"九",bookData);
|
|
|
+ let docx7 = await getPageDocx(json?.TID,bookid,"七",bookData);
|
|
|
+ let docx8 = await getPageDocx(json?.TID,bookid,"八",bookData);
|
|
|
+ let docx9 = await getPageDocx(json?.TID,bookid,"九",bookData);
|
|
|
lastPageList.push(json?.authorSignPDF?.url||docx7);
|
|
|
lastPageList.push(json?.unitMaterial?.url||docx8);
|
|
|
lastPageList.push(docx9);
|
|
@@ -701,7 +709,7 @@ function renderReportDocsByTextbook(textbook){
|
|
|
}
|
|
|
resolve({
|
|
|
code:bookid,
|
|
|
- objectId:json?.objectId,
|
|
|
+ objectId:json?.TID,
|
|
|
title:json?.title,
|
|
|
filePath,
|
|
|
pdfPath,
|