eye-examine-index.vue 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209
  1. <template>
  2. <view class="wrap pr">
  3. <view class="w-full pa tw-top-0 tw-left-0 tw-z-0">
  4. <image class="w-full" :src="config.ossPathPerfixs + '/index-bg.png'" mode="widthFix"></image>
  5. </view>
  6. <view class="w-full pr tw-z-10">
  7. <view class="tw-p-[30rpx]">
  8. <view class="tw-flex tw-items-center tw-justify-start tw-mt-[60rpx]">
  9. <fs-avatar size="100rpx" src="/static/images/tool/logo.png"></fs-avatar>
  10. <text class="tw-text-[#fff] tw-text-[26rpx] tw-ml-[4rpx]"
  11. style="letter-spacing: 1rpx;">太原市中小学学生卫生保健所</text>
  12. </view>
  13. <view class="tw-mt-[20rpx] tw-text-[#fff] tw-text-[32rpx] tw-font-bold">
  14. 学校:{{ schoolInfo.name || userInfo.organization || '暂无学校信息' }}
  15. </view>
  16. </view>
  17. <view class="switch-btn" @click="switchInputMethod">
  18. <van-icon name="exchange" size="20" color="#fff" />
  19. <text class="switch-text">切换录入方式</text>
  20. </view>
  21. <view class="tw-px-[30rpx] tw-mt-[40rpx] tw-pb-[100rpx]">
  22. <view class="tw-bg-white tw-rounded-[20rpx] tw-overflow-hidden" style="height: calc(100vh - 400rpx);">
  23. <view class="tw-flex tw-h-full">
  24. <view class="grade-list">
  25. <view
  26. v-for="grade in grades"
  27. :key="grade"
  28. :class="['grade-item', selectedGrade === grade ? 'active' : '']"
  29. @click="selectGrade(grade)"
  30. >
  31. {{ grade }}
  32. </view>
  33. </view>
  34. <view class="class-list">
  35. <view
  36. v-for="cls in classes"
  37. :key="cls.id"
  38. class="class-item"
  39. @click="selectClass(cls)"
  40. >
  41. {{ cls.class_name }}
  42. </view>
  43. </view>
  44. </view>
  45. </view>
  46. </view>
  47. </view>
  48. </view>
  49. </template>
  50. <script setup>
  51. import config from '@/utils/config'
  52. import { getSchoolInfo, getSchoolGrades, getGradeClasses } from '@/services/common'
  53. const STORAGE_KEY = 'eye_examine_user_info'
  54. const userInfo = ref({})
  55. const schoolInfo = ref({})
  56. const grades = ref([])
  57. const classes = ref([])
  58. const selectedGrade = ref('')
  59. onLoad(async () => {
  60. const savedData = uni.getStorageSync(STORAGE_KEY)
  61. if (savedData) {
  62. userInfo.value = JSON.parse(savedData)
  63. }
  64. const schoolId = userInfo.value.schoolId || ''
  65. if (!schoolId) {
  66. return uni.showToast({
  67. title: '缺少学校ID',
  68. icon: 'none'
  69. })
  70. }
  71. try {
  72. const [schoolRes, gradesRes] = await Promise.all([
  73. getSchoolInfo(schoolId),
  74. getSchoolGrades(schoolId)
  75. ])
  76. if (schoolRes && schoolRes.code === 200) {
  77. schoolInfo.value = schoolRes.data
  78. }
  79. if (gradesRes && gradesRes.code === 200) {
  80. grades.value = gradesRes.data.grades || []
  81. if (grades.value.length > 0) {
  82. selectGrade(grades.value[0])
  83. }
  84. }
  85. } catch (error) {
  86. console.error('获取数据失败', error)
  87. uni.showToast({
  88. title: '获取数据失败',
  89. icon: 'none'
  90. })
  91. }
  92. })
  93. const selectGrade = async (grade) => {
  94. selectedGrade.value = grade
  95. classes.value = []
  96. const schoolId = userInfo.value.schoolId || ''
  97. try {
  98. const res = await getGradeClasses(schoolId, grade)
  99. if (res && res.code === 200) {
  100. classes.value = res.data.list || []
  101. }
  102. } catch (error) {
  103. console.error('获取班级列表失败', error)
  104. uni.showToast({
  105. title: '获取班级列表失败',
  106. icon: 'none'
  107. })
  108. }
  109. }
  110. const selectClass = (cls) => {
  111. const params = {
  112. classId: cls.id,
  113. className: cls.class_name,
  114. grade: selectedGrade.value,
  115. schoolName: schoolInfo.value.name || '',
  116. userName: userInfo.value.name || '',
  117. userPhone: userInfo.value.phone || '',
  118. userOrg: userInfo.value.organization || ''
  119. }
  120. uni.navigateTo({
  121. url: `/pages/index/student-list?${Object.keys(params).map(k => `${k}=${encodeURIComponent(params[k])}`).join('&')}`
  122. })
  123. }
  124. const switchInputMethod = () => {
  125. uni.navigateTo({
  126. url: '/pages/index/input-method-select'
  127. })
  128. }
  129. </script>
  130. <style lang="scss" scoped>
  131. .switch-btn {
  132. position: fixed;
  133. right: 30rpx;
  134. bottom: 10%;
  135. width: 160rpx;
  136. height: 160rpx;
  137. border-radius: 50%;
  138. background: #0063F5;
  139. display: flex;
  140. flex-direction: column;
  141. align-items: center;
  142. justify-content: center;
  143. box-shadow: 0 4rpx 20rpx rgba(0, 99, 245, 0.3);
  144. z-index: 999;
  145. }
  146. .switch-text {
  147. font-size: 22rpx;
  148. font-weight: bold;
  149. color: #fff;
  150. margin-top: 8rpx;
  151. text-align: center;
  152. line-height: 1.2;
  153. }
  154. .grade-list {
  155. width: 200rpx;
  156. background: #f5f5f5;
  157. overflow-y: auto;
  158. height: 100%;
  159. }
  160. .grade-item {
  161. padding: 30rpx 20rpx;
  162. text-align: center;
  163. font-size: 28rpx;
  164. color: #333;
  165. border-left: 4rpx solid transparent;
  166. }
  167. .grade-item.active {
  168. background: #fff;
  169. color: #0063F5;
  170. border-left-color: #0063F5;
  171. }
  172. .class-list {
  173. flex: 1;
  174. padding: 20rpx;
  175. overflow-y: auto;
  176. height: 100%;
  177. }
  178. .class-item {
  179. padding: 30rpx 20rpx;
  180. margin-bottom: 20rpx;
  181. background: #f5f5f5;
  182. border-radius: 10rpx;
  183. text-align: center;
  184. font-size: 28rpx;
  185. color: #333;
  186. }
  187. </style>