Quellcode durchsuchen

自动组卷结构保存

zhangjie vor 2 Jahren
Ursprung
Commit
5397441e71

+ 31 - 20
src/modules/paper/api.js

@@ -22,10 +22,37 @@ export const questionGroupStructListApi = (datas) => {
     { params: datas }
   );
 };
-// import folderPropStruct from "./datas/folderPropStruct.json";
-// export const questionGroupStructListApi = (datas) => {
-//   return Promise.resolve({ data: folderPropStruct, filter: datas });
-// };
+// build-paper-simple
+export const paperSimpleTypeDistributeApi = (courseId) => {
+  return $httpWithMsg.post(
+    `${QUESTION_API}/gen/paper/simple/type/distribute`,
+    {},
+    { params: { courseId } }
+  );
+};
+export const paperSimpleCountDistributeApi = (params) => {
+  return $httpWithMsg.post(
+    `${QUESTION_API}/gen/paper/simple/count/distribute`,
+    {},
+    { params }
+  );
+};
+// build-paper-auto:build-struct
+export const autoBuildPaperStructPageListApi = (params) => {
+  return $httpWithMsg.post(`${QUESTION_API}/auto/struct/page`, {}, { params });
+};
+export const autoBuildPaperStructSaveApi = (datas) => {
+  return $httpWithMsg.post(`${QUESTION_API}/auto/struct/save`, datas);
+};
+export const autoBuildPaperStructDeleteApi = (idList) => {
+  return $httpWithMsg.post(
+    `${QUESTION_API}/auto/struct/delete`,
+    {},
+    {
+      params: { idList },
+    }
+  );
+};
 
 // edit paper
 export const paperDetailInfoApi = ({ paperId, seqMode }) => {
@@ -177,22 +204,6 @@ export const submitPaperApi = (paperIds) => {
   );
 };
 
