Prechádzať zdrojové kódy

检验任务列表添加搜索查询功能

zhangxike 6 dní pred
rodič
commit
c33366bc83

+ 2 - 2
api/work.uts

@@ -489,10 +489,10 @@ export async function saveTaskPhoto(values : string) : Promise<UTSJSONObject> {
 }
 
 
-export async function getTaskInfoList(initData ?: UTSJSONObject | null) : Promise<UTSJSONObject> {
+export async function getTaskInfoList(query : string, initData ?: UTSJSONObject | null) : Promise<UTSJSONObject> {
 
 	// #ifdef APP-ANDROID
-	const result = await selectTaskInfo();
+	const result = await selectTaskInfo(query);
 	console.log(result);
 	return result;
 	// #endif

+ 75 - 5
pages/work/download/DownloadList.uvue

@@ -14,6 +14,9 @@
       <button class="btn btn-first" @click="download">
         下载数据
       </button>
+	  <button class="btn btn-second" @click="search">
+	  	搜索
+	  </button>
     </view>
     <!-- 列表内容 -->
     <!-- #ifdef APP -->
@@ -61,6 +64,10 @@
 			    'bg-black': ( item.photoStatus +  item.keyStatus + item.recordStatus) == 0
 			  }"> {{ (item.photoStatus +  item.keyStatus + item.recordStatus) }} / {{(item.photoTotal + item.keyTotal + item.recordTotal)}} </text>
 			</view>
+			<view class="info-row">
+				<text class="label">上传时间:</text>
+				<text class="value">{{ item.uploadtime }}</text>
+			</view>
 		</view>  
 		
 		<view class="info-row">
@@ -118,6 +125,7 @@
 	keyTotal: number,
 	recordTotal: number,
 	uploadFlag: number,
+	uploadtime : string,
   }
 
   var initDownloads = [] as Task[]
@@ -125,7 +133,7 @@
   const map = ref(new Map<number, string>([[1, '未执行'], [2, '执行中'], [3, '执行完'], [4, '有错误']]))
 
   // #ifdef APP-ANDROID
-  getTaskInfoList(null).then((res : UTSJSONObject) => {
+  getTaskInfoList('', null).then((res : UTSJSONObject) => {
     let dataList = res?.['data'] as UTSJSONObject[] ?? Array<UTSJSONObject>()
     if (dataList != null && dataList.length > 0) {
       dataList.forEach(item => {
@@ -155,7 +163,7 @@
 	createtime : "2025-06-23",
 	totalRecord : 3,
 	statusRecordCount : 3,
-	uploadflag: 1,    
+	uploadFlag: 1,    
     status: 3
 
   }, {
@@ -171,7 +179,7 @@
     updatetime: "2025-08-25",
     totalRecord : 4,
     statusRecordCount : 2,
-    uploadflag: 1,
+    uploadFlag: 1,
     status: 2
   }, {
     pdid: 3,
@@ -186,9 +194,9 @@
     updatetime: "2025-08-25",
     totalRecord : 4,
     statusRecordCount : 0,
-    uploadflag: 1,
+    uploadFlag: 1,
     status: 1
-  }] as Download[];
+  }] as Task[];
 
   // #endif
 
@@ -254,6 +262,68 @@
       }
     });
   }
