|
@@ -1,6 +1,7 @@
|
|
|
import Docxtemplater from 'docxtemplater'
|
|
|
import PizZip from 'pizzip'
|
|
|
import { getNowDate } from './Date';
|
|
|
+import { GetTime } from './Date';
|
|
|
// import HTMLModule from 'docx'
|
|
|
function MakerSpaceWord(data,fund){
|
|
|
//获取模板文件
|
|
@@ -365,8 +366,70 @@ function MakerStudentWord(data,fund){
|
|
|
x.send()
|
|
|
}
|
|
|
|
|
|
+//活动管理的申请表
|
|
|
+function ActivityWord(data){
|
|
|
+ let _url = "./file/附件 2:创客专项资金项目申请表创客活动模板.docx";
|
|
|
+ const x = new XMLHttpRequest();
|
|
|
+ x.open("GET", _url, true);
|
|
|
+ x.responseType = "blob";
|
|
|
+ x.onload = function (e) {
|
|
|
+ const blob = x.response;
|
|
|
+ //转成binary
|
|
|
+ const reader = new FileReader();
|
|
|
+ reader.readAsArrayBuffer(blob);
|
|
|
+ reader.onload=function(a){
|
|
|
+ const buffer = reader.result;
|
|
|
+ const binary = new Uint8Array(buffer)
|
|
|
+ //创建一个PizZip实例
|
|
|
+ const zip = new PizZip(binary);
|
|
|
+ // 将模板内容加载到 Docxtemplater 中
|
|
|
+ const doc = new Docxtemplater().loadZip(zip);
|
|
|
+
|
|
|
+ //处理数据
|
|
|
+ data['chapters'] = JSON.parse(data['chapters']);
|
|
|
+ data['begin_at'] = GetTime(data['begin_at'])
|
|
|
+ data['course_teacher'] = JSON.parse(data['course_teacher'])
|
|
|
+ //模板数据
|
|
|
+ let wordData = {
|
|
|
+ activityName:data['title'],//活动名称
|
|
|
+ money:data['money'],//预算经费
|
|
|
+ pro_leader:data['pro_leader'],//负责人
|
|
|
+ class:data['className'],//所在部门
|
|
|
+ phone:data['phone'],//联系电话
|
|
|
+ activityTime:data['begin_at'],//活动时间
|
|
|
+ studentNum:data['students'],//参加学生人数
|
|
|
+ teacher:data['course_teacher'],//活动指导教师
|
|
|
+ plan:data['chapters'][0].replace(/<[^>]+>/g,""),//活动计划
|
|
|
+ Expectations:data['chapters'][1].replace(/<[^>]+>/g,""),//预期目标
|
|
|
+ EventAudience:data['chapters'][2].replace(/<[^>]+>/g,""),//活动受众面
|
|
|
+ fund:data['chapters'][3].replace(/<[^>]+>/g,""),//经费支出计划
|
|
|
+ }
|
|
|
+ //渲染模板
|
|
|
+ doc.setData(wordData);
|
|
|
+ doc.render();
|
|
|
+ //获取渲染后的文本
|
|
|
+ const output = doc.getZip().generate({
|
|
|
+ type: "blob",
|
|
|
+ mimeType:"application/vnd.openxmlformats-officedocument.wordprocessingml.document",
|
|
|
+ compression: "DEFLATE",
|
|
|
+ });
|
|
|
+ let link = document.createElement("a");
|
|
|
+ link.download = '附件 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,
|
|
|
- MakerStudentWord
|
|
|
+ MakerStudentWord,
|
|
|
+ ActivityWord
|
|
|
}
|