zhangjie 2 年之前
父节点
当前提交
a364a892b1

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

@@ -206,7 +206,7 @@ export default {
         isProperty: this.isProperty,
         isProperty: this.isProperty,
       };
       };
       if (this.isClassify && this.selectedFolderIds.length)
       if (this.isClassify && this.selectedFolderIds.length)
-        data.folderIds = this.selectedFolderIds;
+        data.classifyIdList = this.selectedFolderIds.join();
 
 
       const res = await questionGroupStructListApi(data);
       const res = await questionGroupStructListApi(data);
       this.originList = res.data || [];
       this.originList = res.data || [];

+ 25 - 7
src/modules/question/api.js

@@ -26,19 +26,23 @@ export const propertySecondQueryApi = (firstPropertyId) => {
 };
 };
 
 
 // question-manage
 // question-manage
-export function questionPageListApi(data, { pageNo, pageSize }) {
-  const url = `${QUESTION_API}/importPaper/${pageNo}/${pageSize}`;
-  return $httpWithMsg.post(url, { params: data });
+export function questionPageListApi(data) {
+  const url = `${QUESTION_API}/question/classify/find_classify_content`;
+  return $httpWithMsg.post(url, {}, { params: data });
 }
 }
 export function deleteQuestionApi(questionId) {
 export function deleteQuestionApi(questionId) {
   return $httpWithMsg.post(
   return $httpWithMsg.post(
     `${QUESTION_API}/paper/deleteQuestion/${questionId}`
     `${QUESTION_API}/paper/deleteQuestion/${questionId}`
   );
   );
 }
 }
