Browse Source

修复sql

zhangxike 2 months ago
parent
commit
1ecea484ca
4 changed files with 106 additions and 56 deletions
  1. 36 2
      api/work.uts
  2. 1 1
      pages/work/download/DownloadDetail.uvue
  3. 69 53
      pages/work/report/InspectionList.uvue
  4. BIN
      static/db/QT800.db

+ 36 - 2
api/work.uts

@@ -152,6 +152,40 @@ export type TaskJoinRecord = {
 	invname : string,
 }
 
+export type QcRecord = {
+	sxid: number,
+	pdid: number,
+	pk: string,
+	fk_invcode: string,
+	no: string,
+	invcode: string,
+	invname: string,
+	processStep: string,
+	fk_processTask: string,
+	checkTarget: string,
+	checknum: number,
+	oknum: number,
+	ngnum: number,
+	status: string,
+	result: string,
+	checkTime: string,
+	fk_creator: string,
+	cs: string,
+	ts: string,
+	psxid: number,
+	fk_qcRecord: string,
+	fk_prodcode: string,
+	prodno: string,
+	name: string,
+	nature: string,
+	unit: string,
+	maxNum: string,
+	minNum: string,
+	memo: string,
+	measuredvalue: string,
+	measuredvaluemax: string
+}
+
 export function offlineData(data : UTSJSONObject) : Promise<UTSJSONObject> {
 	return new Promise((resolve, reject) => {
 		let result = JSON.parseObject(JSON.stringify(data)) as UTSJSONObject
@@ -517,10 +551,10 @@ export async function saveTaskRecordItem(data ?: UTSJSONObject | null) : Promise
 	const tableName = 'app_task_record_item';
 
 	// 构造插入的数据字符串,注意数据库字段名和类型
-	const values = `'${data?.getNumber('psxid') ?? 0}','${data?.getString('pk') ?? ''}','${data?.getString('fk_qcRecord') ?? ''}','${data?.getString('fk_prodcode') ?? ''}','${data?.getString('prodno') ?? ''}','${data?.getString('name') ?? ''}','${data?.getString('no') ?? ''}','${data?.getString('nature') ?? ''}','${data?.getString('unit') ?? ''}',${data?.getNumber('maxNum') ?? 0}, ${data?.getNumber('maxNum') ?? 0},'${data?.getString('status') ?? ''}','${data?.getString('memo') ?? ''}','${data?.getString('measuredvalue') ?? ''}','${data?.getString('result') ?? ''}','${data?.getString('cs') ?? ''}','${data?.getString('ts') ?? ''}'`;
+	const values = `'${data?.getNumber('psxid') ?? 0}','${data?.getString('pk') ?? ''}','${data?.getString('fk_qcRecord') ?? ''}','${data?.getString('fk_prodcode') ?? ''}','${data?.getString('prodno') ?? ''}','${data?.getString('name') ?? ''}','${data?.getString('no') ?? ''}','${data?.getString('nature') ?? ''}','${data?.getString('unit') ?? ''}',${data?.getNumber('maxNum') ?? 0}, ${data?.getNumber('maxNum') ?? 0},'${data?.getString('status') ?? ''}','${data?.getString('memo') ?? ''}','${data?.getString('measuredvalue') ?? ''}','${data?.getString('measuredvaluemax') ?? ''}','${data?.getString('result') ?? ''}','${data?.getString('cs') ?? ''}','${data?.getString('ts') ?? ''}'`;
 
 	// 构造字段名字符串
-	const fields = 'psxid,pk,fk_qcRecord,fk_prodcode,prodno,prodno,no,nature,unit,maxNum,minNum,status,memo,measuredvalue,result,cs,ts';
+	const fields = 'psxid,pk,fk_qcRecord,fk_prodcode,prodno,prodno,no,nature,unit,maxNum,minNum,status,memo,measuredvalue,measuredvaluemax,result,cs,ts';
 
 	try {
 		// 调用sqlite的插入方法

+ 1 - 1
pages/work/download/DownloadDetail.uvue

@@ -139,7 +139,7 @@
 	  if (type == 0) {
 		  url = `/pages/work/download/PhotoRecord?pdid=${id}`
 	  }	else if (type == 1) {
-		  url = `/pages/work/report/InspectionList`
+		  url = `/pages/work/report/InspectionList?pdid=${id}`
 	  } else if (type == 2) {
 		  url = `/pages/work/process/ProcessList`
 	  }

+ 69 - 53
pages/work/report/InspectionList.uvue

@@ -22,17 +22,17 @@
 
 		<!-- 检查报告卡片列表 -->
 		<view v-if="reportList.length" class="card-list">
-			<view class="card" v-for="item in reportList" :key="item.id" v-show="current == item.id as number">
+			<view class="card" v-for="item in reportList" :key="item.no" v-show="current == item.no as number">
 				<view class="info-row">
 					<text class="label">序号</text>
 					<view class="value">
-						<uni-number-box v-model="item.id" disabled></uni-number-box>
+						<uni-number-box v-model="item.no" disabled></uni-number-box>
 					</view>
 				</view>
 				<view class="info-row">
 					<text class="label">产品码</text>
 					<view class="value">
-						<input v-model="item.productcode" disabled></input>
+						<input v-model="item.prodno" disabled></input>
 					</view>
 				</view>
 				<view class="info-row">
@@ -44,19 +44,19 @@
 				<view class="info-row">
 					<text class="label">性质</text>
 					<view class="value">
-						<input v-model="item.model" disabled></input>
+						<input v-model="item.nature" disabled></input>
 					</view>
 				</view>
 				<view class="info-row">
 					<text class="label">上限要求</text>
 					<view class="value">
-						<uni-number-box v-model="item.upperlimit" :step="0.1" :min="0.5" disabled></uni-number-box>
+						<uni-number-box v-model="item.minNum" :step="0.1" :min="0.5" disabled></uni-number-box>
 					</view>
 				</view>
 				<view class="info-row">
 					<text class="label">下限要求</text>
 					<view class="value">
-						<uni-number-box v-model="item.lowerlimit" :min="0" disabled></uni-number-box>
+						<uni-number-box v-model="item.maxNum" :min="0" disabled></uni-number-box>
 					</view>
 				</view>
 				<!--
@@ -67,19 +67,19 @@
 				<view class="info-row">
 					<text class="label">实测值小</text>
 					<view class="value">
-						<uni-number-box v-model="item.minactval" :min="0"></uni-number-box>
+						<uni-number-box v-model="item.measuredvalue" :min="0"></uni-number-box>
 					</view>
 				</view>
 				<view class="info-row">
 					<text class="label">实测值大</text>
 					<view class="value">
-						<uni-number-box v-model="item.maxactval" :min="0"></uni-number-box>
+						<uni-number-box v-model="item.measuredvaluemax" :min="0"></uni-number-box>
 					</view>
 				</view>
 				<view class="info-row">
 					<text class="label">结论</text>
 					<view class="value">
-						<input v-model="item.conclusion" class="surround uni-input"></input>
+						<input v-model="item.result" class="surround uni-input"></input>
 					</view>
 				</view>
 			</view>
@@ -108,57 +108,73 @@
 	import {
 		ref
 	} from 'vue'
-
-	type Report = {
-		id : number,
-		productcode : string,
-		invname : string,
-		model : string,
-		upperlimit : number,
-		lowerlimit : number,
-		minactval : number,
-		maxactval : number,
-		conclusion : string,
-		applyDate : string,
-		reportDate : string
-	}
+	import { getJoinList, QcRecord, recordStatusDict, updateData } from '@/api/work';
+	
+	// 存储页面参数
+	let pdid = "";
+	let senum = "";
 	//检查项目最大数量
 	var maxcount = 5
 	var current = ref(1)
-	var reportList = ref<Report[]>([])
+	var reportList = ref<QcRecord[]>([])
+	var initRecords = [] as QcRecord[]
 
-	const initReportList = [{
-		id: 1,
-		productcode: "YH0001",
-		invname: '装配间隙',
-		model: '定量',
-		upperlimit: 0.5,
-		lowerlimit: 0,
-		minactval: 0,
-		maxactval: 0,
-		conclusion: '',
-		applyDate: '2025-08-20 09:15',
-		reportDate: '2025-08-20 17:30'
-	},
-	{
-		id: 2,
-		productcode: "YH0001",
-		invname: '装配间隙',
-		model: '定量',
-		upperlimit: 0.5,
-		lowerlimit: 0,
-		minactval: 0,
-		maxactval: 0,
-		conclusion: '',
-		applyDate: '2025-08-28 10:00',
-		reportDate: '2025-08-28 13:40'
-	}
-	] as Report[];
-	reportList.value = initReportList.filter(item => item.id == current.value)
+	const initReportList = [] as QcRecord[];
+	
+	reportList.value = initReportList.filter(item => item.no == current.value)
+	
 	const tabsClick = (obj : number) => {
 		current.value = obj
-		reportList.value = initReportList.filter(item => item.id == current.value)
+		console.log(initRecords)
+		reportList.value = initReportList.filter(item => parseInt(item.no) == current.value)
+		console.log(reportList.value)
+	}
+	
+	const refreshRecords = (index : number) => {
+		// 清空现有数据
+		initRecords = [];
+		// #ifdef APP-ANDROID
+		getJoinList('app_task_record as r', 'app_task_record_item as i', 'r.*,i.*', 'r.sxid=i.psxid', 'pdid', pdid, null).then((res : UTSJSONObject) => {
+			let dataList = res?.['data'] as UTSJSONObject[] ?? Array<UTSJSONObject>()
+			console.log(dataList)
+			if (dataList != null && dataList.length > 0) {
+				console.log(dataList);
+				dataList.forEach(item => {
+					if (item != null) {
+						let record = JSON.parse<QcRecord>(item.toJSONString());
+						if (record != null) {
+							initRecords.push(record)
+							let noValue = parseInt(record['no'])
+							if (noValue > maxcount) {
+								maxcount = noValue;
+							}
+						}
+					}
+				});
+			}
+			if (initRecords.length > 0) {
+				if (index > 0) {
+					current.value = index
+				} else {
+					current.value = parseInt(initRecords[0].no)
+				}
+				reportList.value = initRecords.filter(item => parseInt(item.no) == current.value)
+				console.log(initRecords)
+			}
+		});
+		// #endif
 	}
+	
+	onLoad((options) => {
+		pdid = options?.pdid ?? "1"
+		senum = options?.senum ?? "1"
+		
+		// 加载初始数据
+		refreshRecords(parseInt(senum))
+	});
+	
+
+	
 </script>
 
 <style scoped>

BIN
static/db/QT800.db