Browse Source

addcourse

zengyicheng 3 years ago
parent
commit
a1691f7073
1 changed files with 159 additions and 313 deletions
  1. 159 313
      src/components/pages/addCourse.vue

+ 159 - 313
src/components/pages/addCourse.vue

@@ -129,19 +129,6 @@
                             :key="index"
                           >
                             <span>{{ item.name }}</span>
-                            <!-- <el-select
-                          v-model="courseTypeId[item.id]"
-                          placeholder="请选择"
-                          @change="getTypeName"
-                        >
-                          <el-option
-                            v-for="item1 in CourseTypeJson[item.id]"
-                            :key="item1.id"
-                            :label="item1.name"
-                            :value="item1.id"
-                          >
-                          </el-option>
-                        </el-select> -->
                             <el-checkbox-group v-model="courseTypeId">
                               <el-checkbox
                                 v-for="item1 in CourseTypeJson[item.id]"
@@ -406,24 +393,6 @@
                       @click="deleteUnit(unitIndex)"
                     ></div>
                   </div>
-                  <!-- <div style="margin: 30px 0 10px; font-size: 18px">
-                    阶段描述
-                  </div>
-                  <div>
-                    <textarea
-                      rows="6"
-                      class="binfo_input"
-                      cols=""
-                      style="width: 80% !important; height: 90px"
-                      v-model="unitJson[unitIndex].dyText"
-                    ></textarea>
-                  </div> -->
-                  <!-- <el-switch
-                    v-model="unitJson[unitIndex].isTalk"
-                    active-text="是否开启评价"
-                    style="margin: 25px 0px 0px 0"
-                  >
-                  </el-switch> -->
                 </div>
                 <div style="margin: 50px 0 10px 0; font-size: 24px">
                   添加任务
@@ -456,7 +425,7 @@
                         <div
                           style="
                             font-weight: unset;
-                            font-size: 1.5rem;
+                            font-size: 1.3rem;
                             width: 110px;
                           "
                         >
@@ -526,8 +495,6 @@
                       </div>
                       <div class="line"></div>
                     </div>
-                    <!-- <h3 class="info_title" style="margin: 0"></h3> -->
-
                     <div>
                       <div
                         class="add_chapters_box"
@@ -692,45 +659,9 @@
                         @click="addAttText(itemTaskIndex)"
                       >
                         附文本添加
-                        <!-- <input
-                          type="file"
-                          accept="application/pdf,.ppt,.pptx,application/msword,application/vnd.openxmlformats-officedocument.wordprocessingml.document"
-                          style="display: none"
-                          @change="
-                            beforeUpload2($event, unitIndex, 3, itemTaskIndex)
-                          "
-                        /> -->
                       </button>
                     </div>
                   </div>
-                  <!-- <div
-                  style="
-                    display: flex;
-                    margin: 23px 0;
-                    flex-direction: row;
-                    justify-content: flex-start;
-                    align-items: center;
-                  "
-                >
-                  <div
-                    style="
-                      font-size: 1.5em;
-                      font-weight: bold;
-                      margin-top: 15px;
-                    "
-                  >
-                    添加提问
-                  </div>
-                  <div class="line"></div>
-                </div>
-                <div>
-                  <input
-                    type="text"
-                    placeholder="请输入问题"
-                    class="binfo_input"
-                    v-model="unitJson[unitIndex].question"
-                  />
-                </div> -->
                   <div
                     style="
                       flex-direction: row;
@@ -759,50 +690,67 @@
                       </div>
                       <div class="line" style="width: 90%"></div>
                     </div>
-
-                    <div>
-                      <input
-                        type="text"
-                        placeholder="添加工具描述"
-                        class="binfo_input"
-                        style="margin: 20px 0; width: 71.5% !important"
-                        v-model="
-                          unitJson[unitIndex].chapterInfo[0].taskJson[
-                            itemTaskIndex
-                          ].toolText
-                        "
-                      />
-                    </div>
                   </div>
                   <div class="toolChoose" style="padding: 0 0 0 30px">
                     <div class="tools">
