zhangxike 1 сар өмнө
parent
commit
50f0ebd7d1

+ 2 - 2
api/work.uts

@@ -98,7 +98,7 @@ export type TaskDownload = {
 	lastupdatetime ?: string,
 	updateuser ?: string,
 	progress ?: string,
-	uploadflag : number
+	uploadFlag : number
 }
 
 export type TaskDetail = {
@@ -570,7 +570,7 @@ 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('measuredvaluemax') ?? ''}','${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?.getString('maxNum') ?? ''}', '${data?.getString('minNum') ?? ''}','${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,measuredvaluemax,result,cs,ts';

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

@@ -121,7 +121,7 @@
 		ver: '',
 		lastupdatetime: '',
 		updateuser: '',
-		uploadflag: 0,
+		uploadFlag: 0,
 		progress: ''
 	})
 

+ 11 - 9
pages/work/download/DownloadList.uvue

@@ -56,8 +56,8 @@
 			<view class="info-row">
 			  <text class="label">进度:</text>
 			  <text class="process-value" :class="{
-			    'bg-green': ( item.photoStatus +  item.keyStatus + item.recordStatus) == 3,
-			    'bg-yellow': ( item.photoStatus +  item.keyStatus + item.recordStatus) < 3,
+			    'bg-green': ( item.photoStatus +  item.keyStatus + item.recordStatus) == (item.photoTotal + item.keyTotal + item.recordTotal),
+			    'bg-yellow': ( item.photoStatus +  item.keyStatus + item.recordStatus) < (item.photoTotal + item.keyTotal + item.recordTotal),
 			    'bg-black': ( item.photoStatus +  item.keyStatus + item.recordStatus) == 0
 			  }"> {{ (item.photoStatus +  item.keyStatus + item.recordStatus) }} / {{(item.photoTotal + item.keyTotal + item.recordTotal)}} </text>
 			</view>
@@ -117,6 +117,7 @@
 	photoTotal: number,
 	keyTotal: number,
 	recordTotal: number,
+	uploadFlag: number,
   }
 
   var initDownloads = [] as Task[]
