Commit 03f275b4e5ae256c5790d589f75fd7d835885026
1 parent
0ebd841a
wip: 代码提交
Showing
3 changed files
with
36 additions
and
49 deletions
src/App.vue
src/views/basic/askTestQuestion/components/wrongQuestionDialog.vue
... | ... | @@ -350,6 +350,8 @@ export default { |
350 | 350 | this.userId + "testData", |
351 | 351 | JSON.stringify(this.testData) |
352 | 352 | ); |
353 | + console.log(data, "data"); | |
354 | + | |
353 | 355 | this.testAddDel(this.groups, data.addArr, data.delArr); |
354 | 356 | } |
355 | 357 | } else { |
... | ... | @@ -429,19 +431,19 @@ export default { |
429 | 431 | })); |
430 | 432 | }, |
431 | 433 | onIFrameLoad(id) { |
432 | - const iframeRef = this.$refs["iframe" + id][0]; // 获取对应的 iframe | |
433 | - const doc = iframeRef.contentDocument || iframeRef.contentWindow.document; | |
434 | - const body = iframeRef.contentWindow.document.body; | |
435 | - body.style.overflowX = "hidden"; // 不允许出现横向滚动条 | |
436 | - const height = body.offsetHeight; // 获取内容的高度 | |
437 | - iframeRef.style.height = `${height + 20}px`; // 设置 iframe 的高度 | |
438 | - // 获取第一个P标签 | |
439 | - const firstP = doc.getElementsByTagName("p")[0]; | |
440 | - // 或者修改第一个 < p > 标签的内容; | |
441 | - if (firstP) { | |
442 | - let a = this.processString(firstP.innerHTML); | |
443 | - firstP.innerHTML = a; | |
444 | - } | |
434 | + // const iframeRef = this.$refs["iframe" + id][0]; // 获取对应的 iframe | |
435 | + // const doc = iframeRef.contentDocument || iframeRef.contentWindow.document; | |
436 | + // const body = iframeRef.contentWindow.document.body; | |
437 | + // body.style.overflowX = "hidden"; // 不允许出现横向滚动条 | |
438 | + // const height = body.offsetHeight; // 获取内容的高度 | |
439 | + // iframeRef.style.height = `${height + 20}px`; // 设置 iframe 的高度 | |
440 | + // // 获取第一个P标签 | |
441 | + // const firstP = doc.getElementsByTagName("p")[0]; | |
442 | + // // 或者修改第一个 < p > 标签的内容; | |
443 | + // if (firstP) { | |
444 | + // let a = this.processString(firstP.innerHTML); | |
445 | + // firstP.innerHTML = a; | |
446 | + // } | |
445 | 447 | }, |
446 | 448 | |
447 | 449 | // 启动编辑模式 |
... | ... | @@ -639,14 +641,11 @@ export default { |
639 | 641 | const addArr = array2.filter( |
640 | 642 | (item2) => !array1.some((item1) => item1.id === item2.id) |
641 | 643 | ); |
642 | - | |
643 | 644 | return { |
644 | 645 | delArr, |
645 | 646 | addArr, |
646 | 647 | }; |
647 | 648 | }, |
648 | - | |
649 | - // 添加,删除 | |
650 | 649 | // 需要的数据,添加的数据,删除的数据 |
651 | 650 | testAddDel(arr1, arr2, arr3) { |
652 | 651 | if (arr2 && arr2.length > 0) { |
... | ... | @@ -672,22 +671,11 @@ export default { |
672 | 671 | } |
673 | 672 | if (arr3 && arr3.length > 0) { |
674 | 673 | // 删除数据 |
675 | - arr3.forEach((item3) => { | |
676 | - // 在 array1 中找到匹配的 type | |
677 | - let matchedArray1Item = arr1.find((item1) => | |
678 | - item1.subQuestionIds.filter((item) => item.id == item3.id) | |
674 | + const ids = new Set(arr3.map((item) => item.id)); | |
675 | + arr1.forEach((obj) => { | |
676 | + obj.subQuestionIds = obj.subQuestionIds.filter( | |
677 | + (item) => !ids.has(item.id) | |
679 | 678 | ); |
680 | - if (matchedArray1Item) { | |
681 | - // 如果找到了匹配的 type,遍历 matchedArray1Item 的 items | |
682 | - let _index = matchedArray1Item.subQuestionIds.findIndex( | |
683 | - (item) => item.id === item3.id | |
684 | - ); | |
685 | - if (_index != -1) { | |
686 | - matchedArray1Item.subQuestionIds.splice(_index, 1); | |
687 | - } | |
688 | - } else { | |
689 | - return; | |
690 | - } | |
691 | 679 | }); |
692 | 680 | } |
693 | 681 | ... | ... |
src/views/basic/askTestQuestion/wrongQuestion.vue
... | ... | @@ -625,23 +625,22 @@ export default { |
625 | 625 | |
626 | 626 | // 获取ref |
627 | 627 | onIFrameLoad(index) { |
628 | - const iframeRef = this.$refs["iframe" + index][0]; // 获取对应的 iframe | |
629 | - const doc = iframeRef.contentDocument || iframeRef.contentWindow.document; | |
630 | - const body = iframeRef.contentWindow.document.body; | |
631 | - body.style.overflowX = "hidden"; // 不允许出现横向滚动条 | |
632 | - const height = body.offsetHeight; // 获取内容的高度 | |
633 | - // console.log("body.offsetHeight:", body.offsetHeight); | |
634 | - // console.log("body.clientHeight:", body.clientHeight); | |
635 | - // console.log("body.scrollHeight:", body.scrollHeight); | |
636 | - | |
637 | - iframeRef.style.height = `${height + 20}px`; // 设置 iframe 的高度 | |
638 | - // 获取第一个P标签 | |
639 | - const firstP = doc.getElementsByTagName("p")[0]; | |
640 | - // 或者修改第一个 < p > 标签的内容; | |
641 | - if (firstP) { | |
642 | - let a = this.processString(firstP.innerHTML); | |
643 | - firstP.innerHTML = a; | |
644 | - } | |
628 | + // const iframeRef = this.$refs["iframe" + index][0]; // 获取对应的 iframe | |
629 | + // const doc = iframeRef.contentDocument || iframeRef.contentWindow.document; | |
630 | + // const body = iframeRef.contentWindow.document.body; | |
631 | + // body.style.overflowX = "hidden"; // 不允许出现横向滚动条 | |
632 | + // const height = body.offsetHeight; // 获取内容的高度 | |
633 | + // // console.log("body.offsetHeight:", body.offsetHeight); | |
634 | + // // console.log("body.clientHeight:", body.clientHeight); | |
635 | + // // console.log("body.scrollHeight:", body.scrollHeight); | |
636 | + // iframeRef.style.height = `${height + 20}px`; // 设置 iframe 的高度 | |
637 | + // // 获取第一个P标签 | |
638 | + // const firstP = doc.getElementsByTagName("p")[0]; | |
639 | + // // 或者修改第一个 < p > 标签的内容; | |
640 | + // if (firstP) { | |
641 | + // let a = this.processString(firstP.innerHTML); | |
642 | + // firstP.innerHTML = a; | |
643 | + // } | |
645 | 644 | }, |
646 | 645 | |
647 | 646 | // 子集删除后 父级需要更新 | ... | ... |