fix: Issues #218 done.

This commit is contained in:
chiayin
2024-03-28 16:34:06 +08:00
parent c608b1cc52
commit 301d49bd08
4 changed files with 184 additions and 94 deletions

View File

@@ -58,6 +58,13 @@ export default {
return value >= 0;
},
},
updateMin: {
type: Number,
required: false,
validator(value) {
return value >= 0;
},
},
size: {
type: String,
default: false,
@@ -133,6 +140,12 @@ export default {
this.calculateTotalSeconds();
},
},
updateMin: {
handler: function(newValue, oldValue) {
this.minTotal = newValue;
this.calculateTotalSeconds();
},
},
},
methods: {
onClose () {
@@ -235,12 +248,17 @@ export default {
// 箭頭向上,數字加一
newVal += this.tUnits[tUnit].inc;
if(newVal > this.tUnits[tUnit].max) {
// 超過該單位最大值時要進位為零
newVal = newVal % (this.tUnits[tUnit].max + 1);
// 前一個更大的單位要進位
if(input.dataset.index > 0) {
const prevUnit = document.querySelector(`input[data-index="${parseInt(input.dataset.index) - 1}"]`);
this.actionUpDown(prevUnit, true);
if(this.tUnits[tUnit].dsp === 'd'){
// 超過 maxDays 要等於最大值
this.totalSeconds = this.maxTotal;
} else {
// 超過該單位最大值時要進位為零
newVal = newVal % (this.tUnits[tUnit].max + 1);
// 前一個更大的單位要進位
if(input.dataset.index > 0) {
const prevUnit = document.querySelector(`input[data-index="${parseInt(input.dataset.index) - 1}"]`);
this.actionUpDown(prevUnit, true);
}
}
}
} else {
@@ -309,6 +327,9 @@ export default {
totalSeconds = this.minTotal;
this.secondToDate(this.minTotal, 'min');
this.totalSeconds = totalSeconds;
} else if((this.size === 'min' && totalSeconds <= this.maxTotal)) {
this.maxDays = Math.floor(this.maxTotal / (3600 * 24));
this.totalSeconds = totalSeconds;
} else {
this.totalSeconds = totalSeconds;
};