Conformance: time duration component add a comment.

This commit is contained in:
chiayin
2023-08-29 14:47:53 +08:00
parent 89aa346b8f
commit 2b90c02a8c
2 changed files with 40 additions and 0 deletions

View File

@@ -122,10 +122,18 @@ export default {
},
},
methods: {
/**
* get focus element
* @param {event} event
*/
onFocus(event) {
this.lastInput = event.target;
this.lastInput.select(); // 當呼叫該方法時,文本框內的文字會被自動選中,這樣使用者可以方便地進行複製或刪除等操作。
},
/**
* when blur update input value and show number
* @param {event} event
*/
onBlur(event) {
isNaN(event.target.value) ?
event.target.value = '00' :
@@ -162,6 +170,10 @@ export default {
this.calculateTotalSeconds();
},
/**
* 上下箭頭時的行為
* @param {event} event
*/
onKeyUp(event) {
event.target.value = event.target.value.replace(/\D/g, '');
@@ -169,6 +181,12 @@ export default {
this.actionUpDown(event.target, event.keyCode === 38, true);
};
},
/**
* 上下箭頭時的行為
* @param {element} input
* @param {number} goUp
* @param {boolean} selectIt
*/
actionUpDown(input, goUp, selectIt = false) {
const tUnit = input.dataset.tunit;
let newVal = parseInt(input.value, 10);
@@ -213,6 +231,11 @@ export default {
};
if (selectIt) input.select();
},
/**
* 設定 dhms 的數值
* @param {number} totalSeconds
* @param {string} size
*/
secondToDate(totalSeconds, size) {
totalSeconds = parseInt(totalSeconds);
if(!isNaN(totalSeconds)) {
@@ -225,6 +248,9 @@ export default {
else if(size === 'min') this.minDays = Math.floor(totalSeconds / (3600 * 24));
};
},
/**
* 計算總秒數
*/
calculateTotalSeconds() {
let totalSeconds = 0;
@@ -245,6 +271,9 @@ export default {
};
this.$emit('total-seconds', this.totalSeconds);
},
/**
* 初始化
*/
async createData() {
let size = this.size;
if (this.maxTotal !== await null && this.minTotal !== await null) {