闫增涛
2024-07-02 92845ee4a3898c4c65bc85bbbe777e4595897e3d
src/views/examination/index.vue
@@ -624,16 +624,16 @@
      domain: 'collectData',
      keys: [props.activeBook.bookId]
    })
    .then(async (res) => {
    .then(async (res:any) => {
      try {
        const collect = JSON.parse(res[0].value)
        if (collect.length) {
          examination.collectList = collect.find((citem) => citem.type == 'bits').collectList
          examination.collectList = collect.find((citem:any) => citem.type == 'bits').collectList
          examination.allCollect[0].collectList = collect.find(
            (citem) => citem.type == 'bits'
            (citem:any) => citem.type == 'bits'
          ).collectList
          examination.allCollect[1].collectList = collect.find(
            (citem) => citem.type == 'json'
            (citem:any) => citem.type == 'json'
          ).collectList
        }
      } catch (error) {}
@@ -663,14 +663,9 @@
}
// 获取收藏夹
const getCollectDataList = async () => {
  if (!examination.collectList.length) {
    examination.loading = false
    examination.noData = true
    return false
  }
  // 开始请求
  let oldData = null
  let oldList = []
  let oldList:any = []
  let cardList = [
    {
      catalogName: '单选题',
@@ -693,11 +688,11 @@
      infoList: []
    }
  ]
  let singleChoiceArr = [] // 单选
  let judgeArr = [] // 判断
  let shortArr = [] // 简答
  let multipleChoiceArr = [] // 多选
  let completionArr = [] // 填空
  let singleChoiceArr:any = [] // 单选
  let judgeArr:any = [] // 判断
  let shortArr:any = [] // 简答
  let multipleChoiceArr:any = [] // 多选
  let completionArr:any = [] // 填空
  // 11
  for (let qindex = 0; qindex < examination.collectList.length; qindex++) {
    const qitem = examination.collectList[qindex]
@@ -791,7 +786,7 @@
        questionObj.stem.stemImage = getPublicImage(questionObj.stem.stemImage, 150)
      }
      if (questionObj.optionStyle == 'Image' || questionObj.optionStyle == 'TxtAndImage') {
        questionObj.option.forEach((optionItem) => {
        questionObj.option.forEach((optionItem:any) => {
          if (optionItem.img) optionItem.img = getPublicImage(optionItem.img, 150)
        })
      }
@@ -813,7 +808,7 @@
          questionObj.questionType == 'judge' ||
          questionObj.questionType == 'multipleChoice')
      ) {
        questionObj.option.forEach((item) => {
        questionObj.option.forEach((item:any) => {
          if (item.txt)
            item.txt = item.txt
              .replace(/\<img/gi, '<img class="option-rich-img"')
@@ -897,9 +892,7 @@
  for (let index = 0; index < jsonCollectList.length; index++) {
    const item = jsonCollectList[index]
    if (item.type && item.type == 'material') {
      examination.cardList.push(item)
    } else if (item.questionType == 'singleChoice') {
  if (item.questionType == 'singleChoice') {
      examination.cardList[0].infoList.push(item)
    } else if (item.questionType == 'judge') {
      examination.cardList[1].infoList.push(item)
@@ -909,6 +902,8 @@
      examination.cardList[3].infoList.push(item)
    } else if (item.questionType == 'shortAnswer') {
      examination.cardList[4].infoList.push(item)
    } else if (item.type && item.type == 'material') {
      examination.cardList[examination.cardList.length] = item
    }
  }
  examination.cardList = examination.cardList.filter((item) => item.infoList.length > 0)
@@ -935,6 +930,7 @@
        examination.cardList = (await getErrorDataList()) as any
        await getJsonError()
      } else {
        examination.noData = true
        examination.loading = false
        ElMessageBox.confirm('错题集暂无数据!', '提示', {
          confirmButtonText: '确定',
@@ -953,12 +949,6 @@
}
// 获取错题集
const getErrorDataList = async () => {
  if (!examination.errorList.length) {
    examination.loading = false
    examination.noData = true
    return false
  }
  // 开始请求
  let oldData = null
  let oldList:any = []
  let cardList = [
@@ -1187,9 +1177,7 @@
  for (let index = 0; index < jsonCollectList.length; index++) {
    const item = jsonCollectList[index]
    if (item.type && item.type == 'material') {
      examination.cardList.push(item)
    } else if (item.questionType == 'singleChoice') {
    if (item.questionType == 'singleChoice') {
      examination.cardList[0].infoList.push(item)
    } else if (item.questionType == 'judge') {
      examination.cardList[1].infoList.push(item)
@@ -1199,6 +1187,8 @@
      examination.cardList[3].infoList.push(item)
    } else if (item.questionType == 'shortAnswer') {
      examination.cardList[4].infoList.push(item)
    } else if (item.type && item.type == 'material') {
      examination.cardList[examination.cardList.length] = item
    }
  }
  examination.cardList = examination.cardList.filter((item) => item.infoList.length > 0)
@@ -1355,7 +1345,7 @@
      keys: [props.info.id]
    })
    .then((res:any) => {
      if(res) {
      if(res.length) {
        data = JSON.parse(res[0].value)
      }
    })
@@ -1426,7 +1416,7 @@
      ]
    })
    .then((res:any) => {
      console.log('错题已保存', examination.allError)
      console.log('错题已清空')
    })
}
defineExpose({ handleExaminationDialog })