From d289a7af555f8017d1009ed5e754fcc57881bca6 Mon Sep 17 00:00:00 2001 From: snsd0805 Date: Sun, 25 Jul 2021 17:22:02 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E6=96=B0=E5=A2=9E=E5=AD=B8=E5=88=86?= =?UTF-8?q?=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 }} 學分 +
+
+
+
+ +