litian
4 天以前 358b9908802e21d74302fe31c2981f68e39b632e
src/components/examinations/index.vue
@@ -7,14 +7,28 @@
      v-show="item.infoList.length"
    >
      <p class="catalogName" :style="{ color: primaryColor }">
        <span v-if="nindex == 0">一、</span>
        <span v-if="nindex == 1">二、</span>
        <span v-if="nindex == 2">三、</span>
        <span v-if="nindex == 3">四、</span>
        <span v-if="nindex == 4">五、</span>
        <span v-html="item.catalogName" ></span>
        <span class="catalogName-box">
          <span v-if="nindex == 0">一、</span>
          <span v-if="nindex == 1">二、</span>
          <span v-if="nindex == 2">三、</span>
          <span v-if="nindex == 3">四、</span>
          <span v-if="nindex == 4">五、</span>
          <span v-html="item.catalogName"></span>
        </span>
        <img
          :src="item.isCollect ? isHeart : heart"
          alt=""
          class="collect-png"
          @click="setCollect(nindex, index)"
          v-if="!hideCollect && item.type == 'material'"
        />
      </p>
      <el-image v-if="item.catalogImage" :src="item.catalogImage"></el-image>
      <el-image
        v-if="item.catalogImage"
        :src="item.catalogImage"
        :preview-src-list="[item.catalogImage]"
        class="catalogImage"
      ></el-image>
      <ul>
        <li
          v-for="(value, index) in item.infoList"
@@ -27,23 +41,28 @@
              <span
                class="questionNum"
                :style="{
                  marginTop: value.questionType == 'completion' ? '12px' : '0',
                  marginTop:
                    value.questionType == 'completion' ||
                    value.questionType == 'mathField'
                      ? '12px'
                      : '0',
                }"
                >{{ index + 1 }}.
              </span>
              <!-- 听力进度条 -->
              <!-- <answerAudioPlayer :audioUrl="value.src" v-show="item.name == '听力题'" /> -->
              <!-- 仅文字 -->
              <p
                class="titleText text-fl"
                v-if="
                  value.stemStyle == 'Txt' && value.questionType != 'completion'
                  value.stemStyle == 'Txt' &&
                  value.questionType != 'completion' &&
                  value.questionType != 'dropdown' &&
                  value.questionType != 'mathField'
                "
                :id="value.id"
                v-html="value.stem.stemTxt"
              >
              </p>
              ></p>
              <!-- 仅图片 -->
              <el-image
                class="stemImg"
@@ -56,8 +75,7 @@
                class="stemTxtAndImage titleText"
                v-else-if="value.stemStyle == 'TxtAndImage'"
              >
                <span v-html="value.stem.stemTxt">
                </span>
                <span v-html="value.stem.stemTxt"> </span>
                <el-image
                  :src="getPublicImage(value.stem.stemImage, 150)"
                  :preview-src-list="[getPublicImage(value.stem.stemImage)]"
@@ -65,7 +83,13 @@
                ></el-image>
              </p>
              <!-- 填空题题干 -->
              <p class="titleText" v-if="value.questionType == 'completion'">
              <p
                class="titleText"
                v-if="
                  value.questionType == 'completion' ||
                  value.questionType == 'mathField'
                "
              >
                <span
                  v-for="(itemText, indexText) in value.stem"
                  :key="indexText + 'questionType'"
@@ -73,15 +97,30 @@
                  <span
                    v-if="typeof itemText == 'string'"
                    v-html="itemText"
                    class="input-txt"
                  ></span>
                  <input
                    v-else
                    v-if="
                      typeof itemText != 'string' &&
                      value.questionType == 'completion'
                    "
                    type="text"
                    class="input"
                    v-model.trim="value.userAnswer[itemText.num]"
                    :disabled="value.isComplete"
                    :style="{ backgroundColor: inputBc }"
                  />
                  <math-field
                    v-if="
                      typeof itemText != 'string' &&
                      value.questionType == 'mathField'
                    "
                    class="mathField"
                    :menuItems="[]"
                    @input="onChangeInput($event, nindex, index, itemText.num)"
                  >
                    {{ value.userAnswer[itemText.num] }}
                  </math-field>
                </span>
              </p>
              <!-- 富文本 -->
