马宇豪
2024-08-08 700eb98db0151940cc91abcc5b3149ce23ec42de
pages/tabBar/wearhouse/questions.vue
@@ -22,7 +22,7 @@
      </view>
      <view class="questions">
        <view class="title">
          <span>【{{currentQ.questionType == 1?'单选题':currentQ.questionType == 2?'多选题':'判断题'}}】</span>
          <span>【{{currentQ.questionType == 1?'单选题':currentQ.questionType == 2?'多选题':currentQ.questionType == 3?'判断题':'简答题'}}】</span>
          {{currentQ.title}}
        </view>
        <view class="content">
@@ -32,7 +32,6 @@
              placement="column"
              iconPlacement="right"
              @change="checkboxChange"
              :disabled="type==3?true:false"
              class="myRadio"
          >
            <u-checkbox
@@ -52,7 +51,7 @@
              placement="column"
              iconPlacement="right"
              @change="checkboxChange"
              :disabled="type==3?true:false"
              disabled
              class="myRadio"
          >
            <u-checkbox
@@ -66,7 +65,7 @@
            </u-checkbox>
          </u-checkbox-group>
          <u-radio-group v-model="currentA" class="myRadio" iconPlacement="right" placement="column" @change="groupChange" v-if="(type == 1 || type == 2)&&(currentQ.questionType==1||currentQ.questionType==3)" :disabled="type==3?true:false">
          <u-radio-group v-model="currentA" class="myRadio" iconPlacement="right" placement="column" @change="groupChange" v-if="(type == 1 || type == 2)&&(currentQ.questionType==1||currentQ.questionType==3)">
            <u-radio
                :customStyle="{marginBottom: '15px'}"
                v-for="(item, index) in currentQ.content.items"
@@ -80,7 +79,7 @@
            </u-radio>
          </u-radio-group>
          <u-radio-group v-model="currentA" class="myRadio" iconPlacement="right" placement="column" @change="groupChange" v-if="type == 3 && (currentQ.questionType==1||currentQ.questionType==3)" :disabled="type==3?true:false">
          <u-radio-group v-model="currentA" class="myRadio" iconPlacement="right" placement="column" @change="groupChange" v-if="type == 3 && (currentQ.questionType==1||currentQ.questionType==3)" disabled>
            <u-radio
                :customStyle="{marginBottom: '15px'}"
                v-for="(item, index) in currentQ.content.items"
@@ -93,6 +92,9 @@
            >
            </u-radio>
          </u-radio-group>
          <u--textarea v-model="currentA" v-if="(type == 1 || type == 2)&&(currentQ.questionType==4)" style="margin-bottom: 15px" :maxlength="-1" placeholder="请输入答案" autoHeight @focus="openAnswer"></u--textarea>
          <u--textarea v-model="currentA" v-if="type == 3&&(currentQ.questionType==4)" :class="currentQ.answer == currentA?'pickedText':'wrongText'" style="margin-bottom: 15px" :maxlength="-1" placeholder="请输入答案" autoHeight disabled></u--textarea>
          <u-button style="width: 80%;margin: 5px auto 15px"
                    v-if="currentQ.questionType==2 && currentB.length>0 && type !== 3"
@@ -127,6 +129,12 @@
        </view>
      </view>
    </u-popup>
    <u-popup :show="showInput" :round="40" mode="bottom" @close="closeInput" @open="openInput">
      <view class="panelTwo">
        <u--textarea v-model="currentA" :maxlength="-1" placeholder="请输入答案"></u--textarea>
        <u-button shape="circle" type="primary" style="width: 80%;margin-top: 20px" text="确认答案" @click="confirmAnswer(1)"></u-button>
      </view>
    </u-popup>
   </view>
</template>
@@ -149,7 +157,8 @@
      currentA: '',
      currentB: [],
      type: '',
      showPanel: false
      showPanel: false,
      showInput: false
      }
   },
  onReady(){
@@ -202,7 +211,10 @@
        uni.$u.toast(res.message)
      }
    },
    openAnswer(){
      const t = this
      t.showInput = true
    },
    async toQuestion(item,index){
      this.curTotalIndex = index
      const curIdList = this.idList.slice(this.curTotalIndex,this.curTotalIndex + 20)
@@ -219,6 +231,12 @@
    close() {
      this.showPanel = false
      // console.log('close');
    },
    openInput() {
      // console.log('open');
    },
    closeInput(){
      this.showInput = false
    },
    async getQuestionIds(id){
      const res = await getQuestionIdList({bankId: id})
@@ -301,6 +319,10 @@
    },
    confirmAnswer(type){
      if(type == 1 && this.currentA == ''){
        uni.$u.toast('答案为空,请先作答')
        return
      }
      const data = {
        answer: this.currentQ.questionType==2?this.currentB.join(','):this.currentA,
        bankId: this.bank.id,
@@ -312,6 +334,9 @@
          this.currentQ.exExerciseAnswer.answer = res.data.answer
          if(type == 2){
            this.nextQ()
          }
          if(this.showInput == true){
            this.showInput = false
          }
          // uni.$u.toast('答案已提交')
        }else{
@@ -504,6 +529,18 @@
    color: #ed6464;
  }
}
.panelTwo{
  height: 60vh;
  background: #f2f2f2;
  padding: 15px;
  box-sizing: border-box;
  /deep/ .u-textarea__field{
    height: calc(60vh - 110px) !important;
  }
}
.m-p-15{
  width: 100%;
  padding: 0 15px;
@@ -549,15 +586,31 @@
    .content{
      padding-left: 10rpx;
      .pickedText{
        border: 1.5px solid #2979ff !important;
      }
      .wrongText{
        border: 1.5px solid #ed6464 !important;
      }
      /deep/ .u-textarea__field{
        min-height: 80px;
      }
      .answers{
        background: #ecf5ff;
        padding: 10px;
        &>view{
          margin-bottom: 5px;
        }
        span{
          width: 100%;
          display: block;
          white-space: pre-wrap;
          font-weight: bolder;
          word-break: break-word;
        }
        .right{
          color: #3c9cff