commit
a2139c3588
1 changed files with 19 additions and 31 deletions
|
|
@ -37,7 +37,7 @@ export default {
|
|||
components: {
|
||||
// eslint-disable-next-line vue/no-reserved-component-names
|
||||
Form,
|
||||
questionsPageLayout,
|
||||
questionsPageLayout
|
||||
},
|
||||
mixins: [baseFormMixin, vehicleQuestionsMixin],
|
||||
async beforeRouteEnter(to, from, next) {
|
||||
|
|
@ -47,8 +47,8 @@ export default {
|
|||
const promiseResultMap = [
|
||||
{
|
||||
resultKey: 'cmsContent',
|
||||
promise: cmsContentPromise,
|
||||
},
|
||||
promise: cmsContentPromise
|
||||
}
|
||||
];
|
||||
|
||||
const resultMap = await settleAllPromises(promiseResultMap);
|
||||
|
|
@ -63,8 +63,8 @@ export default {
|
|||
selectedAnswers: {},
|
||||
currentGlassIndex: 0,
|
||||
rules: {
|
||||
optionRequired: globalRules.OPTION_REQUIRED,
|
||||
},
|
||||
optionRequired: globalRules.OPTION_REQUIRED
|
||||
}
|
||||
};
|
||||
},
|
||||
computed: {
|
||||
|
|
@ -83,23 +83,17 @@ export default {
|
|||
partsOrQuestionsData() {
|
||||
return useMainStore().pageData(issPageValues.CAPABILITY_QUESTIONS)
|
||||
.partsOrQuestions;
|
||||
},
|
||||
}
|
||||
},
|
||||
mounted() {
|
||||
this.getInitialQuestionData();
|
||||
},
|
||||
methods: {
|
||||
arePagePrerequisitesValid() {
|
||||
const capabilityQuestionsFromPageData = useMainStore().pageData(
|
||||
issPageValues.CAPABILITY_QUESTIONS
|
||||
);
|
||||
const capabilityQuestionsFromPageData = useMainStore().pageData(issPageValues.CAPABILITY_QUESTIONS);
|
||||
return (
|
||||
capabilityQuestionsFromPageData?.partsOrQuestions?.some(
|
||||
(part) => part?.glassName
|
||||
) &&
|
||||
capabilityQuestionsFromPageData?.partsOrQuestions?.some(
|
||||
(part) => part?.capabilityQuestions?.length > 0
|
||||
)
|
||||
capabilityQuestionsFromPageData?.partsOrQuestions?.some((part) => part?.glassName)
|
||||
&& capabilityQuestionsFromPageData?.partsOrQuestions?.some((part) => part?.capabilityQuestions?.length > 0)
|
||||
);
|
||||
},
|
||||
getInitialQuestionData() {
|
||||
|
|
@ -140,9 +134,7 @@ export default {
|
|||
// get answerResult2 of returned answer
|
||||
let selectedAnswerResult2;
|
||||
glass.questions.forEach((q) => {
|
||||
const idx = q.answers.findIndex(
|
||||
(a) => a.answerResult === glass.answerData.answerResult
|
||||
);
|
||||
const idx = q.answers.findIndex((a) => a.answerResult === glass.answerData.answerResult);
|
||||
if (idx !== -1) {
|
||||
selectedAnswerResult2 = q.answers[idx].answerResult2;
|
||||
}
|
||||
|
|
@ -154,7 +146,7 @@ export default {
|
|||
result1: glass.answerData.answerResult,
|
||||
result2: selectedAnswerResult2,
|
||||
answeredQuestions: glass.answerData.answeredQuestions,
|
||||
isSuppressedPart: glass.isSuppressedPart,
|
||||
isSuppressedPart: glass.isSuppressedPart
|
||||
};
|
||||
});
|
||||
// clear out answerData for future page loads; must occur prior to store save
|
||||
|
|
@ -162,25 +154,21 @@ export default {
|
|||
glass.answerData = {};
|
||||
});
|
||||
// save to store as order.damage.moldingQuestionArrays (array)
|
||||
await this.mainStore.saveCapabilityQuestionAnswers(
|
||||
questionAnswersArray
|
||||
);
|
||||
await this.mainStore.saveCapabilityQuestionAnswers(questionAnswersArray);
|
||||
// get parts from the capabilityQuestionAnswers
|
||||
const partsOrQuestions = this.partsOrQuestionsData;
|
||||
// eslint-disable-next-line no-restricted-syntax
|
||||
for (const answer of questionAnswersArray) {
|
||||
partsOrQuestions.find(
|
||||
(partOrQuestion) =>
|
||||
partOrQuestion.glassLocation === answer.glassLocation &&
|
||||
partOrQuestion.glassName === answer.glassName
|
||||
).parts[0].childParts = [
|
||||
partsOrQuestions.find((partOrQuestion) =>
|
||||
partOrQuestion.glassLocation === answer.glassLocation
|
||||
&& partOrQuestion.glassName === answer.glassName).parts[0].childParts = [
|
||||
{
|
||||
partNumber: answer.partNum,
|
||||
},
|
||||
partNumber: answer.partNum
|
||||
}
|
||||
];
|
||||
}
|
||||
this.navigateForward(partsOrQuestions, null);
|
||||
},
|
||||
},
|
||||
}
|
||||
}
|
||||
};
|
||||
</script>
|
||||
|
|
|
|||
Loading…
Reference in a new issue