From 82eceb0c9a6fa225aca43ed3edec1b25da9e1063 Mon Sep 17 00:00:00 2001 From: 闫增涛 <1829501689@qq.com> Date: 星期四, 06 六月 2024 18:48:50 +0800 Subject: [PATCH] 舞蹈优化 --- src/components/examinations/index.vue | 42 ++++++++++++++++++++++-------------------- 1 files changed, 22 insertions(+), 20 deletions(-) diff --git a/src/components/examinations/index.vue b/src/components/examinations/index.vue index 393f4cb..9e462e0 100644 --- a/src/components/examinations/index.vue +++ b/src/components/examinations/index.vue @@ -426,7 +426,6 @@ props: { cardList: { type: Array, - default: [], }, primaryColor: { type: String, @@ -446,14 +445,17 @@ cardData:[] }; }, - inject:['changeQuestionData'], + watch:{ + cardList:{ + handler(newVal) { + console.log('11',newVal); + } + } + }, mounted() { this.cardData = this.cardList - }, - computed:{ - cardLists() { - return this.props.cardList - } + console.log('this.cardList',this.cardList); + console.log('this.cardData',this.cardData); }, methods: { // 鏁扮粍杞负瀛楃涓叉柟娉� @@ -488,20 +490,19 @@ } }, redo() { - for (let index = 0; index < this.cardList.length; index++) { - const item = this.cardList[index]; + for (let index = 0; index < this.cardData.length; index++) { + const item = this.cardData[index]; for (let cindex = 0; cindex < item.infoList.length; cindex++) { const citem = item.infoList[cindex]; citem.userAnswer = ""; citem.isComplete = false; } } - console.log('閲嶅仛',this.cardList); }, openAnswers() { this.$data.loading = true; - for (let index = 0; index < this.cardList.length; index++) { - const item = this.cardList[index]; + for (let index = 0; index < this.cardData.length; index++) { + const item = this.cardData[index]; for (let cindex = 0; cindex < item.infoList.length; cindex++) { const citem = item.infoList[cindex]; citem.isComplete = true; @@ -514,7 +515,7 @@ }, // 鎵规敼棰樼洰 (缁冧範,鎴戠殑鍋氶,鎴戠殑鏀惰棌妯″紡涓�) handleQuestion() { - const list = this.$props.cardList; + const list = this.cardData; for (let index = 0; index < list.length; index++) { const item = list[index]; for (let cindex = 0; cindex < item.infoList.length; cindex++) { @@ -559,8 +560,8 @@ } } } - this.$props.cardList = list; - console.log(this.$props.cardList); + this.cardData = list; + console.log(this.cardData); }, getParentWithClass(element, className) { while (element.parentElement) { @@ -572,20 +573,20 @@ }, // 淇濆瓨鎸夐挳 saveAnswer() { - const element = document.getElementsByClassName("examination")[0]; + const element = (this.container ? this.container : document + ).querySelector(".examination"); if (element) { const pageNum = this.getParentWithClass( element, "page-box" ).getAttribute("page"); - console.log(this.config.activeBook.name, pageNum); const oldAnswerData = localStorage.getItem( this.config.activeBook.name + "oldAnswerData" ); let oldData = oldAnswerData ? JSON.parse(oldAnswerData) : {}; const asnwerList = []; - for (let index = 0; index < this.$props.cardList.length; index++) { - const item = this.$props.cardList[index]; + for (let index = 0; index < this.cardData.length; index++) { + const item = this.cardData[index]; for (let cindex = 0; cindex < item.infoList.length; cindex++) { const citem = item.infoList[cindex]; asnwerList.push({ @@ -595,7 +596,8 @@ } } if(oldData[pageNum]) { - oldData[pageNum].push(asnwerList) + oldData[pageNum] = oldData[pageNum].filter(citem => asnwerList.findIndex(ditem => ditem.id == citem.id) == -1 ) + oldData[pageNum].push(...asnwerList) } else { oldData[pageNum] = asnwerList } -- Gitblit v1.9.1