|
@@ -0,0 +1,138 @@
|
|
|
+import Docxtemplater from 'docxtemplater'
|
|
|
+import PizZip from 'pizzip'
|
|
|
+function MakerSpaceWord(data,fund){
|
|
|
+
|
|
|
+ let _url = "./file/2023年二级学院特色创客空间建设项目申报书模板.docx";
|
|
|
+ const x = new XMLHttpRequest();
|
|
|
+ x.open("GET", _url, true);
|
|
|
+ x.responseType = "blob";
|
|
|
+ x.onload = function (e) {
|
|
|
+ const blob = x.response;
|
|
|
+
|
|
|
+
|
|
|
+ const reader = new FileReader();
|
|
|
+ reader.readAsArrayBuffer(blob);
|
|
|
+ reader.onload=function(a){
|
|
|
+ const buffer = reader.result;
|
|
|
+ const binary = new Uint8Array(buffer)
|
|
|
+
|
|
|
+ const zip = new PizZip(binary);
|
|
|
+
|
|
|
+ const doc = new Docxtemplater().loadZip(zip);
|
|
|
+
|
|
|
+ data['chapters'] = JSON.parse(data['chapters']);
|
|
|
+ data['course_teacher'] = JSON.parse(data['course_teacher']);
|
|
|
+ data['course_student'] = JSON.parse(data['course_student']);
|
|
|
+
|
|
|
+ let fundDataArray = [];
|
|
|
+ fund.forEach(item=>{
|
|
|
+ let fundData = {
|
|
|
+ total:"",
|
|
|
+ device:"",deviceRemarks:"",
|
|
|
+ Material:"",MaterialRemarks:"",
|
|
|
+ processing:"",processingRemarks:"",
|
|
|
+ Collaboration:"",CollaborationRemarks:"",
|
|
|
+ APPRAISAL:"",APPRAISALRemarks:"",
|
|
|
+ entery:"",enteryRemarks:"",
|
|
|
+ activities:"",activitiesRemarks:"",
|
|
|
+ Transaction:"",TransactionRemarks:""
|
|
|
+ }
|
|
|
+
|
|
|
+ let direct = JSON.parse(item['directFund']);
|
|
|
+
|
|
|
+ let indirect = JSON.parse(item['indirectFund']);
|
|
|
+
|
|
|
+ fundData['device'] = direct.filter(item=>item['directFundData']==1)[0]['budget'];
|
|
|
+ fundData['deviceRemarks'] = direct.filter(item=>item['directFundData']==1)[0]['reason'];
|
|
|
+
|
|
|
+ fundData['Material'] = direct.filter(item=>item['directFundData']==2)[0]['budget']
|
|
|
+ fundData['MaterialRemarks'] = direct.filter(item=>item['directFundData']==2)[0]['reason'];
|
|
|
+
|
|
|
+ fundData['processing'] = direct.filter(item=>item['directFundData']==3)[0]['budget']
|
|
|
+ fundData['processingRemarks'] = direct.filter(item=>item['directFundData']==3)[0]['reason'];
|
|
|
+
|
|
|
+ fundData['Collaboration'] = direct.filter(item=>item['directFundData']==4)[0]['budget']
|
|
|
+ fundData['CollaborationRemarks'] = direct.filter(item=>item['directFundData']==4)[0]['reason'];
|
|
|
+
|
|
|
+ fundData['APPRAISAL'] = indirect.filter(item=>item['indirectFundData']==1)[0]['budget']
|
|
|
+ fundData['APPRAISALRemarks'] = indirect.filter(item=>item['indirectFundData']==1)[0]['reason'];
|
|
|
+
|
|
|
+ fundData['entery'] = indirect.filter(item=>item['indirectFundData']==2)[0]['budget']
|
|
|
+ fundData['enteryRemarks'] = indirect.filter(item=>item['indirectFundData']==2)[0]['reason'];
|
|
|
+
|
|
|
+ fundData['activities'] = indirect.filter(item=>item['indirectFundData']==3)[0]['budget']
|
|
|
+ fundData['activitiesRemarks'] = indirect.filter(item=>item['indirectFundData']==3)[0]['reason'];
|
|
|
+
|
|
|
+ fundData['Transaction'] = indirect.filter(item=>item['indirectFundData']==4)[0]['budget']
|
|
|
+ fundData['TransactionRemarks'] = indirect.filter(item=>item['indirectFundData']==4)[0]['reason'];
|
|
|
+
|
|
|
+ fundData['total'] = Number(fundData['device'])+Number(fundData['Material'])+Number(fundData['processing'])+Number(fundData['Collaboration'])+Number(fundData['APPRAISAL'])+Number(fundData['entery'])+Number(fundData['activities'])+Number(fundData['Transaction']);
|
|
|
+
|
|
|
+ fundDataArray.push(fundData);
|
|
|
+ })
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ let wordData = {
|
|
|
+ projectName:data['title'],
|
|
|
+ college:data['name'],
|
|
|
+ begin_at:data['begin_at'],
|
|
|
+ plannedEnd_at:data['plannedEnd_at'],
|
|
|
+ pro_leader:data['pro_leader'],
|
|
|
+ lead_leader:data['lead_leader'],
|
|
|
+ people:(data['course_teacher'].length+data['course_student'].length),
|
|
|
+ teacherNum:data['course_teacher'].length,
|
|
|
+ studentNum:data['course_student'].length,
|
|
|
+ teacher:data['course_teacher'],
|
|
|
+ student:data['course_student'],
|
|
|
+ brief:data['brief'],
|
|
|
+ Construction:data['chapters']['Construction'],
|
|
|
+ ProjectBasis:data['chapters']['ProjectBasis'],
|
|
|
+ development:data['chapters']['development'],
|
|
|
+ studio:data['chapters']['studio'],
|
|
|
+ studentTeam:data['chapters']['studentTeam'],
|
|
|
+ studentActivities:data['chapters']['studentActivities'],
|
|
|
+ Transforming:data['chapters']['Transforming'],
|
|
|
+ condition:data['chapters']['condition'],
|
|
|
+ fund:fundDataArray,
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ doc.setData(wordData);
|
|
|
+
|
|
|
+ doc.render();
|
|
|
+ console.log(wordData)
|
|
|
+
|
|
|
+ const output = doc.getZip().generate({
|
|
|
+ type: "blob",
|
|
|
+ mimeType:"application/vnd.openxmlformats-officedocument.wordprocessingml.document",
|
|
|
+ compression: "DEFLATE",
|
|
|
+ });
|
|
|
+ let link = document.createElement("a");
|
|
|
+ link.download = '附件3:2023年二级学院特色创客空间建设项目申报书模板(2).docx';
|
|
|
+ link.style.display = "none";
|
|
|
+ let blob = new Blob([output]);
|
|
|
+ link.href = URL.createObjectURL(blob);
|
|
|
+ document.body.appendChild(link);
|
|
|
+ link.click();
|
|
|
+ document.body.removeChild(link);
|
|
|
+ }
|
|
|
+ return
|
|
|
+
|
|
|
+
|
|
|
+ }
|
|
|
+ x.send()
|
|
|
+}
|
|
|
+
|
|
|
+export{
|
|
|
+ MakerSpaceWord
|
|
|
+}
|