Skip to content

Commit

Permalink
add semester
Browse files Browse the repository at this point in the history
  • Loading branch information
syzygy608 committed Jul 2, 2024
1 parent c6ee844 commit feab94b
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 1 deletion.
26 changes: 25 additions & 1 deletion src/components/pages/main/inputArea.vue
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,15 @@
class="w-full mx-auto my-6 px-4 py-4 bg-gray-100 rounded-lg shadow-lg md:w-9/12 overflow-x-auto">
<div class="text-xl font-semibold">開始建置你的課表</div>
<div class="my-2">
<div class="flex flex-col py-1 w-40">
<div class="flex flex-row py-1 w-40">
<select
class="mx-1 py-1 rounded-md text-center"
v-model="searchSem">
<option selected>選擇課表學期</option>
<option v-for="item in semList" :key="item" :value="item">
{{ item.year }} - {{ item.semester }}
</option>
</select>
<select
class="mx-1 py-1 rounded-md text-center"
v-model="searchType">
Expand Down Expand Up @@ -155,6 +163,7 @@ import {
import {
searchDepartmentByOther,
searchGradeByOther,
searchSemster
} from "@functions/course_search";
import renderImage from "@functions/image_render.ts";
import _ from "lodash";
Expand All @@ -171,6 +180,17 @@ const setSearchTimeMode = (flag) =>
let courseList = computed(() => store.state.course.classListStorage);
let credit = computed(() => store.state.course.credit);
const searchSem = ref("選擇課表學期");
const semList = ref([]);
watch(searchSem, async (inputValue) => {
if (inputValue != "選擇課表學期") {
// 這邊要去抓取課表
console.log("searchSem", inputValue);
}
});
const toggleActive1 = ref(false);
const toggleActive2 = ref(false);
const showListOption = [
Expand Down Expand Up @@ -279,6 +299,7 @@ onMounted(async () => {
console.log("update", temp_list);
store.dispatch("updateCourseList", temp_list);
}
semList.value = await searchSemster();
});
watch(searchType, async (inputValue) => {
Expand Down Expand Up @@ -332,4 +353,7 @@ var clearTable = function () {
var download = function () {
renderImage("WholeTable"); // finish
};
</script>
18 changes: 18 additions & 0 deletions src/functions/course_search.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,24 @@ const env = import.meta.env;

const apiSite = `${env.VITE_BACKEND_DEVICE}/`;

export async function searchSemster() {
const apiUrl = apiSite + "semester/all";

return new Promise((resolve, reject) => {
axios
.get(apiUrl, {})
.then((response) => {
resolve(response.data);
})
.catch((error) => {
// 在這裡處理錯誤
console.error(error);
reject(error);
});
});

}

export async function searchCourse(Input: string) {
const apiUrl = apiSite + "searchCourse";
const keyword = Input.trim();
Expand Down

0 comments on commit feab94b

Please sign in to comment.