Browse Source

添加检验记录自动保存和编辑逻辑,修改sql查询

zhangxike 1 week ago
parent
commit
e411a102e4
2 changed files with 115 additions and 88 deletions
  1. 109 86
      pages/work/download/DownloadDetail.uvue
  2. 6 2
      utils/sqlite.uts

+ 109 - 86
pages/work/download/DownloadDetail.uvue

@@ -21,17 +21,43 @@
 				</uni-tr>
 				<uni-tr class="section-title" @click="enterItem(item.pdid, 0)">
 					<uni-td class="grid-text">拍照点</uni-td>
-					<uni-td class="grid-text">{{item.photoCount}} / {{item.photoTotal}}</uni-td>
+					<uni-td class="grid-text">
+						<text :class="{
+							'bg-green bg-text': item.photoStatus == '已完成',
+							'bg-yellow bg-text': item.photoCount > 0 && item.photoCount < item.photoTotal,
+							'bg-black bg-text': item.photoCount == 0,
+						  }">
+							{{item.photoCount}} / {{item.photoTotal}}
+						</text>
+					</uni-td>
 					<uni-td class="grid-text">{{item.photoStatus}}</uni-td>
 				</uni-tr>
 				<uni-tr class="section-title" @click="enterItem(item.pdid, 1)">
 					<uni-td class="grid-text">检验记录</uni-td>
-					<uni-td class="grid-text">{{item.recordCount}} / {{item.recordTotal}}</uni-td>
-					<uni-td class="grid-text">{{item.recordStatus}}</uni-td>
+					<uni-td class="grid-text">
+						<text :class="{
+							'bg-green bg-text': item.recordStatus == '已完成',
+							'bg-yellow bg-text': item.recordCount > 0 && item.recordCount < item.recordTotal,
+							'bg-black bg-text': item.recordCount == 0,
+						  }">
+							{{item.recordCount}} / {{item.recordTotal}}
+						</text>
+					</uni-td>
+					<uni-td class="grid-text"><text :class="{
+						'ft-red':item.recordStatus == '不合格'
+					}">{{item.recordStatus}}</text></uni-td>
 				</uni-tr>
 				<uni-tr class="section-title" @click="enterItem(item.pdid, 2)">
 					<uni-td class="grid-text">关键工序记录</uni-td>
-					<uni-td class="grid-text">{{item.keyCount}} / {{item.keyTotal}}</uni-td>
+					<uni-td class="grid-text">
+						<text :class="{
+							'bg-green bg-text': item.keyStatus == '已完成',
+							'bg-yellow bg-text': item.keyCount > 0 && item.keyCount < item.keyTotal,
+							'bg-black bg-text': item.keyCount == 0,
+						  }">
+							{{item.keyCount}} / {{item.keyTotal}}
+						</text>
+					</uni-td>
 					<uni-td class="grid-text">{{item.keyStatus}}</uni-td>
 				</uni-tr>
 			</uni-table>
@@ -48,12 +74,12 @@
 		onMounted
 	} from 'vue'
 	import { getList, TaskDownload, statusDict, TaskInfo, getTaskDetail, TaskDetail } from '@/api/work';
-	
+
 	//自定义返回行为,覆盖系统默认返回按钮
 	const backPressOptions = reactive({
 		from: 'backbutton'
 	} as OnBackPressOptions)
