소스 검색

题库:首页添加,路由配置

weiwenhai 6 년 전
부모
커밋
4a1876dff8
4개의 변경된 파일502개의 추가작업 그리고 1개의 파일을 삭제
  1. 88 0
      src/modules/questions/constants/constants.js
  2. 16 0
      src/modules/questions/routes/routes.js
  3. 396 0
      src/modules/questions/views/PaperStructure.vue
  4. 2 1
      src/router.js

+ 88 - 0
src/modules/questions/constants/constants.js

@@ -0,0 +1,88 @@
+import Vue from "vue";
+export const CORE_API = "/api/ecs_core"; //基础信息API
+export const EXAM_WORK_API = "/api/ecs_exam_work"; //考务信息API
+export const Q_API = "/api/ecs_ques"; //题库API
+export const LEVEL_TYPE = [
+  { label: "专升本", value: "ZSB" },
+  { label: "高起专", value: "GQZ" },
+  { label: "高起本", value: "GQB" },
+  { label: "不限", value: "ALL" }
+];
+export const questionTypes = [
+  { value: "SINGLE_ANSWER_QUESTION", label: "单选" },
+  { value: "MULTIPLE_ANSWER_QUESTION", label: "多选" },
+  { value: "BOOL_ANSWER_QUESTION", label: "判断" },
+  { value: "FILL_BLANK_QUESTION", label: "填空" },
+  { value: "TEXT_ANSWER_QUESTION", label: "问答" },
+  { value: "NESTED_ANSWER_QUESTION", label: "套题" }
+];
+//option字母顺序过滤器
+Vue.filter("optionOrderWordFilter", function(value) {
+  return String.fromCharCode(65 + value);
+});
+//题型过滤器
+Vue.filter("questionType", function(value) {
+  for (let questionType of questionTypes) {
+    if (questionType.value === value) {
+      return questionType.label;
+    }
+  }
+});
+
+export const examTypes = [
+  { value: "TRADITION", label: "传统考试" },
+  { value: "ONLINE", label: "网络考试" },
+  { value: "PRACTICE", label: "在线练习" }
+];
+
+export const exportTypes = [
+  { value: "ONLINE", label: "机考" },
+  { value: "NORMAL", label: "普通" }
+];
+
+Vue.filter("examTypesFilter", function(value) {
+  for (let item of examTypes) {
+    if (item.value === value) {
+      return item.label;
+    }
+  }
+});
+Vue.filter("exportTypesFilter", function(value) {
+  for (let item of exportTypes) {
+    if (item.value === value) {
+      return item.label;
+    }
+  }
+});
+
+// Vue.directive("questionAudio", {
+//   bind: function(el, binding, vnode) {
+//     addAudio(el, binding, vnode);
+//   },
+//   inserted: function(el, binding, vnode) {},
+//   update: function(el, binding, vnode) {},
+//   componentUpdated: function(el, binding, vnode) {},
+//   unbind: function(el, binding, vnode) {}
+// });
+
+// function addAudio(el, binding, vnode) {
+//   let $el = $(el);
+//   if (vnode.data.attrs.hasAudio) {
+//     $el.find("p>a").each(function() {
+//       var questionAudioId = $(this).attr("id");
+//       if (questionAudioId) {
+//         vnode.context.$http
+//           .get(Q_API + "/questionAudio/" + questionAudioId)
+//           .then(response => {
+//             if (response && response.body) {
+//               let audioFlag =
+//                 '<audio controls><source src="http://exam-cloud-test.b0.upaiyun.com' +
+//                 response.body.fileUrl +
+//                 '" type="audio/mpeg"></audio>';
+//               $(this).append(audioFlag);
+//             }
+//           });
+//       }
+//     });
+//   }
+// }

+ 16 - 0
src/modules/questions/routes/routes.js

@@ -0,0 +1,16 @@
+import Home from "../../portal/views/home/Home.vue";
+import PaperStructure from "../views/PaperStructure.vue";
+
+export default [
+  {
+    path: "/questions", //首页
+    meta: { auth: false },
+    component: Home,
+    children: [
+      {
+        path: "paper_structure/:isClear", //试卷结构
+        component: PaperStructure
+      }
+    ]
+  }
+];