-                      <div class="leftTools">
-                        <div class="chooseWho">
-                          <div
-                            :class="toolType == 0 ? 'isChooseActive' : ''"
-                            @click="toolType = 0"
-                          >
-                            展示类
+                      <div
+                        class="leftTools"
+                        style="
+                          width: 95%;
+                          padding: 0 0 15px 0;
+                          border-bottom: 1px solid #efefef;
+                          margin-bottom: 15px;
+                        "
+                        v-for="(itemTool, toolIndex) in itemTask.toolChoose"
+                        :key="toolIndex"
+                      >
+                        <div
+                          style="
+                            display: flex;
+                            flex-direction: row;
+                            align-items: baseline;
+                            flex-wrap: nowrap;
+                            justify-content: flex-start;
+                            position: relative;
+                          "
+                        >
+                          <div style="margin-right: 20px">
+                            工具 {{ toolIndex + 1 }} :
                           </div>
-                          <div
-                            :class="toolType == 1 ? 'isChooseActive' : ''"
-                            @click="toolType = 1"
-                          >
-                            思维类
+                          <div class="chooseWho">
+                            <div
+                              :class="toolType == 0 ? 'isChooseActive' : ''"
+                              @click="toolType = 0"
+                            >
+                              展示类
+                            </div>
+                            <div
+                              :class="toolType == 1 ? 'isChooseActive' : ''"
+                              @click="toolType = 1"
+                            >
+                              思维类
+                            </div>
+                            <div
+                              :class="toolType == 2 ? 'isChooseActive' : ''"
+                              @click="toolType = 2"
+                            >
+                              评价类
+                            </div>
                           </div>
                           <div
-                            :class="toolType == 2 ? 'isChooseActive' : ''"
-                            @click="toolType = 2"
-                          >
-                            评价类
-                          </div>
+                            class="remove"
+                            @click="deleteTool(toolIndex)"
+                            v-if="itemTask.toolChoose.length > 1"
+                            style="position: absolute; right: 55px"
+                          ></div>
                         </div>
+
                         <div style="min-height: 163px">
                           <div class="toolSort" v-if="toolType == 0">
                             <div class="tool">
                               <div
                                 class="whiteBIcon"
-                                @click="addTools(8, itemTaskIndex)"
+                                @click="addTools(8, itemTaskIndex, toolIndex)"
                               >
                                 <img
                                   src="../../assets/icon/secondToolList/library.png"
@@ -812,15 +760,12 @@
                               </div>
                               <div
                                 class="check"
-                                @click="addTools(8, itemTaskIndex)"
+                                @click="addTools(8, itemTaskIndex, toolIndex)"
                               >
                                 <img
                                   src="../../assets/icon/checkNo.png"
                                   alt=""
-                                  v-if="
-                                    itemTask.toolChoose &&
-                                    itemTask.toolChoose.indexOf(8) == -1
-                                  "
+                                  v-if="itemTool.tool != 8"
                                 />
                                 <img
                                   src="../../assets/icon/checkedIs.png"
@@ -834,7 +779,7 @@
                             <div class="tool">
                               <div
                                 class="whiteBIcon"
-                                @click="addTools(7, itemTaskIndex)"
+                                @click="addTools(7, itemTaskIndex, toolIndex)"
                               >
                                 <img
                                   src="../../assets/icon/secondToolList/mindNetwork.png"
@@ -844,15 +789,12 @@
                               </div>
                               <div
                                 class="check"
-                                @click="addTools(7, itemTaskIndex)"
+                                @click="addTools(7, itemTaskIndex, toolIndex)"
                               >
                                 <img
                                   src="../../assets/icon/checkNo.png"
                                   alt=""
-                                  v-if="
-                                    itemTask.toolChoose &&
-                                    itemTask.toolChoose.indexOf(7) == -1
-                                  "
+                                  v-if="itemTool.tool != 7"
                                 />
                                 <img
                                   src="../../assets/icon/checkedIs.png"
