소스 검색

3.0阅卷前端改造(格式优化)

nikang 6 년 전
부모
커밋
287d02bf88

+ 1 - 0
src/filters/filters.js

@@ -1 +1,2 @@
 import "../modules/questions/filters/filters";
+import "../modules/marking/filters/filters";

+ 1 - 33
src/modules/marking/constants/constants.js

@@ -1,41 +1,9 @@
 import Vue from "vue";
 
-export const UPAI_YUN = "http://exam-cloud-test.b0.upaiyun.com"; //又拍云前端显示
-
 export const LEVEL_TYPE = [
   { label: "专升本", value: "ZSB" },
   { label: "高起专", value: "GQZ" },
   { label: "不限", value: "ALL" }
 ];
-//标记卷类型
-export const TAGS = [
-  { label: "雷同卷", value: "SAME" },
-  { label: "空白卷", value: "BLANK" },
-  { label: "答非所问", value: "IRRELEVANT" },
-  { label: "科目错误", value: "SUBJECT_ERROR" },
-  { label: "非手写", value: "QUESTIONABLE" }
-];
-//标记卷过滤器
-Vue.filter("tagFilter", function(val) {
-  for (let tag of TAGS) {
-    if (tag.value === val) {
-      return tag.label;
-    }
-  }
-});
-//考试类型
-export const EXAMTYPES = [
-  { label: "在线考试", value: "ONLINE" },
-  { label: "离线考试", value: "OFFLINE" },
-  { label: "传统考试", value: "TRADITION" },
-  { label: "练习", value: "PRACTICE" }
-];
-//考试类型过滤器
-Vue.filter("examTypeFilter", function(val) {
-  for (let examType of EXAMTYPES) {
-    if (examType.value === val) {
-      return examType.label;
-    }
-  }
-});
+
 export const EVENTHUB = new Vue();

+ 32 - 0
src/modules/marking/filters/filters.js

@@ -0,0 +1,32 @@
+import Vue from "vue";
+//标记卷类型
+export const TAGS = [
+  { label: "雷同卷", value: "SAME" },
+  { label: "空白卷", value: "BLANK" },
+  { label: "答非所问", value: "IRRELEVANT" },
+  { label: "科目错误", value: "SUBJECT_ERROR" },
+  { label: "非手写", value: "QUESTIONABLE" }
+];
+//标记卷过滤器
+Vue.filter("tagFilter", function(val) {
+  for (let tag of TAGS) {
+    if (tag.value === val) {
+      return tag.label;
+    }
+  }
+});
+//考试类型
+export const EXAMTYPES = [
+  { label: "在线考试", value: "ONLINE" },
+  { label: "离线考试", value: "OFFLINE" },
+  { label: "传统考试", value: "TRADITION" },
+  { label: "练习", value: "PRACTICE" }
+];
+//考试类型过滤器
+Vue.filter("examTypeFilter", function(val) {
+  for (let examType of EXAMTYPES) {
+    if (examType.value === val) {
+      return examType.label;
+    }
+  }
+});

+ 0 - 126
src/modules/marking/store/Print.js

