浏览代码

提交题库页面

weiwenhai 6 年之前
父节点
当前提交
f5a1b802ba

+ 33 - 33
src/modules/questions/views/BluePaperStructure.vue

@@ -60,7 +60,12 @@
         <el-row>
           <el-form-item>
             <span>批量操作:</span>
-            <el-button size="small" type="danger" @click="deleteStructs">
+            <el-button
+              size="small"
+              type="danger"
+              @click="deleteStructs"
+              :disabled="noBatchSelected"
+            >
               <i class="el-icon-delete"></i> 删除
             </el-button>
           </el-form-item>
@@ -199,39 +204,31 @@ export default {
     },
     //删除多个试卷结构
     deleteStructs() {
-      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 = QUESTION_API + "/paperStruct/" + this.selectedIds;
-          this.$http
-            .delete(url)
-            .then(() => {
-              this.$notify({
-                type: "success",
-                message: "删除成功!"
-              });
-              this.searchAll();
-              this.selectedList = [];
-            })
-            .catch(() => {
-              this.$notify({
-                type: "error",
-                message: "删除失败!"
-              });
-              this.selectedList = [];
+      this.$confirm("是否删除试卷结构?", "提示", {
+        confirmButtonText: "确定",
+        cancelButtonText: "取消",
+        type: "error"
+      }).then(() => {
+        this.loading = true;
+        var url = QUESTION_API + "/paperStruct/" + this.selectedIds;
+        this.$http
+          .delete(url)
+          .then(() => {
+            this.$notify({
+              type: "success",
+              message: "删除成功!"
             });
-        });
-      }
+            this.searchAll();
+            this.selectedList = [];
+          })
+          .catch(() => {
+            this.$notify({
+              type: "error",
+              message: "删除失败!"
+            });
+            this.selectedList = [];
+          });
+      });
       this.loading = false;
     },
     //得到难度
@@ -361,6 +358,9 @@ export default {
         courseList.push({ courseNo: courseNo, courseInfo: courseInfo });
       }
       return courseList;
+    },
+    noBatchSelected() {
+      return this.selectedList.length === 0;
     }
   },
   watch: {

+ 61 - 66
src/modules/questions/views/CourseProperty.vue

@@ -61,10 +61,18 @@
         <el-row>
           <el-form-item class="pull-left">
             <span>批量操作:</span>
-            <el-button size="small" type="primary" @click="openCoursePropertys"
+            <el-button
+              size="small"
+              type="primary"
+              @click="openCoursePropertys"
+              :disabled="noBatchSelected"
               ><i class="el-icon-check"></i> 启用</el-button
             >
-            <el-button size="small" type="danger" @click="closeCoursePropertys"
+            <el-button
+              size="small"
+              type="danger"
+              @click="closeCoursePropertys"
+              :disabled="noBatchSelected"
               ><i class="el-icon-close"></i> 禁用</el-button
             >
           </el-form-item>
@@ -319,39 +327,31 @@ export default {
     },
     //批量启用
     openCoursePropertys() {
-      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 = QUESTION_API + "/courseProperty/opens/" + this.selectedIds;
-          this.$http
-            .put(url)
-            .then(() => {
-              this.$notify({
-                type: "success",
-                message: "开启成功!"
-              });
-              this.searchCourProperty();
-              this.selectedList = [];
-            })
-            .catch(() => {
-              this.$notify({
-                type: "error",
-                message: "开启失败!"
-              });
-              this.selectedList = [];
+      this.$confirm("是否确认开启?", "提示", {
+        confirmButtonText: "确定",
+        cancelButtonText: "取消",
+        type: "error"
+      }).then(() => {
+        this.loading = true;
+        var url = QUESTION_API + "/courseProperty/opens/" + this.selectedIds;
+        this.$http
+          .put(url)
+          .then(() => {
+            this.$notify({
+              type: "success",
+              message: "开启成功!"
             });
-        });
-      }
+            this.searchCourProperty();
+            this.selectedList = [];
+          })
+          .catch(() => {
+            this.$notify({
+              type: "error",
+              message: "开启失败!"
+            });
+            this.selectedList = [];
+          });
+      });
       this.loading = false;
     },
     //关闭
