|
@@ -256,15 +256,19 @@ export default {
|
|
|
// console.log(cachePaperInfo);
|
|
|
return cachePaperInfo;
|
|
|
},
|
|
|
- assignCachePaperData(paperData, cacheData) {
|
|
|
+ assignCachePaperData(paperData, cacheData, mergeReverse = false) {
|
|
|
return paperData.map((detail, dIndex) => {
|
|
|
detail.questions = detail.questions.map((question, qIndex) => {
|
|
|
let k = `${dIndex + 1}_${qIndex + 1}`;
|
|
|
- let nq = this.mergeObjData(question, cacheData[k] || {});
|
|
|
+ let nq = this.mergeObjData(
|
|
|
+ question,
|
|
|
+ cacheData[k] || {},
|
|
|
+ mergeReverse
|
|
|
+ );
|
|
|
if (question.subQuestions && question.subQuestions.length) {
|
|
|
nq.subQuestions = question.subQuestions.map((subq, subqIndex) => {
|
|
|
let k = `${dIndex + 1}_${qIndex + 1}_${subqIndex + 1}`;
|
|
|
- return this.mergeObjData(subq, cacheData[k] || {});
|
|
|
+ return this.mergeObjData(subq, cacheData[k] || {}, mergeReverse);
|
|
|
});
|
|
|
}
|
|
|
return nq;
|
|
@@ -279,10 +283,14 @@ export default {
|
|
|
}
|
|
|
return val === null || val === "" || val === undefined;
|
|
|
},
|
|
|
- mergeObjData(targetObj, cacheObj) {
|
|
|
+ mergeObjData(targetObj, cacheObj, mergeReverse) {
|
|
|
let data = { ...targetObj };
|
|
|
Object.keys(cacheObj).forEach((k) => {
|
|
|
- data[k] = this.isNull(targetObj[k]) ? cacheObj[k] : targetObj[k];
|
|
|
+ if (mergeReverse) {
|
|
|
+ data[k] = this.isNull(cacheObj[k]) ? targetObj[k] : cacheObj[k];
|
|
|
+ } else {
|
|
|
+ data[k] = this.isNull(targetObj[k]) ? cacheObj[k] : targetObj[k];
|
|
|
+ }
|
|
|
});
|
|
|
return data;
|
|
|
},
|
|
@@ -604,7 +612,11 @@ export default {
|
|
|
res.data.detailInfo,
|
|
|
questionInfoField
|
|
|
);
|
|
|
- this.paperData = this.assignCachePaperData(this.paperData, cacheData);
|
|
|
+ this.paperData = this.assignCachePaperData(
|
|
|
+ this.paperData,
|
|
|
+ cacheData,
|
|
|
+ true
|
|
|
+ );
|
|
|
this.questionKey = randomCode();
|
|
|
},
|
|
|
},
|