Conformance: time duration component add a comment.
This commit is contained in:
@@ -54,6 +54,9 @@ export default {
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
|
/**
|
||||||
|
* set props values
|
||||||
|
*/
|
||||||
setTimeValue() {
|
setTimeValue() {
|
||||||
// 深拷貝原始 timeData 的內容
|
// 深拷貝原始 timeData 的內容
|
||||||
this.minVuemin = JSON.parse(JSON.stringify(this.timeData.min));
|
this.minVuemin = JSON.parse(JSON.stringify(this.timeData.min));
|
||||||
@@ -61,9 +64,17 @@ export default {
|
|||||||
this.maxVuemin = JSON.parse(JSON.stringify(this.timeData.min));
|
this.maxVuemin = JSON.parse(JSON.stringify(this.timeData.min));
|
||||||
this.maxVuemax = JSON.parse(JSON.stringify(this.timeData.max));
|
this.maxVuemax = JSON.parse(JSON.stringify(this.timeData.max));
|
||||||
},
|
},
|
||||||
|
/**
|
||||||
|
* get min total seconds
|
||||||
|
* @param {Number} e
|
||||||
|
*/
|
||||||
minTotalSeconds(e) {
|
minTotalSeconds(e) {
|
||||||
this.timeRangeMin = e;
|
this.timeRangeMin = e;
|
||||||
},
|
},
|
||||||
|
/**
|
||||||
|
* get min total seconds
|
||||||
|
* @param {Number} e
|
||||||
|
*/
|
||||||
maxTotalSeconds(e) {
|
maxTotalSeconds(e) {
|
||||||
this.timeRangeMax = e;
|
this.timeRangeMax = e;
|
||||||
this.updateMax = e;
|
this.updateMax = e;
|
||||||
|
|||||||
@@ -122,10 +122,18 @@ export default {
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
|
/**
|
||||||
|
* get focus element
|
||||||
|
* @param {event} event
|
||||||
|
*/
|
||||||
onFocus(event) {
|
onFocus(event) {
|
||||||
this.lastInput = event.target;
|
this.lastInput = event.target;
|
||||||
this.lastInput.select(); // 當呼叫該方法時,文本框內的文字會被自動選中,這樣使用者可以方便地進行複製或刪除等操作。
|
this.lastInput.select(); // 當呼叫該方法時,文本框內的文字會被自動選中,這樣使用者可以方便地進行複製或刪除等操作。
|
||||||
},
|
},
|
||||||
|
/**
|
||||||
|
* when blur update input value and show number
|
||||||
|
* @param {event} event
|
||||||
|
*/
|
||||||
onBlur(event) {
|
onBlur(event) {
|
||||||
isNaN(event.target.value) ?
|
isNaN(event.target.value) ?
|
||||||
event.target.value = '00' :
|
event.target.value = '00' :
|
||||||
@@ -162,6 +170,10 @@ export default {
|
|||||||
|
|
||||||
this.calculateTotalSeconds();
|
this.calculateTotalSeconds();
|
||||||
},
|
},
|
||||||
|
/**
|
||||||
|
* 上下箭頭時的行為
|
||||||
|
* @param {event} event
|
||||||
|
*/
|
||||||
onKeyUp(event) {
|
onKeyUp(event) {
|
||||||
event.target.value = event.target.value.replace(/\D/g, '');
|
event.target.value = event.target.value.replace(/\D/g, '');
|
||||||
|
|
||||||
@@ -169,6 +181,12 @@ export default {
|
|||||||
this.actionUpDown(event.target, event.keyCode === 38, true);
|
this.actionUpDown(event.target, event.keyCode === 38, true);
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
|
/**
|
||||||
|
* 上下箭頭時的行為
|
||||||
|
* @param {element} input
|
||||||
|
* @param {number} goUp
|
||||||
|
* @param {boolean} selectIt
|
||||||
|
*/
|
||||||
actionUpDown(input, goUp, selectIt = false) {
|
actionUpDown(input, goUp, selectIt = false) {
|
||||||
const tUnit = input.dataset.tunit;
|
const tUnit = input.dataset.tunit;
|
||||||
let newVal = parseInt(input.value, 10);
|
let newVal = parseInt(input.value, 10);
|
||||||
@@ -213,6 +231,11 @@ export default {
|
|||||||
};
|
};
|
||||||
if (selectIt) input.select();
|
if (selectIt) input.select();
|
||||||
},
|
},
|
||||||
|
/**
|
||||||
|
* 設定 dhms 的數值
|
||||||
|
* @param {number} totalSeconds
|
||||||
|
* @param {string} size
|
||||||
|
*/
|
||||||
secondToDate(totalSeconds, size) {
|
secondToDate(totalSeconds, size) {
|
||||||
totalSeconds = parseInt(totalSeconds);
|
totalSeconds = parseInt(totalSeconds);
|
||||||
if(!isNaN(totalSeconds)) {
|
if(!isNaN(totalSeconds)) {
|
||||||
@@ -225,6 +248,9 @@ export default {
|
|||||||
else if(size === 'min') this.minDays = Math.floor(totalSeconds / (3600 * 24));
|
else if(size === 'min') this.minDays = Math.floor(totalSeconds / (3600 * 24));
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
|
/**
|
||||||
|
* 計算總秒數
|
||||||
|
*/
|
||||||
calculateTotalSeconds() {
|
calculateTotalSeconds() {
|
||||||
let totalSeconds = 0;
|
let totalSeconds = 0;
|
||||||
|
|
||||||
@@ -245,6 +271,9 @@ export default {
|
|||||||
};
|
};
|
||||||
this.$emit('total-seconds', this.totalSeconds);
|
this.$emit('total-seconds', this.totalSeconds);
|
||||||
},
|
},
|
||||||
|
/**
|
||||||
|
* 初始化
|
||||||
|
*/
|
||||||
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) {
|
||||||
|
|||||||
Reference in New Issue
Block a user