Browse Source

education申请表

Q-ABAB 1 year ago
parent
commit
ebab210ca3

+ 34 - 0
package-lock.json

@@ -10,11 +10,13 @@
       "dependencies": {
         "axios": "^1.2.1",
         "core-js": "^3.8.3",
+        "docxtemplater": "^3.37.2",
         "echarts": "^5.4.2",
         "element-ui": "^2.4.5",
         "exceljs": "^4.3.0",
         "less": "^4.1.3",
         "less-loader": "^11.1.0",
+        "pizzip": "^3.1.4",
         "vue": "^2.6.14",
         "vue-router": "^3.5.1",
         "vue-uuid": "^3.0.0",
@@ -3358,6 +3360,14 @@
         "@xtuc/long": "4.2.2"
       }
     },
+    "node_modules/@xmldom/xmldom": {
+      "version": "0.8.7",
+      "resolved": "https://registry.npmmirror.com/@xmldom/xmldom/-/xmldom-0.8.7.tgz",
+      "integrity": "sha512-sI1Ly2cODlWStkINzqGrZ8K6n+MTSbAeQnAipGyL+KZCXuHaRlj2gyyy8B/9MvsFFqN7XHryQnB2QwhzvJXovg==",
+      "engines": {
+        "node": ">=10.0.0"
+      }
+    },
     "node_modules/@xtuc/ieee754": {
       "version": "1.2.0",
       "resolved": "https://registry.npmmirror.com/@xtuc/ieee754/-/ieee754-1.2.0.tgz",
@@ -5309,6 +5319,17 @@
         "node": ">=6.0.0"
       }
     },
+    "node_modules/docxtemplater": {
+      "version": "3.37.2",
+      "resolved": "https://registry.npmmirror.com/docxtemplater/-/docxtemplater-3.37.2.tgz",
+      "integrity": "sha512-8Q3pw6iZEg8rOnDF/LsP/ZbAEzGVZ6gY/bAJmhQwFK9HMDUKWI/FIvTfBIEnAV5yiROsFaM8/sA9Ry2JmcJSpg==",
+      "dependencies": {
+        "@xmldom/xmldom": "^0.8.7"
+      },
+      "engines": {
+        "node": ">=0.10"
+      }
+    },
     "node_modules/dom-converter": {
       "version": "0.2.0",
       "resolved": "https://registry.npmmirror.com/dom-converter/-/dom-converter-0.2.0.tgz",
@@ -9507,6 +9528,19 @@
         "node": ">=6"
       }
     },
+    "node_modules/pizzip": {
+      "version": "3.1.4",
+      "resolved": "https://registry.npmmirror.com/pizzip/-/pizzip-3.1.4.tgz",
+      "integrity": "sha512-08yol1Of5Og1E0a1R56c+Z1jVkvfTEBUouwG9WYwCqpj8BjdcpEpLgZsrdLFNQYRgtxK0OOe0JpmBWJdrPr6Dg==",
+      "dependencies": {
+        "pako": "^2.1.0"
+      }
+    },
+    "node_modules/pizzip/node_modules/pako": {
+      "version": "2.1.0",
+      "resolved": "https://registry.npmmirror.com/pako/-/pako-2.1.0.tgz",
+      "integrity": "sha512-w+eufiZ1WuJYgPXbV/PO3NCMEc3xqylkKHzp8bxp1uW4qaSNQUkwmLLEc3kKsfz8lpV1F8Ht3U1Cm+9Srog2ug=="
+    },
     "node_modules/pkg-dir": {
       "version": "4.2.0",
       "resolved": "https://registry.npmmirror.com/pkg-dir/-/pkg-dir-4.2.0.tgz",

+ 2 - 0
package.json

@@ -10,11 +10,13 @@
   "dependencies": {
     "axios": "^1.2.1",
     "core-js": "^3.8.3",
+    "docxtemplater": "^3.37.2",
     "echarts": "^5.4.2",
     "element-ui": "^2.4.5",
     "exceljs": "^4.3.0",
     "less": "^4.1.3",
     "less-loader": "^11.1.0",
+    "pizzip": "^3.1.4",
     "vue": "^2.6.14",
     "vue-router": "^3.5.1",
     "vue-uuid": "^3.0.0",

BIN
public/file/2023年二级学院特色创客空间建设项目申报书模板.docx


+ 138 - 0
src/components/tool/getWord.js

@@ -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;
+        //转成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['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'],   //教师组//name:姓名  speciality:专业  title:职称 education:学历    section:所在教研室    work:项目组角色分工
+                student:data['course_student'],   //学生组//name:姓名    class:班级 age:年龄   work:项目组任务分工
+                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,//预算经费
+                    //total:总经费     
+                    //小型仪器设备费:device        deviceRemarks
+                    //材料费:Material             MaterialRemarks
+                    //测试化验加工费:processing    processingRemarks
+                    //项目协作费:Collaboration     CollaborationRemarks
+                    //项目成果鉴定费:APPRAISAL     APPRAISALRemarks
+                    //参展参赛费:entery            enteryRemarks
+                    //创客交流活动费:activities    activitiesRemarks
+                    //知识产权事务费:Transaction   TransactionRemarks
+            }
+            //渲染模板
+            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
+}