@@ -91,13 +130,38 @@
                v-html="value.stem.stemTxt"
                v-cloak
              ></p>
              <!-- 下拉选择题 -->
              <p class="titleText" v-if="value.questionType == 'dropdown'">
                <span
                  v-for="(itemText, indexText) in value.stem"
                  :key="indexText + 'questionType'"
                >
                  <span
                    v-if="typeof itemText == 'string'"
                    v-html="itemText"
                    class="input-txt"
                  ></span>
                  <select
                    v-else
                    v-model="value.userAnswer"
                    :disabled="value.isComplete"
                  >
                    <option
                      v-for="(citem, cindex) in value.option"
                      :key="cindex + 'dropdown'"
                      :label="citem"
                      :value="citem"
                    ></option>
                  </select>
                </span>
              </p>
            </div>
            <img
              :src="value.isCollect ? isHeart : heart"
              alt=""
              class="collect-png"
              @click="setCollect(nindex, index)"
              v-if="!(hideCollect && value.questionType == 'shortAnswer')"
              v-if="!hideCollect && item.type != 'material'"
            />
            <!-- 收藏 -->
          </div>
@@ -212,17 +276,16 @@
              </el-checkbox>
            </el-checkbox-group>
            <!-- 简答 翻译 -->
            <!-- <TEditorVue
            v-else-if="value.questionType == 'shortAnswer'"
            :value="value.userAnswer"
            :disabled="value.isComplete"
            @getContent="
              (val) => {
                value.userAnswer = val.trim();
                inputChange();
              }
            "
          ></TEditorVue> -->
            <TEditorVue
              v-else-if="value.questionType == 'formula'"
              :value="value.userAnswer"
              :disabled="value.isComplete"
              @getContent="
                (val) => {
                  value.userAnswer = val;
                }
              "
            />
            <el-input
              :disabled="value.isComplete"
              style="width: 94%; margin: 0 auto"
@@ -238,7 +301,8 @@
                type != 'mock' &&
                (value.questionType == 'shortAnswer' ||
                  value.questionType == 'multipleChoice' ||
                  value.questionType == 'completion')
                  value.questionType == 'completion' ||
                  value.questionType == 'mathField')
              "
            >
              <el-button @click="checkPares(value)" style="margin-top: 10px"
@@ -249,9 +313,11 @@
            <div class="analysis" v-if="value.isComplete">
              <el-collapse
                v-model="value.isUnfold"
                @change="handleChange(value)"
                accordion
                v-if="value.questionType != 'shortAnswer'"
                v-if="
                  value.questionType != 'shortAnswer' &&
                  value.questionType != 'formula'
                "
              >
                <el-collapse-item :name="value.id" class="objective">
                  <template #title>
@@ -350,8 +416,8 @@
                  ></div>
                  <div v-else>暂无数据</div>
                </el-collapse-item>
                <!-- 主观题 -->
              </el-collapse>
              <!-- 主观题 -->
              <el-collapse v-else v-model="value.isUnfold" accordion>
                <el-collapse-item :name="value.id" class="objective">
                  <template #title>
@@ -379,7 +445,6 @@
                  <div class="referBox" v-if="value.analysisCon">
                    <span>解析:</span>
                    <p
                      v-if="value.analysisCon"
                      v-html="value.analysisCon"
                      :class="
                        [
@@ -389,7 +454,6 @@
                        ].join(' ')
                      "
                    ></p>
                    <p v-else class="ti-2">暂无数据</p>
                  </div>
                </el-collapse-item>
              </el-collapse>
