Add emitter.off cleanup in onBeforeUnmount for 10 components
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -392,7 +392,7 @@
|
||||
* check outcomes in a data table with status indicators.
|
||||
*/
|
||||
|
||||
import { ref, watch } from "vue";
|
||||
import { ref, watch, onBeforeUnmount } from "vue";
|
||||
import { storeToRefs } from "pinia";
|
||||
import { useConformanceStore } from "@/stores/conformance";
|
||||
import iconNA from "@/components/icons/IconNA.vue";
|
||||
@@ -504,7 +504,7 @@ const progressWidth = (value) => {
|
||||
* @returns {string} The formatted percentage string.
|
||||
*/
|
||||
const getPercentLabel = (val) => {
|
||||
if ((val * 100).toFixed(1) >= 100) return 100;
|
||||
if (Number((val * 100).toFixed(1)) >= 100) return 100;
|
||||
else return parseFloat((val * 100).toFixed(1));
|
||||
};
|
||||
|
||||
@@ -562,7 +562,7 @@ const setConformanceTempReportData = (newData) => {
|
||||
Object.values(newData.counts).reduce((acc, val) => acc + val, 0),
|
||||
);
|
||||
const sum = newData.counts.conforming + newData.counts.not_conforming;
|
||||
const rate = ((newData.counts.conforming / sum) * 100).toFixed(1);
|
||||
const rate = sum === 0 ? "0.0" : ((newData.counts.conforming / sum) * 100).toFixed(1);
|
||||
const isNullTime = (value) =>
|
||||
value === null ? null : getNumberLabel((value / 86400).toFixed(1));
|
||||
const isNullCase = (value) =>
|
||||
@@ -974,6 +974,11 @@ emitter.on(
|
||||
"timeRangeMaxMin",
|
||||
(newData) => (selectDurationTime.value = newData),
|
||||
);
|
||||
|
||||
onBeforeUnmount(() => {
|
||||
emitter.off("coverPlate");
|
||||
emitter.off("timeRangeMaxMin");
|
||||
});
|
||||
</script>
|
||||
<style scoped>
|
||||
:deep(.disc) {
|
||||
|
||||
@@ -1725,6 +1725,14 @@ emitter.on("isRadioActSeqFromToChange", (data) => {
|
||||
// beforeUnmount
|
||||
onBeforeUnmount(() => {
|
||||
if (reportWatchTimerId) clearTimeout(reportWatchTimerId);
|
||||
emitter.off("actRadioData");
|
||||
emitter.off("getListSequence");
|
||||
emitter.off("actListData");
|
||||
emitter.off("isRadioChange");
|
||||
emitter.off("isRadioSeqChange");
|
||||
emitter.off("isRadioProcessScopeChange");
|
||||
emitter.off("isRadioActSeqMoreChange");
|
||||
emitter.off("isRadioActSeqFromToChange");
|
||||
isSubmitReset();
|
||||
selectTimeReset();
|
||||
});
|
||||
|
||||
@@ -40,7 +40,7 @@
|
||||
* Checkbox-based activity list for conformance checking input.
|
||||
*/
|
||||
|
||||
import { ref, watch } from "vue";
|
||||
import { ref, watch, onBeforeUnmount } from "vue";
|
||||
import { sortNumEngZhtw } from "@/module/sortNumEngZhtw.js";
|
||||
import emitter from "@/utils/emitter";
|
||||
|
||||
@@ -73,4 +73,8 @@ function actListData() {
|
||||
emitter.on("reset", (data) => {
|
||||
actList.value = data;
|
||||
});
|
||||
|
||||
onBeforeUnmount(() => {
|
||||
emitter.off("reset");
|
||||
});
|
||||
</script>
|
||||
|
||||
@@ -41,7 +41,7 @@
|
||||
* start/end activity input.
|
||||
*/
|
||||
|
||||
import { ref, computed, watch } from "vue";
|
||||
import { ref, computed, watch, onBeforeUnmount } from "vue";
|
||||
import { useConformanceInputStore } from "@/stores/conformanceInput";
|
||||
import { sortNumEngZhtw } from "@/module/sortNumEngZhtw.js";
|
||||
import emitter from "@/utils/emitter";
|
||||
@@ -109,4 +109,8 @@ emitter.on("reset", (data) => {
|
||||
selectedRadio.value = data;
|
||||
});
|
||||
setGlobalActivityRadioDataState();
|
||||
|
||||
onBeforeUnmount(() => {
|
||||
emitter.off("reset");
|
||||
});
|
||||
</script>
|
||||
|
||||
@@ -115,7 +115,7 @@
|
||||
* conformance rule configuration.
|
||||
*/
|
||||
|
||||
import { ref, computed } from "vue";
|
||||
import { ref, computed, onBeforeUnmount } from "vue";
|
||||
import { sortNumEngZhtw } from "@/module/sortNumEngZhtw.js";
|
||||
import emitter from "@/utils/emitter";
|
||||
|
||||
@@ -200,6 +200,10 @@ listSequence.value = props.isSubmit ? newlist : [];
|
||||
emitter.on("reset", (data) => {
|
||||
listSequence.value = [];
|
||||
});
|
||||
|
||||
onBeforeUnmount(() => {
|
||||
emitter.off("reset");
|
||||
});
|
||||
</script>
|
||||
<style scoped>
|
||||
@reference "../../../../assets/tailwind.css";
|
||||
|
||||
@@ -356,7 +356,7 @@
|
||||
* check result statistics.
|
||||
*/
|
||||
|
||||
import { ref, computed, watch } from "vue";
|
||||
import { ref, computed, watch, onBeforeUnmount } from "vue";
|
||||
import { storeToRefs } from "pinia";
|
||||
import { useLoadingStore } from "@/stores/loading";
|
||||
import { useConformanceStore } from "@/stores/conformance";
|
||||
@@ -755,4 +755,13 @@ emitter.on("isRadioActSeqFromToChange", (data) => {
|
||||
emitter.on("reset", (data) => {
|
||||
reset();
|
||||
});
|
||||
|
||||
onBeforeUnmount(() => {
|
||||
emitter.off("isRadioChange");
|
||||
emitter.off("isRadioSeqChange");
|
||||
emitter.off("isRadioProcessScopeChange");
|
||||
emitter.off("isRadioActSeqMoreChange");
|
||||
emitter.off("isRadioActSeqFromToChange");
|
||||
emitter.off("reset");
|
||||
});
|
||||
</script>
|
||||
|
||||
@@ -235,7 +235,7 @@
|
||||
* configuration with calendar inputs.
|
||||
*/
|
||||
|
||||
import { reactive } from "vue";
|
||||
import { reactive, onBeforeUnmount } from "vue";
|
||||
import { storeToRefs } from "pinia";
|
||||
import { useConformanceStore } from "@/stores/conformance";
|
||||
import emitter from "@/utils/emitter";
|
||||
@@ -672,4 +672,13 @@ emitter.on("isRadioActSeqFromToChange", (data) => {
|
||||
reset();
|
||||
}
|
||||
});
|
||||
|
||||
onBeforeUnmount(() => {
|
||||
emitter.off("actRadioData");
|
||||
emitter.off("reset");
|
||||
emitter.off("isRadioChange");
|
||||
emitter.off("isRadioProcessScopeChange");
|
||||
emitter.off("isRadioActSeqMoreChange");
|
||||
emitter.off("isRadioActSeqFromToChange");
|
||||
});
|
||||
</script>
|
||||
|
||||
@@ -29,7 +29,7 @@
|
||||
* matched activities.
|
||||
*/
|
||||
|
||||
import { ref, watch } from "vue";
|
||||
import { ref, watch, onBeforeUnmount } from "vue";
|
||||
import emitter from "@/utils/emitter";
|
||||
|
||||
const props = defineProps(["data", "select"]);
|
||||
@@ -51,4 +51,8 @@ watch(
|
||||
);
|
||||
|
||||
emitter.on("reset", (val) => (displayData.value = val));
|
||||
|
||||
onBeforeUnmount(() => {
|
||||
emitter.off("reset");
|
||||
});
|
||||
</script>
|
||||
|
||||
@@ -29,7 +29,7 @@
|
||||
* and task pairs.
|
||||
*/
|
||||
|
||||
import { ref, watch } from "vue";
|
||||
import { ref, watch, onBeforeUnmount } from "vue";
|
||||
import emitter from "@/utils/emitter";
|
||||
|
||||
const props = defineProps(["timeResultData", "select"]);
|
||||
@@ -45,4 +45,8 @@ watch(
|
||||
);
|
||||
|
||||
emitter.on("reset", (val) => (data.value = val));
|
||||
|
||||
onBeforeUnmount(() => {
|
||||
emitter.off("reset");
|
||||
});
|
||||
</script>
|
||||
|
||||
@@ -62,7 +62,7 @@
|
||||
* fields and bounded min/max validation.
|
||||
*/
|
||||
|
||||
import { ref, computed, watch, onMounted } from "vue";
|
||||
import { ref, computed, watch, onMounted, onBeforeUnmount } from "vue";
|
||||
import emitter from "@/utils/emitter";
|
||||
|
||||
const props = defineProps({
|
||||
@@ -397,6 +397,10 @@ emitter.on("reset", () => {
|
||||
createData();
|
||||
});
|
||||
|
||||
onBeforeUnmount(() => {
|
||||
emitter.off("reset");
|
||||
});
|
||||
|
||||
// mounted
|
||||
onMounted(() => {
|
||||
inputTypes.value = display.value.split("");
|
||||
|
||||
Reference in New Issue
Block a user