From 1f10abd52d879a0b384217e0f3bae0fbd08fbfae Mon Sep 17 00:00:00 2001
From: user1 <10901603+no-distractions1@user.noreply.gitee.com>
Date: 星期一, 01 七月 2024 10:16:32 +0800
Subject: [PATCH] Merge branch 'master' of http://182.92.203.7:2001/r/testbookLayout

---
 src/components/matching/matching.vue |  205 ++++++++++++++++++++++++++++++++++----------------
 1 files changed, 139 insertions(+), 66 deletions(-)

diff --git a/src/components/matching/matching.vue b/src/components/matching/matching.vue
index 85cb98d..10bd215 100644
--- a/src/components/matching/matching.vue
+++ b/src/components/matching/matching.vue
@@ -15,10 +15,9 @@
             :key="index"
             ref="left"
             @mousedown="(e) => touchstart(e, item, index)"
-            :style="{backgroundColor:bc}"
-          >
-            {{ item.label.txt }}
-          </div>
+            :style="{ backgroundColor: primaryColor,border:'1px solid' + bordercolor }"
+            v-html="item.label.txt"
+          ></div>
         </div>
         <div class="answer-box">
           <div
@@ -26,10 +25,9 @@
             v-for="(item, index) in rightArr"
             :key="index"
             ref="right"
-            :style="{backgroundColor:bc}"
-          >
-            {{ item.label.txt }}
-          </div>
+            :style="{ backgroundColor: primaryColor,border:'1px solid' + bordercolor }"
+            v-html="item.label.txt"
+          ></div>
         </div>
       </div>
       <canvas
@@ -48,17 +46,66 @@
     <!-- 鎸夐挳 -->
     <div class="btn-bottom">
       <el-button @click="submitData">鎻愪氦</el-button>
-      <el-button @click="saveData">淇濆瓨</el-button>
+      <el-button @click="saveData" :style="{ borderColor: bordercolor }"
+        >淇濆瓨</el-button
+      >
       <el-button @click="redo">閲嶅仛</el-button>
-      <el-button @click="handleAnswer">鏌ョ湅绛旀</el-button>
+      <el-button @click="handleAnswer" :style="{ borderColor: bordercolor }"
+        >鏌ョ湅绛旀</el-button
+      >
     </div>
     <!-- 瑙f瀽 -->
     <ul class="show-answer" v-if="isShowAnswer">