@@ -864,7 +806,7 @@
                             <div class="tool">
                               <div
                                 class="whiteBIcon"
-                                @click="addTools(1, itemTaskIndex)"
+                                @click="addTools(1, itemTaskIndex, toolIndex)"
                               >
                                 <img
                                   src="../../assets/icon/secondToolList/whiteBoard.png"
@@ -874,15 +816,12 @@
                               </div>
                               <div
                                 class="check"
-                                @click="addTools(1, itemTaskIndex)"
+                                @click="addTools(1, itemTaskIndex, toolIndex)"
                               >
                                 <img
                                   src="../../assets/icon/checkNo.png"
                                   alt=""
-                                  v-if="
-                                    itemTask.toolChoose &&
-                                    itemTask.toolChoose.indexOf(1) == -1
-                                  "
+                                  v-if="itemTool.tool != 1"
                                 />
                                 <img
                                   src="../../assets/icon/checkedIs.png"
@@ -894,7 +833,7 @@
                             <div class="tool">
                               <div
                                 class="whiteBIcon"
-                                @click="addTools(2, itemTaskIndex)"
+                                @click="addTools(2, itemTaskIndex, toolIndex)"
                               >
                                 <img
                                   src="../../assets/icon/secondToolList/note.png"
@@ -904,15 +843,12 @@
                               </div>
                               <div
                                 class="check"
-                                @click="addTools(2, itemTaskIndex)"
+                                @click="addTools(2, itemTaskIndex, toolIndex)"
                               >
                                 <img
                                   src="../../assets/icon/checkNo.png"
                                   alt=""
-                                  v-if="
-                                    itemTask.toolChoose &&
-                                    itemTask.toolChoose.indexOf(2) == -1
-                                  "
+                                  v-if="itemTool.tool != 2"
                                 />
                                 <img
                                   src="../../assets/icon/checkedIs.png"
@@ -924,7 +860,7 @@
                             <div class="tool">
                               <div
                                 class="whiteBIcon"
-                                @click="addTools(6, itemTaskIndex)"
+                                @click="addTools(6, itemTaskIndex, toolIndex)"
                               >
                                 <img
                                   src="../../assets/icon/secondToolList/doc.png"
@@ -934,15 +870,12 @@
                               </div>
                               <div
                                 class="check"
-                                @click="addTools(6, itemTaskIndex)"
+                                @click="addTools(6, itemTaskIndex, toolIndex)"
                               >
                                 <img
                                   src="../../assets/icon/checkNo.png"
                                   alt=""
-                                  v-if="
-                                    itemTask.toolChoose &&
-                                    itemTask.toolChoose.indexOf(6) == -1
-                                  "
+                                  v-if="itemTool.tool != 6"
                                 />
                                 <img
                                   src="../../assets/icon/checkedIs.png"
@@ -954,7 +887,7 @@
                             <div class="tool">
                               <div
                                 class="whiteBIcon"
-                                @click="addTools(3, itemTaskIndex)"
+                                @click="addTools(3, itemTaskIndex, toolIndex)"
                               >
                                 <img
                                   src="../../assets/icon/secondToolList/mindMapping.png"
@@ -964,15 +897,12 @@
                               </div>
                               <div
                                 class="check"
-                                @click="addTools(3, itemTaskIndex)"
+                                @click="addTools(3, itemTaskIndex, toolIndex)"
                               >
                                 <img
                                   src="../../assets/icon/checkNo.png"
                                   alt=""
-                                  v-if="
-                                    itemTask.toolChoose &&
-                                    itemTask.toolChoose.indexOf(3) == -1
-                                  "
+                                  v-if="itemTool.tool != 3"
                                 />
                                 <img
                                   src="../../assets/icon/checkedIs.png"
@@ -986,7 +916,7 @@
                             <div class="tool">
                               <div
                                 class="whiteBIcon"
-                                @click="addTools(5, itemTaskIndex)"
+                                @click="addTools(5, itemTaskIndex, toolIndex)"
                               >
                                 <img
                                   src="../../assets/icon/thirdToolList/score.png"