+  
+  const search = async () => {
+  	
+  	// 检查productNo是否为空
+  	if (productNo.value == null || productNo.value.trim() == '') {
+  		uni.showToast({
+  			title: '请输入产品号',
+  			icon: 'error'
+  		});
+  		return;
+  	}
+  	
+  	// 显示加载提示
+  	uni.showLoading({
+  		title: '搜索中...'
+  	});
+  	
+  	try {
+  		// 使用getRecordInfoList函数并传入productNo.value作为第一个参数
+  		let query = `m.gxpk like '%${productNo.value}%'`
+  		const res = await getTaskInfoList(query, null);
+  		console.log('搜索结果:', res);
+  		
+  		let dataList = res?.['data'] as UTSJSONObject[] ?? Array<UTSJSONObject>();
+  		let searchResults = [] as Task[];
+  		
+  		if (dataList != null && dataList.length > 0) {
+  			dataList.forEach(item => {
+  				if (item != null) {
+  					try {
+  						let download = JSON.parse<Task>(item.toJSONString());
+  						if (download != null) {
+  							searchResults.push(download);
+  						}
+  					} catch (e) {
+  						console.error('解析数据失败:', e);
+  					}
+  				}
+  			});
+  		}
+  		
+  		// 更新downloads数组,显示搜索结果
+  		downloads.value = searchResults;
+  		
+  		// 如果没有搜索到结果,显示提示
+  		if (searchResults.length === 0) {
+  			uni.showToast({
+  				title: '未找到相关数据',
+  				icon: 'none'
+  			});
+  		}
+  	} catch (error) {
+  		console.error('搜索失败:', error);
+  		uni.showToast({
+  			title: '搜索失败,请重试',
+  			icon: 'error'
+  		});
+  	} finally {
+  		// 隐藏加载提示
+  		uni.hideLoading();
+  	}
+  }
 
   defineExpose({
     backPressOptions

+ 10 - 8
pages/work/record/InfoList.uvue

@@ -61,6 +61,10 @@
 						<text class="process-value"> {{ item.uploadCount }} / {{ item.totalRecord }} </text>
 					</view>
 				</view>
+				<view class="info-row">
+					<text class="label">上传时间:</text>
+					<text class="value">{{ item.uploadtime }}</text>
+				</view>
 
 				<view class="info-row">
 					<button class="btn btn-second" @click="upload(item)">
@@ -117,7 +121,8 @@
 		statusRecordCount : number,
 		status4RecordCount : number,
 		uploadCount : number,
-		uploadFlag : number
+		uploadFlag : number,
+		uploadtime : string,
 	}
 
 	var initDownloads = [] as Download[]
@@ -158,7 +163,7 @@
 		totalRecord: 3,
 		statusRecordCount: 3,
 		status4RecordCount: 3,
-		uploadflag: 1,
+		uploadFlag: 1,
 		status: 3
 
 	}, {
@@ -175,7 +180,7 @@
 		totalRecord: 4,
 		statusRecordCount: 2,
 		status4RecordCount: 2,
-		uploadflag: 1,
+		uploadFlag: 1,
 		status: 2
 	}, {
 		pdid: 3,
@@ -191,7 +196,7 @@
 		progress: "0/4",
 		statusRecordCount: 0,
 		status4RecordCount: 0,
-		uploadflag: 1,
+		uploadFlag: 1,
 		status: 1
 	}] as Download[];
 
@@ -253,8 +258,6 @@
 	}
 	
 	const search = async () => {
-		console.log("开始搜索...")
-		console.log(productNo.value)
 		
 		// 检查productNo是否为空
 		if (productNo.value == null || productNo.value.trim() == '') {
@@ -272,9 +275,8 @@
 		
 		try {
 			// 使用getRecordInfoList函数并传入productNo.value作为第一个参数
-			let query = `m.productno = '${productNo.value}'`
+			let query = `m.productno like '%${productNo.value}%'`
 			const res = await getRecordInfoList(query, null);
-			console.log('搜索结果:', res);
 			
 			let dataList = res?.['data'] as UTSJSONObject[] ?? Array<UTSJSONObject>();
 			let searchResults = [] as Download[];

BIN
static/db/QT800.db


+ 6 - 2
utils/sqlite.uts

@@ -594,8 +594,11 @@ export function selectLatestInfoData (
  }
  
  
- export function selectTaskInfo() : Promise<UTSJSONObject> {
- 
+ export function selectTaskInfo(query : string) : Promise<UTSJSONObject> {
+	let querySQL = `where 1=1 `
+	if(query != null && query != '') {
+		querySQL += ` and ${query} `
+	}
  	var sql = `SELECT
 					m.*,
 					CASE WHEN COALESCE(p.photoTotal, 0) > 0 THEN 1 ELSE 0 END as photoTotal,
@@ -632,6 +635,7 @@ export function selectLatestInfoData (
 					LEFT JOIN app_task_record_item i ON r.sxid = i.psxid
 					GROUP BY r.pdid
 				  ) i ON m.pdid = i.pdid
+				${querySQL}  
  				ORDER BY
  					m.pdid DESC`;