@@ -211,13 +212,14 @@
   }
   
   const upload = async (e : Task) => {
-	// if((e.photoStatus +  e.keyStatus + e.recordStatus ) != 3) {
-	// 	uni.showToast({
-	// 	  title: '当前任务还未完成!',
-	// 	  icon: 'error'
-	// 	});
-	// 	return
-	// }
+	if((e.photoStatus +  e.keyStatus + e.recordStatus ) != (e.photoTotal + e.keyTotal + e.recordTotal)) {
+		uni.showToast({
+		  title: '当前任务还未完成!',
+		  icon: 'error'
+		});
+		return
+	}
+	
     console.log("开始上传...")
     uploadDataToAPI(e.gxpk, () => {
 	  // 回调函数中执行刷新,确保数据都保存好,进度条跑完

+ 373 - 368
pages/work/record/InfoList.uvue

@@ -1,392 +1,397 @@
 <template>
-  <view class="container">
-    <!-- 搜索栏 -->
-    <view class="info-row btn-panel search-bar">
-      <view class="search-input">
-		  <input type="text" v-model="productNo" placeholder="请输入产品号"/>
-	  </view>
-      <view class="scan-btn" @click="scanQRCode">
-        <uni-icons type="scan" size="32" color="#00aaff"></uni-icons>
-      </view>
-    </view>
-    <!-- 按钮面板 -->
-    <view class="info-row btn-panel">
-      <button class="btn btn-first" @click="download">
-        下载数据
-      </button>
-    </view>
-    <!-- 列表内容 -->
-    <!-- #ifdef APP -->
-    <scroll-view style="flex:1">
-    <!-- #endif -->
-      <view class="download-card" v-for="(item, index) in downloads" :key="index" >
-		<view @click="enterItem(item.pdid)">
-			<view class="info-row">
-			  <text class="label">工作令:</text>
-			  <text class="value">{{ item.workorder }}</text>
+	<view class="container">
+		<!-- 搜索栏 -->
+		<view class="info-row btn-panel search-bar">
+			<view class="search-input">
+				<input type="text" v-model="productNo" placeholder="请输入产品号" />
 			</view>
-			<view class="info-row">
-			  <text class="label">产品名称:</text>
-			  <text class="value">{{ item.invname }}</text>
+			<view class="scan-btn" @click="scanQRCode">
+				<uni-icons type="scan" size="32" color="#00aaff"></uni-icons>
 			</view>
-			<view class="info-row">
-			  <text class="label">物料编码:</text>
-			  <text class="value">{{ item.graphid }}</text>
-			</view>
-			<view class="info-row">
-			  <text class="label">路卡号:</text>
-			  <text class="value">{{ item.cardno }}</text>
-			</view>
-			<view class="info-row">
-			  <text class="label">产品码:</text>
-			  <text class="value">{{ item.productno }}</text>
-			</view>
-			<view class="info-row">
-			  <text class="label">最近更新时间:</text>
-			  <text class="value">{{ item.updatetime == "" ? item.createtime : item.updatetime }}</text>
-			</view>
-			<view class="info-row">
-			  <text class="label">进度:</text>
-			  <text class="process-value" :class="{
+		</view>
+		<!-- 按钮面板 -->
+		<view class="info-row btn-panel">
+			<button class="btn btn-first" @click="download">
+				下载数据
+			</button>
+		</view>
+		<!-- 列表内容 -->
+		<!-- #ifdef APP -->
+		<scroll-view style="flex:1">
+		<!-- #endif -->
+			<view class="download-card" v-for="(item, index) in downloads" :key="index">
+				<view @click="enterItem(item.pdid)">
+					<view class="info-row">
+						<text class="label">工作令:</text>
+						<text class="value">{{ item.workorder }}</text>
+					</view>
+					<view class="info-row">
+						<text class="label">产品名称:</text>
+						<text class="value">{{ item.invname }}</text>
+					</view>
+					<view class="info-row">
+						<text class="label">物料编码:</text>
+						<text class="value">{{ item.graphid }}</text>
+					</view>
+					<view class="info-row">
+						<text class="label">路卡号:</text>
+						<text class="value">{{ item.cardno }}</text>
+					</view>
+					<view class="info-row">
+						<text class="label">产品码:</text>
+						<text class="value">{{ item.productno }}</text>
+					</view>
+					<view class="info-row">
+						<text class="label">最近更新时间:</text>
+						<text class="value">{{ item.updatetime == "" ? item.createtime : item.updatetime }}</text>
+					</view>
+					<view class="info-row">
+						<text class="label">进度:</text>
+						<text class="process-value" :class="{
 			    'bg-green': item.statusRecordCount === item.totalRecord,
 			    'bg-yellow': item.statusRecordCount < item.totalRecord,
 			    'bg-black': item.statusRecordCount === 0
 			  }"> {{ item.statusRecordCount }} / {{ item.totalRecord }} </text>
+					</view>
+					<view class="info-row">
+						<text class="label">上传进度:</text>
+						<text class="process-value"> {{ item.uploadCount }} / {{ item.totalRecord }} </text>
+					</view>
+				</view>
+
+				<view class="info-row">
+					<button class="btn btn-second" @click="upload(item)">
+						上传数据
+					</button>
+				</view>
 			</view>
-			<view class="info-row">
-			  <text class="label">上传进度:</text>
-			  <text class="process-value" > {{ item.uploadCount }} / {{ item.totalRecord }} </text>
-			</view>
-		</view>  
-		
-		<view class="info-row">
-			<button class="btn btn-second" @click="upload(item)">
-			  上传数据
-			</button>
-		</view>
-      </view>
-	  
-    <!-- #ifdef APP -->
-    </scroll-view>
-    <!-- #endif -->
-  </view>
+
+		<!-- #ifdef APP -->
+		</scroll-view>
+		<!-- #endif -->
+	</view>
 </template>
 
 <script setup>
-  import { ref, reactive } from 'vue'
-  import { getRecordInfoList } from '@/api/work';
-  import { downloadDataFromAPI, uploadDataToAPI } from '@/utils/dataProcessor';
-
-  // 产品号输入框数据
-  const productNo = ref('YH07202507000005');
-  
-  const backPressOptions = reactive({
-    from: 'backbutton'
-  } as OnBackPressOptions)
-
-  onBackPress((options : OnBackPressOptions) : boolean | null => {
-    console.log('onBackPress', options)
-    // 使用reLaunch代替switchTab,避免多层跳转时的闪回问题
-    // reLaunch会关闭所有页面并打开到目标页面,适合需要完全重置导航栈的场景
-    uni.reLaunch({
-      url: `/pages/work/index`,
-    })
-    // 返回true表示拦截默认返回行为
-    return true
-  })
-
-  type Download = {
-    pdid : number,
-    workorder : string,
-    invname : string,
-    productno : string,
-    graphid : string,
-    cardno : string,
-    processno : string,
-    updatetime : string,
-    createtime: string,
-    progress : string,
-    status : number,
-    totalRecord : number,
-    statusRecordCount : number,
-    status4RecordCount : number,
-	uploadCount : number,
-	uploadflag: number
-  }
-
-  var initDownloads = [] as Download[]
-  var downloads = ref<Download[]>([]);
-  const map = ref(new Map<number, string>([[1, '未执行'], [2, '执行中'], [3, '执行完'], [4, '有错误']]))
-
-  // #ifdef APP-ANDROID
-  getRecordInfoList(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 download = JSON.parse<Download>(item.toJSONString());
-          if (download != null) {
-            initDownloads.push(download)
-          }
-        }
-      });
-    }
-    downloads.value = initDownloads
-    console.log(initDownloads)
-  })
-  // #endif
-
-  // #ifdef H5
-  downloads = [{
-    pdid: 1,
-    workorder: "632-P-01",
-    invname: "箱间段",
-	graphid : "",
-    productno: "1CFA1040-00#S",
-    cardno: "LK20230707070012",
-    processno: "Pb/XXX-E11",
-	createtime: "2025-06-23",
-    updatetime: "2025-06-23",
-	progress : "3/3",
-    totalRecord : 3,
-    statusRecordCount : 3,
-    status4RecordCount : 3,
-    uploadflag: 1,
-    status: 3
-
-  }, {
-    pdid: 2,
-    workorder: "712-SY-10-6",
-    invname: "级间架",
-	graphid : "",
-    productno: "1XA1020-00A",
-    cardno: "LK20250215003",
-    processno: "Pb/XXX-E11",
-	createtime: "2025-06-23",
-    updatetime: "2025-08-25",
-	progress : "2/4",
-    totalRecord : 4,
-    statusRecordCount : 2,
-    status4RecordCount : 2,
-    uploadflag: 1,
-    status: 2
-  }, {
-    pdid: 3,
-    workorder: "712-SY-10-6",
-    invname: "级间架",
-	graphid : "",
-    productno: "1XA1020-00A",
-    cardno: "LK20250215003",
-    processno: "Pb/XXX-E11",
-	createtime: "2025-06-23",
-    updatetime: "2025-08-25",
-    totalRecord : 4,
-	progress : "0/4",
-    statusRecordCount : 0,
-    status4RecordCount : 0,
-    uploadflag: 1,
-    status: 1
-  }] as Download[];
-
-  // #endif
-
-  const download = async (e : any) => {
-    console.log("开始下载...")
-    // 调用数据处理工具中的方法下载数据
-	if(productNo.value == null || productNo.value == '') {
-		uni.showToast({
-		  title: '请先扫描或者输入产品号',
-		  icon: 'error'
-		});
-		return
+	import { ref, reactive } from 'vue'
+	import { getRecordInfoList } from '@/api/work';
+	import { downloadDataFromAPI, uploadDataToAPI } from '@/utils/dataProcessor';
+	//测试使用
+	import { globalConfig } from '@/config'
+	import { getCurrentUserSync, getTokenFromApi } from '@/utils/auth.uts'
+
+	// 产品号输入框数据
+	const productNo = ref('YH07202507000005');
+
+	const backPressOptions = reactive({
+		from: 'backbutton'
+	} as OnBackPressOptions)
+
+	onBackPress((options : OnBackPressOptions) : boolean | null => {
+		console.log('onBackPress', options)
+		// 使用reLaunch代替switchTab,避免多层跳转时的闪回问题
+		// reLaunch会关闭所有页面并打开到目标页面,适合需要完全重置导航栈的场景
+		uni.reLaunch({
+			url: `/pages/work/index`,
+		})
+		// 返回true表示拦截默认返回行为
+		return true
+	})
+
+	type Download = {
+		pdid : number,
+		workorder : string,
+		invname : string,
+		productno : string,
+		graphid : string,
+		cardno : string,
+		processno : string,
+		updatetime : string,
+		createtime : string,
+		progress : string,
+		status : number,
+		totalRecord : number,
+		statusRecordCount : number,
+		status4RecordCount : number,
+		uploadCount : number,
+		uploadFlag : number
 	}
-	
-    await downloadDataFromAPI(productNo.value, () => {
-      // 回调函数中执行刷新,确保数据都保存好,进度条跑完
-      uni.reLaunch({ url: '/pages/work/record/InfoList' })
-    }).then((res) => {
-      // 移除这里的刷新逻辑,避免过早刷新
-    })
-  }
-  
-  const upload = async (e : Download) => {
-    console.log("开始上传...")
-    uploadDataToAPI(e.productno, () => {
-	  // 回调函数中执行刷新,确保数据都保存好,进度条跑完
-	  uni.reLaunch({ url: '/pages/work/record/InfoList' })
-	}).then((res) => {
-	  // 移除这里的刷新逻辑,避免过早刷新
-	  // 处理断点续传
+
+	var initDownloads = [] as Download[]
+	var downloads = ref<Download[]>([]);
+	const map = ref(new Map<number, string>([[1, '未执行'], [2, '执行中'], [3, '执行完'], [4, '有错误']]))
+
+	// #ifdef APP-ANDROID
+	getRecordInfoList(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 download = JSON.parse<Download>(item.toJSONString());
+					if (download != null) {
+						initDownloads.push(download)
+					}
+				}
+			});
+		}
+		downloads.value = initDownloads
+		console.log(initDownloads)
 	})
