From d289a7af555f8017d1009ed5e754fcc57881bca6 Mon Sep 17 00:00:00 2001 From: snsd0805 Date: Sun, 25 Jul 2021 17:22:02 +0800 Subject: [PATCH 1/2] =?UTF-8?q?feat:=20=E6=96=B0=E5=A2=9E=E5=AD=B8?= =?UTF-8?q?=E5=88=86=E6=95=B8=E8=A8=88=E7=AE=97?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- js/components/main.vue | 26 +++++++++++++++++++++++++- js/components/table.vue | 3 ++- 2 files changed, 27 insertions(+), 2 deletions(-) diff --git a/js/components/main.vue b/js/components/main.vue index 5406ef8..75add66 100644 --- a/js/components/main.vue +++ b/js/components/main.vue @@ -9,6 +9,7 @@ var mainWindow = { "user": "", 'token': "", 'is_print': false, + 'creditNum': 0, } }, created() { @@ -96,6 +97,14 @@ var mainWindow = { }).then(function (jsonData) { console.log(jsonData) main.selectCourses = JSON.parse(jsonData['data']) + + var courseSet = new Set() + for (var course of main.selectCourses) { + if (!courseSet.has(course.number+course.class)) { // 用 courseID + 班別 判斷是否重複 + main.creditNum += parseFloat(course.credit) + courseSet.add(course) + } + } }) .catch(function (err) { alert("錯誤: " + err) @@ -161,9 +170,11 @@ var mainWindow = { 'name': course.name, 'temp': false, 'number': course.number, - 'class': course.class + 'class': course.class, + 'credit': course.credit }) } + this.creditNum += parseFloat(course.credit) }, 'removeCourse': function (course) { console.log("remove " + course.name) @@ -172,6 +183,7 @@ var mainWindow = { this.selectCourses.splice(i, 1) } } + this.creditNum -= parseFloat(course.credit) }, 'saveTemp': function (course) { if (course == null) { @@ -273,6 +285,7 @@ var mainWindow = { +
@@ -297,7 +310,18 @@ var mainWindow = { >
+
+
+
+
+ 已經選了 {{ creditNum }} 學分 +
+
+
+
+ +
Date: Sun, 25 Jul 2021 18:16:05 +0800 Subject: [PATCH 2/2] =?UTF-8?q?feat:=20=E9=A1=AF=E7=A4=BA=E9=80=A3?= =?UTF-8?q?=E7=B5=90=E5=9C=A8table=E4=B8=8A?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- js/components/main.vue | 3 ++- js/components/table.vue | 4 +++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/js/components/main.vue b/js/components/main.vue index 75add66..7d0d9a1 100644 --- a/js/components/main.vue +++ b/js/components/main.vue @@ -171,7 +171,8 @@ var mainWindow = { 'temp': false, 'number': course.number, 'class': course.class, - 'credit': course.credit + 'credit': course.credit, + 'link': course.link }) } this.creditNum += parseFloat(course.credit) diff --git a/js/components/table.vue b/js/components/table.vue index c3539d2..f4b0791 100644 --- a/js/components/table.vue +++ b/js/components/table.vue @@ -3,6 +3,7 @@ var courseDiv = { template: `
{{ course.name }} +