Conformance: time duration component done.
This commit is contained in:
@@ -2,10 +2,8 @@
|
|||||||
<div class="mt-2">
|
<div class="mt-2">
|
||||||
<p class="h2">Time Range</p>
|
<p class="h2">Time Range</p>
|
||||||
<div class=" text-sm leading-normal">
|
<div class=" text-sm leading-normal">
|
||||||
<p>min: {{ timeData.min }}</p>
|
|
||||||
<p>max: {{ timeData.max }}</p>
|
|
||||||
<div class="flex justify-between items-center">
|
<div class="flex justify-between items-center">
|
||||||
<Durationjs :max="minVuemax" :min="minVuemin" :size="'min'" @total-seconds="minTotalSeconds"></Durationjs>
|
<Durationjs :max="minVuemax" :min="minVuemin" :size="'min'" :updateMax="updateMax" @total-seconds="minTotalSeconds"></Durationjs>
|
||||||
<span>~</span>
|
<span>~</span>
|
||||||
<Durationjs :max="maxVuemax" :min="maxVuemin" :size="'max'" @total-seconds="maxTotalSeconds"></Durationjs>
|
<Durationjs :max="maxVuemax" :min="maxVuemin" :size="'max'" @total-seconds="maxTotalSeconds"></Durationjs>
|
||||||
</div>
|
</div>
|
||||||
@@ -25,56 +23,50 @@ export default {
|
|||||||
},
|
},
|
||||||
timeRangeMin: 0,
|
timeRangeMin: 0,
|
||||||
timeRangeMax: 0,
|
timeRangeMax: 0,
|
||||||
|
minVuemin: 0,
|
||||||
|
minVuemax: 0,
|
||||||
|
maxVuemin: 0,
|
||||||
|
maxVuemax: 0,
|
||||||
|
updateMax: null,
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
components: {
|
components: {
|
||||||
Durationjs,
|
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: {
|
watch: {
|
||||||
time: function(newValue, oldValue) {
|
time: {
|
||||||
if(newValue == null) {
|
handler: function(newValue, oldValue) {
|
||||||
this.timeData = {
|
if(newValue == null) {
|
||||||
min: 0,
|
this.timeData = {
|
||||||
max: 0
|
min: 0,
|
||||||
};
|
max: 0
|
||||||
}else if(newValue != null) {
|
};
|
||||||
this.timeData = {
|
}else if(newValue != null) {
|
||||||
min: newValue.min,
|
this.timeData = {
|
||||||
max: newValue.max
|
min: newValue.min,
|
||||||
};
|
max: newValue.max
|
||||||
}
|
};
|
||||||
|
this.setTimeValue();
|
||||||
|
}
|
||||||
|
},
|
||||||
|
deep: true,
|
||||||
|
immediate: true,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
methods: {
|
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) {
|
minTotalSeconds(e) {
|
||||||
console.log('min:', e);
|
|
||||||
this.timeRangeMin = e;
|
this.timeRangeMin = e;
|
||||||
},
|
},
|
||||||
maxTotalSeconds(e) {
|
maxTotalSeconds(e) {
|
||||||
console.log('max:', e);
|
|
||||||
this.timeRangeMax = e;
|
this.timeRangeMax = e;
|
||||||
|
this.updateMax = e;
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -46,6 +46,13 @@ export default {
|
|||||||
return value >= 0;
|
return value >= 0;
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
updateMax: {
|
||||||
|
type: Number,
|
||||||
|
required: false,
|
||||||
|
validator(value) {
|
||||||
|
return value >= 0;
|
||||||
|
},
|
||||||
|
},
|
||||||
size: {
|
size: {
|
||||||
type: String,
|
type: String,
|
||||||
default: false,
|
default: false,
|
||||||
@@ -94,9 +101,9 @@ export default {
|
|||||||
watch: {
|
watch: {
|
||||||
max: {
|
max: {
|
||||||
handler: function(newValue, oldValue) {
|
handler: function(newValue, oldValue) {
|
||||||
this.maxTotal = newValue;
|
this.maxTotal = newValue;
|
||||||
this.size === 'max' && newValue !== oldValue ? this.createData() : null;
|
this.size === 'max' && newValue !== oldValue ? this.createData() : null;
|
||||||
},
|
},
|
||||||
immediate: true,
|
immediate: true,
|
||||||
},
|
},
|
||||||
min: {
|
min: {
|
||||||
@@ -105,7 +112,14 @@ export default {
|
|||||||
this.size === 'min' && newValue !== oldValue ? this.createData() : null;
|
this.size === 'min' && newValue !== oldValue ? this.createData() : null;
|
||||||
},
|
},
|
||||||
immediate: true,
|
immediate: true,
|
||||||
}
|
},
|
||||||
|
// min 的最大值要等於 max 的總秒數
|
||||||
|
updateMax: {
|
||||||
|
handler: function(newValue, oldValue) {
|
||||||
|
this.maxTotal = newValue;
|
||||||
|
newValue !== oldValue ? this.createData() : null;
|
||||||
|
},
|
||||||
|
},
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
onFocus(event) {
|
onFocus(event) {
|
||||||
@@ -233,7 +247,6 @@ export default {
|
|||||||
},
|
},
|
||||||
async createData() {
|
async createData() {
|
||||||
let size = this.size;
|
let size = this.size;
|
||||||
|
|
||||||
if (this.maxTotal !== await null && this.minTotal !== await null) {
|
if (this.maxTotal !== await null && this.minTotal !== await null) {
|
||||||
switch (size) {
|
switch (size) {
|
||||||
case 'max':
|
case 'max':
|
||||||
@@ -255,7 +268,6 @@ export default {
|
|||||||
},
|
},
|
||||||
mounted() {
|
mounted() {
|
||||||
this.inputTypes = this.display.split('');
|
this.inputTypes = this.display.split('');
|
||||||
// this.createData();
|
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
</script>
|
</script>
|
||||||
|
|||||||
Reference in New Issue
Block a user