@@ -379,39 +379,31 @@ export default {
     },
     //批量关闭
     closeCoursePropertys() {
-      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 = QUESTION_API + "/courseProperty/closes/" + this.selectedIds;
-          this.$http
-            .put(url)
-            .then(() => {
-              this.$notify({
-                type: "success",
-                message: "禁用成功!"
-              });
-              this.searchCourProperty();
-              this.selectedList = [];
-            })
-            .catch(() => {
-              this.$notify({
-                type: "error",
-                message: "禁用失败!"
-              });
-              this.selectedList = [];
+      this.$confirm("是否确认禁用?", "提示", {
+        confirmButtonText: "确定",
+        cancelButtonText: "取消",
+        type: "error"
+      }).then(() => {
+        this.loading = true;
+        var url = QUESTION_API + "/courseProperty/closes/" + this.selectedIds;
+        this.$http
+          .put(url)
+          .then(() => {
+            this.$notify({
+              type: "success",
+              message: "禁用成功!"
             });
-        });
-      }
+            this.searchCourProperty();
+            this.selectedList = [];
+          })
+          .catch(() => {
+            this.$notify({
+              type: "error",
+              message: "禁用失败!"
+            });
+            this.selectedList = [];
+          });
+      });
       this.loading = false;
     },
     //分页
@@ -544,6 +536,9 @@ export default {
         courseList.push(courseInfo);
       }
       return courseList;
+    },
+    noBatchSelected() {
+      return this.selectedList.length === 0;
     }
   },
   watch: {

+ 11 - 4
src/modules/questions/views/GenPaper.vue

@@ -82,15 +82,20 @@
         <el-row>
           <el-form-item>
             <span>批量操作:</span>
+            <el-button
+              size="small"
+              type="danger"
+              @click="batchDeleteGenPaper"
+              :disabled="noBatchSelected"
+            >
+              <i class="el-icon-delete"></i> 删除成卷
+            </el-button>
             <el-button
               size="small"
               type="primary"
               @click="openBatchExportPaperDialog"
               ><i class="el-icon-download"></i> 下载成卷</el-button
             >
-            <el-button size="small" type="danger" @click="batchDeleteGenPaper">
-              <i class="el-icon-delete"></i> 删除成卷
-            </el-button>
           </el-form-item>
         </el-row>
       </el-form>
@@ -743,6 +748,9 @@ export default {
       }
       return courseList;
     },