+ 396 - 0
src/modules/questions/views/PaperStructure.vue

@@ -0,0 +1,396 @@
+<style>
+.form_width {
+  width: 180px;
+}
+</style>
+<template>
+  <div>
+    <section class="content">
+      <div>
+        <!-- 头信息 -->
+        <div><h3 class="box-title">精确结构预设</h3></div>
+        <!-- 正文信息 -->
+        <div class="box-body">
+          <el-form
+            :inline="true"
+            :model="formSearch"
+            label-position="right"
+            label-width="90px"
+          >
+            <el-row :gutter="10">
+              <el-col :xs="7" :sm="7" :md="7" :lg="8">
+                <el-form-item label="结构名称" class="pull-left">
+                  <el-input
+                    placeholder="请输入结构名称"
+                    v-model="formSearch.name"
+                  ></el-input>
+                </el-form-item>
+              </el-col>
+              <el-col :xs="7" :sm="7" :md="7" :lg="8">
+                <el-form-item label="创建人" class="pull-left">
+                  <el-input
+                    placeholder="请输入创建人"
+                    v-model="formSearch.creator"
+                  ></el-input>
+                </el-form-item>
+              </el-col>
+              <el-col :xs="7" :sm="7" :md="7" :lg="8">
+                <el-form-item label="制定课程">
+                  <el-select
+                    v-model="formSearch.courseNo"
+                    class="form_width"
+                    filterable
+                    :remote-method="getCourses"
+                    remote
+                    clearable
+                    placeholder="请选择"
+                  >
+                    <el-option label="请选择" value="ALL" key="ALL"></el-option>
+                    <el-option label="公用" value="" key=""></el-option>
+                    <el-option
+                      v-for="item in courseInfoSelect"
+                      :label="item.courseInfo"
+                      :value="item.courseNo"
+                      :key="item.courseNo"
+                    >
+                    </el-option>
+                  </el-select>
+                </el-form-item>
+              </el-col>
+            </el-row>
+            <el-row>
+              <el-form-item class="pull-right buttonframe">
+                <el-button
+                  size="small"
+                  style="margin-left:90px;"
+                  type="primary"
+                  icon="search"
+                  @click="searchPaperStructs"
+                  >查询</el-button
+                >
+                <el-button
+                  size="small"
+                  type="primary"
+                  icon="plus"
+                  @click="addPaperStruct"
+                  >新增</el-button
+                >
+                <el-button size="small" type="danger" @click="deletePapers"
+                  ><i class="el-icon-delete"></i> 删除</el-button
+                >
+              </el-form-item>
+            </el-row>
+          </el-form>
+
+          <!-- 页面列表 -->
+          <el-table
+            :data="tableData"
+            v-loading="loading"
+            element-loading-text="拼命加载中"
+            border
+            style="width: 100%;text-align:center;"
+            @selection-change="selectionChange"
+          >
+            <el-table-column type="selection"> </el-table-column>
+            <el-table-column label="预设精确结构名称" width="200">
+              <template slot-scope="scope">
+                <div>
+                  <span>{{ scope.row.name }}</span>
+                </div>
+              </template>
+            </el-table-column>
+            <el-table-column label="关联课程" width="180">
+              <template slot-scope="scope">
+                <div>
+                  <span>{{ scope.row.courseName }}</span>
+                </div>
+              </template>
+            </el-table-column>
+            <el-table-column label="课程代码" width="110">
+              <template slot-scope="scope">
+                <div>
+                  <span>{{ scope.row.courseNo }}</span>
+                </div>
+              </template>
+            </el-table-column>
+            <el-table-column label="类型" width="110">
+              <template slot-scope="scope">
+                <div>
+                  <span>{{ getType(scope.row.courseNo) }}</span>
+                </div>
+              </template>
+            </el-table-column>
+            <el-table-column label="大题数" width="80">
+              <template slot-scope="scope">
+                <div>
+                  <span>{{ scope.row.detailCount }}</span>
+                </div>
+              </template>
+            </el-table-column>
+            <el-table-column label="小题数" width="80">
+              <template slot-scope="scope">
+                <div>
+                  <span>{{ scope.row.detailUnitCount }}</span>
+                </div>
+              </template>
+            </el-table-column>
+            <el-table-column label="总分" width="70">
+              <template slot-scope="scope">
+                <div>
+                  <span>{{ scope.row.totalScore }}</span>
+                </div>
+              </template>
+            </el-table-column>
+            <el-table-column label="创建人" width="110">
+              <template slot-scope="scope">
+                <div>
+                  <span>{{ scope.row.creator }}</span>
+                </div>
+              </template>
+            </el-table-column>
+            <el-table-column :context="_self" label="操作" width="140">
+              <div>
+                <el-button
+                  size="mini"
+                  type="info"
+                  @click="editPaperStruct(row);"
+                >
+                  修改
+                </el-button>
+                <el-button
+                  size="mini"
+                  type="danger"
+                  @click="deletePaper($index, row);"
+                >
+                  删除
+                </el-button>
+              </div>
+            </el-table-column>
+          </el-table>
+          <div class="page pull-right">
+            <el-pagination
+              @current-change="handleCurrentChange"
+              :current-page="currentPage"
+              :page-size="pageSize"
+              layout="total, prev, pager, next, jumper"
+              :total="total"
+            >
+            </el-pagination>
+          </div>
+        </div>
+      </div>
+    </section>
+  </div>
+</template>
+
+<script>
+import { CORE_API, Q_API } from "../constants/constants";
+export default {
+  data() {
+    return {
+      courseLoading: false,
+      formSearch: {
+        name: "",
+        creator: "",
+        courseNo: "ALL",
+        type: "EXACT"
+      },
+      paperStructId: "",
+      loading: false,
+      tableData: [],
+      selectedList: [],
+      currentPage: 1,
+      pageSize: 10,
+      total: 10,
+      courseList: [],
+      isClear: 0
+    };
+  },
+  methods: {
+    //查询
+    searchPaperStructs() {
+      this.loading = true;
+      var url =
+        Q_API + "/paperStruct/" + this.currentPage + "/" + this.pageSize;
+      this.$http.get(url, { params: this.formSearch }).then(response => {
+        console.log("response:", response);
+        this.tableData = response.data.content;
+        this.total = response.data.totalElements;
+      });
+      this.loading = false;
+    },
+    //全选
+    selectionChange(val) {
+      this.selectedList = [];
+      var selectedList = this.selectedList;
+      val.forEach(element => {
+        selectedList.push(element.id);
+      });
+      this.selectedList = selectedList;
+    },
+    editPaperStruct(row) {
+      sessionStorage.setItem("paper_stucture", JSON.stringify(this.formSearch));
+      sessionStorage.setItem("paper_stucture_currentPage", this.currentPage);
+      sessionStorage.setItem("paperStruct", JSON.stringify(row));
+      this.$router.push({
+        path: "/index/insert_paper_structure/" + row.id
+      });
+    },
+    //删除单条数据
+    deletePaper(index, row) {
+      this.$confirm("是否删除试卷结构?", "提示", {
+        confirmButtonText: "确定",
+        cancelButtonText: "取消",
+        type: "warning"
+      }).then(() => {
+        var url = Q_API + "/paperStruct/" + row.id;
+        this.loading = true;
+        this.$http.delete(url).then(
+          () => {
+            this.$notify({
+              type: "success",
+              message: "删除成功!"
+            });
+            this.searchPaperStructs();
+          },
+          () => {
+            this.$notify({
+              type: "error",
+              message: "删除失败!"
+            });
+          }
+        );
+      });
+      this.loading = false;
+    },
+    //删除多条数据
+    deletePapers() {
+      var selectedList = this.selectedList;
+      if (selectedList.length === 0) {
+        this.$notify({
+          type: "error",
+          message: "请选择要删除的试卷结构"
+        });
+      } else {
+        this.$confirm("是否删除试卷结构?", "提示", {
+          confirmButtonText: "确定",
+          cancelButtonText: "取消",
+          type: "error"
+        }).then(() => {
+          this.loading = true;
+          var url = Q_API + "/paperStruct/" + this.selectedIds;
+          this.$http
+            .delete(url)
+            .then(() => {
+              this.$notify({
+                type: "success",
+                message: "删除成功!"
+              });
+              this.searchPaperStructs();
+              this.selectedList = [];
+            })
+            .catch(() => {
+              this.$notify({
+                type: "error",
+                message: "删除失败!"
+              });
+              this.selectedList = [];
+            });
+        });
+      }
+      this.loading = false;
+    },
+
+    //新增
+    addPaperStruct() {
+      sessionStorage.setItem("paper_stucture", JSON.stringify(this.formSearch));
+      sessionStorage.setItem("paper_stucture_currentPage", this.currentPage);
+      this.$router.push({
+        path: "/index/insert_paper_structure/add"
+      });
+    },
+
+    //分页跳转
+    handleCurrentChange(val) {
+      this.currentPage = val;
+      this.searchPaperStructs();
+    },
+
+    removeItem() {
+      sessionStorage.removeItem("paperStruct");
+    },
+    //查询所有课程
+    getCourses(query) {
+      console.log("query:", query);
+      query = query.trim();
+      if (query) {
+        if (!(query.indexOf("(") > -1 && query.indexOf(")") > -1)) {
+          this.courseLoading = true;
+          this.$http
+            .get(CORE_API + "/course/query?name=" + query + "&enable=true")
+            .then(response => {
+              this.courseList = response.body;
+              this.courseLoading = false;
+            });
+        }
+      } else {
+        this.courseList = [];
+      }
+    },
+    getType(val) {
+      if (val == "ENSEMBLE") {
+        return "宏观结构";
+      }
+      return "微观结构";
+    }
+  },
+  computed: {
+    selectedIds() {
+      var selectedIdsStr = "";
+      for (let id of this.selectedList) {
+        if (!selectedIdsStr) {
+          selectedIdsStr += id;
+        } else {
+          selectedIdsStr += "," + id;
+        }
+      }
+      return selectedIdsStr;
+    },
+    courseInfoSelect() {
+      var courseList = [];
+      for (let course of this.courseList) {
+        var courseInfo = course.name + "(" + course.code + ")";
+        var courseNo = course.code;
+        courseList.push({ courseNo: courseNo, courseInfo: courseInfo });
+      }
+      return courseList;
+    }
+  },
+  created() {
+    this.isClear = this.$route.params.isClear;
+    if (this.isClear == 0 || !this.isClear) {
+      sessionStorage.removeItem("paper_stucture");
+      sessionStorage.removeItem("paper_stucture_currentPage");
+    } else {
+      this.formSearch = JSON.parse(sessionStorage.getItem("paper_stucture"));
+      this.currentPage = parseInt(
+        sessionStorage.getItem("paper_stucture_currentPage")
+      );
+      if (!this.formSearch) {
+        this.formSearch = {
+          name: "",
+          creator: "",
+          courseNo: "ALL",
+          type: "EXACT"
+        };
+      }
+      if (!this.currentPage) {
+        this.currentPage = 1;
+      }
+    }
+    this.removeItem();
+    this.searchPaperStructs();
+    //this.getCourses();
+  }
+};
+</script>

+ 2 - 1
src/router.js

@@ -2,12 +2,13 @@ import Vue from "vue";
 import Router from "vue-router";
 import PortalRoutes from "./modules/portal/routes/routes";
 import MarklRoutes from "./modules/marking/routes/routes";
+import QuestionsRoutes from "./modules/questions/routes/routes";
 
 Vue.use(Router);
 
 let router = new Router({
   mode: "history",
-  routes: [...PortalRoutes, ...MarklRoutes]
+  routes: [...PortalRoutes, ...MarklRoutes, ...QuestionsRoutes]
 });
 
 // router.beforeEach((to, from, next) => {