compontent time duration 交互影響, 關聯性待修.
This commit is contained in:
@@ -26,9 +26,9 @@
|
|||||||
></ConformanceSelectResult>
|
></ConformanceSelectResult>
|
||||||
<!-- time range -->
|
<!-- time range -->
|
||||||
<ConformanceTimeRange v-if="selectedRuleType === 'Activity duration' || selectedRuleType === 'Processing time' || selectedRuleType === 'Waiting time' || selectedRuleType === 'Cycle time'" :time="selectDurationTime"></ConformanceTimeRange>
|
<ConformanceTimeRange v-if="selectedRuleType === 'Activity duration' || selectedRuleType === 'Processing time' || selectedRuleType === 'Waiting time' || selectedRuleType === 'Cycle time'" :time="selectDurationTime"></ConformanceTimeRange>
|
||||||
selectDurationData:{{selectDurationData}} <br>
|
<!-- selectDurationData:{{selectDurationData}} <br>
|
||||||
selectDurationTime:{{selectDurationTime}} <br>
|
selectDurationTime:{{selectDurationTime}} <br>
|
||||||
isSubmitDurationData:{{isSubmitDurationData}} <br>
|
isSubmitDurationData:{{isSubmitDurationData}} <br> -->
|
||||||
</div>
|
</div>
|
||||||
<!-- button -->
|
<!-- button -->
|
||||||
<div class="space-x-4 p-4 flex justify-center items-content border-t border-neutral-300">
|
<div class="space-x-4 p-4 flex justify-center items-content border-t border-neutral-300">
|
||||||
|
|||||||
@@ -5,12 +5,13 @@
|
|||||||
<p>min: {{ timeData.min }}</p>
|
<p>min: {{ timeData.min }}</p>
|
||||||
<p>max: {{ timeData.max }}</p>
|
<p>max: {{ timeData.max }}</p>
|
||||||
<div class="flex justify-between items-center">
|
<div class="flex justify-between items-center">
|
||||||
<Durationjs></Durationjs>
|
<!-- <Durationjs :max="max" :min="min" :size="'min'" @total-seconds="minTotalSeconds"></Durationjs>
|
||||||
<span>~</span>
|
<span>~</span>
|
||||||
<Durationjs></Durationjs>
|
<Durationjs :max="max" :min="min" :size="'max'" @total-seconds="maxTotalSeconds"></Durationjs> -->
|
||||||
|
<Durationjs :max="minVuemax" :min="minVuemin" :size="'min'" ></Durationjs>
|
||||||
|
<span>~</span>
|
||||||
|
<Durationjs :max="maxVuemax" :min="maxVuemin" :size="'max'" ></Durationjs>
|
||||||
</div>
|
</div>
|
||||||
<!-- <Durationjs></Durationjs> -->
|
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
@@ -22,47 +23,50 @@ export default {
|
|||||||
data() {
|
data() {
|
||||||
return {
|
return {
|
||||||
timeData: {
|
timeData: {
|
||||||
min: null,
|
min: 0,
|
||||||
max: null,
|
max: 0,
|
||||||
},
|
},
|
||||||
selectTimeRange: [20, 80],
|
|
||||||
selectedStart: null,
|
|
||||||
selectedEnd: null,
|
|
||||||
timeStart: ['Sec(s)', 'Min(s)', 'Hour(s)', 'Day(s)', 'Week(s)', 'Mon(s)'],
|
|
||||||
timeEnd: ['Sec(s)', 'Min(s)', 'Hour(s)', 'Day(s)', 'Week(s)', 'Mon(s)'],
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
components: {
|
components: {
|
||||||
Durationjs,
|
Durationjs,
|
||||||
},
|
},
|
||||||
|
computed: { // 一定得用 computed 傳遞資料,不要拿父元件 props 的數值,不然子元件會交互影響。
|
||||||
|
minVuemin() {
|
||||||
|
return this.time ? this.time.min : 0;
|
||||||
|
},
|
||||||
|
minVuemax() {
|
||||||
|
return this.time ? this.time.max : 0;
|
||||||
|
},
|
||||||
|
maxVuemin() {
|
||||||
|
return this.time ? this.time.min : 0;
|
||||||
|
},
|
||||||
|
maxVuemax() {
|
||||||
|
return this.time ? this.time.max : 0;
|
||||||
|
},
|
||||||
|
},
|
||||||
watch: {
|
watch: {
|
||||||
time: function(newValue, oldValue) {
|
time: function(newValue, oldValue) {
|
||||||
|
if(newValue == null) {
|
||||||
|
this.timeData = {
|
||||||
|
min: 0,
|
||||||
|
max: 0
|
||||||
|
};
|
||||||
|
}else if(newValue != null) {
|
||||||
this.timeData = {
|
this.timeData = {
|
||||||
min: newValue.min,
|
min: newValue.min,
|
||||||
max: newValue.max
|
max: newValue.max
|
||||||
}
|
};
|
||||||
|
};
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
created() {
|
methods: {
|
||||||
this.selectedStart = this.timeStart[1];
|
minTotalSeconds(e) {
|
||||||
this.selectedEnd = this.timeEnd[5];
|
// console.log('min:', e);
|
||||||
|
},
|
||||||
|
maxTotalSeconds(e) {
|
||||||
|
// console.log('max:', e);
|
||||||
|
},
|
||||||
},
|
},
|
||||||
|
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
<style>
|
|
||||||
.time-preview {
|
|
||||||
border: 1px solid #eee;
|
|
||||||
max-width: 400px;
|
|
||||||
text-align: center;
|
|
||||||
margin: 0 auto;
|
|
||||||
margin-bottom: 20px;
|
|
||||||
padding: 15px;
|
|
||||||
background: rgb(70, 25, 173);
|
|
||||||
color: #fff;
|
|
||||||
}
|
|
||||||
|
|
||||||
.time-preview-time {
|
|
||||||
font-size: 30px;
|
|
||||||
}
|
|
||||||
</style>
|
|
||||||
|
|||||||
@@ -6,7 +6,10 @@
|
|||||||
<p>{{ minutes }}m</p>
|
<p>{{ minutes }}m</p>
|
||||||
<p>{{ seconds }}s</p>
|
<p>{{ seconds }}s</p>
|
||||||
</div>
|
</div>
|
||||||
<div class="duration-container absolute left-1/2 top-1/2 -translate-x-1/2" v-show="openTiemSelect">
|
<p>maxTotal: {{ maxTotal }}</p>
|
||||||
|
<p>minTotal: {{ minTotal }}</p>
|
||||||
|
<p>size: {{ size }}</p>
|
||||||
|
<div class="duration-container absolute left-0 top-full translate-y-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"
|
||||||
@@ -29,6 +32,29 @@
|
|||||||
|
|
||||||
<script>
|
<script>
|
||||||
export default {
|
export default {
|
||||||
|
props: {
|
||||||
|
max: {
|
||||||
|
type: Number,
|
||||||
|
default: 0,
|
||||||
|
required: true,
|
||||||
|
validator(value) {
|
||||||
|
return value >= 0;
|
||||||
|
},
|
||||||
|
},
|
||||||
|
min: {
|
||||||
|
type: Number,
|
||||||
|
default: 0,
|
||||||
|
required: true,
|
||||||
|
validator(value) {
|
||||||
|
return value >= 0;
|
||||||
|
},
|
||||||
|
},
|
||||||
|
size: {
|
||||||
|
type: String,
|
||||||
|
default: false,
|
||||||
|
required: true,
|
||||||
|
},
|
||||||
|
},
|
||||||
data() {
|
data() {
|
||||||
return {
|
return {
|
||||||
display: 'dhms',
|
display: 'dhms',
|
||||||
@@ -39,11 +65,17 @@ export default {
|
|||||||
maxDays: 0,
|
maxDays: 0,
|
||||||
minDays: 0,
|
minDays: 0,
|
||||||
totalSeconds: 0,
|
totalSeconds: 0,
|
||||||
maxTotal: 8740000,
|
maxTotal: null,
|
||||||
minTotal: 6666666,
|
minTotal: null,
|
||||||
inputTypes: [],
|
inputTypes: [],
|
||||||
lastInput: null,
|
lastInput: null,
|
||||||
openTiemSelect: false,
|
openTiemSelect: false,
|
||||||
|
// tUnits: {
|
||||||
|
// s: { dsp: 's', inc: 1, val: 0, max: 60, rate: 1, min: 0 },
|
||||||
|
// m: { dsp: 'm', inc: 1, val: 0, max: 60, rate: 60, min: 0 },
|
||||||
|
// h: { dsp: 'h', inc: 1, val: 0, max: 24, rate: 3600, min: 0 },
|
||||||
|
// d: { dsp: 'd', inc: 1, val: 0, max: this.maxDays, rate: 86400, min: this.minDays }
|
||||||
|
// },
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
computed: {
|
computed: {
|
||||||
@@ -68,22 +100,16 @@ export default {
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
directives: {
|
watch: {
|
||||||
'click-outside': {
|
max: function(newValue, oldValue) {
|
||||||
bind(el, { value }) {
|
this.maxTotal = newValue;
|
||||||
handleOutsideClick = e => {
|
this.size === 'max' && newValue !== oldValue ? this.createData() : null;
|
||||||
const isClickOutside = e.target !== el && !el.contains(e.target)
|
|
||||||
if (isClickOutside) value(e)
|
},
|
||||||
e.stopPropagation()
|
min: function(newValue, oldValue) {
|
||||||
}
|
this.minTotal = newValue;
|
||||||
document.addEventListener('click', handleOutsideClick)
|
this.size === 'min' && newValue !== oldValue ? this.createData() : null;
|
||||||
document.addEventListener('touchstart', handleOutsideClick)
|
|
||||||
},
|
},
|
||||||
unbind() {
|
|
||||||
document.removeEventListener('click', handleOutsideClick)
|
|
||||||
document.removeEventListener('touchstart', handleOutsideClick)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
onFocus(event) {
|
onFocus(event) {
|
||||||
@@ -120,6 +146,7 @@ export default {
|
|||||||
this.seconds = event.target.value;
|
this.seconds = event.target.value;
|
||||||
break;
|
break;
|
||||||
};
|
};
|
||||||
|
|
||||||
this.calculateTotalSeconds();
|
this.calculateTotalSeconds();
|
||||||
},
|
},
|
||||||
onKeyUp(event) {
|
onKeyUp(event) {
|
||||||
@@ -152,15 +179,28 @@ export default {
|
|||||||
newVal = '00';
|
newVal = '00';
|
||||||
} else {
|
} else {
|
||||||
newVal = '00';
|
newVal = '00';
|
||||||
}
|
};
|
||||||
}
|
};
|
||||||
}
|
};
|
||||||
|
|
||||||
input.value = newVal.toString().padStart(2, '0');
|
input.value = newVal.toString().padStart(2, '0');
|
||||||
|
switch (tUnit) {
|
||||||
|
case 'd':
|
||||||
|
this.days = input.value;
|
||||||
|
break;
|
||||||
|
case 'h':
|
||||||
|
this.hours = input.value;
|
||||||
|
break;
|
||||||
|
case 'm':
|
||||||
|
this.minutes = input.value;
|
||||||
|
break;
|
||||||
|
case 's':
|
||||||
|
this.seconds = input.value;
|
||||||
|
break;
|
||||||
|
};
|
||||||
if (selectIt) input.select();
|
if (selectIt) input.select();
|
||||||
},
|
},
|
||||||
secondToDate(totalSeconds, size) {
|
secondToDate(totalSeconds, size) {
|
||||||
// .toString().padStart(2, '0')
|
|
||||||
totalSeconds = parseInt(totalSeconds);
|
totalSeconds = parseInt(totalSeconds);
|
||||||
if(!isNaN(totalSeconds)) {
|
if(!isNaN(totalSeconds)) {
|
||||||
this.seconds = totalSeconds % 60;
|
this.seconds = totalSeconds % 60;
|
||||||
@@ -183,37 +223,52 @@ export default {
|
|||||||
|
|
||||||
for (const unit in this.tUnits) {
|
for (const unit in this.tUnits) {
|
||||||
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){
|
||||||
|
console.log('>max');
|
||||||
totalSeconds = this.maxTotal;
|
totalSeconds = this.maxTotal;
|
||||||
this.tUnits = tUnits;
|
this.tUnits = tUnits;
|
||||||
this.secondToDate(this.maxTotal, 'max');
|
|
||||||
} else if (totalSeconds <= this.minTotal) {
|
} else if (totalSeconds <= this.minTotal) {
|
||||||
|
console.log('<min');
|
||||||
// 小於最小值時要等於最小值
|
// 小於最小值時要等於最小值
|
||||||
totalSeconds = this.minTotal;
|
totalSeconds = this.minTotal;
|
||||||
this.tUnits = tUnits;
|
this.tUnits = tUnits;
|
||||||
this.secondToDate(this.minTotal, 'min');
|
this.secondToDate(this.minTotal, 'min');
|
||||||
} else {
|
} else {
|
||||||
this.totalSeconds = totalSeconds;
|
this.totalSeconds = totalSeconds;
|
||||||
}
|
};
|
||||||
|
// this.$emit('total-seconds', this.totalSeconds);
|
||||||
|
},
|
||||||
|
createData() {
|
||||||
|
// let size = 'min';
|
||||||
|
let size = this.size;
|
||||||
|
|
||||||
|
switch (size) {
|
||||||
|
case 'max':
|
||||||
|
this.secondToDate(this.minTotal, 'min');
|
||||||
|
this.secondToDate(this.maxTotal, 'max');
|
||||||
|
this.totalSeconds = this.maxTotal;
|
||||||
|
break;
|
||||||
|
case 'min':
|
||||||
|
this.secondToDate(this.maxTotal, 'max');
|
||||||
|
this.secondToDate(this.minTotal, 'min');
|
||||||
|
this.totalSeconds = this.minTotal;
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
};
|
||||||
|
// this.$emit('total-seconds', this.totalSeconds);
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
mounted() {
|
mounted() {
|
||||||
this.inputTypes = this.display.split('');
|
this.inputTypes = this.display.split('');
|
||||||
|
this.createData();
|
||||||
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