Explorar o código

更新SQLite查询功能

oyq28 hai 3 días
pai
achega
a577fa7e96

+ 42 - 2
api/work.uts

@@ -2,6 +2,44 @@
 import {selectTableData, insertTableData} from '@/utils/sqlite'
 // #endif
 
+export type Download = {
+		pdid : number,
+		workorder : string,
+		invname : string,
+		productno : string,
+		graphid : string,
+		cardno : string,
+		processno : string,
+		ver : string,
+		updatetime : string,
+		progress : string,
+		status : number
+	}
+
+export type Record = {
+		sxid : number,
+		senum : number,
+		photoitem : string,
+		productno : string,
+		part : string,
+		descb : string,
+		date : string,
+		partno : string,
+		num : number,
+		status : string,
+		urlspl : string
+		imgname : string[],
+		urlpdt : string[]
+	}
+
+ export type TaskProcess = {
+		id : number
+		name : string
+		num : number
+		step : number
+		status : number
+	}
+
 export function offlineData(data:UTSJSONObject):Promise<UTSJSONObject> {
 	return new Promise((resolve, reject) => {	
 		let result = JSON.parseObject(JSON.stringify(data)) as UTSJSONObject 
@@ -10,10 +48,12 @@ export function offlineData(data:UTSJSONObject):Promise<UTSJSONObject> {
 }
 
 
-export async function getList(tableName:string, condition?:string|null, initData?:UTSJSONObject|null):Promise<UTSJSONObject> {
+
+
+export async function getList(tableName:string, condition?:string|null, value?:string|null, initData?:UTSJSONObject|null):Promise<UTSJSONObject> {
    
     // #ifdef APP-ANDROID
-    const result = await selectTableData(tableName, null, null, null, null);
+    const result = await selectTableData(tableName, condition, value, null, null);
     console.log(result);
 	return result;
 	// #endif

+ 73 - 26
pages/work/download/DownloadDetail.uvue

@@ -26,18 +26,18 @@
 					<uni-td class="grid-text">{{taskProcess.name}}</uni-td>
 					<uni-td class="grid-text">
 						<text :class="{
-							'bg-green bg-text': taskProcess.state === 'done',
-							'bg-yellow bg-text': taskProcess.state === 'doing',
-							'bg-black bg-text': taskProcess.state === 'waiting',
-							'bg-red bg-text': taskProcess.state === 'error'
+							'bg-green bg-text': taskProcess.status === 3,
+							'bg-yellow bg-text': taskProcess.status === 2,
+							'bg-black bg-text': taskProcess.status === 1,
+							'bg-red bg-text': taskProcess.status === 4
 						  }">
 							{{taskProcess.step}}/{{taskProcess.num}}
 						</text>
 					</uni-td>
 					<uni-td class="grid-text">
 						<text :class="{
-							'ft-red': taskProcess.state === 'error'
-						  }">{{ taskProcess.state === 'error' ? "检验失败" : "" }}</text>
+							'ft-red': taskProcess.status === 4
+						  }">{{ taskProcess.status === 4 ? "检验失败" : "" }}</text>
 					</uni-td>
 				</uni-tr>
 			</uni-table>
@@ -53,12 +53,30 @@
 		ref,
 		onMounted
 	} from 'vue'
+	import { getList, Download, TaskProcess } from '@/api/work';
 
 	const titleList = [{
 		title1: "部位", title2: "进度", title3: "状态"
 	}];
-
-	const download = {
+	var taskProcessList = ref<TaskProcess[]>([]);
+	var initTasks = [] as TaskProcess[]
+	
+	const download = ref<Download>({
+		pdid: 0,
+		workorder: "",
+		invname: "",
+		productno: "",
+		graphid: "",
+		cardno: "",
+		processno: "",
+		ver: "",
+		updatetime: "",
+		progress: "",
+		status: 1
+	})
+     
+    // #ifdef H5
+	download.value = {
 		pdid: 1,
 		workorder: "632-P-01",
 		invname: "箱间段",
@@ -70,29 +88,58 @@
 		updatetime: "2025-06-23",
 		progress: "1/3"
 	}
-
-	type TaskProcess = {
-		id : number
-		name : string
-		num : number
-		step : number
-		state : string
-	}
-
+	
 	const taskProcessList : Array<TaskProcess> = [
-		{ id: 1, name: "前底-外侧", num: 5, step: 5, state: "done" },
-		{ id: 2, name: "后底-外侧", num: 3, step: 3, state: "error" },
-		{ id: 3, name: "简段-外侧", num: 12, step: 2, state: "doing" },
-		{ id: 4, name: "前底-内侧", num: 5, step: 0, state: "waiting" },
-		{ id: 5, name: "后底-内侧", num: 6, step: 0, state: "waiting" },
-		{ id: 6, name: "简段-内侧", num: 3, step: 0, state: "waiting" },
-		{ id: 7, name: "隧道管", num: 5, step: 0, state: "waiting" },
+		{ id: 1, name: "前底-外侧", num: 5, step: 5, status: 3 },
+		{ id: 2, name: "后底-外侧", num: 3, step: 3, status: 4 },
+		{ id: 3, name: "简段-外侧", num: 12, step: 2, status: 2 },
+		{ id: 4, name: "前底-内侧", num: 5, step: 0, status: 1 },
+		{ id: 5, name: "后底-内侧", num: 6, step: 0, status: 1 },
+		{ id: 6, name: "简段-内侧", num: 3, step: 0, status: 1 },
+		{ id: 7, name: "隧道管", num: 5, step: 0, status: 1 },
 	];
+	
+	// #endif
 
 	onLoad((options) => {
-		//const downloadId = options?.id ?? ""
+		const downloadId = options?.id ?? ""
 		// 模拟数据加载,建议替换为后端接口请求
-
+        // #ifdef APP-ANDROID
+		    //获取下载产品数据
+         	getList('app_product', 'pdid', downloadId, null).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 data = JSON.parse<Download>(item.toJSONString());
+         							if(data!=null){
+         								download.value = data
+         							}
+         						}
+         					});
+         				} 
+         	 })
+			 
+			 //获取下载产品任务数据
+			 getList('app_product_task', 'pid', downloadId, null).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<TaskProcess>(item.toJSONString());
+			 						if(task!=null){
+			 							initTasks.push(task)
+			 						}
+			 					}
+			 				});
+			 			} 
+				   console.log(initTasks)
+				   taskProcessList.value = initTasks
+			  })
+			 
+        // #endif
 	})
 
 	const goBack = () => {

+ 3 - 16
pages/work/download/DownloadList.uvue

@@ -61,26 +61,13 @@
 	import {
 		ref
 	} from 'vue'
-	import { getList } from '@/api/work';
-		
-	type Download = {
-		pdid : number,
-		workorder : string,
-		invname : string,
-		productno : string,
-		graphid : string,
-		cardno : string,
-		processno : string,
-		ver : string,
-		updatetime : string,
-		progress : string,
-		status : number
-	}
+	import { getList, Download } from '@/api/work';
+	
 	var initDownloads = [] as Download[]
 	var downloads = ref<Download[]>([]);
 	
 	// #ifdef APP-ANDROID	 
-	 getList('app_product', null, null).then((res:UTSJSONObject) => {
+	 getList('app_product', null, null, null).then((res:UTSJSONObject) => {
 	  		console.log(res)
 			let dataList = res?.['data'] as UTSJSONObject[] ?? Array<UTSJSONObject>()
 			if(dataList!=null && dataList.length>0){

+ 63 - 16
pages/work/record/InfoDetail.uvue

@@ -26,18 +26,18 @@
 					<uni-td class="grid-text">{{taskProcess.name}}</uni-td>
 					<uni-td class="grid-text">
 						<text :class="{
-							'bg-green bg-text': taskProcess.state === 'done',
-							'bg-yellow bg-text': taskProcess.state === 'doing',
-							'bg-black bg-text': taskProcess.state === 'waiting',
-							'bg-red bg-text': taskProcess.state === 'error'
+							'bg-green bg-text': taskProcess.status === 3,
+							'bg-yellow bg-text': taskProcess.status === 2,
+							'bg-black bg-text': taskProcess.status === 1,
+							'bg-red bg-text': taskProcess.status === 4
 						  }">
 							{{taskProcess.step}}/{{taskProcess.num}}
 						</text>
 					</uni-td>
 					<uni-td class="grid-text">
 						<text :class="{
-							'ft-red': taskProcess.state === 'error'
-						  }">{{ taskProcess.state === 'error' ? "检验失败" : "" }}</text>
+							'ft-red': taskProcess.status === 4
+						  }">{{ taskProcess.status === 4 ? "检验失败" : "" }}</text>
 					</uni-td>
 				</uni-tr>
 			</uni-table>
@@ -53,11 +53,30 @@
 		ref,
 		onMounted
 	} from 'vue'
+	import { getList, Download, TaskProcess } from '@/api/work';
 
 	const titleList = [{
 		title1: "部位", title2: "进度", title3: "状态"
 	}];
+	
+	var taskProcessList = ref<TaskProcess[]>([]);
+	var initTasks = [] as TaskProcess[]
+	
+	const download = ref<Download>({
+		pdid: 0,
+		workorder: "",
+		invname: "",
+		productno: "",
+		graphid: "",
+		cardno: "",
+		processno: "",
+		ver: "",
+		updatetime: "",
+		progress: "",
+		status: 1
+	})
 
+// #ifdef H5
 	const download = {
 		pdid: 1,
 		workorder: "632-P-01",
@@ -71,14 +90,6 @@
 		progress: "1/3"
 	}
 
-	type TaskProcess = {
-		id : number
-		name : string
-		num : number
-		step : number
-		state : string
-	}
-
 	const taskProcessList : Array<TaskProcess> = [
 		{ id: 1, name: "前底-外侧", num: 5, step: 5, state: "done" },
 		{ id: 2, name: "后底-外侧", num: 3, step: 3, state: "error" },
@@ -88,11 +99,47 @@
 		{ id: 6, name: "简段-内侧", num: 3, step: 0, state: "waiting" },
 		{ id: 7, name: "隧道管", num: 5, step: 0, state: "waiting" },
 	];
-
+    // #endif
+	
 	onLoad((options) => {
 		const downloadId = options?.id ?? ""
 		// 模拟数据加载,建议替换为后端接口请求
-
+           // #ifdef APP-ANDROID
+               //获取下载产品数据
+            	getList('app_media_info', 'pdid', downloadId, null).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 data = JSON.parse<Download>(item.toJSONString());
+            							if(data!=null){
+            								download.value = data
+            							}
+            						}
+            					});
+            				} 
+            	 })
+           	 
+           	 //获取下载产品任务数据
+           	 getList('app_media_task', 'pid', downloadId, null).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<TaskProcess>(item.toJSONString());
+           	 						if(task!=null){
+           	 							initTasks.push(task)
+           	 						}
+           	 					}
+           	 				});
+           	 			} 
+           		   console.log(initTasks)
+           		   taskProcessList.value = initTasks
+           	  })
+           	 
+           // #endif
 	})
 
 	const goBack = () => {

+ 1 - 1
pages/work/record/InfoList.uvue

@@ -71,7 +71,7 @@
 	var downloads = ref<Download[]>([]);
 	
 	// #ifdef APP-ANDROID
-	 getList('app_media_info', null, null).then((res:UTSJSONObject) => {
+	 getList('app_media_info', null, null, null).then((res:UTSJSONObject) => {
 	  		console.log(res)
 			let dataList = res?.['data'] as UTSJSONObject[] ?? Array<UTSJSONObject>()
 			if(dataList!=null && dataList.length>0){

+ 24 - 28
pages/work/record/RecordList.uvue

@@ -15,10 +15,10 @@
 	<!-- #ifdef APP -->
 	<scroll-view style="flex:1">
 	<!-- #endif -->
-		<view class="record-card" v-for="(item, index) in records" :key="index" v-show="current == item.sxid as number">
+		<view class="record-card" v-for="(item, index) in records" :key="index" v-show="current == item.senum as number">
 			<view class="header-row">
 				<text class="label">序号:</text>
-				<text class="value">{{ item.photoitem }}</text>
+				<text class="value">{{ item.senum }}</text>
 				<text class="status" :class="{'status-cancelled': item.status === '已取消'}">{{ item.status }}</text>
 			</view>
 
@@ -31,6 +31,11 @@
 				<text class="label">拍照点:</text>
 				<text class="value">{{ item.part }}</text>
 			</view>
+			
+			<view class="info-row">
+				<text class="label">拍照位置:</text>
+				<text class="value">{{ item.photoitem }}</text>
+			</view>
 
 			<view class="info-row">
 				<text class="label">描述:</text>
@@ -95,30 +100,19 @@
 	import {
 		ref
 	} from 'vue'
-	import { getList } from '@/api/work';
-	type Record = {
-		sxid : number,
-		senum : string,
-		photoitem : number,
-		productno : string,
-		part : string,
-		descb : string,
-		date : string,
-		partno : string,
-		num : number,
-		status : string,
-		urlspl : string
-		imgname : string[],
-		urlpdt : string[]
-	}
+	import { getList, Record } from '@/api/work';
+	
 	//检查项目最大数量
 	var maxcount = 5
 	var current = ref(1)
 	var records = ref<Record[]>([]);
 	var closeTags = ref([true, true, true, true, true, true, true])	
 	var initRecords = [] as Record[]
+	
+	onLoad((options) => {	
+	   const pid = options?.id ?? ""	
 	// #ifdef APP-ANDROID
-	   getList('app_media_record', null, null).then((res:UTSJSONObject) => {
+	   getList('app_media_record', 'pid', pid, null).then((res:UTSJSONObject) => {
 	    		let dataList = res?.['data'] as UTSJSONObject[] ?? Array<UTSJSONObject>()
 	   			if(dataList!=null && dataList.length>0){
 	   				dataList.forEach(item =>{
@@ -137,16 +131,19 @@
 	   				});
 	   			}
 	   		console.log(initRecords)
-			records.value = initRecords.filter(item => item['photoitem'] == current.value)
+			if(initRecords.length>0){
+				current.value = initRecords[0].senum
+				records.value = [initRecords[0]]
+			} 
 	    });
-	
+	});
 	// #endif
 	
 	// #ifdef H5
 	const initRecords = [{
 		sxid: 1,
-		senum: '1',
-		photoitem: 1,
+		senum: 1,
+		photoitem: '前底-外侧',
 		productno: 'YH0001',
 		part: '角焊缝',
 		descb: '角片角焊缝',
@@ -160,8 +157,8 @@
 	},
 	{
 		sxid: 2,
-		senum: '2',
-		photoitem: 2,
+		senum: 2,
+		photoitem: '后底-外侧',
 		productno: 'YH0002',
 		part: '角焊缝',
 		descb: '角片角焊缝',
@@ -173,13 +170,12 @@
 		imgname: ['1.jpg', '2.jpg', '3.jpg'],
 		urlpdt: ['/static/images/demo.png', '/static/images/demo.png', '/static/images/demo.png']
 	}] as Record[];
-	records.value = initRecords.filter(item => item['photoitem'] == current.value)
+	records.value = initRecords.filter(item => item['senum'] == current.value)
 	// #endif
-
 	
 	const tabsClick = (obj : number) => {
 		current.value = obj
-		records.value = initRecords.filter(item => item['photoitem'] == current.value)
+		records.value = initRecords.filter(item => item['senum'] == current.value)
 	}
 	const closeTag = (index : number) => {
 		closeTags.value[index] = false

BIN=BIN
static/db/QT800.db