fix #217; this time finally found the root cause.

If user didn't click any start-end radio button this time,
the start, end value might be null as their initial values are.
So we need to use the earliest value stored in pinia. (In ActRadio.vue created phase)
This commit is contained in:
Cindy Chang
2024-06-07 15:31:53 +08:00
parent 88082c3b8a
commit 7e362d8740
5 changed files with 86 additions and 20 deletions

View File

@@ -10,6 +10,8 @@
</div>
</template>
<script>
import { mapActions, } from 'pinia';
import ConformanceInputStore from "@/stores/conformanceInput";
import { sortNumEngZhtw } from '@/module/sortNumEngZhtw.js';
export default {
@@ -32,18 +34,31 @@ export default {
this.selectedRadio = newValue;
},
},
computed: {
inputActivityRadioData: {
get(){
return {
category: this.category,
task: this.selectedRadio, // For example, "a", or "出院"
};
},
} ,
},
methods: {
/**
* 將選取的 Activity 傳出去
*/
actRadioData() {
this.localSelect = null;
this.$emitter.emit('actRadioData', {
category: this.category,
task: this.selectedRadio, // For example, "a", or "出院"
});
this.$emitter.emit('actRadioData', this.inputActivityRadioData);
this.$emit('selected-task', this.selectedRadio);
}
this.setActivityRadioStartEndData(this.inputActivityRadioData.task);
},
setGlobalActivityRadioDataState(){
//this.title: value might be "From" or "To"
this.setActivityRadioStartEndData(this.inputActivityRadioData.task, this.title);
},
...mapActions(ConformanceInputStore, ['setActivityRadioStartEndData']),
},
created() {
sortNumEngZhtw(this.sortData);
@@ -52,6 +67,7 @@ export default {
this.$emitter.on('reset', (data) => {
this.selectedRadio = data;
});
this.setGlobalActivityRadioDataState();
},
}
</script>

View File

@@ -165,17 +165,23 @@ export default {
switch (category) {
case 'act':
data.forEach(i => {
if(i.label === task) result = i.duration;
if(i.label === task) {
result = i.duration;
}
});
break;
case 'single':
data.forEach(i => {
if(i.task === task) result = i.time;
if(i.task === task) {
result = i.time;
}
});
break;
case 'double':
data.forEach(i => {
if(i.start === task && i.end === taskTwo) result = i.time;
if(i.start === task && i.end === taskTwo) {
result = i.time;
}
});
break;
case 'all':