@@ -1,126 +0,0 @@
-/* @Print.js
- * DH (http://denghao.me)
- * 2017-7-14
- */
-export function Print(dom, options) {
-  if (!(this instanceof Print)) return new Print(dom, options);
-
-  this.options = this.extend(
-    {
-      noPrint: ".no-print"
-    },
-    options
-  );
-
-  if (typeof dom === "string") {
-    this.dom = document.querySelector(dom);
-  } else {
-    this.dom = dom;
-  }
-
-  this.init();
-}
-Print.prototype = {
-  init: function() {
-    var content = this.getStyle() + this.getHtml();
-    this.writeIframe(content);
-  },
-  extend: function(obj, obj2) {
-    for (var k in obj2) {
-      obj[k] = obj2[k];
-    }
-    return obj;
-  },
-
-  getStyle: function() {
-    var str = "",
-      styles = document.querySelectorAll("style,link");
-    for (var i = 0; i < styles.length; i++) {
-      str += styles[i].outerHTML;
-    }
-    str +=
-      "<style>" +
-      (this.options.noPrint ? this.options.noPrint : ".no-print") +
-      "{display:none;}</style>";
-
-    return str;
-  },
-
-  getHtml: function() {
-    var inputs = document.querySelectorAll("input");
-    var textareas = document.querySelectorAll("textarea");
-    var selects = document.querySelectorAll("select");
-
-    for (var k in inputs) {
-      if (inputs[k].type == "checkbox" || inputs[k].type == "radio") {
-        if (inputs[k].checked == true) {
-          inputs[k].setAttribute("checked", "checked");
-        } else {
-          inputs[k].removeAttribute("checked");
-        }
-      } else if (inputs[k].type == "text") {
-        inputs[k].setAttribute("value", inputs[k].value);
-      }
-    }
-
-    for (var k2 in textareas) {
-      if (textareas[k2].type == "textarea") {
-        textareas[k2].innerHTML = textareas[k2].value;
-      }
-    }
-
-    for (var k3 in selects) {
-      if (selects[k3].type == "select-one") {
-        var child = selects[k3].children;
-        for (var i in child) {
-          if (child[i].tagName == "OPTION") {
-            if (child[i].selected == true) {
-              child[i].setAttribute("selected", "selected");
-            } else {
-              child[i].removeAttribute("selected");
-            }
-          }
-        }
-      }
-    }
-
-    return this.dom.outerHTML;
-  },
-
-  writeIframe: function(content) {
-    var w,
-      doc,
-      iframe = document.createElement("iframe"),
-      f = document.body.appendChild(iframe);
-    iframe.id = "myIframe";
-    iframe.style = "position:absolute;width:0;height:0;top:-10px;left:-10px;";
-
-    w = f.contentWindow || f.contentDocument;
-    doc = f.contentDocument || f.contentWindow.document;
-    doc.open();
-    doc.write(content);
-    doc.close();
-    this.toPrint(w);
-    // setTimeout(function() {
-    //   document.body.removeChild(iframe)
-    // }, 100)
-  },
-
-  toPrint: function(frameWindow) {
-    try {
-      setTimeout(function() {
-        frameWindow.focus();
-        try {
-          if (!frameWindow.document.execCommand("print", false, null)) {
-            frameWindow.print();
-          }
-        } catch (e) {
-          frameWindow.print();
-        }
-        frameWindow.close();
-      }, 1000);
-    } catch (err) {
-      console.log("err", err);
-    }
-  }
-};

+ 35 - 21
src/modules/marking/views/MarkWorkOverview.vue

@@ -11,8 +11,8 @@
 
         <div class="box-body">
           <div class="echarts">
-            <!-- <div class="pie"><IEcharts :option="pie"></IEcharts></div> -->
-            <!-- <div class="pie"><IEcharts :option="pie1"></IEcharts></div> -->
+            <div class="pie"><v-charts :options="pie"></v-charts></div>
+            <div class="pie"><v-charts :options="pie1"></v-charts></div>
           </div>
 
           <el-form
@@ -31,14 +31,13 @@
                     v-model="formSearch.courseCode"
                     placeholder="请选择"
                   >
-                    <el-option value="">请选择</el-option>
+                    <el-option value>请选择</el-option>
                     <el-option
                       v-for="item in courseAllListSelect"
                       :label="item.courseInfo"
                       :value="item.code"
                       :key="item.code"
-                    >
-                    </el-option>
+                    ></el-option>
                   </el-select>
                 </el-form-item>
                 <el-form-item>
@@ -61,16 +60,31 @@
             border
             style="width: 100%"
           >
-            <el-table-column label="课程名称" width="200" prop="name">
-            </el-table-column>
-            <el-table-column label="课程代码" min-width="100" prop="code">
-            </el-table-column>
-            <el-table-column label="任务总数" min-width="100" prop="totalCount">
-            </el-table-column>
-            <el-table-column label="完成数" min-width="100" prop="markedCount">
-            </el-table-column>
-            <el-table-column label="待完成" min-width="100" prop="leftCount">
-            </el-table-column>
+            <el-table-column
+              label="课程名称"
+              width="200"
+              prop="name"
+            ></el-table-column>
+            <el-table-column
+              label="课程代码"
+              min-width="100"
+              prop="code"
+            ></el-table-column>
+            <el-table-column
+              label="任务总数"
+              min-width="100"
+              prop="totalCount"
+            ></el-table-column>
+            <el-table-column
+              label="完成数"
+              min-width="100"
+              prop="markedCount"
+            ></el-table-column>
+            <el-table-column
+              label="待完成"
+              min-width="100"
+              prop="leftCount"
+            ></el-table-column>
             <el-table-column label="进度" min-width="100">
               <template slot-scope="scope">
                 <div>