+ 15 - 28
src/views/projectApply/projectApplication.vue

@@ -180,7 +180,7 @@
                         <el-button type="info" style="background-color: #c8c9cc;border-color: #c8c9cc;cursor: no-drop;" v-if="scope.row.isupload==1"  size="mini">审核中</el-button>
                         <el-button type="info" style="background-color: #c8c9cc;border-color: #c8c9cc;cursor: no-drop;" v-if="scope.row.isupload==2"  size="mini">已审核</el-button>
 
-                        <el-button type="primary"  size="mini" @click="appTable(scope.row.typeName)" >申请表</el-button>
+                        <el-button type="primary"  size="mini" @click="appTable(scope.row.typeid,scope.row.courseId)" >申请表</el-button>
                         <!-- <el-button type="primary"  size="mini"><a href="/file/附件 5 :学校创客专项资金使用申请表.xlsx" download="创客活动.doc">申请表</a> </el-button> -->
 
                         <el-button type="primary"  size="mini" @click="del(scope.row)">删除</el-button>
@@ -318,7 +318,7 @@
 
 <script>
 import downloadFile from '@/components/tool/downloadFile.js';
-
+import {MakerSpaceWord} from '@/components/tool/getWord.js'
     export default {
       data() {
         return {
@@ -409,35 +409,22 @@ import downloadFile from '@/components/tool/downloadFile.js';
             
             
         },
-        appTable(name){   //查看申请表
-          if(name=="学生创客项目"){
+        appTable(tid,pid){   //查看申请表
+          if(tid=="学生创客项目"){
             downloadFile('/file/附件2:2023年学生创客项目申报书模板(2).docx',"2023年学生创客项目申报书模板.docx",(_b)=>this.loading = _b);
-          }else if(name=="特色创客空间建设项目"){
-            downloadFile('/file/附件3:2023年二级学院特色创客空间建设项目申报书模板(2).docx',"2023年二级学院特色创客空间建设项目申报书模板.docx",(_b)=>this.loading = _b);
+          }else if(tid=="5f7a66d5-c206-11ed-a4cd-509a4c5b67cf"){
+            this.ajax.get(this.$store.state.api+"/SelectProjectWordMakerSpace",{
+              uid:this.$store.state.userInfo.userid,
+              pid:pid
+            }).then(res=>{
+              MakerSpaceWord(res['data'][0][0],res['data'][1]);
+            }).catch(err=>{
+              console.log(err)
+            })
           }else{
-            this.$message.error("分类错误")
+            this.$message.error("错误")
           }
-          // window.open("https://ccrb.s3.cn-northwest-1.amazonaws.com.cn/%E9%99%84%E4%BB%B6%202%EF%BC%9A%E5%88%9B%E5%AE%A2%E4%B8%93%E9%A1%B9%E8%B5%84%E9%87%91%E9%A1%B9%E7%9B%AE%E7%94%B3%E8%AF%B7%E8%A1%A8%EF%BC%88%E5%88%9B%E5%AE%A2%E6%B4%BB%E5%8A%A8%EF%BC%891681086540732.doc")
-          // downloadFile('/file/附件 1:创客专项资金项目申请表(个人创客)20180511.doc',"创客专项资金项目申请表(个人创客).doc",(_b)=>this.loading = _b);
-          
-          // let data=require('../../assets/file/附件 5 :学校创客专项资金使用申请表.xlsx')
-          // var blob = new Blob(['../../assets/file/附件 5 :学校创客专项资金使用申请表.xlsx']);
-          // const dom = document.createElement("a");
-          // dom.download = '创客专项资金项目申请表(个人创客)';
-          // dom.href = URL.createObjectURL(blob);
-          // dom.id = "upload-file-dom";
-          // dom.style.display = "none";
-          // document.body.appendChild(dom);
-      
-          // // 触发点击事件
-          // dom.click();
-      
-          // // 释放资源
-          // setTimeout(function () {
-          //   URL.revokeObjectURL(dom.href);
-          // document.getElementById("upload-file-dom")?.remove();
-          // }, 100);
-         
+
 
         },
         commit(){    //立项审核对话框里面的确定提交按钮