wolyshaw пре 4 година
родитељ
комит
2450f52a03
1 измењених фајлова са 29 додато и 13 уклоњено
  1. 29 13
      src/views/recodeManager/recodeList.vue

+ 29 - 13
src/views/recodeManager/recodeList.vue

@@ -228,6 +228,7 @@ import { getToken } from "@/utils/auth";
 import pagination from "@/components/Pagination/index";
 import load from "@/utils/loading";
 import qs from "qs";
+import cleanDeep from 'clean-deep'
 import { getTeacher, getEmployeeOrgan } from "@/api/buildTeam";
 import { queryTeacherAttendances } from "@/api/recodeManager";
 import { courseType } from "@/utils/searchArray";
@@ -262,6 +263,15 @@ export default {
       },
     };
   },
+  computed: {
+    isEmptySearch() {
+      return !Object.keys(cleanDeep({...this.searchForm})).length
+    },
+    isEmptyQuery() {
+      console.log(this.isEmptySearch, this.$route.query.search)
+      return this.isEmptySearch && !this.$route.query.search
+    }
+  },
   //生命周期 - 创建完成(可以访问当前this实例)
   created() {},
   //生命周期 - 挂载完成(可以访问DOM元素)
@@ -287,15 +297,25 @@ export default {
     init() {
       this.getList();
     },
-    getList() {
-      let obj = { page: this.rules.page, rows: this.rules.limit };
+    getSearchValues() {
+      let obj = {
+        page: this.rules.page,
+        rows: this.rules.limit,
+        search: this.$route.query.search
+      };
       Object.assign(obj, this.searchForm);
       if (this.courseTime && this.courseTime.length > 0) {
         obj.courseStartDate = this.courseTime[0];
         obj.courseEndDate = this.courseTime[1];
-      } else {
-        this.$message.error("请选择搜索时间");
-        return;
+      }
+      console.log(obj, this.$route.query.search)
+      return obj
+    },
+    getList() {
+      let obj = this.getSearchValues()
+      if (this.isEmptyQuery) {
+        this.$message.error("请至少选择一个条件");
+        return
       }
       queryTeacherAttendances(obj).then((res) => {
         if (res.code == 200) {
@@ -320,14 +340,10 @@ export default {
       this.search();
     },
     onExport() {
-      let obj = { page: this.rules.page, rows: this.rules.limit };
-      Object.assign(obj, this.searchForm);
-      if (this.courseTime && this.courseTime.length > 0) {
-        obj.courseStartDate = this.courseTime[0];
-        obj.courseEndDate = this.courseTime[1];
-      } else {
-        this.$message.error("请选择搜索时间");
-        return;
+      let obj = this.getSearchValues()
+      if (this.isEmptyQuery) {
+        this.$message.error("请至少选择一个条件");
+        return
       }
       let url = "/api-web/export/queryTeacherAttendances";
       const options = {