Переглянути джерело

优化录入流程:添加学校班级信息展示,修复操作人信息传递,完善录入状态判断逻辑

yanhz 3 тижнів тому
батько
коміт
4d6caddfd1

+ 5 - 5
package-lock.json

@@ -984,6 +984,11 @@
 				"lru-cache": "^10.0.1"
 			}
 		},
+		"html5-qrcode": {
+			"version": "2.3.8",
+			"resolved": "https://registry.npmmirror.com/html5-qrcode/-/html5-qrcode-2.3.8.tgz",
+			"integrity": "sha512-jsr4vafJhwoLVEDW3n1KvPnCCXWaQfRng0/EEYk1vNcQGcG/htAdhJX0be8YyqMoSz7+hZvOZSTAepsabiuhiQ=="
+		},
 		"htmlparser2": {
 			"version": "9.1.0",
 			"resolved": "https://registry.npmmirror.com/htmlparser2/-/htmlparser2-9.1.0.tgz",
@@ -1157,11 +1162,6 @@
 			"integrity": "sha512-POQXvpdL69+CluYsillJ7SUhKvytYjW9vG/GKpnf+xP8UWgYEM/RaMzHHofbALDiKbbP1W8UEYmgGl39WkPZsg==",
 			"dev": true
 		},
-		"jsqr": {
-			"version": "1.4.0",
-			"resolved": "https://registry.npmmirror.com/jsqr/-/jsqr-1.4.0.tgz",
-			"integrity": "sha512-dxLob7q65Xg2DvstYkRpkYtmKm2sPJ9oFhrhmudT1dZvNFFTlroai3AWSpLey/w5vMcLBXRgOJsbXpdN9HzU/A=="
-		},
 		"lilconfig": {
 			"version": "3.1.3",
 			"resolved": "https://registry.npmmirror.com/lilconfig/-/lilconfig-3.1.3.tgz",

+ 7 - 3
pages/index/input-method-select.vue

@@ -90,10 +90,14 @@ const handleManualInput = () => {
 const handleScanInput = async () => {
 	scan.value.start({
 		success: (val, res) => {
-			//val是扫描到的二维码内容
-			console.log('扫描成功', val, res)
+			const savedData = uni.getStorageSync(STORAGE_KEY)
+			let userPhone = ''
+			if (savedData) {
+				const info = JSON.parse(savedData)
+				userPhone = info.phone || ''
+			}
 			uni.navigateTo({
-				url: `/pages/index/select-input-type?studentId=${val}`
+				url: `/pages/index/select-input-type?studentId=${val}&userPhone=${encodeURIComponent(userPhone)}`
 			})
 		},
 		fail: (rej) => {

+ 72 - 20
pages/index/select-input-type.vue

@@ -4,6 +4,14 @@
 		<van-nav-bar title="选择录入类型" left-arrow @click-left="onBack" fixed :z-index="999" />
 		<view class="content">
 			<view class="student-info">
+				<view class="info-row">
+					<text class="label">学校</text>
+					<text class="value">{{ schoolName }}</text>
+				</view>
+				<view class="info-row">
+					<text class="label">班级</text>
+					<text class="value">{{ gradeName }} {{ className }}</text>
+				</view>
 				<view class="info-row">
 					<text class="label">姓名</text>
 					<text class="value">{{ studentName }}</text>
@@ -13,6 +21,7 @@
 					<text class="value">{{ studentIdCard }}</text>
 				</view>
 			</view>
+
 			<view class="type-list">
 				<view class="type-card" @click="selectType('vision')" v-if="visionStatus === 0">
 					<view class="type-name">视力数据录入</view>
@@ -22,31 +31,55 @@
 					<view class="type-name">屈光度数据录入</view>
 					<van-icon name="arrow" />
 				</view>
+				<view class="all-done" v-if="visionStatus === 1 && refractionStatus === 1">
+					<van-icon name="checked" color="#07c160" size="48rpx" />
+					<text class="all-done-text">该学生数据已全部录入</text>
+				</view>
 			</view>
 		</view>
 	</view>
 </template>
 
 <script setup>
-import { getStudentInfo } from '@/services/common'
-
+import { getStudentInfo, getStudentVisionData } from '@/services/common'
 
 const studentName = ref('')
 const studentIdCard = ref('')
+const schoolName = ref('')
+const gradeName = ref('')
+const className = ref('')
 const visionStatus = ref(0)
 const refractionStatus = ref(0)
+const studentId = ref('')
 const params = ref({})
 
+const fetchVisionStatus = async () => {
+	if (!studentId.value) return
+	try {
+		const res = await getStudentVisionData(studentId.value)
+		if (res && res.code === 200 && res.data) {
+			visionStatus.value = res.data.vision_input_status || 0
+			refractionStatus.value = res.data.refraction_input_status || 0
+			if (res.data.id) {
+				params.value.visionDataId = res.data.id
+			}
+		}
+	} catch (e) {
+		visionStatus.value = 0
+		refractionStatus.value = 0
+	}
+}
+
 onLoad((options) => {
-	if (options.studentId) {
-		getStudentInfo(
-			options.studentId
-		).then((res) => {
+	if (options.studentId && !options.studentName) {
+		studentId.value = options.studentId
+		getStudentInfo(options.studentId).then((res) => {
 			studentName.value = res.data.name
 			studentIdCard.value = res.data.id_card
-			visionStatus.value = 0
-			refractionStatus.value = 0
-			params.value = res.data
+			schoolName.value = res.data.school_name || ''
+			gradeName.value = res.data.grade || ''
+			className.value = res.data.class_name || ''
+			studentId.value = res.data.id
 
 			params.value = {
 				studentId: res.data.id,
@@ -59,17 +92,20 @@ onLoad((options) => {
 				visionDataId: res.data.vision_data_id || '',
 				schoolName: res.data.school_name || '',
 				userName: res.data.name || '',
-				userPhone:'17766664444',
-				// userOrg: options.userOrg
+				userPhone: options.userPhone || '',
 			}
+
+			fetchVisionStatus()
 		})
 	}
 
 	if (options.studentName) {
+		studentId.value = options.studentId
 		studentName.value = decodeURIComponent(options.studentName || '')
 		studentIdCard.value = decodeURIComponent(options.studentIdCard || '')
-		visionStatus.value = Number(options.visionStatus || 0)
-		refractionStatus.value = Number(options.refractionStatus || 0)
+		schoolName.value = decodeURIComponent(options.schoolName || '')
+		gradeName.value = decodeURIComponent(options.grade || '')
+		className.value = decodeURIComponent(options.className || '')
 
 		params.value = {
 			studentId: options.studentId,
@@ -85,11 +121,13 @@ onLoad((options) => {
 			userPhone: options.userPhone,
 			userOrg: options.userOrg
 		}
-	}
-
-
 
+		fetchVisionStatus()
+	}
+})
 
+onShow(() => {
+	fetchVisionStatus()
 })
 
 const selectType = (type) => {
@@ -100,11 +138,9 @@ const selectType = (type) => {
 const onBack = () => {
 	uni.navigateBack({
 		delta: 1,
-		success: () => { },
+		success: () => {},
 		fail: () => {
-			uni.switchTab({
-				url: '/pages/index/index'
-			})
+			uni.switchTab({ url: '/pages/index/index' })
 		}
 	})
 }
@@ -190,4 +226,20 @@ const onBack = () => {
 	position: absolute;
 	right: 30rpx;
 }
+
+.all-done {
+	background: #fff;
+	border-radius: 20rpx;
+	padding: 50rpx 30rpx;
+	display: flex;
+	align-items: center;
+	justify-content: center;
+	gap: 16rpx;
+}
+
+.all-done-text {
+	font-size: 30rpx;
+	color: #07c160;
+	font-weight: bold;
+}
 </style>

+ 12 - 7
pages/index/vision-input.vue

@@ -109,10 +109,15 @@ onLoad((options) => {
 	visionDataId.value = options.visionDataId || ''
 	schoolName.value = decodeURIComponent(options.schoolName || '')
 	
+	const savedData = uni.getStorageSync(STORAGE_KEY)
+	let savedInfo = {}
+	if (savedData) {
+		savedInfo = JSON.parse(savedData)
+	}
 	userInfo.value = {
-		name: decodeURIComponent(options.userName || ''),
-		phone: decodeURIComponent(options.userPhone || ''),
-		organization: decodeURIComponent(options.userOrg || '')
+		name: savedInfo.name || '',
+		phone: savedInfo.phone || decodeURIComponent(options.userPhone || ''),
+		organization: savedInfo.organization || ''
 	}
 })
 
@@ -244,9 +249,9 @@ const handleSave = async () => {
 					icon: 'success',
 					duration: 1000
 				})
-				// setTimeout(() => {
-				// 	uni.navigateBack({ delta: 2 })
-				// }, 1000)
+				setTimeout(() => {
+					uni.navigateBack({ delta: 1 })
+				}, 1000)
 			}
 		} catch (error) {
 			console.error('保存视力数据失败', error)
@@ -280,7 +285,7 @@ const handleSave = async () => {
 					duration: 1000
 				})
 				setTimeout(() => {
-					uni.navigateBack({ delta: 2 })
+					uni.navigateBack({ delta: 1 })
 				}, 1000)
 			}
 		} catch (error) {

+ 2 - 2
utils/config.js

@@ -1,5 +1,5 @@
-const baseUrl = process.env.NODE_ENV === 'development' ? 'http://10.0.0.198:8080/' : 'http://10.0.0.85:8080/'
-// const baseUrl = process.env.NODE_ENV === 'development' ? 'http://fs.towantto.com:20201/' : 'http://fs.towantto.com:20201/'
+// const baseUrl = process.env.NODE_ENV === 'development' ? 'http://10.0.0.85:8080/' : 'http://10.0.0.85:8080/'
+const baseUrl = process.env.NODE_ENV === 'development' ? 'http://fs.towantto.com:20201/' : 'http://fs.towantto.com:20201/'
 
 const ossPathPerfixs = 'https://fskj-res.oss-cn-zhangjiakou.aliyuncs.com/zxx/images'