featurn: time duration layout done.
This commit is contained in:
@@ -1,14 +1,14 @@
|
|||||||
<template>
|
<template>
|
||||||
<section class="h-full shadow-[1px_0px_4px_rgba(0,0,0,0.25)] bg-neutral-100 absolute inset-y-0 left-0 z-10" :class="isShowBar?'w-full':'w-[300px]'">
|
<section class="h-full shadow-[1px_0px_4px_rgba(0,0,0,0.25)] bg-neutral-100 absolute inset-y-0 left-0 z-10" :class="isShowBar?'w-full':'w-[312px]'">
|
||||||
<!-- header -->
|
<!-- header -->
|
||||||
<div class="bg-neutral-200 px-4">
|
<div class="bg-neutral-200 px-4">
|
||||||
<p class="h2">Rule Settings</p>
|
<p class="h2">Rule Settings</p>
|
||||||
</div>
|
</div>
|
||||||
<!-- contanier -->
|
<!-- contanier -->
|
||||||
<div class="p-4 h-[calc(100%_-_40px)] flex">
|
<div class="p-4 h-[calc(100%_-_40px)] flex">
|
||||||
<div class="h-full flex flex-col justify-between w-[268px]">
|
<div class="h-full flex flex-col justify-between w-[280px]">
|
||||||
<!-- select -->
|
<!-- select -->
|
||||||
<div class="h-full overflow-y-auto scrollbar w-[268px]">
|
<div class="h-full overflow-y-auto scrollbar w-[280px]">
|
||||||
<!-- radio group -->
|
<!-- radio group -->
|
||||||
<ConformanceRadioGroup></ConformanceRadioGroup>
|
<ConformanceRadioGroup></ConformanceRadioGroup>
|
||||||
<!-- show and hidden button -->
|
<!-- show and hidden button -->
|
||||||
|
|||||||
@@ -1,10 +1,15 @@
|
|||||||
<template>
|
<template>
|
||||||
<div class="mt-2">
|
<div class="mt-2">
|
||||||
<p class="h2">Time Range</p>
|
<p class="h2">Time Range</p>
|
||||||
<div>
|
<div class=" text-sm leading-normal">
|
||||||
<p>min: {{ timeData.min }}</p>
|
<p>min: {{ timeData.min }}</p>
|
||||||
<p>max: {{ timeData.max }}</p>
|
<p>max: {{ timeData.max }}</p>
|
||||||
<Durationjs></Durationjs>
|
<div class="flex justify-between items-center">
|
||||||
|
<Durationjs></Durationjs>
|
||||||
|
<span>~</span>
|
||||||
|
<Durationjs></Durationjs>
|
||||||
|
</div>
|
||||||
|
<!-- <Durationjs></Durationjs> -->
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -1,5 +1,12 @@
|
|||||||
<template>
|
<template>
|
||||||
<div class="duration-container">
|
<div class=" relative">
|
||||||
|
<div class="flex justify-center items-center gap-1 px-1 w-32 border border-neutral-500 cursor-pointer" @click="openTiemSelect = !openTiemSelect">
|
||||||
|
<p>{{ days }}d</p>
|
||||||
|
<p>{{ hours }}h</p>
|
||||||
|
<p>{{ minutes }}m</p>
|
||||||
|
<p>{{ seconds }}s</p>
|
||||||
|
</div>
|
||||||
|
<div class="duration-container absolute left-1/2 top-1/2 -translate-x-1/2" v-show="openTiemSelect">
|
||||||
<div class="duration-box" v-for="(unit, index) in inputTypes" :key="unit">
|
<div class="duration-box" v-for="(unit, index) in inputTypes" :key="unit">
|
||||||
<input
|
<input
|
||||||
type="text"
|
type="text"
|
||||||
@@ -17,6 +24,7 @@
|
|||||||
<label class="duration">{{ tUnits[unit].dsp }}</label>
|
<label class="duration">{{ tUnits[unit].dsp }}</label>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
@@ -35,6 +43,7 @@ export default {
|
|||||||
minTotal: 6666666,
|
minTotal: 6666666,
|
||||||
inputTypes: [],
|
inputTypes: [],
|
||||||
lastInput: null,
|
lastInput: null,
|
||||||
|
openTiemSelect: false,
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
computed: {
|
computed: {
|
||||||
@@ -59,6 +68,23 @@ export default {
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
directives: {
|
||||||
|
'click-outside': {
|
||||||
|
bind(el, { value }) {
|
||||||
|
handleOutsideClick = e => {
|
||||||
|
const isClickOutside = e.target !== el && !el.contains(e.target)
|
||||||
|
if (isClickOutside) value(e)
|
||||||
|
e.stopPropagation()
|
||||||
|
}
|
||||||
|
document.addEventListener('click', handleOutsideClick)
|
||||||
|
document.addEventListener('touchstart', handleOutsideClick)
|
||||||
|
},
|
||||||
|
unbind() {
|
||||||
|
document.removeEventListener('click', handleOutsideClick)
|
||||||
|
document.removeEventListener('touchstart', handleOutsideClick)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
methods: {
|
methods: {
|
||||||
onFocus(event) {
|
onFocus(event) {
|
||||||
this.lastInput = event.target;
|
this.lastInput = event.target;
|
||||||
@@ -78,7 +104,22 @@ export default {
|
|||||||
else if(inputValue < min) event.target.value= min.toString().padStart(2, '0');
|
else if(inputValue < min) event.target.value= min.toString().padStart(2, '0');
|
||||||
|
|
||||||
// 數值更新, tUnits 也更新, 並計算 totalSeconds
|
// 數值更新, tUnits 也更新, 並計算 totalSeconds
|
||||||
this.tUnits[event.target.dataset.tunit].val = event.target.value;
|
const dsp = event.target.dataset.tunit;
|
||||||
|
this.tUnits[dsp].val = event.target.value;
|
||||||
|
switch (dsp) {
|
||||||
|
case 'd':
|
||||||
|
this.days = event.target.value;
|
||||||
|
break;
|
||||||
|
case 'h':
|
||||||
|
this.hours = event.target.value;
|
||||||
|
break;
|
||||||
|
case 'm':
|
||||||
|
this.minutes = event.target.value;
|
||||||
|
break;
|
||||||
|
case 's':
|
||||||
|
this.seconds = event.target.value;
|
||||||
|
break;
|
||||||
|
};
|
||||||
this.calculateTotalSeconds();
|
this.calculateTotalSeconds();
|
||||||
},
|
},
|
||||||
onKeyUp(event) {
|
onKeyUp(event) {
|
||||||
@@ -144,7 +185,6 @@ export default {
|
|||||||
const val = parseInt(this.tUnits[unit].val, 10);
|
const val = parseInt(this.tUnits[unit].val, 10);
|
||||||
if (!isNaN(val)) totalSeconds += val * this.tUnits[unit].rate;
|
if (!isNaN(val)) totalSeconds += val * this.tUnits[unit].rate;
|
||||||
}
|
}
|
||||||
console.log(totalSeconds);
|
|
||||||
|
|
||||||
// 大於最大值時要等於最大值
|
// 大於最大值時要等於最大值
|
||||||
if(totalSeconds >= this.maxTotal){
|
if(totalSeconds >= this.maxTotal){
|
||||||
@@ -163,8 +203,17 @@ export default {
|
|||||||
},
|
},
|
||||||
mounted() {
|
mounted() {
|
||||||
this.inputTypes = this.display.split('');
|
this.inputTypes = this.display.split('');
|
||||||
this.secondToDate(this.maxTotal, 'max');
|
|
||||||
this.totalSeconds = this.maxTotal;
|
let size ='min';
|
||||||
|
if(size === 'max') {
|
||||||
|
this.secondToDate(this.minTotal, 'min');
|
||||||
|
this.secondToDate(this.maxTotal, 'max');
|
||||||
|
this.totalSeconds = this.maxTotal;
|
||||||
|
}else if(size === 'min') {
|
||||||
|
this.secondToDate(this.maxTotal, 'max');
|
||||||
|
this.secondToDate(this.minTotal, 'min');
|
||||||
|
this.totalSeconds = this.minTotal;
|
||||||
|
}
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
</script>
|
</script>
|
||||||
|
|||||||
Reference in New Issue
Block a user