Browse Source

feat(workbench): 添加培训考核入口并优化答题进度计算

- 在工作台管理页面添加培训考核的跳转入口
- 修改环境变量从develop改为release
- 优化答题进度计算逻辑,增加字数限制判断
master
前端-胡立永 1 week ago
parent
commit
8e61edad4f
3 changed files with 79 additions and 59 deletions
  1. +67
    -58
      otherPages/authentication/examination/train.vue
  2. +11
    -0
      pages/workbenchManage/index.vue
  3. +1
    -1
      utils/getUrl.js

+ 67
- 58
otherPages/authentication/examination/train.vue View File

@ -1,12 +1,13 @@
<template>
<!-- <view>培训考核</view> -->
<view class="page">
<view class="header">
<view class="flex-rowl color-fff size-28 title">
{{ `答题进度 ${answered}/${total}` }}
</view>
<up-line-progress class="progress" :percentage="progress" activeColor="#FFBF60" inactiveColor="#D9D9D9" height="16rpx" :showText="false"></up-line-progress>
<up-line-progress class="progress" :percentage="progress" activeColor="#FFBF60" inactiveColor="#D9D9D9"
height="16rpx" :showText="false"></up-line-progress>
</view>
<view class="box">
@ -16,15 +17,9 @@
主观题
</view>
</view>
<view >
<questionCard
v-for="(item, qIdx) in list"
:key="`question-${qIdx}`"
:index="qIdx"
:data="item"
v-model="item.value"
:type="TYPE"
></questionCard>
<view>
<questionCard v-for="(item, qIdx) in list" :key="`question-${qIdx}`" :index="qIdx" :data="item"
v-model="item.value" :type="TYPE"></questionCard>
</view>
</view>
</view>
@ -37,62 +32,75 @@
</template>
<script setup>
import { ref, computed } from 'vue'
import { onShow } from '@dcloudio/uni-app'
import { getQuestionList } from '@/api/examination'
import {
ref,
computed
} from 'vue'
import {
onShow
} from '@dcloudio/uni-app'
import {
getQuestionList
} from '@/api/examination'
import questionCard from '../components/questionCard.vue';
const TYPE = '培训'
const list = ref([])
const total = ref(0)
const initQuestion = async () => {
try {
let questions = (await getQuestionList({
type: TYPE
})).map(item => ({
id: item.id,
title: item.title,
value: null,
numberWords: item.numberWords
}))
list.value = questions
total.value = questions.length
} catch (err) {
import questionCard from '../components/questionCard.vue';
}
}
const TYPE = '培训'
const answered = computed(() => {
const list = ref([])
const total = ref(0)
return list.value.filter(item => {
const initQuestion = async () => {
try {
let questions = (await getQuestionList({ type: TYPE })).map(item => ({ id: item.id, title: item.title, value: null }))
if (item.value == null) {
return false
}
list.value = questions
total.value = questions.length
} catch (err) {
if (typeof item.value == 'string') {
return item.value.length >= (item.numberWords || 0)
}
}
}
const answered = computed(() => {
return list.value.filter(item => {
if(item.value == null){
return false
}
if(typeof item.value == 'string'){
return item.value.length >= (item.numberWords || 0)
}
return true
}).length
// return list.value.filter(item => item.value?.length).length
})
const progress = computed(() => {
return Math.floor(answered.value / total.value * 100)
})
const toNext = () => {
uni.navigateTo({
url: "/otherPages/authentication/examination/trainCompleted/index"
return true
}).length
// return list.value.filter(item => item.value?.length).length
})
const progress = computed(() => {
return Math.floor(answered.value / total.value * 100)
})
}
onShow(() => {
initQuestion()
})
const toNext = () => {
uni.navigateTo({
url: "/otherPages/authentication/examination/trainCompleted/index"
})
}
onShow(() => {
initQuestion()
})
</script>
@ -107,6 +115,7 @@ onShow(() => {
top: 0;
background-image: linear-gradient(180deg, #FFBF60 0, #ffbf60 2%, #ffbf60 8%, #f2f2f2 90%);
z-index: 99;
.progress {
margin-top: 19rpx;
}


+ 11
- 0
pages/workbenchManage/index.vue View File

@ -63,6 +63,12 @@
height="68rpx"></up-image>
<view>{{ item.name }}</view>
</view>
<view class="icon-list"@click="handleGoto1()">
<up-image class="mb20" :show-loading="true" width="68rpx"
height="68rpx"></up-image>
<view>123</view>
</view>
</view>
</view>
</view>
@ -203,6 +209,11 @@ import { code } from "../../uni_modules/uview-plus/libs/function/test";
})
}
}
const handleGoto1 = () => {
uni.navigateTo({
url: '/otherPages/authentication/examination/train'
})
}
//
const handleAdd = (type) => {
if (!getLoginStatus()) return


+ 1
- 1
utils/getUrl.js View File

@ -1,4 +1,4 @@
let current = "develop";
let current = "release";
const accountInfo = wx.getAccountInfoSync();
// current = accountInfo.miniProgram.envVersion;


Loading…
Cancel
Save