From 66e09aa85c8d0ead50808251c6c1d4498d42b0a3 Mon Sep 17 00:00:00 2001 From: chiayin Date: Mon, 21 Aug 2023 10:16:24 +0800 Subject: [PATCH] =?UTF-8?q?compontent=20time=20duration=20=E4=BA=A4?= =?UTF-8?q?=E4=BA=92=E5=BD=B1=E9=9F=BF,=20=E9=97=9C=E8=81=AF=E6=80=A7?= =?UTF-8?q?=E5=BE=85=E4=BF=AE.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Conformance/ConformanceSidebar.vue | 4 +- .../ConformanceTimeRange.vue | 80 ++++++----- src/components/durationjs.vue | 133 +++++++++++++----- 3 files changed, 138 insertions(+), 79 deletions(-) diff --git a/src/components/Discover/Conformance/ConformanceSidebar.vue b/src/components/Discover/Conformance/ConformanceSidebar.vue index bc66503..1ad0df3 100644 --- a/src/components/Discover/Conformance/ConformanceSidebar.vue +++ b/src/components/Discover/Conformance/ConformanceSidebar.vue @@ -26,9 +26,9 @@ > - selectDurationData:{{selectDurationData}}
+
diff --git a/src/components/Discover/Conformance/ConformanceSidebar/ConformanceTimeRange.vue b/src/components/Discover/Conformance/ConformanceSidebar/ConformanceTimeRange.vue index 6803af3..fe8bf43 100644 --- a/src/components/Discover/Conformance/ConformanceSidebar/ConformanceTimeRange.vue +++ b/src/components/Discover/Conformance/ConformanceSidebar/ConformanceTimeRange.vue @@ -5,12 +5,13 @@

min: {{ timeData.min }}

max: {{ timeData.max }}

- - ~ - + + + ~ +
- -
@@ -22,47 +23,50 @@ export default { data() { return { timeData: { - min: null, - max: null, + min: 0, + max: 0, }, - selectTimeRange: [20, 80], - selectedStart: null, - selectedEnd: null, - timeStart: ['Sec(s)', 'Min(s)', 'Hour(s)', 'Day(s)', 'Week(s)', 'Mon(s)'], - timeEnd: ['Sec(s)', 'Min(s)', 'Hour(s)', 'Day(s)', 'Week(s)', 'Mon(s)'], } }, components: { Durationjs, }, - watch: { - time: function(newValue, oldValue) { - this.timeData = { - min: newValue.min, - max: newValue.max - } + computed: { // 一定得用 computed 傳遞資料,不要拿父元件 props 的數值,不然子元件會交互影響。 + minVuemin() { + return this.time ? this.time.min : 0; + }, + minVuemax() { + return this.time ? this.time.max : 0; + }, + maxVuemin() { + return this.time ? this.time.min : 0; + }, + maxVuemax() { + return this.time ? this.time.max : 0; }, }, - created() { - this.selectedStart = this.timeStart[1]; - this.selectedEnd = this.timeEnd[5]; + watch: { + time: function(newValue, oldValue) { + if(newValue == null) { + this.timeData = { + min: 0, + max: 0 + }; + }else if(newValue != null) { + this.timeData = { + min: newValue.min, + max: newValue.max + }; + }; + }, + }, + methods: { + minTotalSeconds(e) { + // console.log('min:', e); + }, + maxTotalSeconds(e) { + // console.log('max:', e); + }, }, - } - diff --git a/src/components/durationjs.vue b/src/components/durationjs.vue index fdd65f4..12cf6fa 100644 --- a/src/components/durationjs.vue +++ b/src/components/durationjs.vue @@ -1,12 +1,15 @@