|
@@ -92,6 +92,9 @@ export function offlineData(data : UTSJSONObject) : Promise<UTSJSONObject> {
|
|
|
|
|
|
export const statusDict = { '1': '未执行', '2': '执行中', '3': '已执行', '4': '执行错误', '5': '已取消' }
|
|
|
export const recordStatusDict = { '1': '未拍照', '2': '拍照中', '3': '拍照完成', '4': '检验不清晰', '5': '拍照取消' }
|
|
|
+export const taskType = { '1': '检测任务', '2': '关键工序任务' }
|
|
|
+export const funcType = {'1': '新增', '2': '更新', '3': '删除'}
|
|
|
+//export const moduleType = {'1': '声像记录', '2':'检验任务', '3':'关键工序','4': '系统管理','5':'其它'}
|
|
|
|
|
|
export async function getList(tableName : string, condition ?: string | null, value ?: string | null, condition2 ?: string | null, value2 ?: string | null, initData ?: UTSJSONObject | null) : Promise<UTSJSONObject> {
|
|
|
|
|
@@ -122,6 +125,7 @@ export async function updateData(tableName : string, data : string, lname ?: str
|
|
|
// #ifdef APP-ANDROID
|
|
|
const result = await updateTableData(tableName, data, lname, lvalue);
|
|
|
console.log(result);
|
|
|
+ addLog({module:tableName,dataid:lvalue,content:'更新数据',status:result?.['errMsg']==='ok'?1:0,params:data})
|
|
|
return result;
|
|
|
// #endif
|
|
|
}
|
|
@@ -173,9 +177,11 @@ export async function saveMediaInfo(data ?: UTSJSONObject | null) : Promise<UTSJ
|
|
|
// 调用sqlite的插入方法
|
|
|
const result = await insertTableData(tableName, values, fields);
|
|
|
console.log('保存app_media_info成功:', result);
|
|
|
+ addLog({module:tableName,dataid:0,content:'保存媒体信息',status:1,params:values})
|
|
|
return result;
|
|
|
} catch (error) {
|
|
|
console.error('保存app_media_info失败:', error);
|
|
|
+ addLog({module:tableName,dataid:0,content:'保存媒体信息失败',status:0,params:values})
|
|
|
return { errMsg: '保存失败', data: [] as any[] } as UTSJSONObject;
|
|
|
}
|
|
|
// #endif
|
|
@@ -202,9 +208,11 @@ export async function saveMediaRecord(values : string) : Promise<UTSJSONObject>
|
|
|
// 调用sqlite的插入方法
|
|
|
const result = await insertTableData(tableName, values, fields);
|
|
|
console.log('保存app_media_record成功:', result);
|
|
|
+ addLog({module:tableName,dataid:0,content:'保存媒体记录',status:1,params:values})
|
|
|
return result;
|
|
|
} catch (error) {
|
|
|
console.error('保存app_media_record失败:', error);
|
|
|
+ addLog({module:tableName,dataid:0,content:'保存媒体记录失败',status:0,params:values})
|
|
|
return { errMsg: '保存失败', data: [] as any[] } as UTSJSONObject;
|
|
|
}
|
|
|
// #endif
|
|
@@ -234,9 +242,11 @@ export async function removeTableData(tableName:string, field: string, value: st
|
|
|
// 调用sqlite的删除方法
|
|
|
const result = await deleteTableData(tableName, field, value);
|
|
|
console.log('删除数据成功:', result);
|
|
|
+ addLog({module:tableName,dataid:1,content:'删除数据成功',status:1,params:value})
|
|
|
return result;
|
|
|
} catch (error) {
|
|
|
console.error('删除数据失败:', error);
|
|
|
+ addLog({module:tableName,dataid:1,content:'删除数据失败',status:0,params:value})
|
|
|
return { errMsg: '删除失败', data: [] as any[] } as UTSJSONObject;
|
|
|
}
|
|
|
// #endif
|
|
@@ -253,14 +263,42 @@ export async function removeInfoAndRecord(value:string) : Promise<UTSJSONObject>
|
|
|
try {
|
|
|
// 调用sqlite的删除方法
|
|
|
const result = await deleteTableData('app_media_record', 'pid', value);
|
|
|
+ addLog({module:'app_media_record',dataid:1,content:'删除数据成功',status:1,params:value,updatetime: "strftime('%Y-%m-%d %H:%M:%S', 'now')"})
|
|
|
+
|
|
|
const result2 = await deleteTableData('app_media_info', 'pdid', value);
|
|
|
+ addLog({module:'app_media_info',dataid:1,content:'删除数据成功',status:1,params:value})
|
|
|
return result;
|
|
|
} catch (error) {
|
|
|
console.error('删除数据失败:', error);
|
|
|
+ addLog({module:'app_media_record',dataid:1,content:'删除数据失败',status:0,params:value})
|
|
|
return { errMsg: '删除失败', data: [] as any[] } as UTSJSONObject;
|
|
|
}
|
|
|
// #endif
|
|
|
|
|
|
+ // #ifdef H5
|
|
|
+ return offlineData({ success: true, data: [] } as UTSJSONObject);
|
|
|
+ // #endif
|
|
|
+}
|
|
|
+
|
|
|
+export async function addLog(data ?: UTSJSONObject | null) : Promise<UTSJSONObject> {
|
|
|
+ const tableName = 'app_log';
|
|
|
+ // #ifdef APP-ANDROID
|
|
|
+ const params = data?.getString('params')?.replace(/['"]/g, '')
|
|
|
+ const dataid = data?.getNumber('dataid') ?? 0
|
|
|
+ let fields = 'module,dataid,content,status,params';
|
|
|
+ let values = `'${data?.getString('module') ?? ''}',${data?.getNumber('dataid') ?? 0},'${data?.getString('content') ?? ''}',${data?.getNumber('status') ?? 0},'${params}'`;
|
|
|
+ if(dataid === 0){
|
|
|
+ fields = fields + ",createuser,createtime"
|
|
|
+ values = values + `,'${data?.getString('createuser') ?? 0}',strftime('%Y-%m-%d %H:%M:%S', 'now')`
|
|
|
+ }else{
|
|
|
+ fields = fields + ",updateuser,updatetime"
|
|
|
+ values = values + `,'${data?.getString('updateuser') ?? 0}',strftime('%Y-%m-%d %H:%M:%S', 'now')`
|
|
|
+ }
|
|
|
+
|
|
|
+ const result = await insertTableData(tableName, values, fields);
|
|
|
+ console.log(result);
|
|
|
+ return result;
|
|
|
+ // #endif
|
|
|
// #ifdef H5
|
|
|
return offlineData({ success: true, data: [] } as UTSJSONObject);
|
|
|
// #endif
|