mx-paper.vue 3.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  1. <template>
  2. <view class="page-content h-screen !bg-white">
  3. <mx-nav-bar :title="paperName" :left-click-block="paperQuitBlock"/>
  4. <slot name="top"/>
  5. <mx-tabs-swiper ref="swiper" v-model="index" :tabs="questions" :tab-options="tabOptions" border
  6. :delay="false" :tabs-height="60" template="question">
  7. <template #tab="scope">
  8. <mx-paper-tab-item v-bind="scope"/>
  9. </template>
  10. <template #question="question">
  11. <mx-question :question="question"/>
  12. </template>
  13. </mx-tabs-swiper>
  14. <slot name="bottom">
  15. <mx-question-score-subjective v-if="showScoreSubjective"/>
  16. <mx-question-statistic/>
  17. <mx-question-navigator/>
  18. <mx-paper-completion v-if="!readonly" :continue-name="continueName"/>
  19. </slot>
  20. <mx-paper-navigator-popup ref="navigator"/>
  21. <uv-safe-bottom/>
  22. </view>
  23. </template>
  24. <script setup>
  25. import {ref, watch, computed} from 'vue'
  26. import {useInjectPaperService} from "@/components/mx-paper/usePaperInjection";
  27. import MxPaperTabItem from "@/components/mx-paper/components/mx-paper-tab-item.vue";
  28. import {useInjectQuestionService} from "@/components/mx-question/useQuestionInjection";
  29. import MxPaperCompletion from "@/components/mx-paper/components/mx-paper-completion.vue";
  30. import MxQuestionScoreSubjective from "@/components/mx-question/components/mx-question-score-subjective.vue";
  31. import MxQuestionNavigator from "@/components/mx-question/components/mx-question-navigator.vue";
  32. import MxQuestionStatistic from "@/components/mx-question/components/mx-question-statistic.vue";
  33. import MxPaperNavigatorPopup from "@/components/mx-paper/components/mx-paper-navigator-popup.vue";
  34. import {useProvidePaperNavigatorRef} from "@/components/mx-paper/components/usePaperNavigatorRefInjection";
  35. import {createPropDefine} from "@/utils";
  36. import {useInjectPaperNavigationService} from "@/components/mx-paper/usePaperNavigationServiceInjection";
  37. const props = defineProps({
  38. // 底部按钮
  39. readonly: createPropDefine(false, Boolean),
  40. continueName: createPropDefine('')
  41. })
  42. const {
  43. paperName,
  44. allowScore,
  45. questions,
  46. index,
  47. current,
  48. isObjective
  49. } = useInjectPaperService()
  50. const {} = useInjectQuestionService()
  51. const swiper = ref(null)
  52. const navigator = ref(null)
  53. const isCurrentSubjective = computed(() => !isObjective(current.value))
  54. const showScoreSubjective = computed(() => allowScore.value && isCurrentSubjective.value)
  55. useProvidePaperNavigatorRef(navigator)
  56. const {uncompletedCheckForQuit} = useInjectPaperNavigationService()
  57. const tabOptions = {
  58. scrollable: true,
  59. keyName: 'seq',
  60. lineHeight: 0.5,
  61. lineWidth: 40,
  62. lineColor: 'white'
  63. }
  64. const paperQuitBlock = async () => {
  65. await uncompletedCheckForQuit(navigator.value)
  66. }
  67. </script>
  68. <style scoped lang="scss">
  69. ::v-deep(.uv-tabs) {
  70. .uv-tabs__wrapper__nav {
  71. /* 不能设置__nav的间隔相关属性,会导致uv-tabs内部无法准确计算位置 */
  72. /* 重写__item的样式是没有关系的 */
  73. &__item {
  74. padding: 8px 4px;
  75. box-sizing: border-box;
  76. &:first-child {
  77. padding-left: 8px;
  78. }
  79. &:nth-last-child(2) {
  80. padding-right: 8px;
  81. }
  82. }
  83. &__line {
  84. box-shadow: 0px -2px 5px rgba(0, 0, 255, 0.6);
  85. }
  86. }
  87. }
  88. </style>