猫妈狗爸伴宠师小程序前端代码
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

130 lines
2.5 KiB

2 months ago
  1. <template>
  2. <!-- <view>培训考核</view> -->
  3. <view class="page">
  4. <view class="header">
  5. <view class="flex-rowl color-fff size-28 title">
  6. {{ `答题进度 ${answered}/${total}` }}
  7. </view>
  8. <up-line-progress class="progress" :percentage="progress" activeColor="#FFBF60" inactiveColor="#D9D9D9" height="16rpx" :showText="false"></up-line-progress>
  9. </view>
  10. <view class="box">
  11. <view class="content bg-fff">
  12. <view>
  13. <view class="label size-22">
  14. 主观题
  15. </view>
  16. </view>
  17. <view >
  18. <questionCard
  19. v-for="(item, qIdx) in list"
  20. :key="`question-${qIdx}`"
  21. :index="qIdx"
  22. :data="item"
  23. v-model="item.value"
  24. :type="TYPE"
  25. ></questionCard>
  26. </view>
  27. </view>
  28. </view>
  29. <view class="footer-btn buttom ">
  30. <button plain class="btn" @click="toNext" :disabled="answered < total">
  31. 提交
  32. </button>
  33. </view>
  34. </view>
  35. </template>
  36. <script setup>
  37. import { ref, computed } from 'vue'
  38. import { onShow } from '@dcloudio/uni-app'
  39. import { getQuestionList } from '@/api/examination'
  40. import questionCard from '../components/questionCard.vue';
  41. const TYPE = '培训'
  42. const list = ref([])
  43. const total = ref(0)
  44. const initQuestion = async () => {
  45. try {
  46. let questions = (await getQuestionList({ type: TYPE })).map(item => ({ id: item.id, title: item.title, value: null }))
  47. list.value = questions
  48. total.value = questions.length
  49. } catch (err) {
  50. }
  51. }
  52. const answered = computed(() => {
  53. return list.value.filter(item => {
  54. if(item.value == null){
  55. return false
  56. }
  57. if(typeof item.value == 'string'){
  58. return item.value.length >= 700
  59. }
  60. return true
  61. }).length
  62. // return list.value.filter(item => item.value?.length).length
  63. })
  64. const progress = computed(() => {
  65. return Math.floor(answered.value / total.value * 100)
  66. })
  67. const toNext = () => {
  68. uni.navigateTo({
  69. url: "/otherPages/authentication/examination/trainCompleted/index"
  70. })
  71. }
  72. onShow(() => {
  73. initQuestion()
  74. })
  75. </script>
  76. <style lang="scss" scoped>
  77. .page {
  78. padding-bottom: 144rpx;
  79. }
  80. .header {
  81. padding: 0 36rpx;
  82. position: sticky;
  83. top: 0;
  84. background-image: linear-gradient(180deg, #FFBF60 0, #ffbf60 2%, #ffbf60 8%, #f2f2f2 90%);
  85. z-index: 99;
  86. .progress {
  87. margin-top: 19rpx;
  88. }
  89. }
  90. .box {
  91. margin-top: 31rpx;
  92. padding: 16rpx;
  93. .content {
  94. border-radius: 20rpx;
  95. padding: 15rpx 20rpx;
  96. .label {
  97. display: inline-block;
  98. padding: 5rpx 15rpx;
  99. color: #fff;
  100. background-color: #FFBF60;
  101. }
  102. }
  103. }
  104. </style>