+	// #endif
+
+	// #ifdef H5
+	downloads = [{
+		pdid: 1,
+		workorder: "632-P-01",
+		invname: "箱间段",
+		graphid: "",
+		productno: "1CFA1040-00#S",
+		cardno: "LK20230707070012",
+		processno: "Pb/XXX-E11",
+		createtime: "2025-06-23",
+		updatetime: "2025-06-23",
+		progress: "3/3",
+		totalRecord: 3,
+		statusRecordCount: 3,
+		status4RecordCount: 3,
+		uploadflag: 1,
+		status: 3
+
+	}, {
+		pdid: 2,
+		workorder: "712-SY-10-6",
+		invname: "级间架",
+		graphid: "",
+		productno: "1XA1020-00A",
+		cardno: "LK20250215003",
+		processno: "Pb/XXX-E11",
+		createtime: "2025-06-23",
+		updatetime: "2025-08-25",
+		progress: "2/4",
+		totalRecord: 4,
+		statusRecordCount: 2,
+		status4RecordCount: 2,
+		uploadflag: 1,
+		status: 2
+	}, {
+		pdid: 3,
+		workorder: "712-SY-10-6",
+		invname: "级间架",
+		graphid: "",
+		productno: "1XA1020-00A",
+		cardno: "LK20250215003",
+		processno: "Pb/XXX-E11",
+		createtime: "2025-06-23",
+		updatetime: "2025-08-25",
+		totalRecord: 4,
+		progress: "0/4",
+		statusRecordCount: 0,
+		status4RecordCount: 0,
+		uploadflag: 1,
+		status: 1
+	}] as Download[];
+
+	// #endif
+
+	const download = async (e : any) => {
+		console.log("开始下载...")
+		// 调用数据处理工具中的方法下载数据
+		if (productNo.value == null || productNo.value == '') {
+			uni.showToast({
+				title: '请先扫描或者输入产品号',
+				icon: 'error'
+			});
+			return
+		}
+
+		await downloadDataFromAPI(productNo.value, () => {
+			// 回调函数中执行刷新,确保数据都保存好,进度条跑完
+			uni.reLaunch({ url: '/pages/work/record/InfoList' })
+		}).then((res) => {
+			// 移除这里的刷新逻辑,避免过早刷新
+		})
+	}
+
+	const upload = async (e : Download) => {
+		console.log("开始上传...")
+		uploadDataToAPI(e.productno, () => {
+			// 回调函数中执行刷新,确保数据都保存好,进度条跑完
+			uni.reLaunch({ url: '/pages/work/record/InfoList' })
+		}).then((res) => {
+			// 移除这里的刷新逻辑,避免过早刷新
+			// 处理断点续传
+		})
+
+	}
+
+	const enterItem = (id : number) => {
+		uni.navigateTo({
+			url: `/pages/work/record/InfoDetail?id=${id}`
+		});
+	}
+
+	// 扫描二维码功能
+	const scanQRCode = () => {
+		uni.scanCode({
+			success: (res) => {
+				// 扫描成功,将结果填充到输入框
+				productNo.value = res.result;
+				console.log('扫描结果:', res.result);
+			},
+			fail: (err) => {
+				console.error('扫描失败:', err);
+				uni.showToast({
+					title: '扫描失败,请重试',
+					icon: 'error'
+				});
+			}
+		});
+	}
 
