zhangxike 4 днів тому
батько
коміт
622673d667

+ 15 - 0
api/work.uts

@@ -426,6 +426,21 @@ export async function addLog(data ?: UTSJSONObject | null) : Promise<UTSJSONObje
 	// #endif
 }
 
+export async function addOperateLog(data ?: UTSJSONObject | null) : Promise<UTSJSONObject> {
+	const tableName = 'app_operate_log';
+	// #ifdef APP-ANDROID
+	let fields = 'module,title,content,msg,createuser,createtime';
+	let values = `'${data?.getString('module') ?? ''}','${data?.getString('title') ?? ''}', '${data?.getString('content') ?? ''}', '${data?.getString('msg') ?? ''}', '${data?.getString('createuser') ?? 0}', strftime('%Y-%m-%d %H:%M:%S', 'now', 'localtime')`;
+
+	const result = await insertTableData(tableName, values, fields);
+	console.log(result);
+	return result;
+	// #endif
+	// #ifdef H5
+	return offlineData({ success: true, data: [] } as UTSJSONObject);
+	// #endif
+}
+
 
 export async function saveTaskInfo(data ?: UTSJSONObject | null) : Promise<UTSJSONObject> {
 	// #ifdef APP-ANDROID

+ 27 - 49
pages/work/log/logDetail.uvue

@@ -5,43 +5,37 @@
 		<!-- 报告基础信息 -->
 		<view class="section">
 			<view class="info-item">
-				<text class="label">日志内容</text>
-				<text class="value">{{ log.content}}</text>
+				<text class="label">日志信息</text>
+				<text class="value">{{ log.title}}</text>
 			</view>
 			<view class="info-item">
-				<text class="label">日志模块</text>
+				<text class="label">模块</text>
 				<text class="value">{{ log.module}}</text>
 			</view>	
 		</view>
 
 		<view class="section">
-			<uni-table>
-				<uni-tr class="section-title" v-for="(item,index) in titleList" :key="index">
-					<uni-td class="grid-text">{{item.title1}}</uni-td>
-					<uni-td class="grid-text">{{item.title2}}</uni-td>
-					<uni-td class="grid-text">{{item.title3}}</uni-td>
-				</uni-tr>
-				<uni-tr class="section-title" >
-					<uni-td class="grid-text">{{log.dataid ===0 ? "新增":"变更"}}</uni-td>
-					<uni-td class="grid-text">
-						<text :class="{
-							'bg-green bg-text': log.status === 1,
-							'bg-red bg-text': log.status === 0
-						  }">
-							{{log.status===1?"操作成功":"操作失败"}}
-						</text>
-					</uni-td>
-					<uni-td class="grid-text">
-						{{ log.dataid===0? log.createtime:log.updatetime }}
-					</uni-td>
-				</uni-tr>
-			</uni-table>
+			<view class="info-item">
+				<text class="label">日志详细内容</text>
+			</view>
+			<view class="info-item">
+				<text class="value">{{log.createuser}} 在 {{log.createtime}} {{log.content}}</text>
+			</view>
+		</view>
+		
+		<view class="section" v-if="log.msg !=null && log.msg != ''">
+			<view class="info-item">
+				<text class="label">日志错误信息</text>
+			</view>
+			<view class="info-item">
+				<text class="value">{{log.msg}}</text>
+			</view>
 		</view>
 		
 		<view class="section">
 			<view class="info-item">
-				<text class="label">日志传参</text>
-				<text class="value">{{ log.params}}</text>
+				<text class="label">日志创建时间</text>
+				<text class="value">{{ log.createtime}}</text>
 			</view>
 		</view>
 
@@ -69,45 +63,29 @@
 	type Log = {
 	  id : number,
 	  module : string,
-	  dataid : number,
 	  content : string,
-	  status : number,
-	  params : string,    
-	  updatetime : string,
+	  title ?: string,
+	  msg ?: string,    
+	  createuser : string,
 	  createtime: string   
 	}
 	
 	const log = ref<Log>({
 		id: 0,
 		module: "",
-		dataid: 0,
 		content: "",
-		status: 0,
-		params: "",	
-		updatetime: "",
+		title: "",
+		msg: "",	
+		createuser: "",
 		createtime: "",		
 	})
 
