From 6aac0dd9c6d6bd3de148f3d6e123f9c91b1aab4b Mon Sep 17 00:00:00 2001 From: user1 <10901603+no-distractions1@user.noreply.gitee.com> Date: 星期二, 02 七月 2024 09:31:04 +0800 Subject: [PATCH] Merge branch 'master' of http://182.92.203.7:2001/r/testbookLayout --- src/books/childHealth/view/index.vue | 434 +++--------------------------------------------------- 1 files changed, 24 insertions(+), 410 deletions(-) diff --git a/src/books/childHealth/view/index.vue b/src/books/childHealth/view/index.vue index 118cadf..342cbde 100644 --- a/src/books/childHealth/view/index.vue +++ b/src/books/childHealth/view/index.vue @@ -1,386 +1,21 @@ <template> <div class="temp-book" @mouseup="handleMouseUp"> - <pageHeader></pageHeader> <pageContent></pageContent> </div> </template> <script> -import examinations from "./components/examinations/index.vue"; -import { getPublicImage } from "@/assets/js/middleGround/tool"; -import pageHeader from "./header/index.vue"; import pageContent from "./content/index.vue"; -import {mapState} from 'vuex' export default { - name: "child-health", components: { - pageHeader, pageContent, - examinations, }, data() { - return { - type: "option", - idPathList: [], - cardList: [], - }; + return {}; }, - mounted() { - this.getBookInfo(); - console.log(this.$store.state.qiankun, "this.$store.state.qiankun"); - }, - // computed: { - // ...mapState(['lineHeightList']) - // }, - // wathch: { - // lineHeightList:{ - // handler(){ - // console.log('鐩戝惉鍒發ineHeightList鍙樺寲'); - // this.handleDom() - // }, - // deep:true - // } - // }, + + mounted() {}, methods: { - getBookInfo() { - let query = { - path: "*", - queryType: "*", - productId: this.config.bookId, - favoriteTypes: "FavoriteBookCity", - itemFields: { - "SysType=": "CmsFolder", - }, - coverSize: { - height: 300, - }, - fields: { - seriesName: [], - author: [], - isbn: [], - publicationDate: [], - bookClassification: [], - paperPrice: [], - JDLink: [], - tmallLink: [], - dangdangLink: [], - weidianLink: [], - content: [], - authorIntroduction: [], - // isApplyPaperBook: [], - // isApplyEBook: [], - isApplyBook: [], - isSell: [], - pdf: [], - protectedEpub: [], - probationPage: [], //pdf璇曡椤垫暟 - freeEpubPage: [], //epub璇曡鐧惧垎姣� - }, - }; - this.MG.store.getProductDetail(query).then((res) => { - console.log("鍥句功淇℃伅", res.datas.cmsDatas[0].datas); - const testData = res.datas.cmsDatas[0].datas.find( - (item) => item.refCode == "questionBank" - ); - this.getResourceData(testData); - }); - }, - getResourceData(type) { - let query = { - path: "*", - queryType: "*", - productId: this.config.bookId, - cmsPath: type.productLinkPath, - itemFields: { - SysType: "CmsFolder", - // 璧勬簮绫诲瀷锛岃瘯璇绘枃浠讹紝鏄惁鍏佽涓嬭浇绛夊弬鏁� - selectType: [], - freeFile: [], - file: [], - protectedFile: [], - resourcesClassification: [], - isDownload: [], - jsek_resourceBrief: [], - jsek_link: [], - jsek_questionBank: [], - }, - pading: { - start: 0, - size: 999, - }, - }; - this.MG.store - .getProductDetail(query) - .then(async (res) => { - if (type.refCode == "questionBank") { - const data = res.datas.cmsDatas[0].datas.filter( - (item) => item.refCode == "jsek_questionBank" - ); - if (data.length) return this.getResourceData(data[0]); - } - if (type.refCode == "jsek_questionBank") { - const testDataList = res.datas.cmsDatas[0].datas; - if (testDataList.length > 0) { - // console.log("棰樼洰鍒楄〃", testDataList); - this.$store.commit("setTestList", testDataList); - // this.getIdPathList(testDataList[1]) - } else { - console.log("鏆傛棤璧勬簮"); - } - } - }) - .catch((e) => { - console.log(e); - }); - }, - getIdPathList(data) { - let query = { - path: "*", - queryType: "*", - productId: this.config.bookId, - cmsPath: data.productLinkPath, - pading: { - start: 0, - size: 999, - }, - }; - this.MG.store.getProductDetail(query).then((res) => { - console.log("棰樼洰", res.datas.cmsDatas[0].datas); - this.$data.idPathList = res.datas.cmsDatas[0].datas; - this.getQuestionList(); - }); - }, - // 鑾峰彇棰樺簱棰樼洰 - getQuestionList(oldData) { - // 娓呯┖姝g‘棰樻暟璁板綍 - let flag = 0; - for (let index = 0; index < this.$data.idPathList.length; index++) { - const pathitem = this.$data.idPathList[index]; - const pathList = this.$data.cardList; - pathList.push({ - path: pathitem.productLinkPath, - catalogName: pathitem.name, - infoList: [], - }); - this.$data.cardList = pathList; - // 鑾峰彇棰樼洰 - let query = { - path: "*", - queryType: "*", - productId: this.config.bookId, - cmsPath: pathitem.productLinkPath, - itemFields: { - Embedded_QuestionBank_Stem: [], - Embedded_QuestionBank_AnalysisCon: [], - Embedded_QuestionBank_Answer: [], - Embedded_QuestionBank_Option: [], - Embedded_QuestionBank_QuestionType: [], - Embedded_QuestionBank_StemStyle: [], - Embedded_QuestionBank_OptionStyle: [], - Embedded_QuestionBank_KnowledgePoint: [], - Embedded_QuestionBank_Difficulty: [], - }, - pading: { - start: 0, - size: 999, - }, - }; - this.MG.store.getProductDetail(query).then((res) => { - let oldList; - if (oldData) { - // 鎻愪氦杩囷紝瀛樺湪绛旈璁板綍 - oldList = oldData.find( - (item) => item.path == pathitem.productLinkPath - ).infoList; - this.setData({ - submitStatus: true, - }); - } - res.datas.cmsDatas[0].datas.forEach((item, index) => { - let oldObj = ""; - if (oldList) - oldObj = oldList.find((oldItem) => oldItem.id == item.id); - let questionObj = { - // num: index, // 棰樺彿 - id: item.id, - type: pathitem.name, - stem: - item.Embedded_QuestionBank_QuestionType == "completion" - ? JSON.parse(item.Embedded_QuestionBank_Stem) - .stemTxt.replaceAll("<vacancy>", ",input,") - .split(",") - : JSON.parse(item.Embedded_QuestionBank_Stem), // 棰樺共 - answer: item.Embedded_QuestionBank_Answer, // 绛旀 - option: item.Embedded_QuestionBank_Option - ? JSON.parse(item.Embedded_QuestionBank_Option) - : "", // 閫夋嫨棰橀�夐」 - analysisCon: item.Embedded_QuestionBank_AnalysisCon, // 瑙f瀽 - questionType: item.Embedded_QuestionBank_QuestionType, // 棰樺瀷 - optionStyle: item.Embedded_QuestionBank_OptionStyle, // 閫夐」鏄剧ず绫诲瀷 - stemStyle: item.Embedded_QuestionBank_StemStyle, // 棰樺共鏄剧ず绫诲瀷 - difficulty: item.Embedded_QuestionBank_Difficulty - ? 4 - item.Embedded_QuestionBank_Difficulty - : 0, // 闅惧害绛夌骇 - userAnswer: oldObj - ? oldObj.userAnswer - : item.Embedded_QuestionBank_QuestionType == "completion" || - item.Embedded_QuestionBank_QuestionType == "multipleChoice" - ? [] - : "", - isUserAnswer: oldObj - ? this.isHaveAnswer(oldObj.userAnswer) - : false, - isRight: oldObj ? oldObj.isRight : null, - isComplete: oldObj ? oldObj.isComplete : false, - isCollect: false, - isUnfold: "", // 鎺у埗瑙f瀽鐨勬姌鍙犻潰鏉挎槸鍚﹀睍寮� - }; - // 澶氶�夊拰濉┖绛旀鑲负鏁扮粍锛岃杞崲JSON鏍煎紡 - if ( - questionObj.questionType == "completion" || - questionObj.questionType == "multipleChoice" - ) { - try { - questionObj.answer = JSON.parse(questionObj.answer).toString(); - } catch (error) { - questionObj.answer = item.Embedded_QuestionBank_Answer; - } - } - // 濉┖棰樻敼閫� - if (questionObj.questionType == "completion") { - let index = 0; - for (let i = 0; i < questionObj.stem.length; i++) { - const item = questionObj.stem[i]; - if (item == "input") { - questionObj.stem[i] = { - num: index, - data: "input", - }; - if (!oldObj) questionObj.userAnswer[index] = ""; - index++; - } - } - } - // 棰樺共瀵屾枃鏈鐞� - if (questionObj.stemStyle == "RichText") { - // questionObj.option.txt = '' - questionObj.stem.stemTxt = questionObj.stem.stemTxt - .replace( - /\<img/gi, - '<img style="max-width: 300rpx !important;object-fit: contain;" class="stem-rich-img" ' - ) - .replace(/\<p/gi, '<p class="stem-rich-p"') - .replace("../file", app.config.requestCtx + "/file"); - } - // 閫夐」瀵屾枃鏈鐞� - if ( - questionObj.optionStyle == "RichText" && - (questionObj.questionType == "singleChoice" || - questionObj.questionType == "judge" || - questionObj.questionType == "multipleChoice") - ) { - questionObj.option.forEach((item) => { - if (item.txt) - item.txt = item.txt - .replace(/\<img/gi, '<img class="option-rich-img"') - .replace(/\<p/gi, '<p class="stem-rich-p"') - .replace("../file", app.config.requestCtx + "/file"); - }); - } - // 瑙f瀽瀵屾枃鏈鐞� - if ( - questionObj.analysisCon && - typeof questionObj.analysisCon == "string" - ) { - questionObj.analysisCon = questionObj.analysisCon.replace( - /\<img/gi, - '<img style="max-width: 300rpx !important;object-fit: contain;" class="stem-rich-img" ' - ); - } - // 鍚姏棰樹慨鏀� - // if (questionObj.questionType == 'singleChoice') { - // const src = this.extractSourceSrc(questionObj.stem.stemTxt) - // if (src) { - // questionObj.src = src - // questionObj.stem.stemTxt = this.removeVideoAndAudioTags(questionObj.stem.stemTxt) - // } - // } - // 鑾峰彇鍥剧墖 - if ( - questionObj.stemStyle == "Image" || - questionObj.stemStyle == "TxtAndImage" - ) { - questionObj.stem.stemImage = getPublicImage( - questionObj.stem.stemImage, - 150 - ); - } - if ( - questionObj.optionStyle == "Image" || - questionObj.optionStyle == "TxtAndImage" - ) { - questionObj.option.forEach((optionItem) => { - if (optionItem.img) - optionItem.img = getPublicImage(optionItem.img, 150); - }); - } - // 瀹㈣棰樻�诲垎璧嬪�� - if (questionObj.questionType !== "shortAnswer") { - // this.setData({ - // subjectiveGrade: this.data.subjectiveGrade + 2, - // }); - } - // 鏃ф暟鎹噷 棰樼洰姝g‘ 璁板綍姝g‘鏁伴噺 - if (questionObj.isRight) { - // this.setData({ - // correctNum: this.data.correctNum + 1, - // }); - } - if ( - pathitem.name == "鍒ゆ柇棰�" || - pathitem.name == "濉┖棰�" || - pathitem.name == "澶氶�夐" || - pathitem.name == "鍗曢�夐" || - pathitem.name == "鍚姏棰�" - ) { - if (oldObj) { - // this.setData({ - // subjectiveTotal: this.data.subjectiveTotal + 1, - // }); - } - } - // cardList璧嬪�� - let cardIndex = this.$data.cardList.findIndex( - (item) => item.path == pathitem.productLinkPath - ); - let infoList = this.$data.cardList[cardIndex].infoList; - infoList.push(questionObj); - // this.setData({ - // [`cardList[${cardIndex}].infoList`]: infoList, - // }); - this.$data.cardList[cardIndex].infoList = infoList; - flag++; - let questionList = []; - let grade = 0; - const cardUpdatedList = this.$data.cardList; - // if (flag == this.data.idPathList.length) { - cardUpdatedList.forEach((aitem) => { - aitem.infoList.forEach((bitem, bindex) => { - questionList.push(bitem); - bitem.number = bindex + 1; - bitem.score = 2; - }); - }); - // this.setData({ - // questionDataList: questionList, - // cardList: cardUpdatedList, - // }); - this.$data.cardList = cardUpdatedList; - console.log("棰樼洰鍛�", this.$data.cardList); - }); - }); - } - }, getParentWithClass(element, className) { while (element.parentElement) { element = element.parentElement; @@ -389,74 +24,53 @@ } } }, + handleMouseUp(e) { - const txt = window.getSelection()?.toString(); - const selection = window.getSelection(); - if (selection.type != "none") { + const selection = ( + this.container ? this.container : window + ).getSelection(); + const txt = selection.toString(); + if (selection.type != "none" && txt) { let node = selection.anchorNode.parentNode; let pageHtml = this.getParentWithClass( selection.anchorNode, "page-box" ); - console.log("瀛愰」", selection.anchorNode); let chapterDom = this.getParentWithClass( selection.anchorNode, "chapter" ); let chapterNum; if (chapterDom) chapterNum = chapterDom.getAttribute("num"); - console.log("绗竴澶勫垽鏂�", txt, pageHtml); - if (txt && pageHtml) { + if (pageHtml) { const page = pageHtml.getAttribute("page"); - console.log( - { - chapterNum, - txt, - selection, - node, - page, - x: e.x, - y: e.y, - }, - "sendData" - ); // 鐩戝惉閫変腑鏂囨湰浜嬩欢锛屽苟瑙﹀彂鐖跺眰鏂规硶 - console.log("绗簩澶勫垽鏂�", this.$store.state.qiankun); if (this.$store.state.qiankun.windowSelection) { this.$store.state.qiankun.windowSelection({ + chapterNum, txt, - selection, - node, page, x: e.x, y: e.y, }); } } - } - }, - handleDom() { - const selection = window.getSelection(); - let textDom = this.getParentWithClass(selection.anchorNode, "page-box"); - for (let i = 0; i < this.$store.state.lineHeightList.length; i++) { - let item = this.$store.state.lineHeightList[i]; - let rReg = new RegExp(`${item.selectText}`, "ig"); - let text = textDom.innerHTML; - console.log(item.selectNode, "item.selectNode.innerHTML"); - let nodeHtml = item.selectNode; - let nHtml = ""; - nHtml = nodeHtml.replace( - rReg, - `<span style="background: ${item.color};padding: 2px;cursor: pointer">${item.selectText}</span>` - ); - console.log(nHtml); - let rHtml = ""; - rHtml = text.replace(nodeHtml, nHtml); - textDom.innerHTML = rHtml; + } else { + if (this.$store.state.qiankun.windowSelection) { + this.$store.state.qiankun.windowSelection({ + chapterNum: "", + txt: "", + page: "", + x: e.x, + y: e.y, + }); + } } }, }, }; </script> -<style lang="less" scoped></style> +<style lang="less"> +@import "../assets/main.less"; +</style> -- Gitblit v1.9.1