-  }
-  
-  const enterItem = (id : number) => {
-    uni.navigateTo({
-      url: `/pages/work/record/InfoDetail?id=${id}`
-    });
-  }
-  
-  // 扫描二维码功能
-  const scanQRCode = () => {
-    uni.scanCode({
-      success: (res) => {
-        // 扫描成功,将结果填充到输入框
-        productNo.value = res.result;
-        console.log('扫描结果:', res.result);
-      },
-      fail: (err) => {
-        console.error('扫描失败:', err);
-        uni.showToast({
-          title: '扫描失败,请重试',
-          icon: 'error'
-        });
-      }
-    });
-  }
-
-  defineExpose({
-    backPressOptions
-  })
+	defineExpose({
+		backPressOptions
+	})
 </script>
 
 <style scope>
-  .container {
-    padding: 24rpx;
-    background-color: #f0f4f8;
-    flex: 1;
-    display: flex;
-    flex-direction: column;
-    font-family: "PingFang SC", "Helvetica Neue", Helvetica, Arial, sans-serif;
-    /* #ifndef APP-ANDROID */
-    min-height: 100vh;
-    /* #endif */
-    height: 120rpx;
-  }
-
-  .search-bar {
-	  background-color: #ffffff;
-	  border-radius: 10rpx;
-	  box-shadow: 0 2rpx 10rpx rgba(0, 0, 0, 0.1);
-}
-
-/* 搜索输入框:占满容器剩余空间,放在按钮左侧 */
+	.container {
+		padding: 24rpx;
+		background-color: #f0f4f8;
+		flex: 1;
+		display: flex;
+		flex-direction: column;
+		font-family: "PingFang SC", "Helvetica Neue", Helvetica, Arial, sans-serif;
+		/* #ifndef APP-ANDROID */
+		min-height: 100vh;
+		/* #endif */
+		height: 120rpx;
+	}
+
+	.search-bar {
+		background-color: #ffffff;
+		border-radius: 10rpx;
+		box-shadow: 0 2rpx 10rpx rgba(0, 0, 0, 0.1);
+	}
+
+	/* 搜索输入框:占满容器剩余空间,放在按钮左侧 */
 	.search-input {
-	  /* 清除默认输入框样式 */
-	  border: none;
-	  background: transparent;
-	  width: 70%;
-	  margin-left: 10rpx;
+		/* 清除默认输入框样式 */
+		border: none;
+		background: transparent;
+		width: 70%;
+		margin-left: 10rpx;
 	}
 
-/* 扫描按钮:放在输入框右侧,距离最右10rpx */
+	/* 扫描按钮:放在输入框右侧,距离最右10rpx */
 	.scan-btn {
-	  justify-content: center;
-	  align-items: center; /* 新增:按钮内部图标垂直居中 */
-	  /* 关键:右侧10rpx边距,实现"距离最右10rpx" */
-	  margin-left: auto; /* 自动推到flex容器最右侧 */
-	  margin-right: 10rpx; /* 与容器右边缘保持10rpx间距 */
+		justify-content: center;
+		align-items: center;
+		/* 新增:按钮内部图标垂直居中 */
+		/* 关键:右侧10rpx边距,实现"距离最右10rpx" */
+		margin-left: auto;
+		/* 自动推到flex容器最右侧 */
+		margin-right: 10rpx;
+		/* 与容器右边缘保持10rpx间距 */
+	}
+
+	.download-card {
+		background: #ffffff;
+		border-radius: 20rpx;
+		padding: 24rpx 32rpx;
+		box-shadow: 0 8rpx 15rpx rgba(0, 43, 92, 0.1);
+		display: flex;
+		flex-direction: column;
+		margin-bottom: 20rpx;
+		margin-top: 40rpx;
+		margin-left: 20rpx;
+		margin-right: 20rpx;
+	}
+
+	.download-card .view {
+		margin-bottom: 16rpx;
+	}
+
+	/* 信息行 */
+	.info-row {
+		display: flex;
+		flex-direction: row;
+		/* #ifdef H5 */
+		font-size: 28rpx;
+		color: #33475b;
+		/* #endif */
+		align-items: center;
+	}
+
+	.info-row>.label {
+		margin-left: 10rpx;
+	}
+
+	.info-row>.value {
+		margin-left: 10rpx;
+	}
+
+	.btn-panel {
+		display: flex;
+		justify-content: space-between;
+		align-items: center;
+		margin-left: 5rpx;
+		margin-right: 5rpx;
 	}
 
