zhangjie há 2 anos atrás
pai
commit
77231eecf9

+ 1 - 10
src/modules/question/components/QuestionImportEdit.vue

@@ -183,8 +183,6 @@ export default {
       default() {
         return {
           richText: { sections: [] },
-          importType: "word",
-          importFileTypes: ["docx", "doc"],
           detailInfo: [],
           importData: {
             courseId: "",
@@ -217,10 +215,9 @@ export default {
       uploadAnswerUrl: `${QUESTION_API}/word/parse/import`,
       uploadAnswerData: {},
       // word upload
-      importType: "word",
       importFileTypes: ["docx", "doc"],
       uploadData: {},
-      uploadUrl: ``,
+      uploadUrl: `${QUESTION_API}/word/parse/struct`,
     };
   },
   methods: {
@@ -231,12 +228,6 @@ export default {
       //   richText: paperRichTextJson,
       //   detailInfo: paperParseData,
       // });
-      this.importType = this.data.importType;
-      this.importFileTypes = this.data.importFileTypes;
-      this.uploadUrl =
-        this.importType === "word"
-          ? `${QUESTION_API}/word/parse/struct`
-          : `${QUESTION_API}/word/parse/import_paper_by_excel`;
       this.resetData(this.data);
 
       this.$nextTick(() => {

+ 42 - 9
src/modules/question/views/QuestionManage.vue

@@ -62,6 +62,13 @@
           >
         </div>
         <div>
+          <el-button
+            type="danger"
+            plain
+            icon="el-icon-circle-close"
+            @click="toBatchDelete"
+            >删除</el-button
+          >
           <el-button
             type="primary"
             plain
@@ -92,7 +99,13 @@
         v-loading="loading"
         element-loading-text="加载中"
         :data="questionList"
+        @selection-change="tableSelectChange"
       >
+        <el-table-column
+          type="selection"
+          width="50"
+          align="center"
+        ></el-table-column>
         <el-table-column label="题干" min-width="200">
           <div slot-scope="scope" @click="toViewQuestion(scope.row)">
             <rich-text
@@ -265,6 +278,7 @@ export default {
       curFolderAction: "",
       folderList: [],
       questionList: [],
+      selectedQuestionIds: [],
       currentPage: 1,
       pageSize: 10,
       total: 0,
@@ -286,6 +300,7 @@ export default {
     },
     async getList() {
       this.loading = true;
+      this.selectedQuestionIds = [];
       let data = {
         ...this.filter,
         pageNumber: this.currentPage,
@@ -302,6 +317,9 @@ export default {
       this.pageSize = val;
       this.toPage(1);
     },
+    tableSelectChange(selections) {
+      this.selectedQuestionIds = selections.map((item) => item.id);
+    },
     courseChange(val) {
       this.curCourse = val || {};
     },
@@ -384,16 +402,10 @@ export default {
       this.$message.success("操作成功!");
       this.getList();
     },
-    async toDeleteQuestion(row) {
-      const confirm = await this.$confirm("确认删除试题吗?", "提示", {
-        type: "warning",
-      }).catch(() => {});
-      if (confirm !== "confirm") return;
-
+    async deleteQuestion(ids) {
       this.loading = true;
-      const res = await deleteQuestionApi(row.id).catch(() => {});
+      const res = await deleteQuestionApi(ids.join()).catch(() => {});
       this.loading = false;
-
       if (!res) return;
 
       this.$notify({
@@ -402,6 +414,27 @@ export default {
       });
       this.getList();
     },
+    async toDeleteQuestion(row) {
+      const confirm = await this.$confirm("确认删除试题吗?", "提示", {
+        type: "warning",
+      }).catch(() => {});
+      if (confirm !== "confirm") return;
+
+      this.deleteQuestion([row.id]);
+    },
+    async toBatchDelete() {
+      if (!this.selectedQuestionIds.length) {
+        this.$message.error("请选择试题!");
+        return;
+      }
+
+      const confirm = await this.$confirm("确认删除选中试题吗?", "提示", {
+        type: "warning",
+      }).catch(() => {});
+      if (confirm !== "confirm") return;
+
+      this.deleteQuestion(this.selectedQuestionIds);
+    },
     toRecycle() {
       this.$router.push({
         name: "QuestionRecycle",
@@ -411,7 +444,7 @@ export default {
       this.$refs.FolderQuestionManageDialog.open();
     },
     questionImported(data) {
-      if (data.importType === "zip") {
+      if (data.importType !== "word") {
         this.getList();
         return;
       }