@@ -996,15 +926,12 @@
                               </div>
                               <div
                                 class="check"
-                                @click="addTools(5, itemTaskIndex)"
+                                @click="addTools(5, itemTaskIndex, toolIndex)"
                               >
                                 <img
                                   src="../../assets/icon/checkNo.png"
                                   alt=""
-                                  v-if="
-                                    itemTask.toolChoose &&
-                                    itemTask.toolChoose.indexOf(5) == -1
-                                  "
+                                  v-if="itemTool.tool != 5"
                                 />
                                 <img
                                   src="../../assets/icon/checkedIs.png"
@@ -1023,15 +950,12 @@
                               </div>
                               <div
                                 class="check"
-                                @click="addTools(4, itemTaskIndex)"
+                                @click="addTools(4, itemTaskIndex, toolIndex)"
                               >
                                 <img
                                   src="../../assets/icon/checkNo.png"
                                   alt=""
-                                  v-if="
-                                    itemTask.toolChoose &&
-                                    itemTask.toolChoose.indexOf(4) == -1
-                                  "
+                                  v-if="itemTool.tool != 4"
                                 />
                                 <img
                                   src="../../assets/icon/checkedIs.png"
@@ -1042,156 +966,33 @@
                             </div>
                           </div>
                         </div>
-                        <el-switch
-                          v-model="
-                            unitJson[unitIndex].chapterInfo[0].taskJson[
-                              taskCount
-                            ].isShowTools
-                          "
-                          active-text="是否开启评价"
-                          style="margin: 30px 0px 10px 0; padding-bottom: 30px"
-                        >
-                        </el-switch>
-                      </div>
-                      <!-- <div class="rightTools">
-                      <div class="firstToolList">
-                        <div>知识展示类工具</div>
-                        <div class="iconList">
-                          <div class="iconTool">
-                            <div class="toolIcon">
-                              <img
-                                src="../../assets/icon/firstToolList/project.png"
-                                alt=""
-                              />
-                            </div>
-                            <div>虚拟仿真平台</div>
-                          </div>
-                          <div class="iconTool">
-                            <div class="toolIcon">
-                              <img
-                                src="../../assets/icon/firstToolList/mindMapping.png"
-                                alt=""
-                              />
-                            </div>
-                            <div>文本</div>
-                          </div>
-                          <div class="iconTool">
-                            <div class="toolIcon">
-                              <img
-                                src="../../assets/icon/firstToolList/study.png"
-                                alt=""
-                              />
-                            </div>
-                            <div>文本</div>
-                          </div>
-                        </div>
-                      </div>
-                      <div class="secondToolList">
-                        <div>思维可视化工具</div>
-                        <div></div>
-                      </div>
-                      <div class="thirdToolList">
-                        <div>评价类工具</div>
-                        <div></div>
-                      </div>
-                    </div> -->
-                    </div>
-                  </div>
-                  <!-- <div
-                    class="basic_box"
-                    style="min-height: 0px; padding: 0 0 20px 50px; margin: 0"
-                  > -->
-                  <!-- <div
-                      style="
-                        display: flex;
-                        flex-direction: row;
-                        justify-content: flex-start;
-                        align-items: center;
-                      "
-                    >
-                      <div
-                        style="
-                          font-size: 1.5em;
-                          font-weight: bold;
-                          margin-top: 15px;
-                        "
-                      >
-                        作业设置
-                      </div>
-                      <div class="line"></div>
-                    </div> -->
-                  <!-- <div class="homework_box">
-                      <div
-                        style="
-                          display: flex;
-                          justify-content: flex-start;
-                          align-items: center;
-                        "
-                      >
-                        <div class="addHW" @click="addHw($event)">
-                          <img src="../../assets/icon/addWork.png" alt="" />
+                        <div>
                           <input