+    noBatchSelected() {
+      return this.selectedPaperIds.length === 0;
+    },
     ...mapState({ user: state => state.user })
   },
   watch: {
@@ -750,7 +758,6 @@ export default {
   },
   created() {
     this.initVue();
-
     this.searchExamList();
     this.searchOrgName();
   }

+ 63 - 66
src/modules/questions/views/ImportPaper.vue

@@ -102,10 +102,18 @@
         <el-row>
           <el-form-item>
             <span>批量操作:</span>
-            <el-button size="small" type="primary" @click="useBasePaper"
+            <el-button
+              size="small"
+              type="primary"
+              @click="useBasePaper"
+              :disabled="noBatchSelected"
               ><i class="el-icon-star-on"></i> 使用原卷</el-button
             >
-            <el-button size="small" type="danger" @click="batchDeletePaper"
+            <el-button
+              size="small"
+              type="danger"
+              @click="batchDeletePaper"
+              :disabled="noBatchSelected"
               ><i class="el-icon-delete"></i> 删除原卷</el-button
             >
           </el-form-item>
@@ -448,35 +456,28 @@ export default {
     },
     batchDeletePaper() {
       var paperIds = this.paperIds;
-      if (this.selectedPaperIds.length != 0) {
-        this.$confirm("确认删除试卷吗?", "提示", {
-          type: "warning"
-        }).then(() => {
-          this.loading = true;
-          this.$http.delete(QUESTION_API + "/paper/" + paperIds).then(
-            () => {
-              this.$notify({
-                message: "删除成功",
-                type: "success"
-              });
-              this.searchImportPaper();
-              this.selectedPaperIds = [];
-            },
-            error => {
-              this.$notify({
-                message: error.response.data.msg,
-                type: "error"
-              });
-              this.loading = false;
-            }
-          );
-        });
-      } else {
-        this.$notify({
-          message: "请勾选删除的数据",
-          type: "warning"
-        });
-      }
+      this.$confirm("确认删除试卷吗?", "提示", {
+        type: "warning"
+      }).then(() => {
+        this.loading = true;
+        this.$http.delete(QUESTION_API + "/paper/" + paperIds).then(
+          () => {
+            this.$notify({
+              message: "删除成功",
+              type: "success"
+            });
+            this.searchImportPaper();
+            this.selectedPaperIds = [];
+          },
+          error => {
+            this.$notify({
+              message: error.response.data.msg,
+              type: "error"
+            });
+            this.loading = false;
+          }
+        );
+      });
     },
     //导入试卷
     impPaper() {
@@ -499,45 +500,38 @@ export default {
       }
     },
     useBasePaper() {
-      if (this.selectedPaperIds.length == 0) {
-        this.$notify({
-          message: "请勾选使用的试卷",
-          type: "warning"
-        });
-      } else {
-        this.loading = true;
-        this.$http
-          .put(QUESTION_API + "/useBasePaper/" + this.selectedPaperIds)
-          .then(
-            response => {
-              console.log("come in response:", response);
-              if (!response.data.desc) {
-                this.$notify({
-                  message: "操作成功",
-                  type: "success"
-                });
-              } else {
-                this.$notify({
-                  message: response.data.desc,
-                  type: "error"
-                });
-              }
-              this.loading = false;
-            },
-            error => {
-              var message = error.response.data.desc;
-              var err = message
-                .replace("[", "")
-                .replace("]", "")
-                .substring(message.indexOf("desc") + 4);
+      this.loading = true;
+      this.$http
+        .put(QUESTION_API + "/useBasePaper/" + this.selectedPaperIds)
+        .then(
+          response => {
+            console.log("come in response:", response);
+            if (!response.data.desc) {
               this.$notify({
-                message: err,
+                message: "操作成功",
+                type: "success"
+              });
+            } else {
+              this.$notify({
+                message: response.data.desc,
                 type: "error"
               });
-              this.loading = false;
             }
-          );
-      }
+            this.loading = false;
+          },
+          error => {
+            var message = error.response.data.desc;
+            var err = message
+              .replace("[", "")
+              .replace("]", "")
+              .substring(message.indexOf("desc") + 4);
+            this.$notify({
+              message: err,
+              type: "error"
+            });
+            this.loading = false;
+          }
+        );
     },
     //克隆试卷
     copyImportPaper(row) {
@@ -781,6 +775,9 @@ export default {
       }
       return courseList;
     },
+    noBatchSelected() {
+      return this.selectedPaperIds.length === 0;
+    },
     ...mapState({ user: state => state.user })
   },
   watch: {

+ 33 - 33
src/modules/questions/views/PaperStructure.vue

@@ -74,7 +74,12 @@
         <el-row>
           <el-form-item>
             <span>批量操作:</span>
-            <el-button size="small" type="danger" @click="deletePapers">
+            <el-button
+              size="small"
+              type="danger"
+              @click="deletePapers"
+              :disabled="noBatchSelected"
+            >
               <i class="el-icon-delete"></i> 删除
             </el-button>
           </el-form-item>
@@ -256,39 +261,31 @@ export default {
     },
     //删除多条数据
     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 = QUESTION_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.$confirm("是否删除试卷结构?", "提示", {
+        confirmButtonText: "确定",
+        cancelButtonText: "取消",
+        type: "error"
+      }).then(() => {
+        this.loading = true;
+        var url = QUESTION_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;
     },
 
@@ -374,6 +371,9 @@ export default {
         courseList.push({ courseNo: courseNo, courseInfo: courseInfo });
       }
       return courseList;
+    },
+    noBatchSelected() {
+      return this.selectedList.length === 0;
     }
   },
   watch: {