Procházet zdrojové kódy

检验记录添加结论切换,保存和更新

ZhangLeo před 1 týdnem
rodič
revize
89a77d8fb0
1 změnil soubory, kde provedl 72 přidání a 7 odebrání
  1. 72 7
      pages/work/report/InspectionList.uvue

+ 72 - 7
pages/work/report/InspectionList.uvue

@@ -45,7 +45,7 @@
 				<view class="info-row">
 					<text class="label">上限要求</text>
 					<view class="value">
-						<uni-number-box v-model="currentMinNum" :step="0.1" :min="0.5" disabled></uni-number-box>
+						<uni-number-box v-model="currentMinNum" :min="0" disabled></uni-number-box>
 					</view>
 				</view>
 				<!-- 下限要求:绑定计算属性 parsedMaxNum(对应 item.maxNum) -->
@@ -60,22 +60,23 @@
 				<view class="info-row">
 					<text class="label">实测值小</text>
 					<view class="value">
-						<uni-number-box v-model="currentMeasuredValue" :min="0"></uni-number-box>
+						<uni-number-box v-model="currentMeasuredValue" :step="0.1" :min="0"></uni-number-box>
 					</view>
 				</view>
 				<!-- 实测值大:绑定计算属性 parsedMeasuredMaxValue(对应 item.measuredvaluemax) -->
 				<view class="info-row">
 					<text class="label">实测值大</text>
 					<view class="value">
-						<uni-number-box v-model="currentMeasuredMaxValue" :min="0"></uni-number-box>
+						<uni-number-box v-model="currentMeasuredMaxValue" :step="0.1" :min="0"></uni-number-box>
 					</view>
 				</view>
 				<view class="info-row">
 					<text class="label">结论</text>
 					<view class="value">
-						<!-- <picker @change="bindPickerChange" :value="index" :range="array" v-if="item.nature == '定性'">
-							<view class="uni-input">{{array[index]}}</view>
-						</picker> -->
+						<radio-group class="radio-group-horizontal" @change="resultChange" v-if="item.nature == '定性'">
+							<radio class="radio-group-horizontal-rg" value="1" :checked="item.result == '1'">合格</radio>
+							<radio class="radio-group-horizontal-rg" value="2" :checked="item.result == '2'">未合格</radio>
+						</radio-group>	
 						<input v-model="item.result" class="surround uni-input" v-if="item.nature != '定性'"></input>
 					</view>
 				</view>
@@ -119,6 +120,9 @@
 	const currentMeasuredValue = ref(0);
 	const currentMeasuredMaxValue = ref(0);
 
+	// 下拉框选项数组 - 定性分析选项
+	const array = ref(['合格', '不合格']);
+	
 	const getParsedValue = computed(() => {
 		return (value : string | number) => {
 			if (typeof value === 'number') {
@@ -131,6 +135,25 @@
 			return 0;
 		}
 	});
+	
+	// 处理定性分析下拉框选择变化
+	const bindPickerChange = (e: UTSJSONObject) => {
+		// 获取当前选中的报告项
+		const currentItem = reportList.value.find(item => parseInt(item.no) === current.value);
+		if (currentItem != null && currentItem.nature === '定性') {
+			// 0表示合格,1表示不合格
+			// 简化事件处理,提高兼容性
+			const detail = e['detail'] as UTSJSONObject | null;
+			const value = detail != null ? (detail['value'] as number) : 0;
+			currentItem.result = value == 0 ? '1' : '0';
+		}
+	};
+
+	// 处理picker组件的点击事件,确保在安卓设备上可以正常触发
+	const handlePickerClick = (e: any) => {
+		// 这里可以添加一些处理逻辑,确保在安卓设备上可以正常打开picker
+		console.log('Picker clicked');
+	};
 
 	const updateCurrentValues = (currentItem : QcRecord) => {
 		currentMinNum.value = getParsedValue.value(currentItem.minNum);
@@ -201,7 +224,27 @@
 		});
 		// #endif
 	}
-
+	
+	
+	const resultChange = (event : UniRadioGroupChangeEvent) => {
+		// 获取当前选中的报告项
+		const currentItem = reportList.value.find(item => parseInt(item.no) === current.value);
+		if (currentItem != null) {
+			// 更新结果值
+			currentItem.result = event.detail.value;
+			//更新数据库
+			let updatedData = "result='" + currentItem.result + "'"
+			updateData('app_task_record_item', updatedData, 'sxid', currentItem.sxid.toString()).then((res : UTSJSONObject) => {
+				let data = res?.['data'] as boolean ?? false
+				if (data != null && data== true) {
+					uni.showToast({
+						title: "保存成功!",
+					});
+				}
+			});
+		}
+	}
+	
 	onLoad((options) => {
 		pdid = options?.pdid ?? "1"
 		senum = options?.senum ?? "1"
@@ -378,6 +421,17 @@
 		border-radius: 10rpx;
 	}
 
+	.selectable {
+		/* 确保在安卓设备上文字可以正常显示为可点击状态 */
+		user-select: text;
+		-webkit-user-select: text;
+		cursor: pointer;
+		/* #ifdef APP-ANDROID */
+		/* 安卓设备特别处理,增强可点击性 */
+		background-color: #f8f8f8;
+		/* #endif */
+	}
+
 	.record-card {
 		background: #ffffff;
 		border-radius: 20rpx;
@@ -388,6 +442,17 @@
 		margin-bottom: 20rpx;
 		margin-top: 20rpx;
 	}
+	
+	/* 横向排列radio的样式 */
+	.radio-group-horizontal {
+		display: flex;
+		flex-direction: row;
+		align-items: center;
+	}
+	
+	.radio-group-horizontal-rg{
+		margin-right: 30rpx;
+	}
 
 	.flex-row {
 		flex-direction: row;