-	
+
 	onBackPress((options : OnBackPressOptions) : boolean | null => {
 		console.log('onBackPress', options)
 		uni.navigateTo({
@@ -72,85 +98,86 @@
 	var taskProcessList = ref<TaskDetail[]>([]);
 	var initTasks = [] as TaskDetail[]
 	//const statusMap = ref(new Map<number, string>([[1,'未执行'],[2,'执行中'],[3,'执行完'],[4,'检验失败']]))
-	
+
 	const download = ref<TaskDownload>({
-		pdid : 0,
-		gxpk : '',
-		cardno : '',
-		productcode : '',
-		model : '',
-		workorder : '',
-		invname : '',
-		graphid : '',
-		processno : '',
-		gxno : '',
-		ver : '',
-		lastupdatetime : '',
+		pdid: 0,
+		gxpk: '',
+		cardno: '',
+		productcode: '',
+		model: '',
+		workorder: '',
+		invname: '',
+		graphid: '',
+		processno: '',
+		gxno: '',
+		ver: '',
+		lastupdatetime: '',
 		updateuser: '',
-		uploadflag : 0,
-		progress : ''
+		uploadflag: 0,
+		progress: ''
 	})
 
 	onLoad((options) => {
 		const downloadId = options?.id ?? ""
 		// 模拟数据加载,建议替换为后端接口请求
-        // #ifdef APP-ANDROID
-		    //获取下载产品数据
-         	getList('app_task_info', 'pdid', downloadId, null, null, null).then((res:UTSJSONObject) => {
-         	 		console.log(res)
-         				let dataList = res?.['data'] as UTSJSONObject[] ?? Array<UTSJSONObject>()
-         				if(dataList!=null && dataList.length>0){							
-         					let obj = dataList[0]
-							if (obj != null) {
-								let data = JSON.parse<TaskDownload>(obj.toJSONString());
-								if (data != null) {
-									download.value = data
-								}
-							}
-         				} 
-         	 })
-			 
-			 //获取下载产品任务数据
-			 getTaskDetail('pdid', downloadId).then((res:UTSJSONObject) => {
-			  		console.log(res)
-			 			let dataList = res?.['data'] as UTSJSONObject[] ?? Array<UTSJSONObject>()
-			 			if(dataList!=null && dataList.length>0){							
-			 				dataList.forEach(item =>{
-			 					if(item!=null){
-			 						let task = JSON.parse<TaskDetail>(item.toJSONString());
-			 						if(task!=null){
-			 							initTasks.push(task)
-			 						}
-			 					}
-			 				});
-			 			} 
-				   taskProcessList.value = initTasks
-			  })
-			 
-        // #endif
+		// #ifdef APP-ANDROID
+		//获取下载产品数据
+		getList('app_task_info', 'pdid', downloadId, null, null, null).then((res : UTSJSONObject) => {
+			console.log(res)
+			let dataList = res?.['data'] as UTSJSONObject[] ?? Array<UTSJSONObject>()
+			if (dataList != null && dataList.length > 0) {
+				let obj = dataList[0]
+				if (obj != null) {
+					let data = JSON.parse<TaskDownload>(obj.toJSONString());
+					if (data != null) {
+						download.value = data
+					}
+				}
+			}
+		})
+
+		//获取下载产品任务数据
+		getTaskDetail('pdid', downloadId).then((res : UTSJSONObject) => {
+			console.log(res)
+			let dataList = res?.['data'] as UTSJSONObject[] ?? Array<UTSJSONObject>()
+			if (dataList != null && dataList.length > 0) {
+				dataList.forEach(item => {
+					if (item != null) {
+						let task = JSON.parse<TaskDetail>(item.toJSONString());
+						if (task != null) {
+							initTasks.push(task)
+						}
+					}
+				});
+			}
+			taskProcessList.value = initTasks
+		})
+
+		// #endif
 	})
 
-	const goBack = () => {5
+	const goBack = () => {
+
+		5
 		uni.navigateBack()
 	}
 
 	const enterItem = (id : string, type : number) => {
 		let url = ''
-	  if (type == 0) {
-		  url = `/pages/work/download/PhotoRecord?pdid=${id}`
-	  }	else if (type == 1) {
-		  url = `/pages/work/report/InspectionList?pdid=${id}`
-	  } else if (type == 2) {
-		  url = `/pages/work/process/ProcessList`
-	  }
-	  uni.navigateTo({
-	    url
-	  });
+		if (type == 0) {
+			url = `/pages/work/download/PhotoRecord?pdid=${id}`
+		} else if (type == 1) {
+			url = `/pages/work/report/InspectionList?pdid=${id}`
+		} else if (type == 2) {
+			url = `/pages/work/process/ProcessList`
+		}
+		uni.navigateTo({
+			url
+		});
 	}
 </script>
 
 <style scoped>
-	
 	.container {
 		padding: 40rpx;
 		background-color: #f5f7fa;
@@ -208,58 +235,54 @@
 	/* 表格容器样式 */
 	uni-table {
 		width: 100%;
-		background-color: #fff; /* 设置表格背景色 */
+		background-color: #fff;
+		/* 设置表格背景色 */
 		border-radius: 8rpx;
 		overflow: hidden;
 		/* 去除列表样式,解决第一列前的小短横 */
 		list-style-type: none;
 	}
-	
+
 	/* 表格行样式 */
 	uni-tr {
 		width: 100%;
 		/* #ifdef APP-ANDROID */
-		border-bottom: 1rpx solid #f0f0f0; /* Android设备添加底边框 */
+		border-bottom: 1rpx solid #f0f0f0;
+		/* Android设备添加底边框 */
 		/* #endif */
 	}
-	
+
 	/* 表格单元格样式 */
 	uni-td {
 		/* #ifdef APP-ANDROID */
-		border-right: 1rpx solid #f0f0f0; /* Android设备添加右边框 */
+		border-right: 1rpx solid #f0f0f0;
+		/* Android设备添加右边框 */
 		/* #endif */
 	}
-	
+
 	/* 最后一列去除右边框 */
 	uni-tr uni-td:last-child {
 		/* #ifdef APP-ANDROID */
 		border-right: none;
 		/* #endif */
 	}
-	
+
 	/* 最后一行去除底边框 */
 	uni-table uni-tr:last-child {
 		/* #ifdef APP-ANDROID */
 		border-bottom: none;
 		/* #endif */
 	}
-	
+
 	.grid-text {
 		/* #ifdef APP-NVUE */
 		font-size: 24rpx;
 		color: #000;
 		/* #endif */
-		/* #ifdef APP-ANDROID */
-		font-size: 28rpx; /* Android设备上字体稍大一些 */
-		/* #endif */
-		padding: 20rpx 16rpx; /* 增加内边距 */
+		padding: 10rpx 0 10rpx 0rpx;
 		box-sizing: border-box;
-		margin: 0;
+		margin: 10rpx 10rpx;
 		min-width: 180rpx;
-		background-color: #fff; /* 确保单元格背景色 */
-		/* 去除列表样式标记 */
-		list-style-type: none;
-		list-style-position: inside;
 	}
 
 	.footer-btn {
@@ -301,8 +324,8 @@
 	}
 
 	.bg-text {
-		width: 100rpx;
-		min-width: 80rpx;
+		width: 120rpx;
+		min-width: 100rpx;
 		border-radius: 10rpx;
 		text-align: center;
 	}

+ 6 - 2
utils/sqlite.uts

@@ -711,7 +711,10 @@ export function selectLatestInfoData (
 					CASE WHEN k.keyCount = k.keyTotal THEN '已完成' ELSE '' END as keyStatus,
 					i.recordTotal,
 					i.recordCount,
-					CASE WHEN i.recordCount = i.recordTotal THEN '已完成' ELSE '' END as recordStatus 
+					CASE 
+					WHEN i.errorCount > 0 then '不合格'
+					WHEN i.recordCount = i.recordTotal THEN '已完成' ELSE '' END as recordStatus
+					 
 				FROM
 				  app_task_info m
 				  LEFT JOIN (
@@ -734,7 +737,8 @@ export function selectLatestInfoData (
 					SELECT 
 					  r.pdid,
 					  COUNT(i.sxid) as recordTotal,
-					  SUM(CASE WHEN i.measuredvalue IS NOT NULL and i.measuredvalue != '' THEN 1 ELSE 0 END) as recordCount
+					  SUM(CASE WHEN i.result = '合格' or i.result = '不合格' THEN 1 ELSE 0 END) as recordCount,
+					  SUM(case when i.result = '不合格' then 1 else 0 end) as errorCount
 					FROM app_task_record r
 					LEFT JOIN app_task_record_item i ON r.sxid = i.psxid
 					GROUP BY r.pdid