|
@@ -1,5 +1,5 @@
|
|
|
// #ifdef APP-ANDROID
|
|
|
-import { selectTableData, insertTableData, updateTableData, selectJoinTableData, selectRecordData, selectRecordInfo, selectLatestInfoData, deleteTableData, selectTaskInfo, selectLatestTaskData, selectTaskId } from '@/utils/sqlite'
|
|
|
+import { selectTableData, insertTableData, updateTableData, selectJoinTableData, selectRecordData, selectRecordInfo, selectLatestInfoData, deleteTableData, selectTaskInfo, selectLatestTaskData, selectTaskId, selectTaskDetail, selectTableDataByOrder } from '@/utils/sqlite'
|
|
|
// #endif
|
|
|
|
|
|
export type Download = {
|
|
@@ -69,11 +69,11 @@ export type RecordCalculate = {
|
|
|
|
|
|
//检验任务
|
|
|
export type TaskInfo = {
|
|
|
- gxid : string,
|
|
|
- itemTitle: string,
|
|
|
+ gxid : string,
|
|
|
+ itemTitle : string,
|
|
|
photoitemStep : number,
|
|
|
- photoitemTotal: number,
|
|
|
- photoitemStatus: string,
|
|
|
+ photoitemTotal : number,
|
|
|
+ photoitemStatus : string,
|
|
|
recordStep : number,
|
|
|
recordTotal : number,
|
|
|
recordStatus : string,
|
|
@@ -101,6 +101,57 @@ export type TaskDownload = {
|
|
|
uploadflag : number
|
|
|
}
|
|
|
|
|
|
+export type TaskDetail = {
|
|
|
+ pdid: string,
|
|
|
+ gxno: string,
|
|
|
+ photoTotal: number,
|
|
|
+ photoCount: number,
|
|
|
+ photoStatus: string,
|
|
|
+ keyTotal: number,
|
|
|
+ keyCount: number,
|
|
|
+ keyStatus: string,
|
|
|
+ recordTotal: number,
|
|
|
+ recordCount: number,
|
|
|
+ recordStatus: string,
|
|
|
+}
|
|
|
+
|
|
|
+export type TaskPhoto = {
|
|
|
+ sxid : number,
|
|
|
+ pdid : number,
|
|
|
+ senum: number,
|
|
|
+ photographpoint : string,
|
|
|
+ photographdescription : string,
|
|
|
+ photourl : string,
|
|
|
+ photourlSpl : string[],
|
|
|
+ imgname : string[],
|
|
|
+ exampleurl : string,
|
|
|
+ exampleurlSpl : string[],
|
|
|
+ photoname : string,
|
|
|
+ fk_qcRecord : string,
|
|
|
+ fk_prodcode : string,
|
|
|
+ prodno : string,
|
|
|
+ processStep ?: string,
|
|
|
+}
|
|
|
+
|
|
|
+export type TaskJoinRecord = {
|
|
|
+ sxid : number,
|
|
|
+ pdid : number,
|
|
|
+ photographpoint : string,
|
|
|
+ photographdescription : string,
|
|
|
+ photourl ?: string,
|
|
|
+ photourlSpl ?: string[],
|
|
|
+ imgname : string,
|
|
|
+ exampleurl ?: string,
|
|
|
+ exampleurlSpl ?: string[],
|
|
|
+ photoname ?: string,
|
|
|
+ fk_qcRecord ?: string,
|
|
|
+ fk_prodcode ?: string,
|
|
|
+ prodno ?: string,
|
|
|
+ processStep ?: string,
|
|
|
+ workorder : string,
|
|
|
+ invname : string,
|
|
|
+}
|
|
|
+
|
|
|
export function offlineData(data : UTSJSONObject) : Promise<UTSJSONObject> {
|
|
|
return new Promise((resolve, reject) => {
|
|
|
let result = JSON.parseObject(JSON.stringify(data)) as UTSJSONObject
|
|
@@ -111,7 +162,7 @@ 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 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> {
|
|
@@ -143,7 +194,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})
|
|
|
+ addLog({ module: tableName, dataid: lvalue, content: '更新数据', status: result?.['errMsg'] === 'ok' ? 1 : 0, params: data })
|
|
|
return result;
|
|
|
// #endif
|
|
|
}
|
|
@@ -195,11 +246,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})
|
|
|
+ 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})
|
|
|
+ addLog({ module: tableName, dataid: 0, content: '保存媒体信息失败', status: 0, params: values })
|
|
|
return { errMsg: '保存失败', data: [] as any[] } as UTSJSONObject;
|
|
|
}
|
|
|
// #endif
|
|
@@ -226,11 +277,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})
|
|
|
+ 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})
|
|
|
+ addLog({ module: tableName, dataid: 0, content: '保存媒体记录失败', status: 0, params: values })
|
|
|
return { errMsg: '保存失败', data: [] as any[] } as UTSJSONObject;
|
|
|
}
|
|
|
// #endif
|
|
@@ -241,7 +292,7 @@ export async function saveMediaRecord(values : string) : Promise<UTSJSONObject>
|
|
|
}
|
|
|
|
|
|
|
|
|
-export async function getLatestRecord(productNo:string , initData ?: UTSJSONObject | null) : Promise<UTSJSONObject> {
|
|
|
+export async function getLatestRecord(productNo : string, initData ?: UTSJSONObject | null) : Promise<UTSJSONObject> {
|
|
|
// #ifdef APP-ANDROID
|
|
|
const result = await selectLatestInfoData(productNo);
|
|
|
console.log(result);
|
|
@@ -253,18 +304,18 @@ export async function getLatestRecord(productNo:string , initData ?: UTSJSONObje
|
|
|
// #endif
|
|
|
}
|
|
|
|
|
|
-export async function removeTableData(tableName:string, field: string, value: string) : Promise<UTSJSONObject> {
|
|
|
+export async function removeTableData(tableName : string, field : string, value : string) : Promise<UTSJSONObject> {
|
|
|
// #ifdef APP-ANDROID
|
|
|
|
|
|
try {
|
|
|
// 调用sqlite的删除方法
|
|
|
const result = await deleteTableData(tableName, field, value);
|
|
|
console.log('删除数据成功:', result);
|
|
|
- addLog({module:tableName,dataid:1,content:'删除数据成功',status:1,params:value})
|
|
|
+ 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})
|
|
|
+ addLog({ module: tableName, dataid: 1, content: '删除数据失败', status: 0, params: value })
|
|
|
return { errMsg: '删除失败', data: [] as any[] } as UTSJSONObject;
|
|
|
}
|
|
|
// #endif
|
|
@@ -275,24 +326,24 @@ export async function removeTableData(tableName:string, field: string, value: st
|
|
|
}
|
|
|
|
|
|
|
|
|
-export async function removeInfoAndRecord(value:string) : Promise<UTSJSONObject> {
|
|
|
+export async function removeInfoAndRecord(value : string) : Promise<UTSJSONObject> {
|
|
|
// #ifdef APP-ANDROID
|
|
|
-
|
|
|
+
|
|
|
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')"})
|
|
|
-
|
|
|
+ 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})
|
|
|
+ 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})
|
|
|
+ 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
|
|
@@ -303,16 +354,16 @@ export async function addLog(data ?: UTSJSONObject | null) : Promise<UTSJSONObje
|
|
|
// #ifdef APP-ANDROID
|
|
|
const params = data?.getString('params')?.replace(/['"]/g, '')
|
|
|
const dataid = data?.getNumber('dataid') ?? 0
|
|
|
- let fields = 'module,dataid,content,status,params';
|
|
|
+ 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){
|
|
|
+ if (dataid === 0) {
|
|
|
fields = fields + ",createuser,createtime"
|
|
|
values = values + `,'${data?.getString('createuser') ?? 0}',strftime('%Y-%m-%d %H:%M:%S', 'now')`
|
|
|
- }else{
|
|
|
+ } 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;
|
|
@@ -338,11 +389,11 @@ export async function saveTaskInfo(data ?: UTSJSONObject | null) : Promise<UTSJS
|
|
|
// 调用sqlite的插入方法
|
|
|
const result = await insertTableData(tableName, values, fields);
|
|
|
console.log('保存app_task_info成功:', result);
|
|
|
- addLog({module:tableName,dataid:0,content:'保存检验任务信息成功',status:1,params:values})
|
|
|
+ addLog({ module: tableName, dataid: 0, content: '保存检验任务信息成功', status: 1, params: values })
|
|
|
return result;
|
|
|
} catch (error) {
|
|
|
console.error('保存app_task_info失败:', error);
|
|
|
- addLog({module:tableName,dataid:0,content:'保存检验任务信息失败',status:0,params:values})
|
|
|
+ addLog({ module: tableName, dataid: 0, content: '保存检验任务信息失败', status: 0, params: values })
|
|
|
return { errMsg: '保存失败', data: [] as any[] } as UTSJSONObject;
|
|
|
}
|
|
|
// #endif
|
|
@@ -370,11 +421,11 @@ export async function saveTaskPhoto(values : string) : Promise<UTSJSONObject> {
|
|
|
// 调用sqlite的插入方法
|
|
|
const result = await insertTableData(tableName, values, fields);
|
|
|
console.log('保存app_task_photo成功:', result);
|
|
|
- addLog({module:tableName,dataid:0,content:'保存任务图像记录',status:1,params:values})
|
|
|
+ addLog({ module: tableName, dataid: 0, content: '保存任务图像记录', status: 1, params: values })
|
|
|
return result;
|
|
|
} catch (error) {
|
|
|
console.error('保存app_task_photo失败:', error);
|
|
|
- addLog({module:tableName,dataid:0,content:'保存任务图像记录失败',status:0,params:values})
|
|
|
+ addLog({ module: tableName, dataid: 0, content: '保存任务图像记录失败', status: 0, params: values })
|
|
|
return { errMsg: '保存失败', data: [] as any[] } as UTSJSONObject;
|
|
|
}
|
|
|
// #endif
|
|
@@ -414,11 +465,11 @@ export async function saveTaskKeyProcess(data ?: UTSJSONObject | null) : Promise
|
|
|
// 调用sqlite的插入方法
|
|
|
const result = await insertTableData(tableName, values, fields);
|
|
|
console.log('保存app_task_info成功:', result);
|
|
|
- addLog({module:tableName,dataid:0,content:'保存检验任务信息成功',status:1,params:values})
|
|
|
+ addLog({ module: tableName, dataid: 0, content: '保存检验任务信息成功', status: 1, params: values })
|
|
|
return result;
|
|
|
} catch (error) {
|
|
|
console.error('保存app_task_info失败:', error);
|
|
|
- addLog({module:tableName,dataid:0,content:'保存检验任务信息失败',status:0,params:values})
|
|
|
+ addLog({ module: tableName, dataid: 0, content: '保存检验任务信息失败', status: 0, params: values })
|
|
|
return { errMsg: '保存失败', data: [] as any[] } as UTSJSONObject;
|
|
|
}
|
|
|
// #endif
|
|
@@ -444,11 +495,11 @@ export async function saveTaskRecord(data ?: UTSJSONObject | null) : Promise<UTS
|
|
|
// 调用sqlite的插入方法
|
|
|
const result = await insertTableData(tableName, values, fields);
|
|
|
console.log('保存app_task_record成功:', result);
|
|
|
- addLog({module:tableName,dataid:0,content:'保存检验任务记录信息成功',status:1,params:values})
|
|
|
+ addLog({ module: tableName, dataid: 0, content: '保存检验任务记录信息成功', status: 1, params: values })
|
|
|
return result;
|
|
|
} catch (error) {
|
|
|
console.error('保存app_task_record失败:', error);
|
|
|
- addLog({module:tableName,dataid:0,content:'保存检验任务记录信息失败',status:0,params:values})
|
|
|
+ addLog({ module: tableName, dataid: 0, content: '保存检验任务记录信息失败', status: 0, params: values })
|
|
|
return { errMsg: '保存失败', data: [] as any[] } as UTSJSONObject;
|
|
|
}
|
|
|
// #endif
|
|
@@ -475,11 +526,11 @@ export async function saveTaskRecordItem(data ?: UTSJSONObject | null) : Promise
|
|
|
// 调用sqlite的插入方法
|
|
|
const result = await insertTableData(tableName, values, fields);
|
|
|
console.log('保存app_task_record_item成功:', result);
|
|
|
- addLog({module:tableName,dataid:0,content:'保存检验任务项目信息成功',status:1,params:values})
|
|
|
+ addLog({ module: tableName, dataid: 0, content: '保存检验任务项目信息成功', status: 1, params: values })
|
|
|
return result;
|
|
|
} catch (error) {
|
|
|
console.error('保存app_task_record_item失败:', error);
|
|
|
- addLog({module:tableName,dataid:0,content:'保存检验任务项目信息失败',status:0,params:values})
|
|
|
+ addLog({ module: tableName, dataid: 0, content: '保存检验任务项目信息失败', status: 0, params: values })
|
|
|
return { errMsg: '保存失败', data: [] as any[] } as UTSJSONObject;
|
|
|
}
|
|
|
// #endif
|
|
@@ -490,7 +541,7 @@ export async function saveTaskRecordItem(data ?: UTSJSONObject | null) : Promise
|
|
|
}
|
|
|
|
|
|
|
|
|
-export async function getLatestTask(productNo:string, initData ?: UTSJSONObject | null) : Promise<UTSJSONObject> {
|
|
|
+export async function getLatestTask(productNo : string, initData ?: UTSJSONObject | null) : Promise<UTSJSONObject> {
|
|
|
// #ifdef APP-ANDROID
|
|
|
const result = await selectLatestTaskData(productNo);
|
|
|
console.log(result);
|
|
@@ -502,33 +553,59 @@ export async function getLatestTask(productNo:string, initData ?: UTSJSONObject
|
|
|
// #endif
|
|
|
}
|
|
|
|
|
|
-export async function removeTaskAndRecord(value:string) : Promise<UTSJSONObject> {
|
|
|
+export async function removeTaskAndRecord(value : string) : Promise<UTSJSONObject> {
|
|
|
// #ifdef APP-ANDROID
|
|
|
-
|
|
|
+
|
|
|
try {
|
|
|
// 调用sqlite的删除方法
|
|
|
const taskId = await selectTaskId('app_task_info', 'pdid', 'gxpk', value);
|
|
|
const result = await deleteTableData('app_task_info', 'pdid', taskId);
|
|
|
- addLog({module:'app_task_info',dataid:1,content:'删除数据成功',status:1,params:value,updatetime: "strftime('%Y-%m-%d %H:%M:%S', 'now')"})
|
|
|
-
|
|
|
+ addLog({ module: 'app_task_info', dataid: 1, content: '删除数据成功', status: 1, params: value, updatetime: "strftime('%Y-%m-%d %H:%M:%S', 'now')" })
|
|
|
+
|
|
|
const result2 = await deleteTableData('app_task_photo', 'pdid', taskId);
|
|
|
- addLog({module:'app_task_photo',dataid:1,content:'删除数据成功',status:1,params:value})
|
|
|
+ addLog({ module: 'app_task_photo', dataid: 1, content: '删除数据成功', status: 1, params: value })
|
|
|
|
|
|
const recordId = await selectTaskId('app_task_record', 'sxid', 'pdid', taskId);
|
|
|
const result3 = await deleteTableData('app_task_record_item', 'psxid', recordId);
|
|
|
- addLog({module:'app_task_record_item',dataid:1,content:'删除数据成功',status:1,params:value})
|
|
|
-
|
|
|
+ addLog({ module: 'app_task_record_item', dataid: 1, content: '删除数据成功', status: 1, params: value })
|
|
|
+
|
|
|
const result4 = await deleteTableData('app_task_record', 'sxid', recordId);
|
|
|
- addLog({module:'app_task_record',dataid:1,content:'删除数据成功',status:1,params:value})
|
|
|
+ addLog({ module: 'app_task_record', dataid: 1, content: '删除数据成功', status: 1, params: value })
|
|
|
return {};
|
|
|
} catch (error) {
|
|
|
console.error('删除数据失败:', error);
|
|
|
- addLog({module:'app_media_record',dataid:1,content:'删除数据失败',status:0,params:value})
|
|
|
+ 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 getTaskDetail(field ?: string | null, value ?: string | null) : Promise<UTSJSONObject> {
|
|
|
+
|
|
|
+ // #ifdef APP-ANDROID
|
|
|
+ const result = await selectTaskDetail(field, value);
|
|
|
+ console.log(result);
|
|
|
+ return result;
|
|
|
+ // #endif
|
|
|
+
|
|
|
+ // #ifdef H5
|
|
|
+ return offlineData({ success: true, data: [] } as UTSJSONObject)
|
|
|
+ // #endif
|
|
|
+}
|
|
|
+
|
|
|
+export async function getListByOrder(tableName : string, condition ?: string | null, value ?: string | null, order ?:string | null, initData ?: UTSJSONObject | null) : Promise<UTSJSONObject> {
|
|
|
+
|
|
|
+ // #ifdef APP-ANDROID
|
|
|
+ const result = await selectTableDataByOrder(tableName, condition, value, null, null, order);
|
|
|
+ console.log(result);
|
|
|
+ return result;
|
|
|
+ // #endif
|
|
|
+
|
|
|
+ // #ifdef H5
|
|
|
+ return offlineData(initData)
|
|
|
+ // #endif
|
|
|
}
|