-  .download-card {
-    background: #ffffff;
-    border-radius: 20rpx;
-    padding: 24rpx 32rpx;
-    box-shadow: 0 8rpx 15rpx rgba(0, 43, 92, 0.1);
-    display: flex;
-    flex-direction: column;
-    margin-bottom: 20rpx;
-    margin-top: 40rpx;
-    margin-left: 20rpx;
-    margin-right: 20rpx;
-  }
-
-  .download-card .view {
-    margin-bottom: 16rpx;
-  }
-
-  /* 信息行 */
-  .info-row {
-    display: flex;
-    flex-direction: row;
-	/* #ifdef H5 */
-    font-size: 28rpx;
-    color: #33475b;
-	/* #endif */
-    align-items: center;
-  }
-
-  .info-row>.label {
-    margin-left: 10rpx;
-  }
-
-  .info-row>.value {
-    margin-left: 10rpx;
-  }
-
-  .btn-panel {
-    display: flex;
-    justify-content: space-between;
-    align-items: center;
-    margin-left: 5rpx;
-    margin-right: 5rpx;
-  }
-
-  .label {
-    font-weight: bold;
-    color: #102a43;
-    min-width: 100rpx;
-  }
-
-  .value {
-    flex: 1;
-    white-space: nowrap;
-    overflow: hidden;
-    text-overflow: ellipsis;
-  }
-
-  .btn {
-    align-self: flex-end;
-    background-color: #00aaff;
-    color: #fff;
-    border: none;
-    border-radius: 32rpx;
-    padding: 2rpx 30rpx;
-    font-size: 24rpx;
-    font-weight: bold;
-    /* #ifndef APP-ANDROID */
-    transition: background-color 0.3s ease;
-    /* #endif */
-    margin-top: 30rpx;
-  }
-
-  .process-value {
-    width: 120rpx;
-    min-width: 100rpx;
-    text-align: center;
-    border-radius: 10rpx;
-  }
-
-  .bg-green {
-    background-color: seagreen;
-  }
-
-  .bg-yellow {
-    background-color: yellow;
-  }
-
-  .bg-black {
-    background-color: #102a43;
-  }
-
-  .btn-first {
-    margin-left: 5rpx;
-  }
-
-  .btn-second {
-    margin-right: 5rpx;
-	margin-left: auto;
-  }
-  
+	.label {
+		font-weight: bold;
+		color: #102a43;
+		min-width: 100rpx;
+	}
+
+	.value {
+		flex: 1;
+		white-space: nowrap;
+		overflow: hidden;
+		text-overflow: ellipsis;
+	}
+
+	.btn {
+		align-self: flex-end;
+		background-color: #00aaff;
+		color: #fff;
+		border: none;
+		border-radius: 32rpx;
+		padding: 2rpx 30rpx;
+		font-size: 24rpx;
+		font-weight: bold;
+		/* #ifndef APP-ANDROID */
+		transition: background-color 0.3s ease;
+		/* #endif */
+		margin-top: 30rpx;
+	}
+
+	.process-value {
+		width: 120rpx;
+		min-width: 100rpx;
+		text-align: center;
+		border-radius: 10rpx;
+	}
+
+	.bg-green {
+		background-color: seagreen;
+	}
+
+	.bg-yellow {
+		background-color: yellow;
+	}
+
+	.bg-black {
+		background-color: #102a43;
+	}
+
+	.btn-first {
+		margin-left: 5rpx;
+	}
+
+	.btn-second {
+		margin-right: 5rpx;
+		margin-left: auto;
+	}
 </style>

+ 1 - 1
pages/work/record/camera-scan-code.uvue

