wdkb.vue 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173
  1. <script setup lang='ts'>
  2. import { user } from '~/store/user'
  3. const skzc = ref(1)
  4. const WeekMap = '一二三四五六日'
  5. const tableData2 = ref<any>({})
  6. const loading_table2 = ref(false)
  7. async function queryApi2() {
  8. loading_table2.value = true
  9. tableData2.value = {}
  10. await request({
  11. url: '/xdjx/kbgl_jskbmx/index',
  12. data: { limit: 100, xjj_xm: user.real_name, skzc: skzc.value },
  13. }).then((res) => {
  14. const d = res.data.page_data
  15. // tableData2.value = (Array.from({ length: 8 }).map((_, i) => Array.from({ length: 7 }).map((_, j) => (null))))
  16. d.forEach((el: any) => {
  17. const { skjc, skxq } = el
  18. tableData2.value[skjc] = tableData2.value[skjc] ?? {}
  19. tableData2.value[skjc][skxq] = el
  20. })
  21. // alert(JSON.stringify(tableData2.value));
  22. }).catch((err) => {
  23. console.error(err)
  24. }).finally(() => {
  25. loading_table2.value = false
  26. })
  27. }
  28. queryApi2()
  29. const columns = Array.from({ length: 8 }).map((_, i) => ({ text: `第${i + 1}周`, value: (i + 1) }))
  30. const fieldValue = ref('第1周')
  31. const showPicker = ref(false)
  32. function onConfirm({ selectedOptions }) {
  33. showPicker.value = false
  34. fieldValue.value = selectedOptions[0].text
  35. skzc.value = selectedOptions[0].value
  36. queryApi2()
  37. }
  38. </script>
  39. <template>
  40. <div class="px-2px mb-32px">
  41. <van-field v-model="fieldValue" is-link readonly label="周次" placeholder="选择城市" @click="showPicker = true" />
  42. </div>
  43. <van-popup v-model:show="showPicker" round position="bottom">
  44. <van-picker :columns="columns" @cancel="showPicker = false" @confirm="onConfirm" />
  45. </van-popup>
  46. <div v-if="loading_table2" class="flex_center py-4">
  47. <van-loading />
  48. </div>
  49. <div v-else class="my_table">
  50. <div class="thead divide-x divide-hex-ccc">
  51. <div v-for="i in [1, 2, 3, 4, 5, 6, 7, 8]" :key="i" class="flex_center">
  52. {{ i === 1 ? '' : `周${WeekMap[(i - 2)]}` }}
  53. </div>
  54. </div>
  55. <div v-loading="loading_table2" class="tbody">
  56. <div v-for="(i) in 8" :key="i" class="trow divide-x divide-hex-ccc">
  57. <div v-for="j in 8" :key="j" class="tcell h-full">
  58. <div v-if="j === 1" class="w-full h-full flex_center">
  59. 第{{ i }}节
  60. </div>
  61. <div v-else-if="tableData2?.[i]?.[j - 1]">
  62. <div
  63. class="h-full px-4px py-2px flex flex-col"
  64. :class="tableData2[i][j - 1]?.tkzt_option_k === '3' ? 'text-hex-c0c4cc' : 'text-hex-606266'"
  65. >
  66. <div class="flex w-full mb-3px">
  67. <div class="flex-auto font-bold">
  68. {{ tableData2[i][j - 1]?.subject_name }}
  69. </div>
  70. </div>
  71. <div class="flex-none">
  72. <div>{{ tableData2[i][j - 1]?.grade_name }}</div>
  73. <div>{{ tableData2[i][j - 1]?.class_name }}</div>
  74. </div>
  75. <div v-show="tableData2[i][j - 1]?.tkzt_option_k !== '1'" class="flex-none text-10px">
  76. {{ tableData2[i][j - 1]?.tkzt }}
  77. </div>
  78. </div>
  79. </div>
  80. </div>
  81. </div>
  82. </div>
  83. </div>
  84. </template>
  85. <style lang="scss" scoped>
  86. .flex_center {
  87. display: flex;
  88. justify-content: center;
  89. align-items: center;
  90. }
  91. .my_table {
  92. font-size: 14px;
  93. width: 100%;
  94. height: 100%;
  95. display: flex;
  96. flex-direction: column;
  97. overflow: hidden;
  98. .thead {
  99. padding: 0 4px;
  100. border-top: 1px solid #ccc;
  101. border-bottom: 1px solid #ccc;
  102. flex: none;
  103. width: 100%;
  104. height: 60px;
  105. // background: rgba(102, 255, 255, 0.20);
  106. // color: #66FFFF;
  107. display: flex;
  108. justify-content: space-around;
  109. align-items: center;
  110. font-weight: bold;
  111. &>div {
  112. width: 12.5%;
  113. height: 100%;
  114. }
  115. }
  116. .tbody {
  117. padding: 0 4px;
  118. font-size: 14px;
  119. flex: auto;
  120. // color: #fff;
  121. .trow {
  122. display: flex;
  123. justify-content: space-around;
  124. align-items: center;
  125. height: 68px;
  126. border-bottom: 1px solid #ccc;
  127. .tcell {
  128. width: 12.5%;
  129. height: 100%;
  130. display: flex;
  131. justify-content: center;
  132. align-items: center;
  133. div {
  134. font-size: 12px;
  135. line-height: 12px;
  136. }
  137. }
  138. // &:nth-of-type(2n) {
  139. // background: rgba(102, 255, 255, 0.10);
  140. // }
  141. // &:nth-of-type(2n+1) {
  142. // background: rgba(0, 0, 0, 0.10);
  143. // }
  144. }
  145. }
  146. }
  147. </style>