-
min: {{ timeData.min }}
-
max: {{ timeData.max }}
-
+
~
@@ -25,56 +23,50 @@ export default {
},
timeRangeMin: 0,
timeRangeMax: 0,
+ minVuemin: 0,
+ minVuemax: 0,
+ maxVuemin: 0,
+ maxVuemax: 0,
+ updateMax: null,
}
},
components: {
Durationjs,
},
- computed: {
- minVuemin() {
- let min = 0;
- min = JSON.parse(JSON.stringify(this.timeData.min)); // 深拷貝原始 timeData 的內容
- return min;
- },
- minVuemax() {
- let max = 0;
- max = JSON.parse(JSON.stringify(this.timeData.max)); // 深拷貝原始 timeData 的內容
- return max;
- },
- maxVuemin() {
- let min = 0;
- min = JSON.parse(JSON.stringify(this.timeData.min)); // 深拷貝原始 timeData 的內容
- return min;
- },
- maxVuemax() {
- let max = 0;
- max = JSON.parse(JSON.stringify(this.timeData.max)); // 深拷貝原始 timeData 的內容
- return max;
- },
- },
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
- };
- }
+ time: {
+ handler: function(newValue, oldValue) {
+ if(newValue == null) {
+ this.timeData = {
+ min: 0,
+ max: 0
+ };
+ }else if(newValue != null) {
+ this.timeData = {
+ min: newValue.min,
+ max: newValue.max
+ };
+ this.setTimeValue();
+ }
+ },
+ deep: true,
+ immediate: true,
},
},
methods: {
+ setTimeValue() {
+ // 深拷貝原始 timeData 的內容
+ this.minVuemin = JSON.parse(JSON.stringify(this.timeData.min));
+ this.minVuemax = JSON.parse(JSON.stringify(this.timeData.max));
+ this.maxVuemin = JSON.parse(JSON.stringify(this.timeData.min));
+ this.maxVuemax = JSON.parse(JSON.stringify(this.timeData.max));
+ },
minTotalSeconds(e) {
- console.log('min:', e);
this.timeRangeMin = e;
},
maxTotalSeconds(e) {
- console.log('max:', e);
this.timeRangeMax = e;
+ this.updateMax = e;
},
},
}
diff --git a/src/components/durationjs.vue b/src/components/durationjs.vue
index 667877e..9c1504d 100644
--- a/src/components/durationjs.vue
+++ b/src/components/durationjs.vue
@@ -46,6 +46,13 @@ export default {
return value >= 0;
},
},
+ updateMax: {
+ type: Number,
+ required: false,
+ validator(value) {
+ return value >= 0;
+ },
+ },
size: {
type: String,
default: false,
@@ -94,9 +101,9 @@ export default {
watch: {
max: {
handler: function(newValue, oldValue) {
- this.maxTotal = newValue;
- this.size === 'max' && newValue !== oldValue ? this.createData() : null;
- },
+ this.maxTotal = newValue;
+ this.size === 'max' && newValue !== oldValue ? this.createData() : null;
+ },
immediate: true,
},
min: {
@@ -105,7 +112,14 @@ export default {
this.size === 'min' && newValue !== oldValue ? this.createData() : null;
},
immediate: true,
- }
+ },
+ // min 的最大值要等於 max 的總秒數
+ updateMax: {
+ handler: function(newValue, oldValue) {
+ this.maxTotal = newValue;
+ newValue !== oldValue ? this.createData() : null;
+ },
+ },
},
methods: {
onFocus(event) {
@@ -233,7 +247,6 @@ export default {
},
async createData() {
let size = this.size;
-
if (this.maxTotal !== await null && this.minTotal !== await null) {
switch (size) {
case 'max':
@@ -255,7 +268,6 @@ export default {
},
mounted() {
this.inputTypes = this.display.split('');
- // this.createData();
},
};