Browse Source

2022-10-10 update

1. 新增 html模板导出word的js插件. 暂未调用
2. 添加及编辑试卷页 缓存逻辑需后台修改routes配置项即可
moccus 2 years ago
parent
commit
2d94cb847c

+ 36 - 0
exam-06173-vue/src/utils/export-word.js

@@ -0,0 +1,36 @@
+const Export2Word = (element, filename = '') => {
+  var preHtml = "<html xmlns:o='urn:schemas-microsoft-com:office:office' xmlns:w='urn:schemas-microsoft-com:office:word' xmlns='http://www.w3.org/TR/REC-html40'><head><meta charset='utf-8'><title>Export HTML To Doc</title></head><body>";
+  var postHtml = "</body></html>";
+  var html = preHtml + document.getElementById(element).innerHTML + postHtml;
+
+  var blob = new Blob(['\ufeff', html], {
+    type: 'application/msword'
+  });
+
+  // Specify link url
+  var url = 'data:application/vnd.ms-word;charset=utf-8,' + encodeURIComponent(html);
+
+  // Specify file name
+  filename = filename ? filename + '.doc' : 'document.doc';
+
+  // Create download link element
+  var downloadLink = document.createElement("a");
+
+  document.body.appendChild(downloadLink);
+
+  if (navigator.msSaveOrOpenBlob) {
+    navigator.msSaveOrOpenBlob(blob, filename);
+  } else {
+    // Create a link to the file
+    downloadLink.href = url;
+
+    // Setting the file name
+    downloadLink.download = filename;
+
+    //triggering the function
+    downloadLink.click();
+  }
+
+  document.body.removeChild(downloadLink);
+}
+export default Export2Word

+ 27 - 44
exam-06173-vue/src/views/admin/repo/qu/components/QuSelectDialog.vue

@@ -1,21 +1,10 @@
 <template>
 
-  <el-dialog
-    :visible.sync="dialogVisible"
-    :close-on-click-modal="false"
-    title="选择试题"
-    width="60%"
-    @close="handleClose"
-  >
+  <el-dialog :visible.sync="dialogVisible" :close-on-click-modal="false" title="选择试题" width="60%" @close="handleClose">
 
     <div class="app-container">
 
-      <data-table
-        ref="pagingTable"
-        :options="options"
-        :list-query="listQuery"
-        @select-changed="handleSelected"
-      >
+      <data-table ref="pagingTable" :options="options" :list-query="listQuery" @select-changed="handleSelected">
         <template slot="filter-content">
 
           <el-row>
@@ -23,9 +12,11 @@
 
               <repo-select v-model="listQuery.params.repoId" :is-exam="true" />
 
-              <el-input v-model="listQuery.params.content" placeholder="试题内容" style="width: 200px;" class="filter-item" />
+              <el-input v-model="listQuery.params.content" placeholder="试题内容" style="width: 200px;"
+                class="filter-item" />
 
-              <el-button type="primary" class="filter-item" style="float:  right" @click="handleConfirm">{{ selectedLabel }}</el-button>
+              <el-button type="primary" class="filter-item" style="float:  right" @click="handleConfirm">{{
+              selectedLabel }}</el-button>
 
             </el-col>
           </el-row>
@@ -34,35 +25,20 @@
 
         <template slot="data-columns">
 
-          <el-table-column
-            label="试题类型"
-            align="center"
-            width="100px"
-            prop="quType_dictText"
-          />
-
-          <el-table-column
-            label="试题内容"
-            show-overflow-tooltip
-          >
+          <el-table-column label="试题类型" align="center" width="100px" prop="quType_dictText" />
+
+          <el-table-column label="试题内容" show-overflow-tooltip>
             <template slot-scope="scope">
-              <router-link :to="{ name: 'UpdateQu', params:{ id: scope.row.id}}">
-                {{ scope.row.contentText }}
-              </router-link>
+              <a href="javascript:;" @click="funPush('UpdateQu', {id: scope.row.id})">{{ scope.row.contentText }}</a>
+              <!-- <router-link :to="{ name: 'UpdateQu', params:{ id: scope.row.id}}"> -->
+
+              <!-- </router-link> -->
             </template>
           </el-table-column>
 
-          <el-table-column
-            label="所属题库"
-            align="center"
-            prop="repoId_dictText"
-          />
+          <el-table-column label="所属题库" align="center" prop="repoId_dictText" />
 
-          <el-table-column
-            label="级别"
-            align="center"
-            prop="level_dictText"
-          />
+          <el-table-column label="级别" align="center" prop="level_dictText" />
 
         </template>
 
@@ -168,6 +144,15 @@ export default {
       this.$emit('update:dialogShow', false)
       this.$emit('select', this.selectedList)
       this.$refs.pagingTable.clearSelection()
+    },
+    funPush(name, params) {
+      this.$emit('update:dialogShow', false)
+      this.$emit('select', this.selectedList)
+      this.$refs.pagingTable.clearSelection()
+      this.$router.push({
+        name,
+        params
+      })
     }
 
   }
@@ -175,9 +160,7 @@ export default {
 </script>
 
 <style scoped>
-
-  ::v-deep
-  .el-dialog__body{
-    padding: 0px;
-  }
+::v-deep .el-dialog__body {
+  padding: 0px;
+}
 </style>

+ 4 - 1
exam-06173-vue/src/views/admin/tmpl/form.vue

@@ -14,8 +14,9 @@
 <script>
 import Join1Form from '@/views/admin/tmpl/components/Join1Form'
 import { apiFindTmpl } from '@/api/tmpl/tmpl'
-
+let name = 'ExamTmplAdd'
 export default {
+  name: name,
   components: {
     Join1Form
   },
@@ -40,7 +41,9 @@ export default {
 
     // 查找详情
     const id = this.$route.params.id
+    name = 'ExamTmplAdd'
     if (id !== undefined) {
+      name = 'ExamTmplUpdate'
       this.fetchData(id)
     }
   },

+ 2 - 0
exam-06173-vue/src/views/dashboard/index.vue

@@ -155,6 +155,7 @@
 
 <script>
 import * as echarts from "echarts";
+import exportWord from '@/utils/export-word'
 import {
   getCttTotal,
   getCurrentExam,
@@ -184,6 +185,7 @@ export default {
     this.initChart();
     this.getCttTotal();
     this.getCurrentExam();
+    // exportWord('app', 'app')
   },
   methods: {
     // 获取统计数值