diff --git a/src/api/apis/apis.js b/src/api/apis/apis.js index 3860fda..8d99827 100644 --- a/src/api/apis/apis.js +++ b/src/api/apis/apis.js @@ -8,11 +8,11 @@ const defaltService = (url, data) => { data, }); }; -const defaltGetService = (url, data) => { +const defaltGetService = (url, params) => { return service({ url: url, - method: "Get", - data, + method: "GET", + params, }); }; const downService = (url, data) => { diff --git a/src/views/basic/askTestQuestion/wrongQuestion.vue b/src/views/basic/askTestQuestion/wrongQuestion.vue index 662807a..6189afb 100644 --- a/src/views/basic/askTestQuestion/wrongQuestion.vue +++ b/src/views/basic/askTestQuestion/wrongQuestion.vue @@ -471,11 +471,10 @@ export default { }, // 全部删除 handleDelTest() { - let list = this.removeMatchingValues( - this.topicList.map((item) => item.id), - this.questions.map((item) => item.id) - ); + let list = this.removeMatchingValues(this.topicList, this.questions); this.questions = list; + console.log("移除本业", this.questions); + localStorage.setItem("testlist", JSON.stringify(this.questions)); }, // 重置 去除locastorage 以及 questions @@ -496,11 +495,11 @@ export default { }, // 去除第二数组中存在第一数组中的值 removeMatchingValues(arr1, arr2) { - // 将第一个数组的值存入 Set,提高查找效率 - const valuesSet = new Set(arr1); + const arr1Ids = arr1.map((item) => item.id); + const res = arr2.filter((item) => !arr1Ids.includes(item.id)); + console.log(res, "res"); - // 过滤第二个数组,保留不在 Set 中的值 - return arr2.filter((value) => !valuesSet.has(value)); + return res; }, // 判断第一个数组在第二个种是否全部存在 @@ -525,6 +524,8 @@ export default { console.log(data, "--------"); this.subjectList = data.data.subjectNames; + console.log(this.subjectList, "我被打印了"); + this.formData.subjectName = this.subjectList[0]; this.getClassList(); }, @@ -547,13 +548,17 @@ export default { }, // 获取班级信息 async getClassList() { - let data = await this.$request.getClassList({ + console.log(this.formData, "this.formDate"); + + let data = await this.$request.getGradeList({ grade: this.formData.grade, subjectName: this.formData.subjectName, }); this.classList = [ { className: "全部", classId: null }, - ...data.data.list, + ...data.data.map((item) => { + return { className: item.className, classId: item.id }; + }), ]; this.formData.classId = null; this.getList(); @@ -591,18 +596,18 @@ export default { // 获取ref onIFrameLoad(index) { const iframeRef = this.$refs["iframe" + index][0]; // 获取对应的 iframe - const doc = iframeRef.contentDocument || iframeRef.contentWindow.document; - const body = iframeRef.contentWindow.document.body; - body.style.overflowX = "hidden"; // 不允许出现横向滚动条 - const height = body.scrollHeight; // 获取内容的高度 - iframeRef.style.height = `${height}px`; // 设置 iframe 的高度 - // 获取第一个P标签 - const firstP = doc.getElementsByTagName("p")[0]; - // 或者修改第一个 < p > 标签的内容; - if (firstP) { - let a = this.processString(firstP.innerHTML); - firstP.innerHTML = a; - } + // const doc = iframeRef.contentDocument || iframeRef.contentWindow.document; + // const body = iframeRef.contentWindow.document.body; + // body.style.overflowX = "hidden"; // 不允许出现横向滚动条 + // const height = body.scrollHeight; // 获取内容的高度 + // iframeRef.style.height = `${height}px`; // 设置 iframe 的高度 + // // 获取第一个P标签 + // const firstP = doc.getElementsByTagName("p")[0]; + // // 或者修改第一个 < p > 标签的内容; + // if (firstP) { + // let a = this.processString(firstP.innerHTML); + // firstP.innerHTML = a; + // } }, // 子集删除后 父级需要更新