-      <li>绛旀缁撴灉锛�</li>
+      <li v-if="isRight !== null">
+        绛旀缁撴灉锛�
+        <!-- <span v-if="isRight" style="color: #83e089">姝g‘</span>
+        <span v-if="isRight == false" style="color: #d81e06">閿欒</span> -->
+        <!-- 姝g‘ -->
+        <svg t="1718283080456" class="icon" viewBox="0 0 1024 1024" version="1.1"
+          xmlns="http://www.w3.org/2000/svg" p-id="97920" xmlns:xlink="http://www.w3.org/1999/xlink"
+          width="20" height="20" v-if="isRight">
+          <path
+            d="M1005.038 514.114c0 271.97-220.503 492.457-492.48 492.457-271.962 0-492.449-220.487-492.449-492.457 0-271.984 220.487-492.464 492.449-492.464 271.977 0 492.48 220.48 492.48 492.464z"
+            fill="#F5CB2B" p-id="97921"></path>
+          <path
+            d="M288.394 516.789c-19.68 0-35.773-16.094-35.773-35.773v-85.854c0-19.673 16.093-35.773 35.773-35.773 19.68 0 35.773 16.101 35.773 35.773v85.854c0 19.679-16.093 35.773-35.773 35.773zM736.752 516.789c-19.68 0-35.773-16.094-35.773-35.773v-85.854c0-19.673 16.094-35.773 35.773-35.773 19.681 0 35.773 16.101 35.773 35.773v85.854c0 19.679-16.092 35.773-35.773 35.773z"
+            fill="#3E3417" p-id="97922"></path>
+          <path
+            d="M511.79 702.128c-154.229 0-196.709-88.296-198.441-92.056-5.787-12.56-0.302-27.433 12.266-33.227 12.567-5.778 27.425-0.294 33.227 12.259 1.115 2.253 32.73 62.942 152.949 62.942 120.521 0 153.476-61.549 154.816-64.163 5.967-12.484 20.825-17.616 33.303-11.656 12.492 5.961 17.69 21.067 11.738 33.544-1.809 3.775-45.885 92.357-199.858 92.357z"
+            fill="#3E3417" p-id="97923"></path>
+          <path
+            d="M259.703 569.793c0 39.579-32.096 71.652-71.667 71.652-39.586 0-71.653-32.073-71.653-71.652 0-39.586 32.066-71.659 71.653-71.659 39.571 0 71.667 32.073 71.667 71.659zM949.298 569.793c0 39.579-32.082 71.652-71.652 71.652-39.586 0-71.651-32.073-71.651-71.652 0-39.586 32.065-71.659 71.651-71.659 39.57 0 71.652 32.073 71.652 71.659z"
+            fill="#EC7184" p-id="97924"></path>
+        </svg>
+        <!-- 閿欒 -->
+        <svg t="1718283143947" class="icon" viewBox="0 0 1024 1024" version="1.1"
+          xmlns="http://www.w3.org/2000/svg" p-id="110219" xmlns:xlink="http://www.w3.org/1999/xlink"
+          width="20" height="20" v-if="isRight == false">
+          <path d="M512 512m-512 0a512 512 0 1 0 1024 0 512 512 0 1 0-1024 0Z" fill="#F9DF1E" p-id="110220"></path>
+          <path
+            d="M704.984615 433.230769h-7.876923c-27.569231-7.876923-106.338462-47.261538-86.646154-90.584615 11.815385-35.446154 110.276923-59.076923 165.415385-70.892308 11.815385-3.938462 19.692308 3.938462 23.630769 15.753846 3.938462 11.815385-3.938462 19.692308-15.753846 23.63077-66.953846 11.815385-129.969231 35.446154-137.846154 47.261538 3.938462 7.876923 35.446154 27.569231 63.015385 39.384615 11.815385 3.938462 15.753846 15.753846 11.815385 27.569231-3.938462 3.938462-7.876923 7.876923-15.753847 7.876923z"
+            fill="#542913" p-id="110221"></path>
+          <path
+            d="M797.198342 462.421106a78.769231 39.384615 56.995 1 0 66.057691-42.906563 78.769231 39.384615 56.995 1 0-66.057691 42.906563Z"
+            fill="#4DCEFF" p-id="110222"></path>
+          <path
+            d="M512 707.465846m-157.538462 0a157.538462 157.538462 0 1 0 315.076924 0 157.538462 157.538462 0 1 0-315.076924 0Z"
+            fill="#542913" p-id="110223"></path>
+          <path
+            d="M393.846154 809.865846v-11.815384c7.876923-59.076923 59.076923-98.461538 118.153846-94.523077 59.076923-3.938462 110.276923 35.446154 118.153846 94.523077v11.815384c-59.076923 63.015385-157.538462 70.892308-220.553846 11.815385-7.876923 0-11.815385-3.938462-15.753846-11.815385z"
+            fill="#EA3B3B" p-id="110224"></path>
+          <path
+            d="M319.015385 433.230769c-7.876923 0-15.753846-3.938462-19.692308-11.815384-3.938462-11.815385 0-19.692308 11.815385-23.63077 31.507692-11.815385 63.015385-35.446154 63.015384-43.323077-7.876923-11.815385-70.892308-31.507692-137.846154-43.323076-11.815385-3.938462-15.753846-15.753846-15.753846-23.63077 3.938462-11.815385 11.815385-19.692308 23.630769-15.753846 55.138462 11.815385 153.6 35.446154 165.415385 70.892308 15.753846 47.261538-63.015385 82.707692-86.646154 90.584615h-3.938461z"
+            fill="#542913" p-id="110225"></path>
+          <path
+            d="M145.776323 508.859333a39.384615 78.769231 33.005 1 0 85.813125-132.115383 39.384615 78.769231 33.005 1 0-85.813125 132.115383Z"
+            fill="#4DCEFF" p-id="110226"></path>
+        </svg>
+      </li>
       <li class="show-answer-box">
         <div>绛旀:</div>
         <div>
-          <img :src="item.answerImg" alt="" class="w100">
+          <img :src="question.answerImg" alt="" class="w100" />
         </div>
       </li>
     </ul>
@@ -85,8 +132,8 @@
       checkItemIndex: null,
       isShowAnswer: false,
       isRight: null,
-      value:[{left:0,right:0}],
-      pageNum:null
+      value: [],
+      pageNum: null,
     };
   },
   props: {
@@ -99,15 +146,19 @@
         };
       },
     },
