From fd4b28c930ccb9b05312ef3c958b4451aac93dd2 Mon Sep 17 00:00:00 2001 From: vincentinttsh Date: Sun, 24 Jan 2021 02:14:20 +0800 Subject: [PATCH 1/4] =?UTF-8?q?=E5=8E=BB=E9=99=A4=E5=9C=96=E6=AA=94?= =?UTF-8?q?=E7=9A=84=E3=80=8C=E5=88=AA=E9=99=A4=E3=80=8D=E6=8C=89=E9=88=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- js/components/main.vue | 20 +++++++++++++++----- js/components/table.vue | 6 ++++-- 2 files changed, 19 insertions(+), 7 deletions(-) diff --git a/js/components/main.vue b/js/components/main.vue index a271e99..fb28d35 100644 --- a/js/components/main.vue +++ b/js/components/main.vue @@ -7,7 +7,8 @@ var mainWindow = { 'selectDepartment': '', 'foundName': "", "user": "", - 'token': "" + 'token': "", + 'is_print': false, } }, created() { @@ -194,6 +195,7 @@ var mainWindow = { } }, 'generatePic': function () { + this.is_print = true; html2canvas(document.getElementById('course-table-div')).then(function (canvas) { var a = document.createElement('a'); a.href = canvas.toDataURL("image/jpeg").replace("image/jpeg", "image/octet-stream"); @@ -206,7 +208,10 @@ var mainWindow = { $('#share').modal('show'); else this.login() - } + }, + 'enableDelete': function () { + this.is_print = !this.is_print; + }, }, components: { 'course-table': courseTable, @@ -249,14 +254,18 @@ var mainWindow = {
-
+
-
+
-
+
+
+
+
+
@@ -291,6 +300,7 @@ var mainWindow = { id="course-table-div" v-bind:selectCourses="selectCourses" v-bind:select_c="selectCourses" + v-bind:is_print="is_print" v-bind:is_shared="false" v-on:remove-course="removeCourse" > diff --git a/js/components/table.vue b/js/components/table.vue index 936594a..999c6b1 100644 --- a/js/components/table.vue +++ b/js/components/table.vue @@ -1,5 +1,5 @@ var courseDiv = { - props: ['course', 'is_shared'], + props: ['course', 'is_shared', 'is_print'], template: `
{{ course.name }} @@ -7,6 +7,7 @@ var courseDiv = { v-if="!is_shared" v-on:click="$emit('remove-course', course.name)" class="btn btn-danger btn-sm" + :style="{'display': is_print ? 'none' : 'inline-block'}" > 刪 @@ -22,7 +23,7 @@ var tempDiv = { ` } var courseTable = { - props: ['select_c', 'is_shared'], + props: ['select_c', 'is_shared', 'is_print'], data: function(){ return { 'courses': {}, @@ -112,6 +113,7 @@ var courseTable = { v-if="exist(week+String.fromCharCode(97+((hour<5)?(hour-1):(hour-2)))) && !courses[week+String.fromCharCode(97+((hour<5)?(hour-1):(hour-2)))].temp" v-bind:course="courses[week+String.fromCharCode(97+((hour<5)?(hour-1):(hour-2)))]" v-bind:is_shared="is_shared" + v-bind:is_print="is_print" v-on:remove-course="removeCourseHandler" > Date: Sun, 24 Jan 2021 17:12:38 +0800 Subject: [PATCH 2/4] =?UTF-8?q?=E5=8E=BB=E9=99=A4=E5=9C=96=E6=AA=94?= =?UTF-8?q?=E7=9A=84=E3=80=8C=E5=88=AA=E9=99=A4=E3=80=8D=E6=8C=89=E9=88=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- js/components/main.vue | 19 ++++++++----------- 1 file changed, 8 insertions(+), 11 deletions(-) diff --git a/js/components/main.vue b/js/components/main.vue index fb28d35..8dd2edf 100644 --- a/js/components/main.vue +++ b/js/components/main.vue @@ -195,13 +195,17 @@ var mainWindow = { } }, 'generatePic': function () { - this.is_print = true; + var main = this + main.is_print = true; html2canvas(document.getElementById('course-table-div')).then(function (canvas) { var a = document.createElement('a'); a.href = canvas.toDataURL("image/jpeg").replace("image/jpeg", "image/octet-stream"); a.download = '課表.jpg'; a.click(); }); + setTimeout(function(){ + main.is_print = false; + }, 5000); }, 'share': function () { if (this.user != "") @@ -209,9 +213,6 @@ var mainWindow = { else this.login() }, - 'enableDelete': function () { - this.is_print = !this.is_print; - }, }, components: { 'course-table': courseTable, @@ -254,18 +255,14 @@ var mainWindow = {
-
+
-
+
-
-
-
-
-
+
From c9094b465b7c76476ebcb228ea58bde286c9ed7e Mon Sep 17 00:00:00 2001 From: vincentinttsh Date: Sun, 24 Jan 2021 17:46:15 +0800 Subject: [PATCH 3/4] =?UTF-8?q?=E5=8E=BB=E9=99=A4=E5=9C=96=E6=AA=94?= =?UTF-8?q?=E7=9A=84=E3=80=8C=E5=88=AA=E9=99=A4=E3=80=8D=E6=8C=89=E9=88=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- js/components/main.vue | 25 ++++++++++++++++--------- 1 file changed, 16 insertions(+), 9 deletions(-) diff --git a/js/components/main.vue b/js/components/main.vue index 8dd2edf..e92a6a4 100644 --- a/js/components/main.vue +++ b/js/components/main.vue @@ -7,7 +7,7 @@ var mainWindow = { 'selectDepartment': '', 'foundName': "", "user": "", - 'token': "", + 'token': "", 'is_print': false, } }, @@ -196,16 +196,23 @@ var mainWindow = { }, 'generatePic': function () { var main = this - main.is_print = true; - html2canvas(document.getElementById('course-table-div')).then(function (canvas) { - var a = document.createElement('a'); - a.href = canvas.toDataURL("image/jpeg").replace("image/jpeg", "image/octet-stream"); - a.download = '課表.jpg'; - a.click(); + const doPrint = new Promise((resolve, reject) => { + main.is_print = true; + resolve(); }); - setTimeout(function(){ + doPrint + .then(() =>{ + html2canvas(document.getElementById('course-table-div')).then(function (canvas) { + var a = document.createElement('a'); + a.href = canvas.toDataURL("image/jpeg").replace("image/jpeg", "image/octet-stream"); + a.download = '課表.jpg'; + a.click(); + }); + console.log("adasd"); + }) + .then(() => { main.is_print = false; - }, 5000); + }) }, 'share': function () { if (this.user != "") From 1651428f057326e2f716aee2d5eaa5d62131595f Mon Sep 17 00:00:00 2001 From: vincentinttsh Date: Sun, 24 Jan 2021 17:49:54 +0800 Subject: [PATCH 4/4] =?UTF-8?q?=E5=8E=BB=E9=99=A4=E5=9C=96=E6=AA=94?= =?UTF-8?q?=E7=9A=84=E3=80=8C=E5=88=AA=E9=99=A4=E3=80=8D=E6=8C=89=E9=88=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- js/components/main.vue | 1 - 1 file changed, 1 deletion(-) diff --git a/js/components/main.vue b/js/components/main.vue index e92a6a4..abe0332 100644 --- a/js/components/main.vue +++ b/js/components/main.vue @@ -208,7 +208,6 @@ var mainWindow = { a.download = '課表.jpg'; a.click(); }); - console.log("adasd"); }) .then(() => { main.is_print = false;