-// build-paper
-export const paperSimpleTypeDistributeApi = (courseId) => {
-  return $httpWithMsg.post(
-    `${QUESTION_API}/gen/paper/simple/type/distribute`,
-    {},
-    { params: { courseId } }
-  );
-};
-export const paperSimpleCountDistributeApi = (params) => {
-  return $httpWithMsg.post(
-    `${QUESTION_API}/gen/paper/simple/count/distribute`,
-    {},
-    { params }
-  );
-};
-
 // paper-recycle
 export function paperRecycleListApi(data = {}) {
   return $httpWithMsg.post(

+ 213 - 0
src/modules/paper/components/AutoBuildPaperStructManage.vue

@@ -0,0 +1,213 @@
+<template>
+  <div>
+    <el-dialog
+      :visible.sync="modalIsShow"
+      title="试卷结构列表"
+      :modal="false"
+      :close-on-click-modal="false"
+      :close-on-press-escape="false"
+      append-to-body
+      fullscreen
+      @opened="dialogOpened"
+    >
+      <!-- 正文信息 -->
+      <div class="part-box">
+        <el-form class="part-filter-form" :inline="true" :model="filter">
+          <el-form-item label="课程名称">
+            <course-select v-model="filter.courseId" :disabled="!!courseId">
+            </course-select>
+          </el-form-item>
+          <el-form-item label="结构名称">
+            <el-input
+              v-model="filter.structName"
+              placeholder="结构名称"
+            ></el-input>
+          </el-form-item>
+          <el-form-item>
+            <el-button type="danger" @click="toPage(1)">查询</el-button>
+          </el-form-item>
+        </el-form>
+        <div class="part-box-action">
+          <el-button
+            type="danger"
+            plain
+            icon="el-icon-delete"
+            @click="toBatchDelete"
+            >批量删除</el-button
+          >
+        </div>
+      </div>
+
+      <div class="part-box">
+        <el-table
+          v-loading="loading"
+          element-loading-text="加载中"
+          :data="dataList"
+          @selection-change="tableSelectChange"
+        >
+          <el-table-column
+            type="selection"
+            width="50"
+            align="center"
+          ></el-table-column>
+          <el-table-column label="试卷结构名称" prop="structName">
+          </el-table-column>
+          <el-table-column label="关联课程">
+            <template slot-scope="scope">
+              <span
+                >{{ scope.row.courseName }}({{ scope.row.courseCode }})</span
+              >
+            </template>
+          </el-table-column>
+          <el-table-column label="大题数" prop="detailCount" width="100">
+          </el-table-column>
+          <el-table-column label="小题数" prop="questionCount" width="100">
+          </el-table-column>
+          <el-table-column label="总分" prop="totalScore" width="100">
+          </el-table-column>
+          <el-table-column label="创建人" prop="creatorName" width="120">
+          </el-table-column>
+          <el-table-column label="创建时间" width="170" prop="creationTime">
+          </el-table-column>
+          <el-table-column label="操作" width="180" fixed="right">
+            <template slot-scope="scope">
+              <div class="operate_left">
+                <el-button
+                  size="mini"
+                  type="primary"
+                  plain
+                  @click="toEdit(scope.row)"
+                  >编辑</el-button
+                >
+                <el-button
+                  size="mini"
+                  type="danger"
+                  plain
+                  @click="toDelete(scope.row)"
+                  >删除</el-button
+                >
+              </div>
+            </template>
+          </el-table-column>
+        </el-table>
+        <div class="part-page">
+          <el-pagination
+            :current-page="currentPage"
+            :page-size="pageSize"
+            :page-sizes="[10, 20, 50, 100, 200, 300]"
+            layout="total, sizes, prev, pager, next, jumper"
+            :total="total"
+            @current-change="toPage"
+            @size-change="handleSizeChange"
+          >
+          </el-pagination>
+        </div>
+      </div>
+    </el-dialog>
+  </div>
+</template>
+
+<script>
+import {
+  autoBuildPaperStructPageListApi,
+  autoBuildPaperStructDeleteApi,
+} from "../api";
+
+export default {
+  name: "AutoBuildPaperStructManage",
+  props: {
+    courseId: {
+      type: [String, Number],
+      default: "",
+    },
+  },
+  data() {
+    return {
+      modalIsShow: false,
+      loading: false,
+      filter: {
+        courseId: "",
+        structName: "",
+      },
+      dataList: [],
+      currentPage: 1,
+      pageSize: 10,
+      total: 0,
+      selectedQuestionIds: [],
+    };
+  },
+  methods: {
+    dialogOpened() {
+      this.filter.courseId = this.courseId;
+      this.toPage(1);
+    },
+    cancel() {
+      this.modalIsShow = false;
+    },
+    open() {
+      this.modalIsShow = true;
+    },
+    toPage(page) {
+      this.currentPage = page;
+      this.getList();
+    },
+    async getList() {
+      this.loading = true;
+      let data = {
+        ...this.filter,
+        curPage: this.currentPage,
+        pageSize: this.pageSize,
+      };
+      const res = await autoBuildPaperStructPageListApi(data).catch(() => {});
+      this.loading = false;
+      if (!res) return;
+      this.dataList = res.data.content;
+      this.total = res.data.totalElements;
+    },
+    handleSizeChange(val) {
+      this.pageSize = val;
+      this.toPage(1);
+    },
+    tableSelectChange(selections) {
+      this.selectedQuestionIds = selections.map((item) => item.id);
+    },
+    toEdit(row) {
+      console.log(row);
+    },
+    async toDelete(row) {
+      const confirm = await this.$confirm("确认删除结构吗?", "提示", {
+        type: "warning",
+      }).catch(() => {});
+      if (confirm !== "confirm") return;
+
+      this.deleteStruct([row.id]);
+    },
+    async deleteStruct(ids) {
+      this.loading = true;
+      const res = await autoBuildPaperStructDeleteApi(ids.join()).catch(
+        (error) => {
+          this.$message.error(error.response.data.desc);
+        }
+      );
+
+      if (!res) return;
+
+      this.$message.success("删除成功");
+      this.getList();
+    },
+    async toBatchDelete() {
+      if (!this.selectedQuestionIds.length) {
+        this.$message.error("请选择试题!");
+        return;
+      }
+
+      const confirm = await this.$confirm("确认删除选中数据吗?", "提示", {
+        type: "warning",
+      }).catch(() => {});
+      if (confirm !== "confirm") return;
+
+      this.deleteStruct(this.selectedQuestionIds);
+    },
+  },
+};
+</script>

+ 17 - 5
src/modules/paper/components/BuildPaperAuto.vue

@@ -48,7 +48,7 @@
         <table class="table detail-info">
           <tr>
             <td>题型</td>
-            <td>{{ detail.questionType | questionType }}</td>
+            <td>{{ detail.sourceDetailName }}</td>
             <td>小题数</td>
             <td>{{ detail.questionCount }}</td>
             <td>总分</td>
@@ -60,7 +60,7 @@
           :filter-data="{
             courseId,
             questionType: detail.questionType,
-            detailName: detail.sourceDetailName,
+            sourceDetailId: detail.sourceDetailId,
           }"
           @count-change="(val) => structCountChange(val, detail)"
         ></question-group-struct>
@@ -73,16 +73,26 @@
       :detail="curDetail"
       @modified="detailModified"
     ></modify-detail-struct>
+    <!-- AutoBuildPaperStructManage -->
+    <auto-build-paper-struct-manage
+      ref="AutoBuildPaperStructManage"
+      :course-id="courseId"
+    ></auto-build-paper-struct-manage>
   </div>
 </template>
 
 <script>
 import ModifyDetailStruct from "../components/ModifyDetailStruct.vue";
 import QuestionGroupStruct from "./QuestionGroupStruct.vue";
+import AutoBuildPaperStructManage from "./AutoBuildPaperStructManage.vue";
 
 export default {
   name: "BuildPaperAuto",
-  components: { ModifyDetailStruct, QuestionGroupStruct },
+  components: {
+    ModifyDetailStruct,
+    QuestionGroupStruct,
+    AutoBuildPaperStructManage,
+  },
   props: {
     courseId: {
       type: [String, Number],
@@ -97,7 +107,9 @@ export default {
     };
   },
   methods: {
-    toSelectStruct() {},
+    toSelectStruct() {
+      this.$refs.AutoBuildPaperStructManage.open();
+    },
     addDetail() {
       this.curDetail = { courseId: this.courseId };
       this.$refs.ModifyDetailStruct.open();
@@ -140,7 +152,7 @@ export default {
           questionType: item.questionType,
           description: item.description,
           detailName: item.detailName,
-          sourceDetailName: item.sourceDetailName,
+          sourceDetailId: item.sourceDetailId,
           courseId: item.courseId,
           score: structData.questionCount * item.scorePerQuestion,
           ...structData,

+ 2 - 1
src/modules/paper/components/QuestionGroupStruct.vue

@@ -137,6 +137,7 @@ export default {
         return {
           courseId: "",
           questionType: "",
+          sourceDetailId: "",
         };
       },
     },
@@ -289,7 +290,7 @@ export default {
           isClassify: true,
           questionCount: data.questionCount,
           selectCount: undefined,
-          difficultDistributeInfo: null,
+          difficultDistributeInfo: [],
         };
         if (
           data.difficultDistributeInfo &&

+ 22 - 1
src/modules/paper/views/BuildPaper.vue

@@ -8,6 +8,12 @@
           <span>课程名称:{{ modalForm.courseName }}</span>
         </div>
         <div>
+          <el-checkbox
+            v-if="IS_AUTO_MODE"
+            v-model="isSaveStructInfo"
+            style="margin-right: 10px"
+            >同时保存为试卷结构模板</el-checkbox
+          >
           <el-button
             type="primary"
             size="small"
@@ -131,7 +137,7 @@
 import BuildPaperAuto from "../components/BuildPaperAuto.vue";
 import BuildPaperManual from "../components/BuildPaperManual.vue";
 import BuildPaperSimple from "../components/BuildPaperSimple.vue";
-import { buildPaperApi } from "../api";
+import { buildPaperApi, autoBuildPaperStructSaveApi } from "../api";
 
 const initModalForm = {
   courseId: "",
@@ -191,6 +197,7 @@ export default {
           name: "手动组卷",
         },
       ],
+      isSaveStructInfo: false,
     };
   },
   computed: {
@@ -200,6 +207,9 @@ export default {
     IS_MANUAL_MODE() {
       return this.genModelType === "manual";
     },
+    IS_AUTO_MODE() {
+      return this.genModelType === "auto";
+    },
   },
   created() {
     let genPaperInfo = sessionStorage.getItem("gen_paper");
@@ -219,6 +229,10 @@ export default {
       this.loading = true;
 
       let questionInfo = this.$refs.BuildPaperDetail.getData();
+      if (this.IS_AUTO_MODE && this.isSaveStructInfo) {
+        this.saveAutoBuildPaperStruct(questionInfo.detailInfo);
+      }
+
       const datas = {
         ...this.modalForm,
         ...questionInfo,
@@ -229,6 +243,13 @@ export default {
 
       this.$message.success("组卷成功!");
     },
+    async saveAutoBuildPaperStruct(structInfo) {
+      await autoBuildPaperStructSaveApi({
+        structName: `${this.modalForm.courseName}-${this.modalForm.courseCode}-${this.modalForm.paperName}`,
+        structInfo: JSON.stringify(structInfo),
+        courseId: this.modalForm.courseId,
+      });
+    },
     toback() {
       window.history.go(-1);
     },