select-input-type.vue 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245
  1. <template>
  2. <view class="page">
  3. <view class="bg-gradient"></view>
  4. <van-nav-bar title="选择录入类型" left-arrow @click-left="onBack" fixed :z-index="999" />
  5. <view class="content">
  6. <view class="student-info">
  7. <view class="info-row">
  8. <text class="label">学校</text>
  9. <text class="value">{{ schoolName }}</text>
  10. </view>
  11. <view class="info-row">
  12. <text class="label">班级</text>
  13. <text class="value">{{ gradeName }} {{ className }}</text>
  14. </view>
  15. <view class="info-row">
  16. <text class="label">姓名</text>
  17. <text class="value">{{ studentName }}</text>
  18. </view>
  19. <view class="info-row">
  20. <text class="label">身份证号</text>
  21. <text class="value">{{ studentIdCard }}</text>
  22. </view>
  23. </view>
  24. <view class="type-list">
  25. <view class="type-card" @click="selectType('vision')" v-if="visionStatus === 0">
  26. <view class="type-name">视力数据录入</view>
  27. <van-icon name="arrow" />
  28. </view>
  29. <view class="type-card" @click="selectType('refraction')" v-if="refractionStatus === 0">
  30. <view class="type-name">屈光度数据录入</view>
  31. <van-icon name="arrow" />
  32. </view>
  33. <view class="all-done" v-if="visionStatus === 1 && refractionStatus === 1">
  34. <van-icon name="checked" color="#07c160" size="48rpx" />
  35. <text class="all-done-text">该学生数据已全部录入</text>
  36. </view>
  37. </view>
  38. </view>
  39. </view>
  40. </template>
  41. <script setup>
  42. import { getStudentInfo, getStudentVisionData } from '@/services/common'
  43. const studentName = ref('')
  44. const studentIdCard = ref('')
  45. const schoolName = ref('')
  46. const gradeName = ref('')
  47. const className = ref('')
  48. const visionStatus = ref(0)
  49. const refractionStatus = ref(0)
  50. const studentId = ref('')
  51. const params = ref({})
  52. const fetchVisionStatus = async () => {
  53. if (!studentId.value) return
  54. try {
  55. const res = await getStudentVisionData(studentId.value)
  56. if (res && res.code === 200 && res.data) {
  57. visionStatus.value = res.data.vision_input_status || 0
  58. refractionStatus.value = res.data.refraction_input_status || 0
  59. if (res.data.id) {
  60. params.value.visionDataId = res.data.id
  61. }
  62. }
  63. } catch (e) {
  64. visionStatus.value = 0
  65. refractionStatus.value = 0
  66. }
  67. }
  68. onLoad((options) => {
  69. if (options.studentId && !options.studentName) {
  70. studentId.value = options.studentId
  71. getStudentInfo(options.studentId).then((res) => {
  72. studentName.value = res.data.name
  73. studentIdCard.value = res.data.id_card
  74. schoolName.value = res.data.school_name || ''
  75. gradeName.value = res.data.grade || ''
  76. className.value = res.data.class_name || ''
  77. studentId.value = res.data.id
  78. params.value = {
  79. studentId: res.data.id,
  80. studentName: res.data.name,
  81. studentGender: res.data.gender,
  82. studentIdCard: res.data.id_card,
  83. classId: res.data.class_id,
  84. className: res.data.class_name,
  85. grade: res.data.grade,
  86. visionDataId: res.data.vision_data_id || '',
  87. schoolName: res.data.school_name || '',
  88. userName: res.data.name || '',
  89. userPhone: options.userPhone || '',
  90. }
  91. fetchVisionStatus()
  92. })
  93. }
  94. if (options.studentName) {
  95. studentId.value = options.studentId
  96. studentName.value = decodeURIComponent(options.studentName || '')
  97. studentIdCard.value = decodeURIComponent(options.studentIdCard || '')
  98. schoolName.value = decodeURIComponent(options.schoolName || '')
  99. gradeName.value = decodeURIComponent(options.grade || '')
  100. className.value = decodeURIComponent(options.className || '')
  101. params.value = {
  102. studentId: options.studentId,
  103. studentName: options.studentName,
  104. studentGender: options.studentGender,
  105. studentIdCard: options.studentIdCard,
  106. classId: options.classId,
  107. className: options.className,
  108. grade: options.grade,
  109. visionDataId: options.visionDataId || '',
  110. schoolName: options.schoolName,
  111. userName: options.userName,
  112. userPhone: options.userPhone,
  113. userOrg: options.userOrg
  114. }
  115. fetchVisionStatus()
  116. }
  117. })
  118. onShow(() => {
  119. fetchVisionStatus()
  120. })
  121. const selectType = (type) => {
  122. const url = `/pages/index/vision-input?${Object.keys(params.value).map(k => `${k}=${encodeURIComponent(params.value[k])}`).join('&')}&type=${type}`
  123. uni.navigateTo({ url })
  124. }
  125. const onBack = () => {
  126. uni.navigateBack({
  127. delta: 1,
  128. success: () => {},
  129. fail: () => {
  130. uni.switchTab({ url: '/pages/index/index' })
  131. }
  132. })
  133. }
  134. </script>
  135. <style lang="scss" scoped>
  136. .page {
  137. min-height: 100vh;
  138. position: relative;
  139. }
  140. .bg-gradient {
  141. position: fixed;
  142. top: 0;
  143. left: 0;
  144. right: 0;
  145. bottom: 0;
  146. background: linear-gradient(180deg, #4A9FF5 0%, #FFFFFF 100%);
  147. z-index: 0;
  148. }
  149. .content {
  150. padding: 20rpx;
  151. padding-top: calc(20rpx + 46px);
  152. position: relative;
  153. z-index: 1;
  154. }
  155. .student-info {
  156. background: #fff;
  157. border-radius: 20rpx;
  158. padding: 30rpx;
  159. margin-bottom: 20rpx;
  160. }
  161. .info-row {
  162. display: flex;
  163. align-items: center;
  164. font-size: 28rpx;
  165. margin-bottom: 20rpx;
  166. }
  167. .info-row:last-child {
  168. margin-bottom: 0;
  169. }
  170. .label {
  171. width: 160rpx;
  172. color: #999;
  173. }
  174. .value {
  175. flex: 1;
  176. color: #333;
  177. }
  178. .type-list {
  179. display: flex;
  180. flex-direction: column;
  181. gap: 20rpx;
  182. }
  183. .type-card {
  184. background: #fff;
  185. border-radius: 20rpx;
  186. display: flex;
  187. align-items: center;
  188. justify-content: center;
  189. padding: 50rpx 30rpx;
  190. box-shadow: 0 2rpx 10rpx rgba(0, 0, 0, 0.05);
  191. position: relative;
  192. }
  193. .type-name {
  194. font-size: 32rpx;
  195. font-weight: bold;
  196. color: #333;
  197. flex: 1;
  198. text-align: center;
  199. }
  200. .type-card :deep(.van-icon) {
  201. position: absolute;
  202. right: 30rpx;
  203. }
  204. .all-done {
  205. background: #fff;
  206. border-radius: 20rpx;
  207. padding: 50rpx 30rpx;
  208. display: flex;
  209. align-items: center;
  210. justify-content: center;
  211. gap: 16rpx;
  212. }
  213. .all-done-text {
  214. font-size: 30rpx;
  215. color: #07c160;
  216. font-weight: bold;
  217. }
  218. </style>