@@ -276,7 +276,7 @@
 						this.renameFile(this.path, newPath)
 
 						uni.navigateTo({
-							url: `/pages/work/record/RecordList?part=${this.joinRecord.part}&num=${this.senum}&pid=${this.joinRecord.pid}`,
+							url: `/pages/work/record/RecordList?part=${this.joinRecord.part}&senum=${this.senum}&pid=${this.joinRecord.pid}`,
 							// 修改动画方向为从左到右退回
 							animationType: 'slide-in-left', // 使用从左到右滑出的动画效果
 							animationDuration: 300 // 动画持续时间,单位ms

+ 49 - 17
pages/work/report/InspectionList.uvue

@@ -246,18 +246,33 @@
 			currentItem.measuredvalue = event.detail.value;
 			let updatedData = "measuredvalue='" + currentItem.measuredvalue + "', recorder='" + getCurrentUserSync() + "' "
 			if (currentItem.nature == '定量') {
-				let minValue = parseFloat(currentItem.minNum ?? '0');
-				let maxValue = parseFloat(currentItem.maxNum ?? '0');
-				let currenMinValue = parseFloat(currentItem.measuredvalue ?? '0');
-				let currenMaxValue = parseFloat(currentItem.measuredvaluemax ?? '0');
-				if (currenMinValue > maxValue || currenMinValue < minValue|| currenMaxValue > maxValue || currenMaxValue < minValue) {
-					currentItem.result = '不合格'
-				} else {
-					currentItem.result = '合格'
+			// 初始化结果为合格(上下限都为空时保持为合格)
+			currentItem.result = '合格';
+			// 解析实测值
+			const measuredMin = parseFloat(currentItem.measuredvalue ?? '0');
+			const measuredMax = parseFloat(currentItem.measuredvaluemax ?? '0');
+			
+			// 检查下限值(如果有设置)
+			if (currentItem.minNum !== '' && currentItem.minNum !== null) {
+				const lowerLimit = parseFloat(currentItem.minNum);
+				// 下限非空时,实测最大最小值都需>=下限值,否则为不合格
+				if (measuredMin < lowerLimit || measuredMax < lowerLimit) {
+					currentItem.result = '不合格';
 				}
-				updatedData += " , result = '" + currentItem.result + "' "
 			}
 			
+			// 检查上限值(如果有设置且当前仍为合格)
+			if (currentItem.result === '合格' && currentItem.maxNum !== '' && currentItem.maxNum !== null) {
+				const upperLimit = parseFloat(currentItem.maxNum);
+				// 上限非空时,实测最大最小值都需<=上限值,否则为不合格
+				if (measuredMin > upperLimit || measuredMax > upperLimit) {
+					currentItem.result = '不合格';
+				}
+			}
+			
+			updatedData += " , result = '" + currentItem.result + "' "
+		}
+			
 			//更新数据库
 			updateData('app_task_record_item', updatedData, 'sxid', currentItem.sxid.toString()).then((res : UTSJSONObject) => {
 				let data = res?.['data'] as boolean ?? false
@@ -279,15 +294,32 @@
 			//更新数据库
 			let updatedData = "measuredvaluemax='" + currentItem.measuredvaluemax + "', recorder='" + getCurrentUserSync() + "' "
 			if (currentItem.nature == '定量') {
-				let minValue = parseFloat(currentItem.minNum ?? '0');
-				let maxValue = parseFloat(currentItem.maxNum ?? '0');
-				let currenMinValue = parseFloat(currentItem.measuredvalue ?? '0');
-				let currenMaxValue = parseFloat(currentItem.measuredvaluemax ?? '0');
-				if (currenMinValue > maxValue || currenMinValue < minValue|| currenMaxValue > maxValue || currenMaxValue < minValue) {
-					currentItem.result = '不合格'
-				} else {
-					currentItem.result = '合格'
+				// 初始化结果为合格
+				currentItem.result = '合格';
+				
+				// 解析实测值
+				const measuredMin = parseFloat(currentItem.measuredvalue ?? '0');
+				const measuredMax = parseFloat(currentItem.measuredvaluemax ?? '0');
+				
+				// 检查下限值
+				if (currentItem.minNum != null && currentItem.minNum != '') {
+					const minLimit = parseFloat(currentItem.minNum);
+					// 实测最大值和最小值都需要大于等于下限值
+					if (measuredMin < minLimit || measuredMax < minLimit) {
+						currentItem.result = '不合格';
+					}
+				}
+				
+				// 检查上限值
+				if (currentItem.result === '合格' && currentItem.maxNum != null && currentItem.maxNum != '') {
+					const maxLimit = parseFloat(currentItem.maxNum);
+					// 实测最大值和最小值都需要小于等于上限值
+					if (measuredMin > maxLimit || measuredMax > maxLimit) {
+						currentItem.result = '不合格';
+					}
 				}
+				
+				// 如果上下限都为空,结果保持为合格
 				updatedData += " ,result = '" + currentItem.result + "', recorder='" + getCurrentUserSync() + "' "
 			}
 			updateData('app_task_record_item', updatedData, 'sxid', currentItem.sxid.toString()).then((res : UTSJSONObject) => {

BIN
static/db/QT800.db


+ 43 - 36
utils/dataProcessor.uts

@@ -395,13 +395,13 @@ export const uploadDataToAPI = async (productCode : string, callback ?: () => vo
 
 	try {
 		//暂定需要上传的数据文件
-		//const infoJson = await getLatestRecord(productCode, null);
 		const apiToken = await getTokenFromApi();
 		if (apiToken == null || apiToken == '') {
 			uni.hideLoading();
 			uni.showToast({ title: `获取Token失败,请联系技术IT`, icon: 'error' });
 			return false
 		}
+		// const apiToken = ''
 
 		// 获取数据
 		let query = `productno = '${productCode}' and uploadFlag = '0' and urlpdt is not null  AND (LENGTH(urlpdt) - LENGTH(REPLACE(urlpdt, ',', '')) + 1) = num`
@@ -489,32 +489,26 @@ export const uploadDataToAPI = async (productCode : string, callback ?: () => vo
 						},
 						success: (uploadRes) => {
 							if (uploadRes.statusCode === 200) {
-								console.log(`文件${path}上传成功`, uploadRes);
-								// 解析响应数据
-								const resData = JSON.parse(uploadRes.data) as UTSJSONObject;
-								console.log(resData)
-								if (resData?.['_id'] != null && resData?.['_id'] != '') {
-									successCount++;
-									//更新数据库记录
-									let updatedData = " uploadflag = 1 "
-									updateData('app_media_record', updatedData, 'sxid', sxid).then((res : UTSJSONObject) => {
-										console.log(`更新图片记录的上传标识 ${sxid}`)
-									});
-									// 等待一小段时间确保文件完全上传并处理完成
-									setTimeout(() => {
-										resolve();
-									}, 1000);
-								} else {
-									setTimeout(() => {
-										reject('响应数据无效');
-									}, 500);
-								}
+								successCount++;
+								//更新数据库记录
+								let updatedData = " uploadFlag = 1 "
+								updateData('app_media_record', updatedData, 'sxid', sxid).then((res : UTSJSONObject) => {
+									console.log(`更新图片记录的上传标识 ${sxid}`)
+								});
+								// 等待一小段时间确保文件完全上传并处理完成
+								setTimeout(() => {
+									resolve();
+								}, 1000);
 							} else {
 								console.error(`文件${path}上传失败,状态码:`, uploadRes.statusCode);
-								let updatedData = " uploadflag = 0 "
+								let updatedData = " uploadFlag = 0 "
 								updateData('app_media_record', updatedData, 'sxid', sxid).then((res : UTSJSONObject) => {
 									console.log(`上传失败更新图片记录的上传标识 ${sxid}`)
 								});
+								uni.showModal({
+									content: `图片上传失败,状态码:${uploadRes.statusCode}`,
+									title: '图片上传失败'
+								})
 								setTimeout(() => {
 									reject(new Error(`上传失败,状态码: ${uploadRes.statusCode}`));
 								}, 500);
@@ -523,10 +517,14 @@ export const uploadDataToAPI = async (productCode : string, callback ?: () => vo
 						fail: (err) => {
 							console.error(`文件${path}上传失败`, err);
 							// 上传失败也继续处理下一张,但记录错误
-							let updatedData = " uploadflag = 0 "
+							let updatedData = " uploadFlag = 0 "
 							updateData('app_media_record', updatedData, 'sxid', sxid).then((res : UTSJSONObject) => {
 								console.log(`上传错误更新图片记录的上传标识 ${sxid}`)
 							});
+							uni.showModal({
+								content: `文件上传失败:${err}`,
+								title: '图片上传失败'
+							})
 							setTimeout(() => {
 								reject(err);
 							}, 500);
@@ -549,6 +547,11 @@ export const uploadDataToAPI = async (productCode : string, callback ?: () => vo
 				// 捕获上传失败的错误,将失败的图片信息添加到错误数组
 				console.log(`处理第${i + 1}张图片时出错:`, error);
 				failedImages.push({ sxid, pk, path });
+				
+				uni.showModal({
+					content: `文件上传失败:${error}`,
+					title: '图片上传失败'
+				})
 			}
 
 			// 在两次上传之间增加一个短暂的延迟,避免请求过于频繁
@@ -599,26 +602,26 @@ export const uploadDataToAPI = async (productCode : string, callback ?: () => vo
 						success: (uploadRes) => {
 							if (uploadRes.statusCode === 200) {
 								console.log(`重试文件${path}上传成功`, uploadRes);
-								const resData = JSON.parse(uploadRes.data) as UTSJSONObject;
-								if (resData?.['_id'] != null && resData?.['_id'] != '') {
-									currentSuccessCount++;
-									//更新数据库
-									let updatedData = " uploadflag = 1 "
-									updateData('app_media_record', updatedData, 'sxid', sxid).then((res : UTSJSONObject) => {
-										console.log(`更新图片记录的上传标识 ${sxid}`)
-									});
-								} else {
-									currentFailedImages.push({ sxid, pk, path });
-								}
+								currentSuccessCount++;
+								//更新数据库
+								let updatedData = " uploadFlag = 1 "
+								updateData('app_media_record', updatedData, 'sxid', sxid).then((res : UTSJSONObject) => {
+									console.log(`更新图片记录的上传标识 ${sxid}`)
+								});
+								resolve();
 							} else {
 								currentFailedImages.push({ sxid, pk, path });
 							}
 							console.log(`重试上传完成,当前成功: ${currentSuccessCount}, 当前失败: ${currentFailedImages.length}`);
-							resolve();
+							
 						},
 						fail: (err) => {
 							console.error(`重试文件${path}上传失败`, err);
 							currentFailedImages.push({sxid, pk, path });
+							uni.showModal({
+								content: `文件上传失败:${err}`,
+								title: '图片上传失败'
+							})
 							resolve();
 						},
 						complete: () => {
@@ -671,7 +674,7 @@ export const uploadDataToAPI = async (productCode : string, callback ?: () => vo
 		}
 
 		if (finalFailedCount === 0) {
-			let updatedData = " uploadflag = 1 "
+			let updatedData = " uploadFlag = 1 "
 			updateData('app_media_info', updatedData, 'productno', productCode).then((res : UTSJSONObject) => {
 				console.log(`更新完上传标识 ${productCode}`)
 			});
@@ -682,6 +685,10 @@ export const uploadDataToAPI = async (productCode : string, callback ?: () => vo
 		console.error(error);
 		uni.showToast({ title: '上传失败,请重试', icon: 'error' });
 		uni.hideLoading();
+		uni.showModal({
+			content: `文件上传失败:${error}`,
+			title: '图片上传失败'
+		})
 		return false;
 	}
 }

+ 46 - 44
utils/qcDataProcessor.uts

@@ -470,7 +470,7 @@ export const uploadDataToAPI = async (gxpk : string, callback ?: () => void) : P
 				return false;
 			}
 
-
+			uni.showLoading({ title: `开始上传数据`});
 			let taskInfo = JSON.parse<Task>(taskInfoJson.toJSONString());
 			let canContinueFlag = true;
 
@@ -544,31 +544,26 @@ export const uploadDataToAPI = async (gxpk : string, callback ?: () => void) : P
 								success: (uploadRes) => {
 									if (uploadRes.statusCode === 200) {
 										console.log(`文件${path}上传成功`, uploadRes);
-										// 解析响应数据
-										const resData = JSON.parse(uploadRes.data) as UTSJSONObject;
-										console.log(resData)
-										if (resData?.['_id'] != null && resData?.['_id'] != '') {
-											successCount++;
-											//更新数据库记录
-											let updatedData = " uploadflag = 1 "
-											updateData('app_task_photo', updatedData, 'sxid', sxid).then((res : UTSJSONObject) => {
-												console.log(`更新图片记录的上传标识 ${sxid}`)
-											});
-											// 等待一小段时间确保文件完全上传并处理完成
-											setTimeout(() => {
-												resolve();
-											}, 1000);
-										} else {
-											setTimeout(() => {
-												reject('响应数据无效');
-											}, 500);
-										}
+										successCount++;
+										//更新数据库记录
+										let updatedData = " uploadFlag = 1 "
+										updateData('app_task_photo', updatedData, 'sxid', sxid).then((res : UTSJSONObject) => {
+											console.log(`更新图片记录的上传标识 ${sxid}`)
+										});
+										// 等待一小段时间确保文件完全上传并处理完成
+										setTimeout(() => {
+											resolve();
+										}, 1000);
 									} else {
 										console.error(`文件${path}上传失败,状态码:`, uploadRes.statusCode);
-										let updatedData = " uploadflag = 0 "
+										let updatedData = " uploadFlag = 0 "
 										updateData('app_task_photo', updatedData, 'sxid', sxid).then((res : UTSJSONObject) => {
 											console.log(`上传失败更新图片记录的上传标识 ${sxid}`)
 										});
+										uni.showModal({
+											content: `图片上传失败,状态码:${uploadRes.statusCode}`,
+											title: '图片上传失败'
+										})
 										setTimeout(() => {
 											reject(new Error(`上传失败,状态码: ${uploadRes.statusCode}`));
 										}, 500);
@@ -577,10 +572,14 @@ export const uploadDataToAPI = async (gxpk : string, callback ?: () => void) : P
 								fail: (err) => {
 									console.error(`文件${path}上传失败`, err);
 									// 上传失败也继续处理下一张,但记录错误
-									let updatedData = " uploadflag = 0 "
+									let updatedData = " uploadFlag = 0 "
 									updateData('app_task_photo', updatedData, 'sxid', sxid).then((res : UTSJSONObject) => {
 										console.log(`上传错误更新图片记录的上传标识 ${sxid}`)
 									});
+									uni.showModal({
+										content: `文件上传失败:${err}`,
+										title: '图片上传失败'
+									})
 									setTimeout(() => {
 										reject(err);
 									}, 500);
@@ -604,6 +603,10 @@ export const uploadDataToAPI = async (gxpk : string, callback ?: () => void) : P
 						console.log(`处理第${i + 1}张图片时出错:`, error);
 						failedImages.push({ sxid, pk, path });
 						// 出错后继续处理下一张图片
+						uni.showModal({
+							content: `文件上传失败:${error}`,
+							title: '图片上传失败'
+						})
 					}
 
 					// 在两次上传之间增加一个短暂的延迟,避免请求过于频繁
@@ -653,23 +656,18 @@ export const uploadDataToAPI = async (gxpk : string, callback ?: () => void) : P
 								},
 								success: (uploadRes) => {
 									if (uploadRes.statusCode === 200) {
-										console.log(`重试文件${path}上传成功`, uploadRes);
-										const resData = JSON.parse(uploadRes.data) as UTSJSONObject;
-										if (resData?.['_id'] != null && resData?.['_id'] != '') {
-											currentSuccessCount++;
-											//更新数据库
-											let updatedData = " uploadflag = 1 "
-											updateData('app_task_photo', updatedData, 'sxid', sxid).then((res : UTSJSONObject) => {
-												console.log(`更新图片记录的上传标识 ${sxid}`)
-											});
-										} else {
-											currentFailedImages.push({ sxid, pk, path });
-										}
+										currentSuccessCount++;
+										//更新数据库
+										let updatedData = " uploadFlag = 1 "
+										updateData('app_task_photo', updatedData, 'sxid', sxid).then((res : UTSJSONObject) => {
+											console.log(`更新图片记录的上传标识 ${sxid}`)
+										});
+										console.log(`重试上传完成,当前成功: ${currentSuccessCount}, 当前失败: ${currentFailedImages.length}`);
+										resolve();
 									} else {
 										currentFailedImages.push({ sxid, pk, path });
 									}
-									console.log(`重试上传完成,当前成功: ${currentSuccessCount}, 当前失败: ${currentFailedImages.length}`);
-									resolve();
+									
 								},
 								fail: (err) => {
 									console.error(`重试文件${path}上传失败`, err);
@@ -777,25 +775,28 @@ export const uploadDataToAPI = async (gxpk : string, callback ?: () => void) : P
 			console.log("请求体:", requestTask)
 
 			const requestResult = await new Promise<UTSJSONObject>((resolve, reject) => {
+				// Ensure we properly stringify the JSON object and set the correct content-type
 				uni.request({
 					url: `${globalConfig.uploadTaskURL}`,
 					method: 'POST',
 					header: {
-						'token': apiToken
-					},
-					data: {
-						checkresult: requestTask
+						'token': apiToken,
+						'content-type': 'application/json'
 					},
+					data: JSON.stringify(requestTask), // Convert object to JSON string
 					success: (res) => resolve(res?.['data'] as UTSJSONObject ?? {} as UTSJSONObject),
 					fail: (err) => reject(err)
 				});
 			});
 
-			console.log(requestResult)
 
 			// 检查返回的code值
 			const code = requestResult?.['code'] as number;
 			if (code === 666) {
+				let updatedData = " uploadFlag = 1 "
+				updateData('app_task_info', updatedData, 'pdid', taskInfo?.pdid.toString()).then((res : UTSJSONObject) => {
+					console.log(`更新检验任务记录的上传标识 ${taskInfo?.pdid.toString()}`)
+				});
 				uni.showToast({
 					title: `上传成功`,
 					icon: 'success'
@@ -809,14 +810,15 @@ export const uploadDataToAPI = async (gxpk : string, callback ?: () => void) : P
 				});
 			}
 		}
-
-
-
 		return true;
 	} catch (error) {
 		console.error(error);
 		uni.showToast({ title: '上传失败,请重试', icon: 'error' });
 		uni.hideLoading();
+		uni.showModal({
+			content: `文件上传失败:${error}`,
+			title: '图片上传失败'
+		})
 		return false;
 	}
 }