ソースを参照

新增删除题目功能

zengyicheng 2 年 前
コミット
8190e98e61
2 ファイル変更86 行追加38 行削除
  1. BIN
      src/assets/remove1.png
  2. 86 38
      src/components/pages/addCourse.vue

BIN
src/assets/remove1.png


+ 86 - 38
src/components/pages/addCourse.vue

@@ -3185,16 +3185,24 @@
             :key="stIndex"
             style="padding-bottom: 20px"
           >
-            <div class="sentenTop">
-              <div>题目设置</div>
-              <div>
-                <el-input
-                  placeholder="请输入卡片内容"
-                  v-model="st.sentenceTitle"
-                ></el-input>
+            <div class="sentenTopBox">
+              <div class="sentenTop">
+                <div>题目设置</div>
+                <div>
+                  <el-input
+                    placeholder="请输入卡片内容"
+                    v-model="st.sentenceTitle"
+                  ></el-input>
+                </div>
+                <div @click="addSen(stIndex)">添加</div>
               </div>
-              <div @click="addSen(stIndex)">添加</div>
+              <div
+                class="remove1"
+                v-if="sentenceList.length > 1"
+                @click="deleteSentence(stIndex)"
+              ></div>
             </div>
+
             <div class="cardList">
               <div v-if="st.addSentence.length > 0" class="cardBox">
                 <div
@@ -3226,7 +3234,10 @@
                     :key="rIndex"
                     class="cardCss"
                   >
-                    <div class="isCard1" @click="returnCard(r, stIndex, rIndex)">
+                    <div
+                      class="isCard1"
+                      @click="returnCard(r, stIndex, rIndex)"
+                    >
                       <el-tooltip
                         class="item"
                         effect="light"
@@ -3865,6 +3876,24 @@ export default {
           });
       }
     },
+    deleteSentence(i) {
+      var _this = this;
+      if (_this.time()) {
+        _this
+          .$confirm("确定删除此题目吗?", "提示", {
+            confirmButtonText: "确定",
+            cancelButtonText: "取消",
+            type: "warning",
+          })
+          .then(() => {
+            _this.sentenceList.splice(i, 1);
+            _this.$message.success("删除成功");
+          })
+          .catch(() => {
+            return;
+          });
+      }
+    },
     openT() {
       window.parent.postMessage({ tools: "25" }, "*");
     },
@@ -5058,7 +5087,9 @@ export default {
             )
           );
         } else {
-          var sentenceList = [{ sentenceTitle: "", addSentence: [], rightAnswer: [] }]
+          var sentenceList = [
+            { sentenceTitle: "", addSentence: [], rightAnswer: [] },
+          ];
           this.sentenceList = sentenceList;
         }
         this.dialogVisibleSentence = true;