-                            type="file"
-                            style="display: none"
-                            @change="
-                              beforeUpload2($event, unitIndex, 5, itemTaskIndex)
-                            "
+                            type="text"
+                            placeholder="添加工具描述"
+                            class="binfo_input"
+                            style="margin: 20px 0; width: 71.5% !important"
+                            v-model="itemTool.toolDetail"
                           />
                         </div>
-                        <div style="height: 25px">添加作业</div>
                       </div>
-                      <div style="display: flex; height: 90px">
-                        <div
-                          class="zyBox"
-                          v-for="(item2, index2) in itemTask.homeworkList"
-                          :key="index2"
-                        >
-                          <div
-                            class="deleteZy"
-                            @click="deleteHomeworkBox(unitIndex, index, index2)"
-                          >
-                            <img src="../../assets/icon/delete.png" alt="" />
-                          </div>
-                          <div class="zyImg">
-                            <img src="../../assets/zy.png" alt="" />
-                          </div>
-                          <div
-                            style="
-                              width: 110px;
-                              font-size: 15px;
-                              overflow: hidden;
-                              white-space: nowrap;
-                            "
-                          >
-                            {{ item2.name }}
-                          </div>
+                      <div class="addToolFun" @click="addToolFun">
+                        <div class="addToolImg">
+                          <img src="../../assets/icon/add.png" alt="" />
                         </div>
+                        <div>添加工具</div>
                       </div>
-                    </div> -->
-
-                  <!-- <div class="time">
-                    <div class="small_title">
-                      开始时间<span style="color: red">*</span>
                     </div>
-                    <el-date-picker
-                      v-model="unitJson[unitIndex].startTime"
-                      type="date"
-                      placeholder="选择日期"
-                      style="margin-left: 5px"
-                    >
-                    </el-date-picker>
-                    <div class="small_title" style="margin-left: 40px">
-                      结束时间<span style="color: red">*</span>
-                    </div>
-                    <el-date-picker
-                      v-model="unitJson[unitIndex].endTime"
-                      type="date"
-                      placeholder="选择日期"
-                      style="margin-left: 5px"
-                    >
-                    </el-date-picker>
-                  </div> -->
-                  <!-- </div> -->
+                  </div>
+                  <el-switch
+                    v-model="
+                      unitJson[unitIndex].chapterInfo[0].taskJson[taskCount]
+                        .isShowTools
+                    "
+                    active-text="是否开启评价"
+                    style="margin: 30px 0px 10px 0; padding-bottom: 30px"
+                  >
+                  </el-switch>
                   <div class="funBlock" style="padding: 0">
                     <div class="fold">
                       <div @click="fold(itemTaskIndex, $event, 1)">折叠</div>
@@ -1556,7 +1357,7 @@ export default {
                   taskDetail: "",
                   chapterData: [],
                   toolText: "",
-                  toolChoose: [],
+                  toolChoose: [{ tool: null, toolDetail: "" }],
                   isShowTools: false,
                   askCount: 1,
                   isFold: 0,
@@ -1771,6 +1572,26 @@ export default {
           });
       }
     },
+    deleteTool(i) {
+      var _this = this;
+      if (_this.time()) {
+        _this
+          .$confirm("确定删除此工具吗?", "提示", {
+            confirmButtonText: "确定",
+            cancelButtonText: "取消",
+            type: "warning",
+          })
+          .then(() => {
+            _this.unitJson[_this.unitIndex].chapterInfo[0].taskJson[
+              _this.taskCount
+            ].toolChoose.splice(i, 1);
+            _this.$message.success("删除成功");
+          })
+          .catch(() => {
+            return;
+          });
+      }
+    },
 
     handlePictureCardPreview(file) {
       this.dialogImageUrl = file.url;
@@ -2008,7 +1829,7 @@ export default {
                 taskDetail: "",
                 chapterData: [],
                 toolText: "",
-                toolChoose: [],
+                toolChoose: [{ tool: null, toolDetail: "" }],
                 isShowTools: false,
                 askCount: 1,
                 isFold: 0,
@@ -2033,13 +1854,21 @@ export default {
         this.unitSet(this.unitIndex);
       }, 0);
     },
