Browse Source

分类及选择题功能

zengyicheng 2 years ago
parent
commit
464fd74f69

+ 244 - 39
src/components/pages/addCourse.vue

@@ -2707,38 +2707,120 @@
                   v-model="testJson.testJson[index1].answer"
                   v-if="testJson.testJson[index1].type == 1"
                 >
-                  <el-radio
-                    v-for="(item2, checkIndex) in testJson.testJson[index1]
-                      .testItem"
-                    :key="checkIndex"
-                    :label="checkIndex"
-                  >
-                    <el-input
-                      v-model="testJson.testJson[index1].checkList[checkIndex]"
-                      placeholder="请输入选项..."
-                      style="width: 300px; margin-right: 10px"
-                    ></el-input>
-                  </el-radio>
+                  <div class="radioBox">
+                    <el-radio
+                      v-for="(item2, checkIndex) in testJson.testJson[index1]
+                        .testItem"
+                      :key="checkIndex"
+                      :label="checkIndex"
+                    >
+                      <div
+                        style="margin-right: 10px; width: 300px"
+                        v-if="
+                        testJson.testJson[index1].checkList[checkIndex] &&
+                          testJson.testJson[index1].checkList[checkIndex]
+                            .imgType &&
+                          testJson.testJson[index1].checkList[checkIndex]
+                            .imgType == 1
+                        "
+                      >
+                        <div class="inImg">
+                          <img
+                            :src="
+                              testJson.testJson[index1].checkList[checkIndex]
+                                .src
+                            "
+                            alt=""
+                          />
+                        </div>
+                      </div>
+
+                      <el-input
+                        v-else
+                        v-model="
+                          testJson.testJson[index1].checkList[checkIndex]
+                        "
+                        placeholder="请输入选项..."
+                        style="width: 300px; margin-right: 10px"
+                      ></el-input>
+                      <!-- <div>
+                        <el-button
+                          type="primary"
+                          size="small"
+                          @click="addImg($event)"
+                          >上传图片
+                          <input
+                            type="file"
+                            accept="image/*"
+                            style="display: none"
+                            @change="beforeUploadTi($event, index1, checkIndex)"
+                          />
+                        </el-button>
+                      </div> -->
+                    </el-radio>
+                  </div>
                 </el-radio-group>
                 <el-checkbox-group
                   v-model="testJson.testJson[index1].answer"
                   v-if="testJson.testJson[index1].type == '2'"
                 >
-                  <el-checkbox
-                    v-for="(item2, checkIndex) in testJson.testJson[index1]
-                      .testItem"
-                    :key="checkIndex"
-                    :label="checkIndex"
-                  >
-                    <el-input
-                      v-model="testJson.testJson[index1].checkList[checkIndex]"
-                      placeholder="请输入选项..."
-                      style="width: 300px; margin-right: 10px"
-                    ></el-input>
-                  </el-checkbox>
+                  <div class="radioBox">
+                    <el-checkbox
+                      v-for="(item2, checkIndex1) in testJson.testJson[index1]
+                        .testItem"
+                      :key="checkIndex1"
+                      :label="checkIndex1"
+                    >
+                      <div
+                        style="margin-right: 10px; width: 300px"
+                        v-if="
+                          testJson.testJson[index1].checkList[checkIndex1] &&
+                          testJson.testJson[index1].checkList[checkIndex1]
+                            .imgType &&
+                          testJson.testJson[index1].checkList[checkIndex1]
+                            .imgType == 1
+                        "
+                      >
+                        <div class="inImg">
+                          <img
+                            :src="
+                              testJson.testJson[index1].checkList[checkIndex1]
+                                .src
+                            "
+                            alt=""
+                          />
+                        </div>
+                      </div>
+
+                      <el-input
+                        v-else
+                        v-model="
+                          testJson.testJson[index1].checkList[checkIndex1]
+                        "
+                        placeholder="请输入选项..."
+                        style="width: 300px; margin-right: 10px"
+                      ></el-input>
+                      <!-- <div>
+                        <el-button
+                          type="primary"
+                          size="small"
+                          @click="addImg($event)"
+                          >上传图片
+                          <input
+                            type="file"
+                            accept="image/*"
+                            style="display: none"
+                            @change="
+                              beforeUploadTi($event, index1, checkIndex1)
+                            "
+                          />
+                        </el-button>
+                      </div> -->
+                    </el-checkbox>
+                  </div>
                 </el-checkbox-group>
               </div>