-	// #ifdef H5
-	log.value = {
-		id: 1,
-		module: "app_media_info",
-		dataid: 0,
-		content : "新增数据成功",
-		params: "1CFA1040-00#S",    
-		createtime: "2025-06-23",
-		updatetime: "2025-06-23",	
-		status: 1
-  }
-
-	// #endif
-
 	onLoad((options) => {
 		const logId = options?.id ?? ""
 		// 模拟数据加载,建议替换为后端接口请求
 		// #ifdef APP-ANDROID
 		//获取下载产品数据			   
-		getList('app_log', 'id', logId, null, null, null).then((res : UTSJSONObject) => {
+		getList('app_operate_log', 'id', logId, null, null, null).then((res : UTSJSONObject) => {
 			console.log(res)
 			let dataList = res?.['data'] as UTSJSONObject[] ?? Array<UTSJSONObject>()
 			if (dataList != null && dataList.length > 0) {

+ 13 - 19
pages/work/log/logList.uvue

@@ -9,24 +9,20 @@
       <view class="download-card" v-for="(item, index) in logs" :key="index" >
 		<view @click="enterItem(item.id)">
 			<view class="info-row">
-			  <text class="label">数据表:</text>
+			  <text class="label">模块:</text>
 			  <text class="value">{{ item.module }}</text>
 			</view>
-			<view class="info-row">
-			  <text class="label">数据类型:</text>
-			  <text class="value">{{ item.dataid == 0 ? "新增" : "变更" }}</text>
-			</view>
 			<view class="info-row">
 			  <text class="label">日志内容:</text>
-			  <text class="value">{{ item.content }}</text>
+			  <text class="value">{{ item.title }}</text>
 			</view>
 			<view class="info-row">
-			  <text class="label">操作结果:</text>
-			  <text class="value">{{ item.status === 1 ? "操作成功" : "操作失败" }}</text>
+			  <text class="label">操作人员</text>
+			  <text class="value">{{ item.createuser }}</text>
 			</view>			
 			<view class="info-row">
 			  <text class="label">操作时间:</text>
-			  <text class="value">{{ item.dataid === 0 ? item.createtime : item.updatetime }}</text>
+			  <text class="value">{{ item.createtime }}</text>
 			</view>			
 		</view> 
       </view>  
@@ -63,11 +59,10 @@
   type Log = {
     id : number,
     module : string,
-    dataid : number,
+	title : string,
     content : string,
-    status : number,
-    params : string,    
-    updatetime : string,
+    msg : string,  
+	createuser: string,  
     createtime: string   
   }
 
@@ -98,7 +93,7 @@
     }
     loading.value = true
     let offset = currentPage.value === 1 ? 0 : (currentPage.value-1) * 10	
-  	selectPageSql('app_log', 'createtime', offset).then((res : UTSJSONObject) => {
+  	selectPageSql('app_operate_log', 'id', offset).then((res : UTSJSONObject) => {
   		console.log(res)
   		let dataList = res?.['data'] as UTSJSONObject[] ?? Array<UTSJSONObject>()
   		if (dataList != null && dataList.length > 0) {
@@ -254,11 +249,10 @@
   }
 
   .value {
-    flex: 1;
-    white-space: nowrap;
-    overflow: hidden;
-    text-overflow: ellipsis;
-  }
+	  flex: 1;
+	  word-break: break-all;
+	  word-wrap: break-word;
+  }	
 
   .btn {
     align-self: flex-end;

BIN
static/db/QT800.db


+ 6 - 1
utils/dataProcessor.uts

@@ -1,5 +1,5 @@
 import { getCurrentUserSync, getTokenFromApi } from '@/utils/auth.uts'
-import { saveMediaInfo, saveMediaRecord, getLatestRecord, removeInfoAndRecord, getList, updateData, addLog } from '@/api/work'
+import { saveMediaInfo, saveMediaRecord, getLatestRecord, removeInfoAndRecord, getList, updateData, addLog, addOperateLog } from '@/api/work'
 import { globalConfig } from '@/config'
 
 
@@ -360,6 +360,8 @@ export const downloadDataFromAPI = async (productCode : string, callback ?: () =
 							});
 							
 							addLog({ module: null, dataid: 0, content: '下载声像记录', status: 1, params: productCode, createuser: getCurrentUserSync()??'' })
+							addOperateLog({ module: '声像记录', title: '下载声像记录', content: `下载声像记录任务,产品编号:${productCode}`, msg: null, createuser: getCurrentUserSync()??'' })
+							
 							resolve(true);
 						} else {
 							uni.hideLoading();
@@ -384,6 +386,7 @@ export const downloadDataFromAPI = async (productCode : string, callback ?: () =
 	} catch (error) {
 		console.error(error);
 		uni.showToast({ title: '下载失败,请重试', icon: 'error' });
+		addOperateLog({ module: '声像记录', title: '下载声像记录失败', content: `下载声像记录任务失败,产品编号:${productCode}`, msg: `错误信息Err:${error}`, createuser: getCurrentUserSync()??'' })
 		uni.hideLoading();
 		return false;
 	}
@@ -674,6 +677,7 @@ export const uploadDataToAPI = async (productCode : string, callback ?: () => vo
 			updateData('app_media_info', updatedData, 'productno', productCode).then((res : UTSJSONObject) => {
 				console.log(`更新完上传标识 ${productCode}`)
 			});
+			addOperateLog({ module: '声像记录',title: '上传声像记录', content: `上传声像记录任务,产品编号:${productCode}`, msg: null, createuser: getCurrentUserSync()??'' })
 		}
 
 		if (callback != null) {
@@ -685,6 +689,7 @@ export const uploadDataToAPI = async (productCode : string, callback ?: () => vo
 		console.error(error);
 		uni.showToast({ title: '上传失败,请重试', icon: 'error' });
 		uni.hideLoading();
+		addOperateLog({ module: '声像记录',title: '上传声像记录失败', content: `上传声像记录任务失败,产品编号:${productCode}`, msg:`错误信息Err:${error}`, createuser: getCurrentUserSync()??'' })
 		uni.showModal({
 			content: `文件上传失败:${error}`,
 			title: '图片上传失败'

+ 11 - 1
utils/qcDataProcessor.uts

@@ -1,5 +1,5 @@
 import { getToken, getTokenFromApi, getCurrentUserNameSync, getCurrentUserSync } from './auth'
-import { saveTaskInfo, saveTaskPhoto, saveTaskKeyProcess, saveTaskRecord, saveTaskRecordItem, getLatestTask, removeTaskAndRecord, getList, updateData } from '@/api/work'
+import { saveTaskInfo, saveTaskPhoto, saveTaskKeyProcess, saveTaskRecord, saveTaskRecordItem, getLatestTask, removeTaskAndRecord, getList, updateData, addOperateLog } from '@/api/work'
 import { globalConfig } from '@/config'
 
 
@@ -394,6 +394,8 @@ export const downloadDataFromAPI = async (gxpk : string, callback ?: () => void)
 			// 所有记录处理完成,显示完成提示
 			uni.hideLoading();
 			uni.showToast({ title: `下载完成`, icon: 'success' });
+			addOperateLog({ module: '检验任务', title: '下载检验任务', content: `下载检验任务,工序码:${gxpk}`, msg: null, createuser: getCurrentUserSync()??'' })
+			
 			if (callback != null) {
 				callback();
 			}
@@ -402,11 +404,14 @@ export const downloadDataFromAPI = async (gxpk : string, callback ?: () => void)
 			const errorMsg = requestResult?.msg != null ? requestResult.msg : '未知错误';
 			uni.hideLoading();
 			uni.showToast({ title: `请求失败: ${errorMsg}`, icon: 'error' });
+			addOperateLog({ module: '检验任务', title: '下载检验任务失败', content: `下载检验任务失败,工序码:${gxpk}`, msg: `错误信息Err:${errorMsg}`, createuser: getCurrentUserSync()??'' })
 			return false;
 		}
 	} catch (error) {
 		console.error('下载数据时发生错误:', error);
 		uni.hideLoading();
+		addOperateLog({ module: '检验任务', title: '下载检验任务失败', content: `下载检验任务失败,工序码:${gxpk}`, msg: `错误信息Err:${error}`, createuser: getCurrentUserSync()??'' })
+		
 		uni.showToast({ title: '下载失败,请重试', icon: 'error' });
 		return false;
 	}
@@ -806,6 +811,8 @@ export const uploadDataToAPI = async (gxpk : string, callback ?: () => void) : P
 				updateData('app_task_info', updatedData, 'pdid', taskInfo?.pdid.toString()).then((res : UTSJSONObject) => {
 					console.log(`更新检验任务记录的上传标识 ${taskInfo?.pdid.toString()}`)
 				});
+				addOperateLog({ module: '检验任务', title: '上传检验任务', content: `上传检验任务,工序码:${gxpk}`, msg: null, createuser: getCurrentUserSync()??'' })
+				
 				uni.showToast({
 					title: `上传成功`,
 					icon: 'success'
@@ -817,6 +824,7 @@ export const uploadDataToAPI = async (gxpk : string, callback ?: () => void) : P
 					title: `上传失败: ${errorMsg}`,
 					icon: 'error'
 				});
+				addOperateLog({ module: '检验任务', title: '上传检验任务失败', content: `上传检验任务失败,工序码:${gxpk}`, msg: `错误信息Err:${errorMsg}`, createuser: getCurrentUserSync()??'' })
 			}
 			
 			if (callback != null) {
@@ -828,6 +836,8 @@ export const uploadDataToAPI = async (gxpk : string, callback ?: () => void) : P
 		console.error(error);
 		uni.showToast({ title: '上传失败,请重试', icon: 'error' });
 		uni.hideLoading();
+		addOperateLog({ module: '检验任务', title: '上传检验任务失败', content: `上传检验任务失败,工序码:${gxpk}`, msg: `错误信息Err:${error}`, createuser: getCurrentUserSync()??'' })
+		
 		uni.showModal({
 			content: `文件上传失败:${error}`,
 			title: '图片上传失败'

+ 2 - 2
utils/sqlite.uts

@@ -323,8 +323,8 @@ export function selectTableData (
    *
    */
   export function pullSQL(dbTable: string, id: string, num: number) : Promise<UTSJSONObject> {
-	var sql = `SELECT * FROM ${dbTable} ORDER BY '${id}' DESC LIMIT 10 OFFSET '${num}'` 
-	const sqlite = createSQLiteContext(dbName); 
+	var sql = `SELECT * FROM ${dbTable} ORDER BY ${id} DESC LIMIT 10 OFFSET '${num}'` 
+	const sqlite = createSQLiteContext(dbName);
     return new Promise((resolve, reject) => {
       const selectSqlOptions ={
       		  sql: sql,