@@ -5223,8 +5254,8 @@ export default {
       if (i == 47) {
         if (
           !this.unitJson[this.unitIndex].chapterInfo[0].taskJson[itemTaskIndex]
-            .toolChoose[toolIndex].sentenceList || 
-            this.unitJson[this.unitIndex].chapterInfo[0].taskJson[itemTaskIndex]
+            .toolChoose[toolIndex].sentenceList ||
+          this.unitJson[this.unitIndex].chapterInfo[0].taskJson[itemTaskIndex]
             .toolChoose[toolIndex].sentenceList[0].rightAnswer == 0
         ) {
           this.openTools(itemTaskIndex, 47, toolIndex);
@@ -5283,7 +5314,7 @@ export default {
           return;
         }
       }
-      
+
       if (
         this.unitJson[this.unitIndex].chapterInfo[0].taskJson[itemTaskIndex]
           .toolChoose[toolIndex].tool.length > 0
@@ -6132,16 +6163,16 @@ export default {
     addSentenceTool() {
       for (var i = 0; i < this.sentenceList.length; i++) {
         if (this.sentenceList[i].rightAnswer.length == 0) {
-            this.$message.error("请将信息填写完整!");
-            return;
+          this.$message.error("请将信息填写完整!");
+          return;
         }
         if (
-            this.sentenceList[i].addSentence.length !=
-            this.sentenceList[i].rightAnswer.length
-          ) {
-            this.$message.error("请将信息填写完整!");
-            return;
-          }
+          this.sentenceList[i].addSentence.length !=
+          this.sentenceList[i].rightAnswer.length
+        ) {
+          this.$message.error("请将信息填写完整!");
+          return;
+        }
       }
       this.unitJson[this.unitIndex].chapterInfo[0].taskJson[
         this.taskCount
@@ -6151,11 +6182,11 @@ export default {
       ];
       this.dialogVisibleSentence = false;
       this.unitJson[this.unitIndex].chapterInfo[0].taskJson[
-          itemTaskIndex
-        ].toolChoose[toolIndex].tool = [];
-        this.unitJson[this.unitIndex].chapterInfo[0].taskJson[
-          itemTaskIndex
-        ].toolChoose[toolIndex].tool.push(i);
+        itemTaskIndex
+      ].toolChoose[toolIndex].tool = [];
+      this.unitJson[this.unitIndex].chapterInfo[0].taskJson[
+        itemTaskIndex
+      ].toolChoose[toolIndex].tool.push(i);
     },
   },
   beforeDestroy() {
@@ -6549,7 +6580,7 @@ export default {
 
 .chapter_contentbox div:nth-child(3),
 .remove {
-  background-image: url(../../assets/remove.png);
+  background-image: url("../../assets/remove.png");
   cursor: pointer;
   opacity: 0.5;
   width: 40px;
@@ -6557,6 +6588,14 @@ export default {
   background-repeat: no-repeat;
   background-position: 5px 10px;
 }
+.remove1 {
+  background-image: url("../../assets/remove1.png");
+  background-repeat: no-repeat;
+  background-position: 5px 10px;
+  width: 40px;
+  height: 50px;
+  cursor: pointer;
+}
 
 .binfo_input {
   font: inherit;
@@ -8434,7 +8473,7 @@ ol {
   background: #fff;
   height: 600px;
   overflow: auto;
-  background-image: url(/static/img/csBg.86b5321.png);
+  background-image: url("../../assets/icon/conSentences/csBg.png");
   background-position: 102%;
   background-repeat: no-repeat;
   background-size: 60%;
@@ -8456,8 +8495,6 @@ ol {
   flex-direction: row;
   flex-wrap: nowrap;
   align-items: center;
-  padding: 55px 0 0 20px;
-  box-sizing: border-box;
 }
 .sentenTop > div:nth-child(2) {
   width: 300px;
@@ -8491,29 +8528,30 @@ ol {
   align-items: center;
   align-content: center;
 }
-.isCard,.isCard1 {
-  width: 130px;
-  height: 60px;
+.isCard,
+.isCard1 {
+  width: 140px;
+  height: 65px;
   text-align: center;
-  line-height: 60px;
+  line-height: 65px;
   font-size: 20px;
   cursor: pointer;
   background-image: url("../../assets/icon/conSentences/titleBorder.png");
   background-size: cover;
 }
-.isCard1{
+.isCard1 {
   background-image: url("../../assets/icon/conSentences/answerBorder.png");
 }
 .isCard > div {
   white-space: nowrap;
   overflow: hidden;
   text-overflow: ellipsis;
-  width: 75%;
+  width: 80%;
   margin: 0 auto;
 }
 .card {
-  width: 130px;
-  height: 60px;
+  width: 140px;
+  height: 65px;
 }
 .card > img {
   width: 100%;
@@ -8543,4 +8581,14 @@ ol {
   text-align: center;
   line-height: 20px;
 }
+.sentenTopBox {
+  display: flex;
+  flex-direction: row;
+  flex-wrap: nowrap;
+  align-items: center;
+  justify-content: space-between;
+  padding: 55px 0 0 20px;
+  box-sizing: border-box;
+  width: 85%;
+}
 </style>