+    addToolFun() {
+      this.unitJson[this.unitIndex].chapterInfo[0].taskJson[
+        this.taskCount
+      ].toolChoose.push({
+        tool: null,
+        toolDetail: "",
+      });
+    },
     addTaskBorder() {
       this.unitJson[this.unitIndex].chapterInfo[0].taskJson.push({
         task: "",
         taskDetail: "",
         chapterData: [],
         toolText: "",
-        toolChoose: [],
+        toolChoose: [{ tool: null, toolDetail: "" }],
         isShowTools: false,
         askCount: 1,
         isFold: 0,
@@ -2370,32 +2199,29 @@ export default {
         this.dialogVisible5 = true;
       }
     },
-    addTools(i, itemTaskIndex) {
+    addTools(i, itemTaskIndex, toolIndex) {
       if (
         this.unitJson[this.unitIndex].chapterInfo[0].taskJson[itemTaskIndex]
-          .toolChoose.length == 0
+          .toolChoose[toolIndex].tool == null
       ) {
         this.unitJson[this.unitIndex].chapterInfo[0].taskJson[
           itemTaskIndex
-        ].toolChoose.push(i);
+        ].toolChoose[toolIndex].tool = i;
       } else {
         if (
-          this.unitJson[this.unitIndex].chapterInfo[0].taskJson[
-            itemTaskIndex
-          ].toolChoose.indexOf(i) != -1
+          this.unitJson[this.unitIndex].chapterInfo[0].taskJson[itemTaskIndex]
+            .toolChoose[toolIndex].tool != null &&
+          this.unitJson[this.unitIndex].chapterInfo[0].taskJson[itemTaskIndex]
+            .toolChoose[toolIndex].tool != i
         ) {
-          this.unitJson[this.unitIndex].chapterInfo[0].taskJson[
-            itemTaskIndex
-          ].toolChoose.splice(
-            this.unitJson[this.unitIndex].chapterInfo[0].taskJson[
-              itemTaskIndex
-            ].toolChoose.indexOf(i),
-            1
-          );
+          this.$message({
+            message: "每个工具只能添加一个",
+            type: "error",
+          });
         } else {
           this.unitJson[this.unitIndex].chapterInfo[0].taskJson[
             itemTaskIndex
-          ].toolChoose.push(i);
+          ].toolChoose[toolIndex].tool = null;
         }
       }
       this.$forceUpdate();
@@ -2883,7 +2709,8 @@ export default {
   cursor: pointer;
 }
 .wordPic > img,
-.deleteWord > img {
+.deleteWord > img,
+.addToolImg > img {
   width: 100%;
   height: 100%;
 }
@@ -2964,7 +2791,8 @@ export default {
   width: 380px;
 }
 
-.chapter_contentbox div:nth-child(3) {
+.chapter_contentbox div:nth-child(3),
+.remove {
   background-image: url(../../assets/remove.png);
   cursor: pointer;
   opacity: 0.5;
@@ -3825,7 +3653,7 @@ ol {
 .tools {
   width: 100%;
   display: flex;
-  flex-direction: row;
+  flex-direction: column;
   flex-wrap: nowrap;
   align-items: flex-start;
 }
@@ -3872,7 +3700,7 @@ ol {
   margin-top: 20px;
   min-height: 1160px;
   position: relative;
-  background: #f7f7f7;
+  background: #fbfbfb;
 }
 .smallTaskBorder {
   height: 135px;
@@ -3921,4 +3749,22 @@ ol {
   height: 15px;
   margin-left: 10px;
 }
+.addToolFun {
+  display: flex;
+  width: 150px;
+  flex-direction: row;
+  align-items: center;
+  justify-content: center;
+  border: 1px dashed;
+  border-radius: 5px;
+  height: 50px;
+  margin: 35px auto 0;
+  cursor: pointer;
+}
+
+.addToolImg {
+  width: 30px;
+  height: 30px;
+  margin-right: 20px;
+}
 </style>