-export function moveQuestionApi(questionId, folderId) {
-  return $httpWithMsg.post(`${QUESTION_API}/paper/moveQuestion/`, {
-    params: { questionId, folderId },
-  });
+export function moveQuestionApi(questionIdList, targetClassifyId) {
+  return $httpWithMsg.post(
+    `${QUESTION_API}/question/classify/move_questions_to_classify`,
+    {},
+    {
+      params: { questionIdList, targetClassifyId },
+    }
+  );
 }
 }
 export function copyQuestionApi(questionId) {
 export function copyQuestionApi(questionId) {
   return $httpWithMsg.post(`${QUESTION_API}/paper/copyQuestion/`, {
   return $httpWithMsg.post(`${QUESTION_API}/paper/copyQuestion/`, {
@@ -81,3 +85,17 @@ export function classifyTreeApi() {
 export function updateClassifyApi(datas) {
 export function updateClassifyApi(datas) {
   return $httpWithMsg.post(`${QUESTION_API}/question/classify/save`, datas);
   return $httpWithMsg.post(`${QUESTION_API}/question/classify/save`, datas);
 }
 }
+export function deleteClassifyApi(questionClassifyIdList) {
+  return $httpWithMsg.post(`${QUESTION_API}/question/classify/dalete`, {
+    questionClassifyIdList,
+  });
+}
+export function moveClassifyApi(movedClassifyId, targetClassifyId) {
+  return $httpWithMsg.post(
+    `${QUESTION_API}/question/classify/move`,
+    {},
+    {
+      params: { movedClassifyId, targetClassifyId },
+    }
+  );
+}

+ 126 - 0
src/modules/question/components/ModifyFolder.vue

@@ -0,0 +1,126 @@
+<template>
+  <el-dialog
+    custom-class="side-dialog"
+    :visible.sync="modalIsShow"
+    title="试题导入"
+    width="700px"
+    :modal="false"
+    :close-on-click-modal="false"
+    :close-on-press-escape="false"
+    append-to-body
+    @open="visibleChange"
+  >
+    <el-form
+      ref="modalFormComp"
+      :model="modalForm"
+      :rules="rules"
+      label-width="120px"
+    >
+      <el-form-item label="导入类型">
+        <el-radio-group v-model="modalForm.importType">
+          <el-radio label="word">word</el-radio>
+          <el-radio label="zip">zip</el-radio>
+        </el-radio-group>
+      </el-form-item>
+      <el-form-item prop="courseId" label="导入类型">
+        <course-select v-model="modalForm.courseId"> </course-select>
+      </el-form-item>
+      <el-form-item label="是否使用原卷">
+        <el-radio-group v-model="modalForm.userPaper">
+          <el-radio :label="true">是</el-radio>
+          <el-radio :label="false">否</el-radio>
+        </el-radio-group>
+      </el-form-item>
+      <el-form-item
+        v-if="modalForm.userPaper"
+        prop="paperName"
+        label="试卷名称"
+      >
+        <el-input
+          v-model="modalForm.paperName"
+          placeholder="请输入试卷名称"
+          clearable
+        >
+        </el-input>
+      </el-form-item>
+      <el-form-item label="总分校验">
+        <el-radio-group v-model="modalForm.scoreCheck">
+          <el-radio :label="true">开启</el-radio>
+          <el-radio :label="false">关闭</el-radio>
+        </el-radio-group>
+      </el-form-item>
+      <el-form-item prop="file">
+        <import-file
+          ref="ImportFile"
+          :format="[modalForm.importType]"
+          :template-url="templateUrl"
+          only-fetch-file
+          @file-change="fileChange"
+          @confirm="confirm"
+        ></import-file>
+      </el-form-item>
+    </el-form>
+
+    <div slot="footer"></div>
+  </el-dialog>
+</template>
+
+<script>
+import { updateClassifyApi } from "../api";
+
+const initModalForm = {
+  id: "",
+  name: "",
+};
+
+export default {
+  name: "ModifyFolder",
+  data() {
+    return {
+      modalIsShow: false,
+      modalForm: {
+        ...initModalForm,
+      },
+      rules: {
+        name: [
+          {
+            required: true,
+            message: "请输入文件夹名称",
+            trigger: "change",
+          },
+        ],
+      },
+      loading: false,
+    };
+  },
+  methods: {
+    visibleChange() {
+      this.modalForm = { ...initModalForm };
+    },
+    cancel() {
+      this.modalIsShow = false;
+    },
+    open() {
+      this.modalIsShow = true;
+    },
+    async confirm() {
+      const valid = await this.$refs.modalFormComp.validate().catch(() => {});
+      if (!valid) return;
+
+      if (this.loading) return;
+      this.loading = true;
+
+      const res = await updateClassifyApi(this.modalForm, {
+        md5: this.fileData.md5,
+      }).catch(() => {});
+      this.loading = false;
+
+      if (!res) return;
+
+      this.$message.success("修改成功!");
+      this.$emit("modified");
+      this.cancel();
+    },
+  },
+};
+</script>

+ 32 - 12
src/modules/question/components/QuestionFolderDialog.vue

@@ -41,11 +41,13 @@
               <el-button
               <el-button
                 type="primary"
                 type="primary"
                 icon="el-icon-check"
                 icon="el-icon-check"
+                :disabled="loading"
                 @click="toCreateFolder"
                 @click="toCreateFolder"
               ></el-button>
               ></el-button>
               <el-button
               <el-button
                 type="danger"
                 type="danger"
                 icon="el-icon-close"
                 icon="el-icon-close"
+                :disabled="loading"
                 @click="toRemoveFolder(node, data)"
                 @click="toRemoveFolder(node, data)"
               ></el-button>
               ></el-button>
             </el-form-item>
             </el-form-item>
@@ -60,13 +62,20 @@
     </el-tree>
     </el-tree>
 
 
     <div slot="footer" class="box-justify">
     <div slot="footer" class="box-justify">
-      <el-button
-        v-if="isEdit"
-        type="primary"
-        :disabled="curNodeData.level >= MAX_FOLDER_LEVEL"
-        @click="toAddFolder"
-        >新建文件夹</el-button
-      >
+      <div v-if="isEdit">
+        <el-button
+          type="primary"
+          :disabled="curNodeData.level >= MAX_FOLDER_LEVEL"
+          @click="toAddFolder"
+          >新建文件夹</el-button
+        >
+        <el-button
+          type="danger"
+          :disabled="curNodeData.level >= MAX_FOLDER_LEVEL"
+          @click="toDeleteFolder"
+          >删除文件夹</el-button
+        >
+      </div>
       <div>
       <div>
         <el-button v-if="!isEdit" type="primary" @click="confirm"
         <el-button v-if="!isEdit" type="primary" @click="confirm"
           >确定</el-button
           >确定</el-button
@@ -78,7 +87,7 @@
 </template>
 </template>
 
 
 <script>
 <script>
-import { classifyTreeApi, updateClassifyApi } from "../api";
+import { classifyTreeApi, updateClassifyApi, deleteClassifyApi } from "../api";
 
 
 const initModalForm = {
 const initModalForm = {
   id: null,
   id: null,
@@ -89,10 +98,6 @@ const initModalForm = {
 export default {
 export default {
   name: "QuestionFolderDialog",
   name: "QuestionFolderDialog",
   props: {
   props: {
-    folderId: {
-      type: [String, Number],
-      default: "",
-    },
     isEdit: {
     isEdit: {
       type: Boolean,
       type: Boolean,
       default: true,
       default: true,
@@ -238,6 +243,21 @@ export default {
       const index = children.findIndex((d) => d.id === data.id);
       const index = children.findIndex((d) => d.id === data.id);
       children.splice(index, 1);
       children.splice(index, 1);
     },
     },
+    async toDeleteFolder() {
+      if (!this.curNodeData.id) return;
+      const confirm = await this.$confirm(`确定要删除选中的文件夹吗?`, "提示", {
+        type: "warning",
+      }).catch(() => {});
+      if (confirm !== "confirm") return;
+
+      if (this.loading) return;
+      this.loading = true;
+      const res = await deleteClassifyApi(this.curNodeData.id).catch(() => {});
+      this.loading = false;
+      if (!res) return;
+      this.$message.success("操作成功");
+      await this.getClassifyTree();
+    },
     confirm() {
     confirm() {
       if (!this.curNodeData.id && this.curNodeData.id !== 0) {
       if (!this.curNodeData.id && this.curNodeData.id !== 0) {
         this.$message.error("请选择文件夹!");
         this.$message.error("请选择文件夹!");

+ 103 - 35
src/modules/question/views/QuestionManage.vue

@@ -10,11 +10,11 @@
           </course-select>
           </course-select>
         </el-form-item>
         </el-form-item>
         <el-form-item label="题型">
         <el-form-item label="题型">
-          <question-type-select v-model="filter.questionType">
+          <question-type-select v-model="filter.quesStructType">
           </question-type-select>
           </question-type-select>
         </el-form-item>
         </el-form-item>
         <el-form-item label="题目内容">
         <el-form-item label="题目内容">
-          <el-input v-model="filter.name" placeholder="题目内容"></el-input>
+          <el-input v-model="filter.content" placeholder="题目内容"></el-input>
         </el-form-item>
         </el-form-item>
         <el-form-item label="属性名">
         <el-form-item label="属性名">
           <property-select
           <property-select
@@ -63,7 +63,7 @@
             type="primary"
             type="primary"
             plain
             plain
             icon="el-icon-folder-opened"
             icon="el-icon-folder-opened"
-            @click="toAddDir"
+            @click="toAddFolder"
             >新建文件夹</el-button
             >新建文件夹</el-button
           >
           >
           <el-button
           <el-button
@@ -88,7 +88,40 @@
       <el-table
       <el-table
         v-loading="loading"
         v-loading="loading"
         element-loading-text="加载中"
         element-loading-text="加载中"
-        :data="tableData"
+        :data="folderList"
+      >
+        <el-table-column prop="classifyName" label="文件名称">
+        </el-table-column>
+        <el-table-column label="操作" width="180" fixed="right">
+          <template slot-scope="scope">
+            <el-button
+              size="mini"
+              type="primary"
+              plain
+              @click="toEditFolder(scope.row)"
+              >编辑</el-button
+            >
+            <el-button
+              size="mini"
+              type="primary"
+              plain
+              @click="toMoveFolder(scope.row)"
+              >移动</el-button
+            >
+            <el-button
+              size="mini"
+              type="danger"
+              plain
+              @click="toDeleteFolder(scope.row)"
+              >删除</el-button
+            >
+          </template>
+        </el-table-column>
+      </el-table>
+      <el-table
+        v-loading="loading"
+        element-loading-text="加载中"
+        :data="questionList"
       >
       >
         <el-table-column
         <el-table-column
           type="selection"
           type="selection"
@@ -101,7 +134,7 @@
               class="row-question-body"
               class="row-question-body"
               title="点击查看试题"
               title="点击查看试题"
               :text-json="scope.row.quesBody"
               :text-json="scope.row.quesBody"
-              @click="toView(scope.row)"
+              @click="toViewQuestion(scope.row)"
             ></rich-text>
             ></rich-text>
           </template>
           </template>
         </el-table-column>
         </el-table-column>
@@ -131,7 +164,7 @@
                 size="mini"
                 size="mini"
                 type="primary"
                 type="primary"
                 plain
                 plain
-                @click="toEdit(scope.row)"
+                @click="toEditQuestion(scope.row)"
                 >编辑</el-button
                 >编辑</el-button
               >
               >
               <el-dropdown>
               <el-dropdown>
@@ -144,7 +177,7 @@
                       size="mini"
                       size="mini"
                       type="primary"
                       type="primary"
                       plain
                       plain
-                      @click="toMove(scope.row)"
+                      @click="toMoveQuestion(scope.row)"
                       >移动</el-button
                       >移动</el-button
                     >
                     >
                   </el-dropdown-item>
                   </el-dropdown-item>
@@ -153,7 +186,7 @@
                       size="mini"
                       size="mini"
                       type="primary"
                       type="primary"
                       plain
                       plain
-                      @click="toCopy(scope.row)"
+                      @click="toCopyQuestion(scope.row)"
                       >复制</el-button
                       >复制</el-button
                     >
                     >
                   </el-dropdown-item>
                   </el-dropdown-item>
@@ -162,7 +195,7 @@
                       size="mini"
                       size="mini"
                       type="danger"
                       type="danger"
                       plain
                       plain
-                      @click="toDelete(scope.row)"
+                      @click="toDeleteQuestion(scope.row)"
                       >删除</el-button
                       >删除</el-button
                     >
                     >
                   </el-dropdown-item>
                   </el-dropdown-item>
@@ -171,7 +204,7 @@
                       size="mini"
                       size="mini"
                       type="primary"
                       type="primary"
                       plain
                       plain
-                      @click="toLink(scope.row)"
+                      @click="toLinkQuestion(scope.row)"
                       >关联属性</el-button
                       >关联属性</el-button
                     >
                     >
                   </el-dropdown-item>
                   </el-dropdown-item>
@@ -213,7 +246,6 @@
     <question-folder-dialog
     <question-folder-dialog
       ref="QuestionFolderDialog"
       ref="QuestionFolderDialog"
       :is-edit="isEditFolder"
       :is-edit="isEditFolder"
-      :folder-id="curQuestionFolderId"
       @selected="folderSelected"
       @selected="folderSelected"
     ></question-folder-dialog>
     ></question-folder-dialog>
     <!-- QuestionImportDialog -->
     <!-- QuestionImportDialog -->
@@ -229,7 +261,9 @@ import {
   questionPageListApi,
   questionPageListApi,
   deleteQuestionApi,
   deleteQuestionApi,
   moveQuestionApi,
   moveQuestionApi,
+  moveClassifyApi,
   copyQuestionApi,
   copyQuestionApi,
+  deleteClassifyApi,
 } from "../api";
 } from "../api";
 import QuestionStatisticsDialog from "../components/QuestionStatisticsDialog.vue";
 import QuestionStatisticsDialog from "../components/QuestionStatisticsDialog.vue";
 import QuestionSafetySetDialog from "../components/QuestionSafetySetDialog.vue";
 import QuestionSafetySetDialog from "../components/QuestionSafetySetDialog.vue";
@@ -249,22 +283,25 @@ export default {
   data() {
   data() {
     return {
     return {
       filter: {
       filter: {
+        classifyId: null,
         courseId: "",
         courseId: "",
-        questionType: "",
-        name: "",
+        quesStructType: "",
+        content: "",
         coursePropertyId: "",
         coursePropertyId: "",
         firstPropertyId: "",
         firstPropertyId: "",
         secondPropertyId: "",
         secondPropertyId: "",
       },
       },
-      tableData: [],
+      folderList: [],
+      questionList: [],
       currentPage: 1,
       currentPage: 1,
       pageSize: 10,
       pageSize: 10,
       total: 0,
       total: 0,
       loading: false,
       loading: false,
       isEditFolder: true,
       isEditFolder: true,
-      curQuestionFolderId: null,
       curQuestion: {},
       curQuestion: {},
+      curFolder: {},
       curCourse: {},
       curCourse: {},
+      curMoveType: "",
     };
     };
   },
   },
   mounted() {
   mounted() {
@@ -277,13 +314,16 @@ export default {
     },
     },
     async getList() {
     async getList() {
       this.loading = true;
       this.loading = true;
-      const res = await questionPageListApi(this.filter, {
-        pageNo: this.currentPage,
+      const res = await questionPageListApi({
+        ...this.filter,
+        curPage: this.currentPage,
         pageSize: this.pageSize,
         pageSize: this.pageSize,
-      });
-      this.tableData = res.data.content;
-      this.total = res.data.totalElements;
+      }).catch(() => {});
       this.loading = false;
       this.loading = false;
+      if (!res) return;
+      this.folderList = res.data.questionClassifyResultList;
+      this.questionList = res.data.questionPageResult.content;
+      this.total = res.data.questionPageResult.totalElements;
     },
     },
     handleSizeChange(val) {
     handleSizeChange(val) {
       this.pageSize = val;
       this.pageSize = val;
@@ -302,9 +342,8 @@ export default {
     toSafetySet() {
     toSafetySet() {
       this.$refs.QuestionSafetySetDialog.open();
       this.$refs.QuestionSafetySetDialog.open();
     },
     },
-    toAddDir() {
+    toAddFolder() {
       this.isEditFolder = true;
       this.isEditFolder = true;
-      this.curQuestionFolderId = null;
       this.$refs.QuestionFolderDialog.open();
       this.$refs.QuestionFolderDialog.open();
     },
     },
     toCreateQuestion() {
     toCreateQuestion() {
@@ -322,39 +361,44 @@ export default {
     toImportQuestion() {
     toImportQuestion() {
       this.$refs.QuestionImportDialog.open();
       this.$refs.QuestionImportDialog.open();
     },
     },
-    toView(row) {
+    toViewQuestion(row) {
       console.log(row);
       console.log(row);
     },
     },
-    toEdit(row) {
+    toEditQuestion(row) {
       console.log(row);
       console.log(row);
       // todo:编辑试题
       // todo:编辑试题
       this.curQuestion = row;
       this.curQuestion = row;
       this.$refs.QuestionEditDialog.open();
       this.$refs.QuestionEditDialog.open();
     },
     },
-    toMove(row) {
+    toMoveQuestion(row) {
       this.isEditFolder = false;
       this.isEditFolder = false;
-      this.curQuestionFolderId = row.foldId || null;
+      this.curMoveType = "question";
+      this.curQuestion = row;
       this.$refs.QuestionFolderDialog.open();
       this.$refs.QuestionFolderDialog.open();
     },
     },
     async folderSelected(folder) {
     async folderSelected(folder) {
-      console.log(folder);
-      const res = await moveQuestionApi(
-        this.curQuestionFolderId,
-        folder.id
-      ).catch(() => {});
-
+      let res = null;
+      if (this.curMoveType === "question") {
+        res = await moveQuestionApi(this.curQuestion.id, folder.id).catch(
+          () => {}
+        );
+      } else {
+        res = await moveClassifyApi(this.curFolder.id, folder.id).catch(
+          () => {}
+        );
+      }
       if (!res) return;
       if (!res) return;
       this.$message.success("操作成功!");
       this.$message.success("操作成功!");
       this.getList();
       this.getList();
     },
     },
-    async toCopy(row) {
+    async toCopyQuestion(row) {
       console.log(row);
       console.log(row);
       const res = await copyQuestionApi(row.id).catch(() => {});
       const res = await copyQuestionApi(row.id).catch(() => {});
       if (!res) return;
       if (!res) return;
       this.$message.success("操作成功!");
       this.$message.success("操作成功!");
       this.getList();
       this.getList();
     },
     },
-    async toDelete(row) {
+    async toDeleteQuestion(row) {
       const confirm = await this.$confirm("确认删除试题吗?", "提示", {
       const confirm = await this.$confirm("确认删除试题吗?", "提示", {
         type: "warning",
         type: "warning",
       }).catch(() => {});
       }).catch(() => {});
@@ -376,8 +420,32 @@ export default {
       });
       });
       this.getList();
       this.getList();
     },
     },
-    toLink(row) {
+    toLinkQuestion(row) {
+      console.log(row);
+    },
+    toEditFolder(row) {
+      console.log(row);
+    },
+    toMoveFolder(row) {
       console.log(row);
       console.log(row);
+      this.isEditFolder = false;
+      this.curMoveType = "folder";
+      this.curFolder = row;
+      this.$refs.QuestionFolderDialog.open();
+    },
+    async toDeleteFolder(row) {
+      const confirm = await this.$confirm(`确定要删除选中的文件夹吗?`, "提示", {
+        type: "warning",
+      }).catch(() => {});
+      if (confirm !== "confirm") return;
+
+      if (this.loading) return;
+      this.loading = true;
+      const res = await deleteClassifyApi(row.id).catch(() => {});
+      this.loading = false;
+      if (!res) return;
+      this.$message.success("操作成功");
+      await this.getClassifyTree();
     },
     },
   },
   },
 };
 };