-              <div class="a_add_body_div">
+              <div class="a_add_body_div" style="margin-bottom: 3px">
                 <el-button
                   type="primary"
                   size="small"
@@ -3527,9 +3609,12 @@
       :before-close="handleClose"
       class="dialog_diy"
     >
-      <div
-      >
-        <Time :preTime="preTime" @updateTimeNum="updateTime" v-if="dialogVisiblePreTime"></Time>
+      <div>
+        <Time
+          :preTime="preTime"
+          @updateTimeNum="updateTime"
+          v-if="dialogVisiblePreTime"
+        ></Time>
       </div>
       <span slot="footer" class="dialog-footer">
         <el-button @click="dialogVisiblePreTime = false">取 消</el-button>
@@ -3603,7 +3688,7 @@ import Time from "../tools/time.vue";
 import Sunburst from "../tools/sunburst";
 import SeeBoard from "../tools/seeBoard";
 export default {
-  components: { EditorBar, Mind,Time, Sunburst, SeeBoard, Table },
+  components: { EditorBar, Mind, Time, Sunburst, SeeBoard, Table },
   data() {
     return {
       checkAll: false,
@@ -3632,7 +3717,7 @@ export default {
       courseName: "",
       isTeacherSee: true,
       courseText: "",
-      preTime:0,
+      preTime: 0,
       formLabelWidth: "100px",
       choosePicVisible: false,
       sysPicVisible: false,
@@ -3669,7 +3754,7 @@ export default {
       dialogVisibleTable: false,
       tableJson: { text: "" },
       dialogVisibleMoreUpload: false,
-      dialogVisiblePreTime:false,
+      dialogVisiblePreTime: false,
       uploadJson: [],
       classJuri: [],
       cover: [], //项目封面
@@ -3905,7 +3990,10 @@ export default {
     handleClose(done) {
       done();
     },
-
+    imgChange2(i, j) {
+      var _tmp = this.testJson.testJson[i].checkList[j];
+      this.noneBtnImg = _tmp.length >= 1;
+    },
     imgChange1(file, fileList, type, itemTaskIndex) {
       if (type == 1) {
         var _tmp = this.cover;
@@ -4315,6 +4403,55 @@ export default {
       this.$forceUpdate();
       this.dialogVisible7 = true;
     },
+    beforeUploadTi(event, i, j) {
+      const loading = this.openLoading();
+      var file = event.target.files[0];
+      var credentials = {
+        accessKeyId: "AKIATLPEDU37QV5CHLMH",
+        secretAccessKey: "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",
+      }; //秘钥形式的登录上传
+      window.AWS.config.update(credentials);
+      window.AWS.config.region = "cn-northwest-1"; //设置区域
+
+      var bucket = new window.AWS.S3({ params: { Bucket: "ccrb" } }); //选择桶
+      var _this = this;
+
+      if (file) {
+        var params = {
+          Key:
+            file.name.split(".")[0] +
+            new Date().getTime() +
+            "." +
+            file.name.split(".")[file.name.split(".").length - 1],
+          ContentType: file.type,
+          Body: file,
+          "Access-Control-Allow-Credentials": "*",
+          ACL: "public-read",
+        }; //key可以设置为桶的相抵路径,Body为文件, ACL最好要设置
+        var options = {
+          partSize: 2048 * 1024 * 1024,
+          queueSize: 2,
+          leavePartsOnError: true,
+        };
+        bucket
+          .upload(params, options)
+          .on("httpUploadProgress", function (evt) {
+            //这里可以写进度条
+            // console.log("Uploaded : " + parseInt((evt.loaded * 80) / evt.total) + '%');
+          })
+          .send(function (err, data) {
+            loading.close();
+            if (err) {
+              _this.$message.error("上传失败");
+            } else {
+              _this.testJson.testJson[i].checkList[j] = {};
+              _this.testJson.testJson[i].checkList[j].src = data.Location;
+              _this.testJson.testJson[i].checkList[j].imgType = 1;
+              _this.imgChange2(i, j);
+            }
+          });
+      }
+    },
     beforeUpload1(event, type) {
       const loading = this.openLoading();
       var file = event.target.files[0];
@@ -5453,8 +5590,7 @@ export default {
           this.sentenceList = sentenceList;
         }
         this.dialogVisibleSentence = true;
-      }
-       else if (i == 48) {
+      } else if (i == 48) {
         if (
           this.unitJson[this.unitIndex].chapterInfo[0].taskJson[itemTaskIndex]
             .toolChoose[toolIndex].tableJson
@@ -5471,8 +5607,7 @@ export default {
           this.tableJson = tableJson;
         }
         this.dialogVisibleTable = true;
-      }
-      else if (i == 50) {
+      } else if (i == 50) {
         if (
           this.unitJson[this.unitIndex].chapterInfo[0].taskJson[itemTaskIndex]
             .toolChoose[toolIndex].uploadJson
@@ -6412,6 +6547,55 @@ export default {
       console.log(this.courseTypeId);
       this.$forceUpdate();
     },
+    selectAllType() {
+      let params = {
+        org: this.org && this.org != "" ? this.org : "",
+        oid: this.oid && this.oid != "" ? this.oid : "",
+      };
+      this.ajax
+        .get(this.$store.state.api + "selectAllType", params)
+        .then((res) => {
+          this.CourseType = res.data;
+          for (var i = 0; i < res.data[0].length; i++) {
+            if (!this.cid) {
+              this.courseTypeId[res.data[0][i].id] = [];
+            }
+            if (!this.CourseTypeJson[res.data[0][i].id]) {
+              this.CourseTypeJson[res.data[0][i].id] = [];
+            }
+            if (this.oid == "69893dca-1d47-11ed-8c78-005056b86db5") {
+              if (res.data[0][i].name == "栏目") {
+                this.CourseType[0][i].name = "主题";
+              }
+            }
+            if (res.data[2].length == 0 && res.data[3].length == 0) {
+              for (var j = 0; j < res.data[1].length; j++) {
+                if (res.data[0][i].id == res.data[1][j].pid) {
+                  this.CourseTypeJson[res.data[0][i].id].push(res.data[1][j]); // 去除公共分类
+                }
+              }
+            } else {
+              if (res.data[2].length > 0) {
+                for (var j = 0; j < res.data[2].length; j++) {
+                  if (res.data[0][i].id == res.data[2][j].pid) {
+                    this.CourseTypeJson[res.data[0][i].id].push(res.data[2][j]); // 去除公共分类
+                  }
+                }
+              }
+              if (res.data[3].length > 0) {
+                for (var j = 0; j < res.data[3].length; j++) {
+                  if (res.data[0][i].id == res.data[3][j].pid) {
+                    this.CourseTypeJson[res.data[0][i].id].push(res.data[3][j]); // 去除公共分类
+                  }
+                }
+              }
+            }
+          }
+        })
+        .catch((err) => {
+          console.error(err);
+        });
+    },
     selectType() {
       this.ajax
         .get(this.$store.state.api + "selectType")
@@ -6753,7 +6937,7 @@ export default {
         this.addTools(50, this.taskCount, this.toolIndex);
       }
     },
-    addPreTime(){
+    addPreTime() {
       if (this.preTime == 0) {
         this.unitJson[this.unitIndex].chapterInfo[0].taskJson[
           this.taskCount
@@ -6812,7 +6996,7 @@ export default {
         this.addTools(49, this.taskCount, this.toolIndex);
       }
     },
-    updateTime(preTime){
+    updateTime(preTime) {
       this.preTime = preTime;
     },
   },
@@ -6834,7 +7018,8 @@ export default {
     this.getTeacher();
     this.getClass();
     this.getTemplate();
-    this.selectType();
+    // this.selectType();
+    this.selectAllType();
     this.selectEva();
     this.loading = false;
     this.timer2 = setInterval(() => {
@@ -9372,4 +9557,24 @@ ol {
 .groupContent >>> .el-input-number.is-without-controls .el-input__inner {
   text-align: left;
 }
+.radioBox > div {
+  margin: 10px 0 0 10px;
+}
+.radioBox >>> .el-radio__input,
+.radioBox >>> .el-checkbox__inner {
+  margin-left: 10px;
+}
+.radioBox >>> .el-radio__label,
+.radioBox >>> .el-checkbox__label {
+  display: flex;
+  align-items: center;
+}
+.inImg {
+  width: 100px;
+}
+.inImg > img {
+  width: 100%;
+  height: 100%;
+  object-fit: cover;
+}
 </style>

+ 116 - 25
src/components/pages/components/worksDetail2.vue

@@ -517,7 +517,8 @@
                             </div>
                             <div
                               class="a_add_box"
-                              v-for="(item1, index1) in worksDetail[sIndex].chooseInfo[0].testCount"
+                              v-for="(item1, index1) in worksDetail[sIndex]
+                                .chooseInfo[0].testCount"
                               :key="index1"
                             >
                               <div class="a_add_head">
@@ -525,13 +526,22 @@
                                   {{ index1 + 1 + "、" }}
                                   <div>
                                     题目:{{
-                                      worksDetail[sIndex].chooseInfo[0].testJson[index1].teststitle
+                                      worksDetail[sIndex].chooseInfo[0]
+                                        .testJson[index1].teststitle
                                     }}
                                   </div>
                                 </div>
                                 <img
-                                  v-if="worksDetail[sIndex].chooseInfo[0].testJson[index1].img"
-                                  :src="worksDetail[sIndex].chooseInfo[0].testJson[index1].img"
+                                  v-if="
+                                    worksDetail[sIndex].chooseInfo[0].testJson[
+                                      index1
+                                    ].img
+                                  "
+                                  :src="
+                                    worksDetail[sIndex].chooseInfo[0].testJson[
+                                      index1
+                                    ].img
+                                  "
                                   style="
                                     height: 300px;
                                     margin-top: 10px;
@@ -542,31 +552,86 @@
                               <div class="a_add_body">
                                 <div class="a_add_input">
                                   <el-radio-group
-                                    v-model="worksDetail[sIndex].chooseInfo[0].radio[index1]"
-                                    v-if="worksDetail[sIndex].chooseInfo[0].testJson[index1].type == '1'"
+                                    v-model="
+                                      worksDetail[sIndex].chooseInfo[0].radio[
+                                        index1
+                                      ]
+                                    "
+                                    v-if="
+                                      worksDetail[sIndex].chooseInfo[0]
+                                        .testJson[index1].type == '1'
+                                    "
                                   >
-                                    <el-radio
-                                      v-for="(item2, checkIndex) in worksDetail[sIndex].chooseInfo[0].testJson[index1].checkList"
-                                      :key="checkIndex"
-                                      :label="checkIndex"
-                                      disabled
-                                      class="redioStyle"
-                                      ><span v-html="item2"></span
-                                    ></el-radio>
+                                    <div class="radioBox">
+                                      <el-radio
+                                        v-for="(
+                                          item2, checkIndex
+                                        ) in worksDetail[sIndex].chooseInfo[0]
+                                          .testJson[index1].checkList"
+                                        :key="checkIndex"
+                                        :label="checkIndex"
+                                        disabled
+                                        class="redioStyle"
+                                      >
+                                        <div
+                                          style="margin-right: 10px"
+                                          v-if="
+                                            item2 &&
+                                            item2.imgType &&
+                                            item2.imgType == 1
+                                          "
+                                        >
+                                          <div
+                                            class="inImg"
+                                            @click.stop="previewImg(item2.src)"
+                                          >
+                                            <img :src="item2.src" alt="" />
+                                          </div>
+                                        </div>
+                                        <span v-else v-html="item2"></span>
+                                      </el-radio>
+                                    </div>
                                   </el-radio-group>
                                   <el-checkbox-group
-                                    v-model="worksDetail[sIndex].chooseInfo[0].radio[index1]"
-                                    v-if="worksDetail[sIndex].chooseInfo[0].testJson[index1].type == '2'"
+                                    v-model="
+                                      worksDetail[sIndex].chooseInfo[0].radio[
+                                        index1
+                                      ]
+                                    "
+                                    v-if="
+                                      worksDetail[sIndex].chooseInfo[0]
+                                        .testJson[index1].type == '2'
+                                    "
                                   >
-                                    <el-checkbox
-                                      v-for="(item2, checkIndex) in worksDetail[sIndex].chooseInfo[0].testJson[index1].checkList"
-                                      :key="checkIndex"
-                                      :label="checkIndex"
-                                      disabled
-                                      class="redioStyle"
-                                    >
-                                      <span v-html="item2"></span>
-                                    </el-checkbox>
+                                    <div class="radioBox">
+                                      <el-checkbox
+                                        v-for="(
+                                          item2, checkIndex
+                                        ) in worksDetail[sIndex].chooseInfo[0]
+                                          .testJson[index1].checkList"
+                                        :key="checkIndex"
+                                        :label="checkIndex"
+                                        disabled
+                                        class="redioStyle"
+                                      >
+                                        <div
+                                          style="margin-right: 10px"
+                                          v-if="
+                                            item2 &&
+                                            item2.imgType &&
+                                            item2.imgType == 1
+                                          "
+                                        >
+                                          <div
+                                            class="inImg"
+                                            @click.stop="previewImg(item2.src)"
+                                          >
+                                            <img :src="item2.src" alt="" />
+                                          </div>
+                                        </div>
+                                        <span v-else v-html="item2"></span>
+                                      </el-checkbox>
+                                    </div>
                                   </el-checkbox-group>
                                 </div>
                               </div>
@@ -3223,4 +3288,30 @@ export default {
   border-color: #dcdfe6;
   background-color: #fff;
 }
+.radioBox {
+  display: flex;
+  flex-direction: row;
+  flex-wrap: nowrap;
+  align-items: center;
+}
+.radioBox > div {
+  margin: 10px 0 0 10px;
+}
+.radioBox >>> .el-radio__input,
+.radioBox >>> .el-checkbox__inner {
+  margin-left: 10px;
+}
+.radioBox >>> .el-radio,
+.radioBox >>> .el-checkbox {
+  display: flex;
+  align-items: center;
+}
+.inImg {
+  width: 100px;
+}
+.inImg > img {
+  width: 100%;
+  height: 100%;
+  object-fit: cover;
+}
 </style>

+ 82 - 21
src/components/pages/components/worksDetail3.vue

@@ -307,16 +307,34 @@
                                 ].type == '1'
                               "
                             >
-                              <el-radio
-                                v-for="(item2, checkIndex) in worksDetail[
-                                  sIndex
-                                ].chooseInfo[0].testJson[index1].checkList"
-                                :key="checkIndex"
-                                :label="checkIndex"
-                                disabled
-                                class="redioStyle"
-                                ><span v-html="item2"></span
-                              ></el-radio>
+                              <div class="radioBox">
+                                <el-radio
+                                  v-for="(item2, checkIndex) in worksDetail[
+                                    sIndex
+                                  ].chooseInfo[0].testJson[index1].checkList"
+                                  :key="checkIndex"
+                                  :label="checkIndex"
+                                  disabled
+                                  class="redioStyle"
+                                >
+                                  <div
+                                    style="margin-right: 10px"
+                                    v-if="
+                                      item2 &&
+                                      item2.imgType &&
+                                      item2.imgType == 1
+                                    "
+                                  >
+                                    <div
+                                      class="inImg"
+                                      @click.stop="previewImg(item2.src)"
+                                    >
+                                      <img :src="item2.src" alt="" />
+                                    </div>
+                                  </div>
+                                  <span v-else v-html="item2"></span>
+                                </el-radio>
+                              </div>
                             </el-radio-group>
                             <el-checkbox-group
                               v-model="
@@ -328,17 +346,34 @@
                                 ].type == '2'
                               "
                             >
-                              <el-checkbox
-                                v-for="(item2, checkIndex) in worksDetail[
-                                  sIndex
-                                ].chooseInfo[0].testJson[index1].checkList"
-                                :key="checkIndex"
-                                :label="checkIndex"
-                                disabled
-                                class="redioStyle"
-                              >
-                                <span v-html="item2"></span>
-                              </el-checkbox>
+                              <div class="radioBox">
+                                <el-checkbox
+                                  v-for="(item2, checkIndex) in worksDetail[
+                                    sIndex
+                                  ].chooseInfo[0].testJson[index1].checkList"
+                                  :key="checkIndex"
+                                  :label="checkIndex"
+                                  disabled
+                                  class="redioStyle"
+                                >
+                                  <div
+                                    style="margin-right: 10px"
+                                    v-if="
+                                      item2 &&
+                                      item2.imgType &&
+                                      item2.imgType == 1
+                                    "
+                                  >
+                                    <div
+                                      class="inImg"
+                                      @click.stop="previewImg(item2.src)"
+                                    >
+                                      <img :src="item2.src" alt="" />
+                                    </div>
+                                  </div>
+                                  <span v-else v-html="item2"></span>
+                                </el-checkbox>
+                              </div>
                             </el-checkbox-group>
                           </div>
                         </div>
@@ -2896,4 +2931,30 @@ export default {
 .rightScoreFullBox {
   width: 40%;
 }
+.radioBox {
+  display: flex;
+  flex-direction: row;
+  flex-wrap: nowrap;
+  align-items: center;
+}
+.radioBox > div {
+  margin: 10px 0 0 10px;
+}
+.radioBox >>> .el-radio__input,
+.radioBox >>> .el-checkbox__inner {
+  margin-left: 10px;
+}
+.radioBox >>> .el-radio,
+.radioBox >>> .el-checkbox {
+  display: flex;
+  align-items: center;
+}
+.inImg {
+  width: 100px;
+}
+.inImg > img {
+  width: 100%;
+  height: 100%;
+  object-fit: cover;
+}
 </style>

+ 51 - 1
src/components/pages/course.vue

@@ -551,6 +551,55 @@ export default {
         });
       // }
     },
+    selectAllType() {
+      let params = {
+        org: this.org && this.org != "" ? this.org : "",
+        oid: this.oid && this.oid != "" ? this.oid : "",
+      };
+      this.ajax
+        .get(this.$store.state.api + "selectAllType", params)
+        .then((res) => {
+          this.CourseType = res.data;
+          for (var i = 0; i < res.data[0].length; i++) {
+            if (!this.cid) {
+              this.courseTypeId[res.data[0][i].id] = [];
+            }
+            if (!this.CourseTypeJson[res.data[0][i].id]) {
+              this.CourseTypeJson[res.data[0][i].id] = [];
+            }
+            if (this.oid == "69893dca-1d47-11ed-8c78-005056b86db5") {
+              if (res.data[0][i].name == "栏目") {
+                this.CourseType[0][i].name = "主题";
+              }
+            }
+            if (res.data[2].length == 0 && res.data[3].length == 0) {
+              for (var j = 0; j < res.data[1].length; j++) {
+                if (res.data[0][i].id == res.data[1][j].pid) {
+                  this.CourseTypeJson[res.data[0][i].id].push(res.data[1][j]); // 去除公共分类
+                }
+              }
+            } else {
+              if (res.data[2].length > 0) {
+                for (var j = 0; j < res.data[2].length; j++) {
+                  if (res.data[0][i].id == res.data[2][j].pid) {
+                    this.CourseTypeJson[res.data[0][i].id].push(res.data[2][j]); // 去除公共分类
+                  }
+                }
+              }
+              if (res.data[3].length > 0) {
+                for (var j = 0; j < res.data[3].length; j++) {
+                  if (res.data[0][i].id == res.data[3][j].pid) {
+                    this.CourseTypeJson[res.data[0][i].id].push(res.data[3][j]); // 去除公共分类
+                  }
+                }
+              }
+            }
+          }
+        })
+        .catch((err) => {
+          console.error(err);
+        });
+    },
     selectType() {
       this.ajax
         .get(this.$store.state.api + "selectType")
@@ -674,7 +723,8 @@ export default {
   },
   created() {
     this.page = 1;
-    this.selectType();
+    // this.selectType();
+    this.selectAllType();
     this.getCourse();
   }
 };