diff --git a/src/components/pages/main/inputArea.vue b/src/components/pages/main/inputArea.vue
index 4947b05..2f8d131 100644
--- a/src/components/pages/main/inputArea.vue
+++ b/src/components/pages/main/inputArea.vue
@@ -7,8 +7,8 @@
-
-
-
-
+
+
+
+
@@ -181,14 +181,15 @@ let courseList = computed(() => store.state.course.classListStorage);
let credit = computed(() => store.state.course.credit);
const searchSem = ref("選擇課表學期");
-
const semList = ref([]);
+const selectedYear = ref(null);
+const selectedSem = ref(null);
watch(searchSem, async (inputValue) => {
- if (inputValue != "選擇課表學期") {
- // 這邊要去抓取課表
- console.log("searchSem", inputValue);
- }
+ selectedYear.value = inputValue.year;
+ selectedSem.value = inputValue.semester;
+ console.log(selectedYear.value, selectedSem.value);
+ store.dispatch("set_yearNsemester", [selectedYear.value, selectedSem.value]);
});
const toggleActive1 = ref(false);
@@ -245,6 +246,8 @@ let show = computed(() => store.state.course.showTable);
let opened = computed(() => store.state.course.timeSearchMode);
onMounted(async () => {
+ semList.value = await searchSemster();
+ searchSem.value = semList.value[semList.value.length - 1];
let temp_list = _.cloneDeep(courseList.value);
let update = false;
for (let i = 0; i < temp_list.length; i++) {
@@ -278,6 +281,8 @@ onMounted(async () => {
obj["Teacher"],
obj["classroom"],
obj["Credit"],
+ selectedYear.value,
+ selectedSem.value,
);
obj["department"] = result[0].department;
update = true;
@@ -289,6 +294,8 @@ onMounted(async () => {
obj["Teacher"],
obj["classroom"],
obj["Credit"],
+ selectedYear.value,
+ selectedSem.value,
);
obj["grade"] = result[0].grade;
update = true;
@@ -299,7 +306,6 @@ onMounted(async () => {
console.log("update", temp_list);
store.dispatch("updateCourseList", temp_list);
}
- semList.value = await searchSemster();
});
watch(searchType, async (inputValue) => {
diff --git a/src/components/pages/main/serach_modes/course_name.vue b/src/components/pages/main/serach_modes/course_name.vue
index f1a03a2..33f1066 100644
--- a/src/components/pages/main/serach_modes/course_name.vue
+++ b/src/components/pages/main/serach_modes/course_name.vue
@@ -38,7 +38,6 @@ import {
GetCourseTable,
} from "@functions/general";
import {
- recordcourse,
searchCourse,
} from "@functions/course_search.ts";
import { splittime } from "@functions/tool.ts";
@@ -54,6 +53,7 @@ import {
watch,
reactive,
computed,
+ watchEffect,
} from "vue";
import { useStore } from "vuex";
import { v4 as uuidv4 } from "uuid";
@@ -75,12 +75,28 @@ let cleanInputArea = function () {
searchInput.value = "";
};
+const props = defineProps({
+ year: Number,
+ sem: Number,
+})
+
+const selectedYear = ref(props.year);
+const selectedSemester = ref(props.sem);
+
+watchEffect(() => {
+ selectedYear.value = props.year;
+ selectedSemester.value = props.sem;
+ isLoading.value = false;
+ show_search_box.value = false;
+ searchInput.value = "";
+});
+
watch(searchInput, async (inputValue) => {
show_search_box.value = true;
if (inputValue != "") {
isLoading.value = true;
show_search_box.value = true;
- data.value = await searchCourse(inputValue);
+ data.value = await searchCourse(inputValue, selectedYear.value, selectedSemester.value);
// console.log(data.value);
data.value = data.value.map((temp) => {
temp["conflict"] = classconflict(temp);
diff --git a/src/components/pages/main/serach_modes/department.vue b/src/components/pages/main/serach_modes/department.vue
index a6bdec5..37ea086 100644
--- a/src/components/pages/main/serach_modes/department.vue
+++ b/src/components/pages/main/serach_modes/department.vue
@@ -87,7 +87,7 @@ import {
push_to_table,
} from "@functions/course_add.ts";
import "animate.css";
-import { onMounted, ref, watch, computed } from "vue";
+import { onMounted, ref, watch, computed, watchEffect } from "vue";
import { useStore } from "vuex";
const env = import.meta.env;
@@ -110,6 +110,21 @@ const gradeList = ref();
const courseList = ref([]);
const gradeSelection = ref();
+const props = defineProps({
+ year: Number,
+ sem: Number,
+})
+
+const selectedYear = ref(props.year);
+const selectedSemester = ref(props.sem);
+
+watchEffect(async () => {
+ selectedYear.value = props.year;
+ selectedSemester.value = props.sem;
+ departmentInput.value = "";
+ departmentList = await getDepartment(selectedYear.value, selectedSemester.value);
+});
+
const filteredClassList = computed(() => {
if (departmentInput.value == "") return [];
if (gradeSelection.value == "all") return courseList.value;
@@ -160,13 +175,13 @@ watch(departmentInput, async (inputValue) => {
async function clickDepartment() {
gradeList.value = [];
- getGradeByDepartment(departmentInput.value).then((data) => {
+ getGradeByDepartment(departmentInput.value, selectedYear.value, selectedSemester.value).then((data) => {
if (data.length == 1) data = [];
gradeList.value = data;
gradeList.value.unshift({ grade: "all" });
gradeSelection.value = "all";
});
- let coursedata = await getCourseByDepartment(departmentInput.value);
+ let coursedata = await getCourseByDepartment(departmentInput.value, selectedYear.value, selectedSemester.value);
courseList.value = coursedata;
// department 給 1
setConflictState(1);
@@ -181,7 +196,7 @@ onMounted(async () => {
department_search_list.value.style.maxHeight =
(2 * env.VITE_UL_ROW).toString() + "rem";
}
- departmentList = await getDepartment();
+ departmentList = await getDepartment(selectedYear.value, selectedSemester.value);
setSearchTimeMode(false);
});
diff --git a/src/components/pages/main/serach_modes/teacher.vue b/src/components/pages/main/serach_modes/teacher.vue
index ea3f261..b010e16 100644
--- a/src/components/pages/main/serach_modes/teacher.vue
+++ b/src/components/pages/main/serach_modes/teacher.vue
@@ -54,6 +54,7 @@ import {
watch,
reactive,
computed,
+ watchEffect,
} from "vue";
import { useStore } from "vuex";
import { v4 as uuidv4 } from "uuid";
@@ -70,17 +71,34 @@ const show_search_box = ref(false);
const data = ref([]);
const searchList = ref(null);
+const props = defineProps({
+ year: Number,
+ sem: Number,
+});
+
+const selectedYear = ref(props.year);
+const selectedSem = ref(props.sem);
+
let cleanInputArea = function () {
console.log(48763);
show_search_box.value = !show_search_box.value;
searchInput.value = "";
};
+
+watchEffect(() => {
+ selectedYear.value = props.year;
+ selectedSem.value = props.sem;
+ show_search_box.value = false;
+ cleanInputArea();
+});
+
+
watch(searchInput, async (inputValue) => {
show_search_box.value = true;
if (inputValue != "") {
isLoading.value = true;
show_search_box.value = true;
- data.value = await searchByTeacher(inputValue);
+ data.value = await searchByTeacher(inputValue, selectedYear.value, selectedSem.value);
data.value = data.value.map((temp) => {
temp["conflict"] = classconflict(temp);
return temp;
diff --git a/src/components/pages/main/timeSelection.vue b/src/components/pages/main/timeSelection.vue
index 986da32..2290923 100644
--- a/src/components/pages/main/timeSelection.vue
+++ b/src/components/pages/main/timeSelection.vue
@@ -130,6 +130,9 @@ const selectedCoursesearchtime = ref({});
const out = ref();
const toggle = ref(0);
+const selectedYear = computed(() => store.state.course.selectedYear);
+const selectedSemester = computed(() => store.state.course.selectedSemester);
+
const filteredClassList = computed(() => {
if(toggle.value == 0) // 顯示全部課程
return search_class_list_in_timemode.value;
@@ -171,6 +174,8 @@ watch(searchTimeArgument, async () => {
searchTimeArgument.value[0],
searchTimeArgument.value[1],
searchTimeArgument.value[2],
+ selectedYear.value,
+ selectedSemester.value,
);
search_class_list_in_timemode.value = [];
for (let i = 0; i < data.length; i++) {
diff --git a/src/functions/course_search.ts b/src/functions/course_search.ts
index 156f670..c00ddb4 100644
--- a/src/functions/course_search.ts
+++ b/src/functions/course_search.ts
@@ -23,7 +23,7 @@ export async function searchSemster() {
}
-export async function searchCourse(Input: string) {
+export async function searchCourse(Input: string, year: number, semester: number) {
const apiUrl = apiSite + "searchCourse";
const keyword = Input.trim();
// const delay = (n:number) => new Promise( r => setTimeout(r, n*1000));
@@ -35,6 +35,8 @@ export async function searchCourse(Input: string) {
.get(apiUrl, {
params: {
keyword: keyword,
+ year: year,
+ semester: semester,
},
})
.then((response) => {
@@ -54,7 +56,7 @@ export async function searchCourse(Input: string) {
});
}
-export async function recordcourse(course: object) {
+export async function recordcourse(course: object, year: number, semester: number) {
const apiUrl = apiSite + "record/userSelectClass";
//console.log(apiUrl)
@@ -63,6 +65,8 @@ export async function recordcourse(course: object) {
.get(apiUrl, {
params: {
keyword: course,
+ year: year,
+ semester: semester,
},
})
.then((response) => {
@@ -77,7 +81,7 @@ export async function recordcourse(course: object) {
});
}
-export async function searchByTeacher(Input: string) {
+export async function searchByTeacher(Input: string, year: number, semester: number) {
const apiUrl = apiSite + "searchCourse/ByTeacher";
const keyword = Input.trim();
// const delay = (n:number) => new Promise( r => setTimeout(r, n*1000));
@@ -89,6 +93,8 @@ export async function searchByTeacher(Input: string) {
.get(apiUrl, {
params: {
Teacher: keyword,
+ year: year,
+ semester: semester,
},
})
.then((response) => {
@@ -116,6 +122,8 @@ export async function searchCourseByTime(
day: number,
start: number,
end: number,
+ year: number,
+ semester: number,
) {
const apiUrl = apiSite + "searchCourse/ByTime";
@@ -126,6 +134,8 @@ export async function searchCourseByTime(
day: day,
start: start,
end: end,
+ year: year,
+ semester: semester,
},
})
.then((response) => {
@@ -141,12 +151,17 @@ export async function searchCourseByTime(
});
}
-export async function getDepartment() {
+export async function getDepartment(year: number, semester: number) {
const apiUrl = apiSite + "searchCourse/getDepartment";
return new Promise((resolve, reject) => {
axios
- .get(apiUrl, {})
+ .get(apiUrl, {
+ params: {
+ year: year,
+ semester: semester
+ },
+ })
.then((response) => {
resolve(response.data);
})
@@ -158,7 +173,7 @@ export async function getDepartment() {
});
}
-export async function getGradeByDepartment(Department: string) {
+export async function getGradeByDepartment(Department: string, year: number, semester: number) {
const apiUrl = apiSite + "searchCourse/GetGardeByDepartment";
return new Promise((resolve, reject) => {
@@ -166,6 +181,8 @@ export async function getGradeByDepartment(Department: string) {
.get(apiUrl, {
params: {
Department: Department,
+ year: year,
+ semester: semester
},
})
.then((response) => {
@@ -179,7 +196,7 @@ export async function getGradeByDepartment(Department: string) {
});
}
-export async function getCourseByDepartment(Department: string) {
+export async function getCourseByDepartment(Department: string, year: number, semester: number) {
const apiUrl = apiSite + "searchCourse/ByDepartment";
return new Promise((resolve, reject) => {
@@ -187,6 +204,8 @@ export async function getCourseByDepartment(Department: string) {
.get(apiUrl, {
params: {
Department: Department,
+ year: year,
+ semester: semester
},
})
.then((response) => {
@@ -206,6 +225,8 @@ export async function searchDepartmentByOther(
teacher: string,
class_room: string,
credit: number,
+ year: number,
+ semester: number,
) {
const apiUrl = apiSite + "searchCourse/searchDepartmentByOther";
@@ -218,6 +239,8 @@ export async function searchDepartmentByOther(
teacher: teacher,
class_room: class_room,
credit: credit,
+ year: year,
+ semester: semester,
},
})
.then((response) => {
@@ -237,6 +260,8 @@ export async function searchGradeByOther(
teacher: string,
class_room: string,
credit: number,
+ year: number,
+ semester: number,
) {
const apiUrl = apiSite + "searchCourse/searchGradeByOther";
@@ -249,6 +274,8 @@ export async function searchGradeByOther(
teacher: teacher,
class_room: class_room,
credit: credit,
+ year: year,
+ semester: semester,
},
})
.then((response) => {
diff --git a/src/store/course.ts b/src/store/course.ts
index c017f7f..4ccbf13 100644
--- a/src/store/course.ts
+++ b/src/store/course.ts
@@ -19,6 +19,8 @@ interface State {
timeSearchMode: boolean;
timeSearchArgument: Array;
runConflict: number;
+ selectedYear: number;
+ selectedSemester: number;
}
function Transfer(data: any) {
@@ -57,8 +59,14 @@ const store: Module = {
timeSearchMode: false,
timeSearchArgument: [0, 0, 0],
runConflict: 0,
+ selectedYear: 113,
+ selectedSemester: 1,
},
mutations: {
+ set_yearNsemester(state: State, data: Array) {
+ state.selectedYear = data[0];
+ state.selectedSemester = data[1];
+ },
display(state: State) {
state.show = true;
},
@@ -204,6 +212,9 @@ const store: Module = {
},
},
actions: {
+ set_yearNsemester(context: any, data: Array) {
+ context.commit("set_yearNsemester", data);
+ },
display(context: any) {
context.commit("display");
},