lsc 1 年之前
父節點
當前提交
406ac8a3d0

+ 1 - 1
dist/index.html

@@ -25,7 +25,7 @@
       height: 100%;
       width: 100%;
       background: #e6eaf0;
-    }</style><link href=./static/css/app.0f181971c731e10cef9f7b2966d9eb85.css rel=stylesheet></head><body><div id=app></div><script type=text/javascript src=./static/js/manifest.571c38d63f24b1ae9e16.js></script><script type=text/javascript src=./static/js/vendor.e51d5125d19cac079824.js></script><script type=text/javascript src=./static/js/app.e4e12f9fac35dc846354.js></script></body></html><script>function stopSafari() {
+    }</style><link href=./static/css/app.b3996c45b4691a518ea501f737c594f4.css rel=stylesheet></head><body><div id=app></div><script type=text/javascript src=./static/js/manifest.571c38d63f24b1ae9e16.js></script><script type=text/javascript src=./static/js/vendor.e51d5125d19cac079824.js></script><script type=text/javascript src=./static/js/app.87862cc3bb44d66f725e.js></script></body></html><script>function stopSafari() {
     //阻止safari浏览器双击放大功能
     let lastTouchEnd = 0  //更新手指弹起的时间
     document.documentElement.addEventListener("touchstart", function (event) {

File diff suppressed because it is too large
+ 0 - 0
dist/static/css/app.b3996c45b4691a518ea501f737c594f4.css


File diff suppressed because it is too large
+ 0 - 0
dist/static/css/app.b3996c45b4691a518ea501f737c594f4.css.map


File diff suppressed because it is too large
+ 0 - 0
dist/static/js/app.87862cc3bb44d66f725e.js


File diff suppressed because it is too large
+ 0 - 0
dist/static/js/app.87862cc3bb44d66f725e.js.map


File diff suppressed because it is too large
+ 0 - 0
dist/static/js/manifest.571c38d63f24b1ae9e16.js.map


+ 158 - 33
src/components/pages/test/check/index.vue

@@ -73,7 +73,8 @@
                 <span class="serach_icon" @click="searchCourse"></span>
               </div>
               <div class="btnA" v-if="stype == 1 && !pdfLoading" @click="exportPDF">导出PDF</div>
-              <!-- <div class="btnA" v-if="stype == 2 || stype == 3">导出人员数据</div> -->
+              <div class="btnA" v-if="stype == 2" @click="exportAllWord">导出人员数据</div>
+              <div class="btnA" v-if="stype == 3" @click="exportAllWord2">导出人员数据</div>
             </div>
           </div>
           <div class="title_content" v-if="stype == 1">
@@ -157,7 +158,7 @@
             </div>
           </div>
           <div class="table_content" v-if="stype == 2">
-            <el-table class="el-table" ref="table" :data="worksArray" border :height="tableHeight" :fit="true" :key="2"
+            <el-table class="el-table" ref="table" :data="worksArray" border :fit="true" :key="2"
               v-loading="isLoading" style="width: 100%" :header-cell-style="{ background: '#f1f1f1', fontSize: '17px' }">
               <el-table-column fixed label="序号" width="80px" align="left">
                 <template slot-scope="scope">
@@ -210,7 +211,7 @@
           </div>
           <div class="table_content" v-if="stype == 3">
             <div class="student_table">
-              <el-table ref="table" :data="tableData" border :height="tableHeight" :fit="true" v-loading="isLoading"
+              <el-table ref="table" :data="tableData" border :fit="true" v-loading="isLoading"
                 style="width: 100%" :header-cell-style="{ background: '#f1f1f1', fontSize: '17px' }"
                 :row-class-name="tableRowClassName">
                 <el-table-column prop="username" label="提交人" min-width="15" align="center">
@@ -261,6 +262,8 @@ import wordcloud from 'vue-wordcloud';
 import checkPie from '../data/checkPie.vue';
 
 import { downloadPDF } from '../../../tools/pdf'
+import JSZip from "jszip";
+import FileSaver from "file-saver";
 
 export default {
   components: {
@@ -845,13 +848,13 @@ export default {
         if (item.type == 1) {
           for (let j = 0; j < item.json.array.length; j++) {
             let check = item.json.array[j]
-            let _option = `<div style='margin:10px 0 0 40px;'>${item.json.answer2.indexOf(j) == -1 ? '☐' : '☑'} ${check.option}</div>`
+            let _option = `<div style='margin:10px 0 0 40px;'>${(item.json.answer2 && item.json.answer2.indexOf(j) !== -1) ? '☑' : '☐'} ${check.option}</div>`
             _test += _option
           }
-        } else if (item.type == 3) {
+        } else if (item.type == 3 && item.json.answer2) {
           let _option = `<div style='margin:10px 0 0 40px;'>${item.json.answer2}</div>`
           _test += _option
-        } else if (item.type == 5) {
+        } else if (item.type == 5 && item.json.file) {
           for (let j = 0; j < item.json.file.length; j++) {
             let check = item.json.file[j]
             let _option = `<div style='margin:10px 0 0 40px;'>${check.name} <a href='${check.url}'>${check.url}</a></div>`
@@ -861,7 +864,7 @@ export default {
       }
       _test += `</div>`
       let _html = _title + _content + _detail + _test;
-      this.exportToWord(_data.name+' '+_data.time, _html);
+      this.exportToWord(_data.name + '-' + _data.time, _html);
     },
     setWordHtml2(data) {
       let _data = data
@@ -881,13 +884,13 @@ export default {
         if (item.type == 1) {
           for (let j = 0; j < item.json.array.length; j++) {
             let check = item.json.array[j]
-            let _option = `<div style='margin:10px 0 0 40px;'>${item.json.answer2.indexOf(j) == -1 ? '☐' : '☑'} ${check.option}</div>`
+            let _option = `<div style='margin:10px 0 0 40px;'>${(item.json.answer2 && item.json.answer2.indexOf(j) !== -1) ? '☑' : '☐'} ${check.option}</div>`
             _test += _option
           }
-        } else if (item.type == 3) {
+        } else if (item.type == 3 && item.json.answer2) {
           let _option = `<div style='margin:10px 0 0 40px;'>${item.json.answer2}</div>`
           _test += _option
-        } else if (item.type == 5) {
+        } else if (item.type == 5 && item.json.file) {
           for (let j = 0; j < item.json.file.length; j++) {
             let check = item.json.file[j]
             let _option = `<div style='margin:10px 0 0 40px;'>${check.name} <a href='${check.url}'>${check.url}</a></div>`
@@ -897,7 +900,7 @@ export default {
       }
       _test += `</div>`
       let _html = _title + _content + _detail + _test;
-      this.exportToWord(_data.username+' '+_data.time, _html);
+      this.exportToWord(_data.username + '-' + _data.time, _html);
     },
     async exportToWord(a, html) {
       // 将html文件中需要用到的数据挂载到store上
@@ -932,43 +935,165 @@ export default {
       link.click();
       document.body.removeChild(link);
     },
+    setWordHtmlAll(data) {
+      let _data = data
+
+      let _title = `<div style="font-size:40px;font-weight:bold;text-align:center;">${this.testJson.title}</div>`;
+      let score = this.score(data.courseJson)
+      let isScore = this.score2(data.courseJson)
+      let scoreContent = score ? `<b>(得分/总分)${isScore}/${score}</b>` : ''
+      let _content = `<div style="font-size:25px;text-align:center;margin-top: 20px;"><b style="margin-right:40px">(答题人)${_data.name}</b>${scoreContent}(填写范围)${this.testJson.juriP ? this.testJson.juriP : '所有人'}(提交时间)${_data.time}</div>`
+      let _detail = this.testJson.brief ? `<div style="font-size:25px;text-align:center;margin-top: 20px;">${this.testJson.brief}</div>` : ''
+
+      let _test = `<div style='margin-top:40px;'>`
+      for (let i = 0; i < _data.array.length; i++) {
+        let item = _data.array[i]
+        let _div = `<div style='margin-top:20px;font-weight:bold;'>${i + 1}、${item.json.title}</div>`
+        _test += _div
+        if (item.type == 1) {
+          for (let j = 0; j < item.json.array.length; j++) {
+            let check = item.json.array[j]
+            let _option = `<div style='margin:10px 0 0 40px;'>${(item.json.answer2 && item.json.answer2.indexOf(j) !== -1) ? '☑' : '☐'} ${check.option}</div>`
+            _test += _option
+          }
+        } else if (item.type == 3 && item.json.answer2) {
+          let _option = `<div style='margin:10px 0 0 40px;'>${item.json.answer2}</div>`
+          _test += _option
+        } else if (item.type == 5 && item.json.file) {
+          for (let j = 0; j < item.json.file.length; j++) {
+            let check = item.json.file[j]
+            let _option = `<div style='margin:10px 0 0 40px;'>${check.name} <a href='${check.url}'>${check.url}</a></div>`
+            _test += _option
+          }
+        }
+      }
+      _test += `</div>`
+      let _html = _title + _content + _detail + _test;
+      return this.exportToWordAll(_data.name + '-' + _data.time, _html);
+    },
+    setWordHtmlAll2(data) {
+      let _data = data
+      _data.array = this.JSONSetting(JSON.parse(JSON.stringify(JSON.parse(data.courseJson))))
+      let _title = `<div style="font-size:40px;font-weight:bold;text-align:center;">${this.testJson.title}</div>`;
+      let score = this.score(JSON.parse(data.courseJson))
+      let isScore = this.score2(JSON.parse(data.courseJson))
+      let scoreContent = score ? `<b>(得分/总分)${isScore}/${score}</b>` : ''
+      let _content = `<div style="font-size:25px;text-align:center;margin-top: 20px;"><b style="margin-right:40px">(答题人)${_data.username}</b>${scoreContent}(填写范围)${this.testJson.juriP ? this.testJson.juriP : '所有人'}(提交时间)${_data.time}</div>`
+      let _detail = this.testJson.brief ? `<div style="font-size:25px;text-align:center;margin-top: 20px;">${this.testJson.brief}</div>` : ''
+
+      let _test = `<div style='margin-top:40px;'>`
+      for (let i = 0; i < _data.array.length; i++) {
+        let item = _data.array[i]
+        let _div = `<div style='margin-top:20px;font-weight:bold;'>${i + 1}、${item.json.title}</div>`
+        _test += _div
+        if (item.type == 1) {
+          for (let j = 0; j < item.json.array.length; j++) {
+            let check = item.json.array[j]
+            let _option = `<div style='margin:10px 0 0 40px;'>${(item.json.answer2 && item.json.answer2.indexOf(j) !== -1) ? '☑' : '☐'} ${check.option}</div>`
+            _test += _option
+          }
+        } else if (item.type == 3 && item.json.answer2) {
+          let _option = `<div style='margin:10px 0 0 40px;'>${item.json.answer2}</div>`
+          _test += _option
+        } else if (item.type == 5 && item.json.file) {
+          for (let j = 0; j < item.json.file.length; j++) {
+            let check = item.json.file[j]
+            let _option = `<div style='margin:10px 0 0 40px;'>${check.name} <a href='${check.url}'>${check.url}</a></div>`
+            _test += _option
+          }
+        }
+      }
+      _test += `</div>`
+      let _html = _title + _content + _detail + _test;
+      return this.exportToWordAll(_data.username + '-' + _data.time, _html);
+    },
+    async exportToWordAll(a, html) {
+      // 将html文件中需要用到的数据挂载到store上
+      const content = `<!DOCTYPE html>
+      <html lang="en">
+      <head>
+          <meta charset="UTF-8">
+          <meta http-equiv="X-UA-Compatible" content="IE=edge">
+          <meta name="viewport" content="width=device-width, initial-scale=1.0">
+          <title>${a}</title>
+          <style>
+          </style>
+      </head>
+      <body>
+      ${html}
+      </body>
+      </html>`;
+      // debugger
+      // 生成报告
+      const link = document.createElement("a");
+      let dname = a + ".doc";
+      // link.download = "报告.html"; // 文件名
+      link.download = dname; // 文件名
+      link.style.display = "none";
+      // 创建文件流
+      // 创建bolb实例时,内容一定要放在[]中
+      const blob = new Blob([content], {
+        type: "text/plain;charset='utf-8'",
+      });
+      return blob;
+    },
     exportAllWord() {
-      this.isloading = true;
-      const _chapInfo = this.checkJson.file;
+      this.pdfLoading = true;
+      const _chapInfo = this.worksArray;
       let url = [];
       for (let i = 0; i < _chapInfo.length; i++) {
         url.push({
-          name: _chapInfo[i].name,
-          url: _chapInfo[i].url,
+          name: _chapInfo[i].name + '-' + _chapInfo[i].time,
+          blob: this.setWordHtmlAll(_chapInfo[i]),
         });
       }
       console.log(url);
       this.downLoadAll(url);
     },
+    exportAllWord2() {
+      this.pdfLoading = true;
+
+      let params = {
+        cid: this.cid,
+        page: 1,
+        pageSize: 999,
+        cn: this.courseName
+      };
+      this.ajax
+        .get(this.$store.state.api + "getTestWorksPage3", params)
+        .then((res) => {
+          const _chapInfo = res.data[0];
+          let url = [];
+          for (let i = 0; i < _chapInfo.length; i++) {
+            url.push({
+              name: _chapInfo[i].username + '-' + _chapInfo[i].time,
+              blob: this.setWordHtmlAll2(_chapInfo[i]),
+            });
+          }
+          console.log(url);
+          this.downLoadAll(url);
+        })
+        .catch((err) => {
+          console.error(err);
+        });
+      
+    },
     downLoadAll(url) {
       const data = url; // 需要下载打包的路径, 可以是本地相对路径, 也可以是跨域的全路径
       const zip = new JSZip();
       const cache = {};
-      const promises = [];
       data.forEach((item) => {
-        const promise = getFile(item.url).then((data) => {
-          if (data.data != 1) {
-            // 下载文件, 并存成ArrayBuffer对象
-            const file_name = item.name; // 获取文件名
-            zip.file(file_name, data.data, { binary: true }); // 逐个添加文件
-            cache[file_name] = data.data;
-          }
-        });
-        promises.push(promise);
+        // 下载文件, 并存成ArrayBuffer对象
+        const file_name = item.name; // 获取文件名
+        zip.file(file_name+'.doc', item.blob, { binary: true }); // 逐个添加文件
+        cache[file_name] = item.blob;
       });
-      Promise.all(promises).then(() => {
-        zip.generateAsync({ type: "blob" }).then((content) => {
-          // 生成二进制流
-          FileSaver.saveAs(content, "附件.zip"); // 利用file-saver保存文件  自定义文件名
-          setTimeout(() => {
-            this.isloading = false;
-          }, 2000);
-        });
+      zip.generateAsync({ type: "blob" }).then((content) => {
+        // 生成二进制流
+        FileSaver.saveAs(content, this.testJson.title+".zip"); // 利用file-saver保存文件  自定义文件名
+        setTimeout(() => {
+          this.pdfLoading = false;
+        }, 2000);
       });
     },
   },

Some files were not shown because too many files changed in this diff