-    item: {
+    question: {
       type: Object,
       default: () => {
         return [];
       },
     },
-    bc:{
+    primaryColor: {
+      type: String,
+      default: "#fff",
+    },
+    bordercolor:{
       type:String,
-      default:"#0bab87"
+      default:'#f49a4c'
     }
   },
   watch: {
@@ -120,7 +171,7 @@
   },
   mounted() {
     // 鑾峰彇褰撳墠椤电爜锛岀敤浜庡尮閰嶆湰娆″瓨鍌ㄩ鐩暟鎹�
-    this.pageNum = this.handlePage()
+    this.pageNum = this.handlePage();
     // 娣诲姞婊氬姩浜嬩欢 鐩戝惉 瑙e喅鍥犱负婊氬姩寮曡捣鐨勬嫋鍔ㄧ嚎涓嶅鐨勯棶棰�
     window.addEventListener(
       "scroll",
@@ -142,7 +193,7 @@
     this.$nextTick(() => {
       this.drawing();
     });
-    this.getAnswer()
+    this.getAnswer();
   },
   methods: {
     init() {
@@ -181,14 +232,16 @@
     },
     // 瑙︽懜缁撴潫
     touchend(e, index) {
-      console.log("鎶捣", e, this.checkItem);
       this.isDragging = false;
-      if (this.item.showAnswer) {
+      if (this.question.showAnswer) {
         return false;
       }
       // let event = e.changedTouches[0];
       // document.elementFromPoint 閲嶇偣锛屾牴鎹畑,y鍧愭爣 鍙栧綋鍓嶅厓绱� 鎵�鏈夎兘杩愯鐨勯�昏緫 閮戒緷鎵樹簬杩欓噷銆�
-      let dom = document.elementFromPoint(e.pageX, e.pageY);
+      let dom = (this.container ? this.container : document).elementFromPoint(
+        e.pageX,
+        e.pageY
+      );
       // 鍙宠竟鐨刣om鏄摢涓�
       let right = this.rightDom.find((r) => r.bom === dom);
       // 涓嶇鏄摢涓兘娓呴櫎鎺� 搴曢儴鐨勭嚎
@@ -219,13 +272,12 @@
         })
         .filter((r) => r.right !== undefined);
       this.$emit("input", model);
-      this.item.userChoise = model;
-      console.log(JSON.stringify(model));
+      this.question.userChoise = model;
+      // console.log(JSON.stringify(model));
     },
     // 瑙︽懜寮�濮�
     touchstart(e, item, index) {
       this.isDragging = true;
-      console.log("鎸変笅", e);
       this.checkItem = item;
       this.checkItemIndex = index;
       e.stopPropagation();
@@ -239,7 +291,7 @@
     // touchmove(e, item) {
     //     if(!this.isDragging) return false
     //     console.log('绉诲姩',e);
-    //     if (this.item.showAnswer) {
+    //     if (this.question.showAnswer) {
     //         return false;
     //     }
     //     // let event = e.targetTouches[0];
@@ -251,10 +303,9 @@
     // 绉诲姩涓�
     mousemove(e) {
       if (!this.isDragging) return false;
-      if (this.item.showAnswer) {
+      if (this.question.showAnswer) {
         return false;
       }
-      // console.log('绉诲姩',e);
       this.checkItem.line[2] = e.pageX;
       this.checkItem.line[3] =
         e.pageY - this.$refs.connect.getBoundingClientRect().y + this.scrollTop;
@@ -282,8 +333,8 @@
       canvasA.lineWidth = 2;
       for (let i = 0; i < this.leftArr.length; i++) {
         const line = this.leftArr[i].line;
-        console.log(line);
-        console.log(this.leftArr[i]);
+        // console.log(line);
+        // console.log(this.leftArr[i]);
         if (line.length) {
           canvasA.moveTo(line[0], line[1]);
           canvasA.lineTo(line[2], line[3]);
@@ -330,37 +381,34 @@
     // 鎻愪氦
     submitData() {
       const answerArr = [];
-      const values = this.item.options.values;
+      const values = this.question.options.values;
       for (let index = 0; index < values.length; index++) {
         const item = values[index];
-        const rightIndex = this.item.options.linkValues.findIndex(
+        const rightIndex = this.question.options.linkValues.findIndex(
           (citem) => citem.oldId == item.oldId
         );
-        debugger;
+
         answerArr.push({
           left: index,
           right: rightIndex,
         });
       }
-      this.isRight = this.areArraysEqual(this.item.userChoise,answerArr)
-      console.log(
-        "绛旀",
-        answerArr,
-        this.item.userChoise,
-        this.isRight 
-      );
+      console.log(this.question.userChoise,answerArr);
+      this.isRight = this.areArraysEqual(this.question.userChoise, answerArr);
+      this.isShowAnswer = true;
     },
     // 鑾峰彇褰撳墠椤电爜
     handlePage() {
-      let pageNum = null
-      const element = document.getElementsByClassName("matching")[0];
+      let pageNum = null;
+      const element = (
+        this.container ? this.container : document
+      ).querySelector("matching");
       if (element) {
-        pageNum = this.getParentWithClass(
-          element,
-          "page-box"
-        ).getAttribute("page");
+        pageNum = this.getParentWithClass(element, "page-box").getAttribute(
+          "page"
+        );
       }
-      return pageNum
+      return pageNum;
     },
     getParentWithClass(element, className) {
       while (element.parentElement) {
@@ -372,29 +420,39 @@
     },
     // 鑾峰彇鏈湴瀛樺偍棰樼洰绛旀
     getAnswer() {
-      const data =  localStorage.getItem(this.config.activeBook.name + '-matching-' + this.pageNum)
-      if(data) {
-       this.value = JSON.parse(data)
+      const data = localStorage.getItem(
+        this.config.activeBook.name + "-matching-" + this.pageNum
+      );
+      if (data) {
+        this.value = JSON.parse(data);
       }
     },
     // 淇濆瓨
     saveData() {
-      if(this.item.userChoise.length)
-      localStorage.setItem(this.config.activeBook.name + '-matching-' + this.pageNum,JSON.stringify(this.item.userChoise))
-      console.log('淇濆瓨鎴愬姛',this.config.activeBook.name,this.pageNum);
+      if (this.question.userChoise.length)
+        localStorage.setItem(
+          this.config.activeBook.name + "-matching-" + this.pageNum,
+          JSON.stringify(this.question.userChoise)
+        );
+      // console.log('淇濆瓨鎴愬姛',this.config.activeBook.name,this.pageNum);
     },
     // 閲嶅仛
     redo() {
-      localStorage.removeItem(this.config.activeBook.name + '-matching-' + this.pageNum)
-      this.value = []
+      this.question.showAnswer = false;
+      localStorage.removeItem(
+        this.config.activeBook.name + "-matching-" + this.pageNum
+      );
+      this.value = [];
       for (let index = 0; index < this.leftArr.length; index++) {
         const item = this.leftArr[index];
-        item.value = []
-        item.line = []
+        item.value = [];
+        item.line = [];
       }
-      this.leftArr
-      this.drawing()
-    }
+      this.leftArr;
+      this.drawing();
+      this.isShowAnswer = false;
+      this.isRight = null
+    },
   },
 };
 </script>
@@ -438,7 +496,7 @@
       border-radius: 4px;
       box-shadow: 0 2px 12px 0 rgba(0, 0, 0, 0.1);
       margin-bottom: 20px;
-      line-height: 40px;
+      line-height: 24px;
       padding: 6px;
     }
 
@@ -460,9 +518,8 @@
   margin: 30px auto;
   width: 100%;
   height: min-content;
-  // background-color: pink;
   box-shadow: 0 2px 12px 0 rgba(0, 0, 0, 0.1);
-  .show-answer-box {
+  li {
     padding: 10px;
   }
 }
@@ -471,10 +528,26 @@
   margin: 70px auto 0 auto;
   display: flex;
   justify-content: space-evenly;
+  flex-wrap: wrap;
+  .el-button {
+    margin-top: 10px;
+  }
 }
 .el-button {
-  height:30px;
-  padding:9px;
-  min-width: 78px
+  height: 30px;
+  padding: 7px;
+  min-width: 78px;
+}
+.answer-box-item {
+  /deep/ .un1 {
+    -webkit-text-emphasis-style: dot;
+    -moz-text-emphasis-style: dot;
+    -ms-text-emphasis-style: dot;
+    text-emphasis-style: dot;
+    -webkit-text-emphasis-position: under;
+    -moz-text-emphasis-position: under;
+    -ms-text-emphasis-position: under;
+    text-emphasis-position: under;
+  }
 }
 </style>

--
Gitblit v1.9.1