@@ -486,9 +550,12 @@
</template>
<script>
import { MathfieldElement } from "mathlive";
import { Message } from "element-ui";
import TEditorVue from "../teditor/index.vue";
export default {
  name: "examination-option",
  components: { TEditorVue },
  props: {
    cardList: {
      type: Array,
@@ -551,7 +618,6 @@
  watch: {
    cardList: {
      handler(newVal) {
        // console.log('新值',newVal);
        this.cardData = this.cardList;
        if (newVal && newVal.length) {
          this.loading = false;
@@ -566,6 +632,24 @@
    this.getErrorList();
  },
  methods: {
    // 获取不受保护的图片
    getPublicImage(md5, width, height) {
      if (!md5) return;
      if (md5.includes("http")) {
        if (width) {
          return md5 + `?width=${width}`;
        } else {
          return md5;
        }
      }
      let src = null;
      if (md5) {
        src = process.env.VUE_APP_API_URL + `/file/GetPreViewImage?md5=${md5}`;
      }
      if (width) src += `&width=${width}`;
      if (height) src += `&height=${height}`;
      return src;
    },
    // 数组转为字符串方法
    arrayToString(data) {
      // 检查是否为数组
@@ -602,7 +686,18 @@
        const item = this.cardData[index];
        for (let cindex = 0; cindex < item.infoList.length; cindex++) {
          const citem = item.infoList[cindex];
          citem.userAnswer = "";
          if (typeof citem.userAnswer == "string") {
            citem.userAnswer = "";
          } else {
            if (citem.questionType == "multipleChoice") {
              citem.userAnswer = [];
            } else {
              // 填空题
              for (let dindex = 0; dindex < citem.userAnswer.length; dindex++) {
                citem.userAnswer[dindex] = "";
              }
            }
          }
          citem.isComplete = false;
        }
      }
@@ -646,14 +741,17 @@
            }
          } else if (
            citem.questionType == "singleChoice" ||
            citem.questionType == "judge"
            citem.questionType == "judge" ||
            citem.questionType == "dropdown"
          ) {
            if (citem.id == "63825") console.log("i", item);
            citem.isRight = citem.answer == citem.userAnswer;
          } else if (citem.questionType == "shortAnswer") {
            // 简答 翻译
            citem.isRight = null;
          } else if (citem.questionType == "completion") {
          } else if (
            citem.questionType == "completion" ||
            citem.questionType == "mathField"
          ) {
            // 填空
            if (typeof citem.answer == "string") {
              citem.isRight = citem.answer == citem.userAnswer[0];
@@ -760,8 +858,14 @@
    },
    // 题目收藏按钮,收藏和取消同一接口,取消数组减去该项id
    setCollect(num, number) {
      const item = this.cardData[num].infoList[number];
      let item = null;
      if (number) {
        item = this.cardData[num].infoList[number];
      } else {
        item = this.cardData[num];
      }
      item.isCollect = !item.isCollect;
      console.log(111, item);
      if (this.cardData.length == 0) {
        this.collectList.push(item.id);
      } else {
@@ -779,7 +883,7 @@
        const item = this.allCollect[index];
        if (item.type == this.sourceType) item.collectList = this.collectList;
      }
      // console.log(this.allCollect, this.collectList, list);
      console.log("点击收藏按钮", this.allCollect);
      this.MG.identity
        .setUserKey({
          setKeyRequests: [
@@ -806,6 +910,7 @@
        .then((res) => {
          try {
            const collect = JSON.parse(res[0].value);
            console.log("全部收藏id", collect);
            if (collect.length) {
              this.collectList = collect.find(
                (citem) => citem.type == this.sourceType
@@ -849,21 +954,36 @@
              ).errorList;
            }
          } catch (error) {}
          console.log("错题列表", this.allError);
        })
        .catch(() => {});
    },
    onChangeInput(e, index, cindex, num) {
      this.cardData[index].infoList[cindex].userAnswer[num] = e.target.value;
    },
  },
};
</script>
<style lang="less">
.titleText img {
  max-width: 80%;
  min-width: 220px;
}
</style>
<style lang="less" scoped>
.catalogName {
.catalogName {
  display: flex;
  text-indent: 1em !important;
  font-size: 16px;
  .catalogName-box {
    display: inline-block;
    width: 94%;
  }
}
.catalogImage {
  width: 50%;
}
.examination {
  min-height: 100px;
  ul {
@@ -1000,32 +1120,41 @@
      font-weight: bold;
    }
    .text-fl {
      display:flex;
      align-items:center;
      flex-wrap:wrap;
      display: flex;
      align-items: center;
      flex-wrap: wrap;
    }
    .titleText {
      display: flex;
      flex-wrap: wrap;
      align-items: center;
      text-align: left;
      min-width: 90%;
      font-size: 16px;
      line-height: 32px;
      color: #000;
      .input-txt {
        display: flex;
        flex-wrap: wrap;
        align-items: center;
      }
      span {
        display: inline-block;
        font-size: 16px;
        // line-height: 26px;
        color: #000;
        font-weight: 400;
        margin-top: 6px;
      }
      select {
        outline: none;
        min-width: 100px;
      }
      input {
        width: 140px;
        height: 24px;
        border: 0;
        outline: none;
        border-bottom: 1px solid #15c0f2;
        border-bottom: 1px solid #000;
      }
      /deep/ .el-textarea.is-disabled .el-textarea__inner {
@@ -1054,6 +1183,10 @@
    width: 21px;
    height: 21px;
  }
  .mathField {
    min-width: 200px;
    max-width: 518px;
  }
}
/** 选项 */