lsc 1 year ago
parent
commit
c672d2289b

+ 1 - 1
dist/index.html

@@ -25,7 +25,7 @@
       height: 100%;
       width: 100%;
       background: #e6eaf0;
-    }</style><link href=./static/css/app.d27710b54fde679b5a9dcee1a4a30527.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.ec3d1d4bcaf07cff2996.js></script></body></html><script>function stopSafari() {
+    }</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() {
     //阻止safari浏览器双击放大功能
     let lastTouchEnd = 0  //更新手指弹起的时间
     document.documentElement.addEventListener("touchstart", function (event) {

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


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


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


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


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


+ 108 - 9
src/components/pages/test/check/index.vue

@@ -168,8 +168,8 @@
               </el-table-column>
               <el-table-column prop="time" label="提交时间" width="170px" align="left">
               </el-table-column>
-              <el-table-column v-for="(item, index) in chapters" :key="index" :label="item.json.title" :min-width="item.type == 5 ? 200 : 150"
-                align="left" :filters="item.type == 1 ? item.nameFilters : null"
+              <el-table-column v-for="(item, index) in chapters" :key="index" :label="item.json.title"
+                :min-width="item.type == 5 ? 200 : 150" align="left" :filters="item.type == 1 ? item.nameFilters : null"
                 :filter-method="item.type == 1 ? (value, row) => { return filterName(value, row, index) } : null"
                 :filter-placement="item.type == 1 ? filterPlacement : null">
                 <template slot-scope="scope">
@@ -202,7 +202,7 @@
               <el-table-column label="操作" width="300px" fixed="right">
                 <template slot-scope="scope">
                   <el-button @click="getTest(scope.row)" type="primary" size="small">查看</el-button>
-                  <!-- <el-button @click="setWordHtml(scope.row)" type="primary" size="small">导出答题信息</el-button> -->
+                  <el-button @click="setWordHtml(scope.row)" type="primary" size="small">导出答题信息</el-button>
                   <el-button @click="deleteTest(scope.row.id)" type="primary" size="small">删除</el-button>
                 </template>
               </el-table-column>
@@ -222,9 +222,10 @@
                     <div>{{ scope.row.type == 3 ? '是' : '否' }}</div>
                   </template>
                 </el-table-column>
-                <el-table-column label="操作" width="200px">
+                <el-table-column label="操作" width="300px">
                   <template slot-scope="scope">
                     <el-button @click="getTest(scope.row)" type="primary" size="small">查看</el-button>
+                    <el-button @click="setWordHtml2(scope.row)" type="primary" size="small">导出答题信息</el-button>
                     <el-button @click="deleteTest(scope.row.id)" type="primary" size="small">删除</el-button>
                   </template>
                 </el-table-column>
@@ -828,16 +829,75 @@ export default {
     },
     setWordHtml(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 _detail = this.testJson.brief ? `<div style="font-size:25px;text-align:center;margin-top: 20px;">${this.testJson.brief}</div>` : ''
 
-      let _html = _title + _content + _detail;
-      this.exportToWord(_data.name, _html);
+      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.indexOf(j) == -1 ? '☐' : '☑'} ${check.option}</div>`
+            _test += _option
+          }
+        } else if (item.type == 3) {
+          let _option = `<div style='margin:10px 0 0 40px;'>${item.json.answer2}</div>`
+          _test += _option
+        } else if (item.type == 5) {
+          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;
+      this.exportToWord(_data.name+' '+_data.time, _html);
+    },
+    setWordHtml2(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.indexOf(j) == -1 ? '☐' : '☑'} ${check.option}</div>`
+            _test += _option
+          }
+        } else if (item.type == 3) {
+          let _option = `<div style='margin:10px 0 0 40px;'>${item.json.answer2}</div>`
+          _test += _option
+        } else if (item.type == 5) {
+          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;
+      this.exportToWord(_data.username+' '+_data.time, _html);
     },
     async exportToWord(a, html) {
       // 将html文件中需要用到的数据挂载到store上
@@ -871,7 +931,46 @@ export default {
       document.body.appendChild(link);
       link.click();
       document.body.removeChild(link);
-    }
+    },
+    exportAllWord() {
+      this.isloading = true;
+      const _chapInfo = this.checkJson.file;
+      let url = [];
+      for (let i = 0; i < _chapInfo.length; i++) {
+        url.push({
+          name: _chapInfo[i].name,
+          url: _chapInfo[i].url,
+        });
+      }
+      console.log(url);
+      this.downLoadAll(url);
+    },
+    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);
+      });
+      Promise.all(promises).then(() => {
+        zip.generateAsync({ type: "blob" }).then((content) => {
+          // 生成二进制流
+          FileSaver.saveAs(content, "附件.zip"); // 利用file-saver保存文件  自定义文件名
+          setTimeout(() => {
+            this.isloading = false;
+          }, 2000);
+        });
+      });
+    },
   },
   beforeDestroy() {
     document.getElementsByTagName('html')[0].style.overflow = ''

+ 118 - 113
src/components/pages/testStudent/view/component/file.vue

@@ -7,9 +7,10 @@
             <div class="c_title">
                 <div class="title" style="display: flex;">
                     <!-- + `(${option[checkJson.type].name})` -->
-                    <span style="min-width: fit-content;">{{ tindex + 1 + "、"  }}</span>
+                    <span style="min-width: fit-content;">{{ tindex + 1 + "、" }}</span>
                     <span>{{ checkJson.title }}</span>
-                    <span style="color: #efa030;min-width: fit-content;" v-if="checkJson.score">({{ '分值:' + checkJson.score + '分' }})</span>
+                    <span style="color: #efa030;min-width: fit-content;" v-if="checkJson.score">({{ '分值:' + checkJson.score
+                        + '分' }})</span>
                 </div>
 
                 <!-- </div><div v-html="checkJson.title"></div> -->
@@ -30,9 +31,12 @@
                 <div class="binfo_input">
                     <div class="fileBox" v-if="checkJson.file && checkJson.file.length">
                         <div class="fileC">
-                            <div class="file" v-for="(item, index) in checkJson.file" :key="index" v-loading="downLoading == item.url" @click.stop="checkFile(item)">
-                                <img class="del" src="../../../../../assets/icon/fileIcon/deleteworks.png"  @click.stop="delFile(index)" v-if="checktype == 1" />
-                                <img class="download" src="../../../../../assets/icon/fileIcon/download.png" @click.stop="downloadFile(item)" :style="{right: checktype != 1 ? '10px' : '45px'}" />
+                            <div class="file" v-for="(item, index) in checkJson.file" :key="index"
+                                v-loading="downLoading == item.url" @click.stop="checkFile(item)">
+                                <img class="del" src="../../../../../assets/icon/fileIcon/deleteworks.png"
+                                    @click.stop="delFile(index)" v-if="checktype == 1" />
+                                <img class="download" src="../../../../../assets/icon/fileIcon/download.png"
+                                    @click.stop="downloadFile(item)" :style="{ right: checktype != 1 ? '10px' : '45px' }" />
                                 <img class="img" :src="wordIcon" alt="" v-if="item.type == 1" />
                                 <img class="img" :src="videoIcon" alt="" v-if="item.type == 2" />
                                 <img class="img" :src="item.url" alt="" v-if="item.type == 3" />
@@ -103,42 +107,42 @@ import JSZip from "jszip";
 import FileSaver from "file-saver";
 
 const getFile = (url) => {
-  return new Promise((resolve, reject) => {
-    var credentials = {
-        accessKeyId: "AKIATLPEDU37QV5CHLMH",
-        secretAccessKey: "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",
-      }; //秘钥形式的登录上传
-      window.AWS.config.update(credentials);
-      window.AWS.config.region = "cn-northwest-1"; //设置区域
-      let url2 = url;
-      let _url2 = "";
-      if (
-        url2.indexOf("https://view.officeapps.live.com/op/view.aspx?src=") != -1
-      ) {
-        _url2 = url2.split(
-          "https://view.officeapps.live.com/op/view.aspx?src="
-        )[1];
-      } else {
-        _url2 = url2;
-      }
-      var s3 = new window.AWS.S3({ params: { Bucket: "ccrb" } });
-      let name = decodeURIComponent(_url2.split("https://ccrb.s3.cn-northwest-1.amazonaws.com.cn/")[1])
-      var params = {
-        Bucket: "ccrb",
-        Key: name
-      };
-      s3.getObject(params, function (err, data) {
-        if (err) {
-          console.log(err, err.stack)
-          resolve({ data: 1 });
-        }else {
-          resolve({ data: data.Body });
-          console.log(data); 
-        }          // sxuccessful response
-
-      });
-    // axios({
-  });
+    return new Promise((resolve, reject) => {
+        var credentials = {
+            accessKeyId: "AKIATLPEDU37QV5CHLMH",
+            secretAccessKey: "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",
+        }; //秘钥形式的登录上传
+        window.AWS.config.update(credentials);
+        window.AWS.config.region = "cn-northwest-1"; //设置区域
+        let url2 = url;
+        let _url2 = "";
+        if (
+            url2.indexOf("https://view.officeapps.live.com/op/view.aspx?src=") != -1
+        ) {
+            _url2 = url2.split(
+                "https://view.officeapps.live.com/op/view.aspx?src="
+            )[1];
+        } else {
+            _url2 = url2;
+        }
+        var s3 = new window.AWS.S3({ params: { Bucket: "ccrb" } });
+        let name = decodeURIComponent(_url2.split("https://ccrb.s3.cn-northwest-1.amazonaws.com.cn/")[1])
+        var params = {
+            Bucket: "ccrb",
+            Key: name
+        };
+        s3.getObject(params, function (err, data) {
+            if (err) {
+                console.log(err, err.stack)
+                resolve({ data: 1 });
+            } else {
+                resolve({ data: data.Body });
+                console.log(data);
+            }          // sxuccessful response
+
+        });
+        // axios({
+    });
 };
 
 export default {
@@ -149,7 +153,7 @@ export default {
         checkfile
     },
     props: {
-        tindex:{
+        tindex: {
             type: Number
         },
         cJson: {
@@ -182,9 +186,9 @@ export default {
             wordIcon: wordIcon,
             fileIcon: fileIcon,
             downLoading: '',
-            dialogVisiblePdf:false,
-            dialogVisibleVideo:false,
-            dialogVisibleOffice:false,
+            dialogVisiblePdf: false,
+            dialogVisibleVideo: false,
+            dialogVisibleOffice: false,
             dialogVisiblefile: false,
             wurl: "",
             isloading: false,
@@ -215,7 +219,7 @@ export default {
                 this.$message.error('请输入大于0的数字')
                 this.checkJson.score2 = ''
             }
-            if(parseInt(this.checkJson.score2) > parseInt(this.checkJson.score)){
+            if (parseInt(this.checkJson.score2) > parseInt(this.checkJson.score)) {
                 this.$message.error('不能输入大于得分的数字')
                 this.checkJson.score2 = this.checkJson.score
             }
@@ -454,18 +458,18 @@ export default {
             }
             this.$forceUpdate();
         },
-        checkFile(item){
-            if(item.type == 3){
+        checkFile(item) {
+            if (item.type == 3) {
                 this.$hevueImgPreview(item.url);
-            }else if(item.type == 5){
+            } else if (item.type == 5) {
                 this.downloadFile(item);
-            }else if(item.type == 1){
+            } else if (item.type == 1) {
                 this.dialogVisibleOffice = true
                 this.wurl = item.url
-            }else if(item.type == 2){
+            } else if (item.type == 2) {
                 this.dialogVisibleVideo = true
                 this.wurl = item.url
-            }else if(item.type == 4){
+            } else if (item.type == 4) {
                 this.dialogVisiblePdf = true
                 this.wurl = item.url
             }
@@ -475,44 +479,44 @@ export default {
             this.$forceUpdate();
         },
         uploadCourse() {
-          this.isloading = true;
-          const _chapInfo = this.checkJson.file;
-          let url = [];
-          for (let i = 0; i < _chapInfo.length; i++) {
-            url.push({
-                name: _chapInfo[i].name,
-                url: _chapInfo[i].url,
+            this.isloading = true;
+            const _chapInfo = this.checkJson.file;
+            let url = [];
+            for (let i = 0; i < _chapInfo.length; i++) {
+                url.push({
+                    name: _chapInfo[i].name,
+                    url: _chapInfo[i].url,
+                });
+            }
+            console.log(url);
+            this.downLoadAll(url);
+        },
+        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);
             });
-          }
-          console.log(url);
-          this.downLoadAll(url);
-    },
-    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);
-      });
-      Promise.all(promises).then(() => {
-        zip.generateAsync({ type: "blob" }).then((content) => {
-          // 生成二进制流
-          FileSaver.saveAs(content, "附件.zip"); // 利用file-saver保存文件  自定义文件名
-          setTimeout(() => {
-            this.isloading = false;
-          }, 2000);
-        });
-      });
-    },
+            Promise.all(promises).then(() => {
+                zip.generateAsync({ type: "blob" }).then((content) => {
+                    // 生成二进制流
+                    FileSaver.saveAs(content, "附件.zip"); // 利用file-saver保存文件  自定义文件名
+                    setTimeout(() => {
+                        this.isloading = false;
+                    }, 2000);
+                });
+            });
+        },
     },
     mounted() {
         this.checkJson = this.cJson ? this.depthCopy(this.cJson) : undefined
@@ -577,7 +581,7 @@ export default {
     align-items: center;
     justify-content: center;
     background: rgb(249, 250, 251);
-    color:rgb(124, 124, 124);
+    color: rgb(124, 124, 124);
     border-radius: 5px;
     cursor: pointer;
 }
@@ -716,48 +720,49 @@ export default {
     justify-content: center;
     cursor: pointer;
 }
-.choice_box> .c_title {
+
+.choice_box>.c_title {
     display: flex;
     justify-content: space-between;
 }
-.choice_box> .c_title .title {
+
+.choice_box>.c_title .title {
     font-weight: bold;
     width: 100%;
     word-break: break-all;
 }
 
-.choice_box> .c_title .p_box{
+.choice_box>.c_title .p_box {
     margin-left: 5px;
     min-width: fit-content;
     display: flex;
     align-items: center;
 }
 
-.p_box > .btnU{
-color: #fff;
-  background-color: #0061FF;
-  padding: 0 24px;
-  font-size: 14px;
-  min-width: 64px;
-  font-weight: 500;
-  border-radius: 4px;
-  box-sizing: border-box;
-  border: none;
-  cursor: pointer;
-  transition: all 0.2s ease-in-out;
-  height: 36px;
-  display: flex;
-  align-items: center;
-  justify-content: center;
-  line-height: 1;
+.p_box>.btnU {
+    color: #fff;
+    background-color: #0061FF;
+    padding: 0 24px;
+    font-size: 14px;
+    min-width: 64px;
+    font-weight: 500;
+    border-radius: 4px;
+    box-sizing: border-box;
+    border: none;
+    cursor: pointer;
+    transition: all 0.2s ease-in-out;
+    height: 36px;
+    display: flex;
+    align-items: center;
+    justify-content: center;
+    line-height: 1;
 }
 
 .c_input {
     width: 90px;
 }
 
-.c_input >>> .el-input__inner{
+.c_input>>>.el-input__inner {
     padding: 0 5px;
     text-align: right;
-}
-</style>
+}</style>

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