Pārlūkot izejas kodu

检验任务上传请求体修改,修改数据库文件

ZhangLeo 3 mēneši atpakaļ
vecāks
revīzija
a0452c5626

+ 5 - 5
pages/work/process/ProcessList.uvue

@@ -110,6 +110,7 @@
 <script setup>
 	import { ref, computed } from 'vue' // 1. 引入 computed(计算属性核心)
 	import { getListByOrder, TaskKeyProcess, recordStatusDict, updateData } from '@/api/work';
+	import { getCurrentUser } from '@/utils/auth';
 
 	// 存储页面参数
 	let pdid = "";
@@ -175,7 +176,6 @@
 						item['senum'] = index
 						const record = JSON.parse<TaskKeyProcess>(item.toJSONString());
 						if (record != null) {
-							console.log(record);
 							initRecords.value.push(record)
 							index++;
 						}
@@ -206,7 +206,7 @@
 			// 更新结果值
 			currentItem.result = event.detail.value;
 			//更新数据库
-			let updatedData = "result='" + currentItem.result + "'"
+			let updatedData = "result='" + currentItem.result + "', operator='" + getCurrentUser() + "' "
 			updateData('app_task_keyprocess', updatedData, 'sxid', currentItem.sxid.toString()).then((res : UTSJSONObject) => {
 				let data = res?.['data'] as boolean ?? false
 				if (data != null && data== true) {
@@ -226,7 +226,7 @@
 			currentItem.measuredvaluemin = event.detail.value;
 			// 检查measuredvalue是否为null或undefined,避免空指针异常
 			const measuredValue = currentItem.measuredvaluemin ?? '';
-			let updatedData = "measuredvaluemin='" + measuredValue + "'"
+			let updatedData = "measuredvaluemin='" + measuredValue + "', operator='" + getCurrentUser() + "' "
 			
 			//更新数据库
 			updateData('app_task_keyprocess', updatedData, 'sxid', currentItem.sxid.toString()).then((res : UTSJSONObject) => {
@@ -247,7 +247,7 @@
 			// 更新结果值
 			currentItem.measuredvaluemax = event.detail.value;
 			//更新数据库
-			let updatedData = "measuredvaluemax='" + currentItem.measuredvaluemax + "'"
+			let updatedData = "measuredvaluemax='" + currentItem.measuredvaluemax + "', operator='" + getCurrentUser() + "' "
 		
 			updateData('app_task_keyprocess', updatedData, 'sxid', currentItem.sxid.toString()).then((res : UTSJSONObject) => {
 				let data = res?.['data'] as boolean ?? false
@@ -267,7 +267,7 @@
 			// 更新结果值
 			currentItem.memo = event.detail.value;
 			//更新数据库
-			let updatedData = "memo='" + currentItem.memo + "'"
+			let updatedData = "memo='" + currentItem.memo + "', operator='" + getCurrentUser() + "' "
 			updateData('app_task_keyprocess', updatedData, 'sxid', currentItem.sxid.toString()).then((res : UTSJSONObject) => {
 				let data = res?.['data'] as boolean ?? false
 				if (data != null && data== true) {

+ 8 - 6
pages/work/report/InspectionList.uvue

@@ -110,6 +110,7 @@
 <script setup>
 	import { ref, computed } from 'vue' // 1. 引入 computed(计算属性核心)
 	import { getJoinList, QcRecord, recordStatusDict, updateData } from '@/api/work';
+	import { getCurrentUser } from '@/utils/auth';
 
 	// 存储页面参数
 	let pdid = "";
@@ -224,7 +225,8 @@
 			// 更新结果值
 			currentItem.result = event.detail.value;
 			//更新数据库
-			let updatedData = "result='" + currentItem.result + "'"
+			let updatedData = "result='" + currentItem.result + "', recorder='" + getCurrentUser() + "' "
+			console.log(updatedData)
 			updateData('app_task_record_item', updatedData, 'sxid', currentItem.sxid.toString()).then((res : UTSJSONObject) => {
 				let data = res?.['data'] as boolean ?? false
 				if (data != null && data== true) {
@@ -242,7 +244,7 @@
 		if (currentItem != null) {
 			// 更新结果值
 			currentItem.measuredvalue = event.detail.value;
-			let updatedData = "measuredvalue='" + currentItem.measuredvalue + "'"
+			let updatedData = "measuredvalue='" + currentItem.measuredvalue + "', recorder='" + getCurrentUser() + "' "
 			if (currentItem.nature == '定量') {
 				let minValue = parseFloat(currentItem.minNum ?? '0');
 				let maxValue = parseFloat(currentItem.maxNum ?? '0');
@@ -253,7 +255,7 @@
 				} else {
 					currentItem.result = '合格'
 				}
-				updatedData += " ,result = '" + currentItem.result + "'"
+				updatedData += " , result = '" + currentItem.result + "' "
 			}
 			
 			//更新数据库
@@ -275,7 +277,7 @@
 			// 更新结果值
 			currentItem.measuredvaluemax = event.detail.value;
 			//更新数据库
-			let updatedData = "measuredvaluemax='" + currentItem.measuredvaluemax + "'"
+			let updatedData = "measuredvaluemax='" + currentItem.measuredvaluemax + "', recorder='" + getCurrentUser() + "' "
 			if (currentItem.nature == '定量') {
 				let minValue = parseFloat(currentItem.minNum ?? '0');
 				let maxValue = parseFloat(currentItem.maxNum ?? '0');
@@ -286,7 +288,7 @@
 				} else {
 					currentItem.result = '合格'
 				}
-				updatedData += " ,result = '" + currentItem.result + "'"
+				updatedData += " ,result = '" + currentItem.result + "', recorder='" + getCurrentUser() + "' "
 			}
 			updateData('app_task_record_item', updatedData, 'sxid', currentItem.sxid.toString()).then((res : UTSJSONObject) => {
 				let data = res?.['data'] as boolean ?? false
@@ -306,7 +308,7 @@
 			// 更新结果值
 			currentItem.memo = event.detail.value;
 			//更新数据库
-			let updatedData = "memo='" + currentItem.memo + "'"
+			let updatedData = "memo='" + currentItem.memo + "', recorder='" + getCurrentUser() + "' "
 			updateData('app_task_record_item', updatedData, 'sxid', currentItem.sxid.toString()).then((res : UTSJSONObject) => {
 				let data = res?.['data'] as boolean ?? false
 				if (data != null && data== true) {

BIN
static/db/QT800.db


+ 1 - 1
utils/auth.uts

@@ -15,7 +15,7 @@ export function removeToken():void {
   return uni.removeStorageSync(TokenKey)
 }
 
-export function getCurrentUSer():string {
+export function getCurrentUser():string {
 	return storage.getString(constant.name) as string | '';
 }
 

+ 3 - 3
utils/dataProcessor.uts

@@ -1,4 +1,4 @@
-import { getCurrentUSer, getTokenFromApi } from './auth'
+import { getCurrentUser, getTokenFromApi } from './auth'
 import { saveMediaInfo, saveMediaRecord, getLatestRecord, removeInfoAndRecord, getList, updateData, addLog } from '@/api/work'
 import { globalConfig } from '@/config'
 
@@ -175,6 +175,7 @@ export const downloadDataFromAPI = async (productCode : string, callback ?: () =
 								});
 							} else {
 								// 用户取消覆盖
+								uni.hideLoading();
 								overwiteFlag.value = false;
 								resolve(false);
 							}
@@ -358,7 +359,7 @@ export const downloadDataFromAPI = async (productCode : string, callback ?: () =
 								}
 							});
 							
-							addLog({ module: null, dataid: 0, content: '下载声像记录', status: 1, params: productCode, createuser: getCurrentUSer()??'' })
+							addLog({ module: null, dataid: 0, content: '下载声像记录', status: 1, params: productCode, createuser: getCurrentUser()??'' })
 							resolve(true);
 						} else {
 							uni.hideLoading();
@@ -546,7 +547,6 @@ export const uploadDataToAPI = async (productCode : string, callback ?: () => vo
 				// 捕获上传失败的错误,将失败的图片信息添加到错误数组
 				console.log(`处理第${i + 1}张图片时出错:`, error);
 				failedImages.push({ sxid, pk, path });
-				// 出错后继续处理下一张图片
 			}
 
 			// 在两次上传之间增加一个短暂的延迟,避免请求过于频繁

+ 11 - 7
utils/qcDataProcessor.uts

@@ -64,6 +64,7 @@ export type AppTaskRecordItem = {
 	result ?: string;
 	cs ?: string;
 	ts ?: string;
+	recorder ?: string;
 }
 
 export type AppTaskPhoto = {
@@ -106,6 +107,7 @@ export type AppTaskKeyProcess = {
 	fks_operator ?: string;
 	cs ?: string;
 	ts ?: string;
+	operator ?: string;
 }
 
 export type UploadImg = {
@@ -193,8 +195,8 @@ export const moveFile = (oldPath : string) : Promise<string> => {
 	});
 }
 
-//声像任务下载
-export const downloadDataFromAPI = async (productCode : string, callback ?: () => void) : Promise<boolean> => {
+//检验任务下载
+export const downloadDataFromAPI = async (gxpk : string, callback ?: () => void) : Promise<boolean> => {
 	try {
 		uni.showLoading({ title: '任务开始下载' });
 		const apiToken = await getTokenFromApi();
@@ -207,7 +209,7 @@ export const downloadDataFromAPI = async (productCode : string, callback ?: () =
 
 		//校验是否已经存在未执行的产品号,若已经存在则提示用户该产品号是否需要被覆盖,
 		//如果没有则直接保存。如果有存在已经在执行中的产品号,则提示已存在执行中的任务
-		const infoJson = await getLatestTask(productCode, null);
+		const infoJson = await getLatestTask(gxpk, null);
 		if (infoJson?.['data'] != null) {
 			let info = infoJson?.['data'] as UTSJSONObject ?? {} as UTSJSONObject
 			// let ingNum = parseInt(info?.['pdid'] as string);
@@ -233,7 +235,7 @@ export const downloadDataFromAPI = async (productCode : string, callback ?: () =
 								// 标记为需要覆盖
 								overwiteFlag.value = true;
 								// 执行删除数据操作
-								removeTaskAndRecord(productCode).then((recordDelResponse) => {
+								removeTaskAndRecord(gxpk).then((recordDelResponse) => {
 									console.log('删除数据响应:', recordDelResponse);
 									// 删除成功,解析Promise并允许继续执行
 									// 确保模态框已完全关闭后再解析Promise
@@ -247,6 +249,7 @@ export const downloadDataFromAPI = async (productCode : string, callback ?: () =
 								});
 							} else {
 								// 用户取消覆盖
+								uni.hideLoading();
 								overwiteFlag.value = false;
 								resolve(false);
 							}
@@ -268,8 +271,9 @@ export const downloadDataFromAPI = async (productCode : string, callback ?: () =
 
 		// 直接使用async/await处理HTTP请求,避免嵌套Promise
 		const requestResult = await new Promise<UTSJSONObject>((resolve, reject) => {
+			console.log(`${globalConfig.host}${globalConfig.downloadTaskURL}${gxpk}`)
 			uni.request({
-				url: `${globalConfig.host}${globalConfig.downloadTaskURL}${productCode}`,
+				url: `${globalConfig.host}${globalConfig.downloadTaskURL}${gxpk}`,
 				method: 'GET',
 				header: {
 					'token': apiToken
@@ -371,7 +375,7 @@ export const downloadDataFromAPI = async (productCode : string, callback ?: () =
 							}
 						}
 					} else {
-						console.log('保存媒体信息成功,但未获取到主键ID');
+						console.log('保存信息成功,但未获取到主键ID');
 					}
 				}
 			}
@@ -759,7 +763,7 @@ export const uploadDataToAPI = async (gxpk : string, callback ?: () => void) : P
 				let qcRecordItemList = qcRecoerdItemRes?.['data'] as UTSJSONObject[] ?? Array<UTSJSONObject>()
 				if (qcRecordItemList != null && qcRecordItemList.length > 0) {
 					let itemList = [] as AppTaskRecordItem[]
-					keyList.forEach(item => {
+					qcRecordItemList.forEach(item => {
 						let itemObj = JSON.parse<AppTaskRecordItem>(item.toJSONString());
 						if (itemObj != null){
 							itemList.push(itemObj)

+ 3 - 3
utils/sqlite.uts

@@ -687,19 +687,19 @@ export function selectLatestInfoData (
  
 
  export function selectLatestTaskData (
-   productNo?: string,
+   gxpk?: string,
  ):Promise<UTSJSONObject>
  {
    var sql = `SELECT
  					m.*
  				FROM
  					app_task_info m
-				where gxpk = '${productNo}'
+				where gxpk = '${gxpk}'
  				ORDER BY
  					m.pdid DESC
 				LIMIT 1`;
    const sqlite = createSQLiteContext(dbName);
-   
+   console.log(sql)
    return new Promise<UTSJSONObject>((resolve, reject) => {
      const selectSqlOptions ={		
    	  sql: sql,