index.vue 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107
  1. <template>
  2. <Container :title="title">
  3. <view class="p-20">
  4. <uni-segmented-control
  5. :flex="false"
  6. :current="current"
  7. :values="list.map((i) => i.name)"
  8. style-type="text"
  9. @clickItem="(e) => (current = e.currentIndex)"
  10. />
  11. <!-- 执业药师 -->
  12. <template v-for="(item, index) in list" :key="item.id">
  13. <view v-if="current === index" class="grid">
  14. <view v-for="i in item?.children" class="flex" @click="clickClass(i)">
  15. <view
  16. class="bg-red"
  17. :style="{
  18. background: '#d9d9d9',
  19. }"
  20. >{{ i.name }}</view
  21. >
  22. </view>
  23. </view>
  24. </template>
  25. </view>
  26. </Container>
  27. </template>
  28. <script setup name="real">
  29. import { ref, onMounted } from "vue";
  30. import Container from "../../components/Container/Container.vue";
  31. import { getRoute, router } from "../../utils/router";
  32. import { arrayToTree } from "../../utils";
  33. import { request } from "../../utils/request";
  34. const title = ref("");
  35. const list = ref([]);
  36. const current = ref(0);
  37. const clickClass = (item) => {
  38. router.push({
  39. url: "/pages/real/history",
  40. params: {
  41. id: item.id,
  42. title: item.name,
  43. },
  44. });
  45. }
  46. onMounted(async () => {
  47. const params = getRoute().params;
  48. title.value = params.title;
  49. const res = await request(
  50. "api/question_bank/question_reception/chapter/get",
  51. {},
  52. "POST"
  53. );
  54. list.value = arrayToTree({
  55. list: res.data,
  56. });
  57. });
  58. </script>
  59. <style scoped lang="scss">
  60. .title {
  61. font-family: "PingFang SC, PingFang SC";
  62. font-weight: 700;
  63. font-size: 32rpx;
  64. color: #000000;
  65. }
  66. .p-20 {
  67. padding: 0 30rpx 30rpx;
  68. display: flex;
  69. flex-direction: column;
  70. gap: 20rpx;
  71. }
  72. .grid {
  73. display: grid;
  74. grid-template-columns: repeat(3, 1fr);
  75. gap: 20rpx;
  76. }
  77. .grid-3 {
  78. display: grid;
  79. grid-template-columns: repeat(3, 1fr);
  80. gap: 20rpx;
  81. height: 100%;
  82. }
  83. .flex {
  84. display: flex;
  85. flex-direction: column;
  86. gap: 20rpx;
  87. align-items: center;
  88. justify-content: center;
  89. }
  90. .bg-red {
  91. width: 146rpx;
  92. height: 198rpx;
  93. display: flex;
  94. align-items: center;
  95. justify-content: center;
  96. }
  97. </style>