@@ -97,8 +111,7 @@
               :page-size="10"
               layout="total, prev, pager, next, jumper"
               :total="total"
-            >
-            </el-pagination>
+            ></el-pagination>
           </div>
         </div>
       </div>
@@ -109,10 +122,11 @@
 <script>
 import { MARKING_API } from "@/constants/constants";
 import { mapState } from "vuex";
-// import IEcharts from 'vue-echarts-v3/src/full.vue'
+import ECharts from "vue-echarts/components/ECharts";
+import "echarts/lib/chart/pie";
 export default {
   components: {
-    // IEcharts
+    "v-charts": ECharts
   },
   data() {
     return {
@@ -132,7 +146,7 @@ export default {
       pie: {
         title: {
           text: "试卷进度情况",
-          x: "center"
+          left: "center"
         },
         tooltip: {
           trigger: "item",
@@ -182,7 +196,7 @@ export default {
       pie1: {
         title: {
           text: "课程进度情况",
-          x: "center"
+          left: "center"
         },
         tooltip: {
           trigger: "item",

+ 18 - 16
src/modules/marking/views/TpMain.vue

@@ -12,12 +12,12 @@
             <div class="paper" v-show="this.markSign">
               <div class="fixed marktitle signTitle">
                 <el-button-group class="itemTitle">
-                  <el-button type="info" size="small"
-                    ><span class="">当前题</span></el-button
-                  >
-                  <el-button type="info" size="small"
-                    ><span class="">{{ itemTitle }}</span></el-button
-                  >
+                  <el-button type="info" size="small">
+                    <span class>当前题</span>
+                  </el-button>
+                  <el-button type="info" size="small">
+                    <span class>{{ itemTitle }}</span>
+                  </el-button>
                 </el-button-group>
                 <!--
                   <el-button type="primary" size="small" @click="saveMarkSign">保存轨迹</el-button>
@@ -47,9 +47,9 @@
               style="float: right;margin-right: 20px;"
               class="no-print"
             >
-              <el-button size="small" type="success" @click="pdfDown();">
-                下载
-              </el-button>
+              <el-button size="small" type="success" @click="pdfDown();"
+                >下载</el-button
+              >
             </div>
           </div>
         </div>
@@ -58,9 +58,9 @@
         <el-tab-pane label="标答" name="second">
           <div id="answer-source" v-if="this.examType == 'OFFLINE'">
             <div style="float: right;margin-right: 20px;" class="no-print">
-              <el-button size="small" type="success" @click="printAnswer();">
-                打印
-              </el-button>
+              <el-button size="small" type="success" @click="printAnswer();"
+                >打印</el-button
+              >
             </div>
             <div
               class="paper"
@@ -75,8 +75,8 @@
 </template>
 <script>
 import { Drawing } from "../canvas/mark_sign";
-import { EVENTHUB, UPAI_YUN } from "../constants/constants";
-import { Print } from "../store/Print";
+import { EVENTHUB } from "../constants/constants";
+import printJS from "print-js";
 export default {
   data() {
     return {
@@ -256,12 +256,14 @@ export default {
     },
     //打印
     printAnswer() {
-      Print("#answer-source");
+      printJS({ printable: "answer-content", type: "html" });
     },
     pdfDown() {
       var url = this.studentPaper.studentSubjectiveHtml;
       if (url != "undefined" && url != "") {
-        url = url.replace(UPAI_YUN, "");
+        url = new URL(url);
+        url = url.pathname;
+        url = decodeURIComponent(url);
         let xhr = new XMLHttpRequest();
         xhr.responseType = "blob";
         xhr.open("GET", url, true);