Browse Source

record表添加exampleid字段,存放当前record下所有的样张id,以逗号拼接

zhangxike 1 tuần trước cách đây
mục cha
commit
4a1b5705ed
3 tập tin đã thay đổi với 22 bổ sung2 xóa
  1. 1 1
      api/work.uts
  2. BIN
      static/db/QT800.db
  3. 21 1
      utils/dataProcessor.uts

+ 1 - 1
api/work.uts

@@ -180,7 +180,7 @@ export async function saveMediaRecord(values : string) : Promise<UTSJSONObject>
 	const tableName = 'app_media_record';
 
 	// 构造字段名字符串
-	const fields = 'senum,photoitem,productno,part,partno,pk,descb,num,status,date,urlspl,imgname,urlpdt,createtime,createuser,updatetime,updateuser,pid';
+	const fields = 'senum,photoitem,productno,part,partno,pk,exampleid,descb,num,status,date,urlspl,imgname,urlpdt,createtime,createuser,updatetime,updateuser,pid';
 
 	try {
 		// 调用sqlite的插入方法

BIN
static/db/QT800.db


+ 21 - 1
utils/dataProcessor.uts

@@ -32,6 +32,7 @@ export type MediaRecordData = {
 	part ?: string;
 	partno ?: string;
 	pk : string;
+	exampleid ?: string;
 	descb ?: string;
 	num ?: number;
 	urlspl ?: string;
@@ -41,6 +42,11 @@ export type MediaRecordData = {
 	createuser ?: string;
 	updatetime ?: string;
 	updateuser ?: string;
+	photoFiles_example ?: PhotoFilesExample[];
+}
+
+export type PhotoFilesExample = {
+	_id ?: string,
 }
 
 export const downloadDataFromAPI = async (productCode: string, callback ?: () => void) : Promise<boolean> => {
@@ -133,6 +139,7 @@ export const downloadDataFromAPI = async (productCode: string, callback ?: () =>
                         if (recordList != null && recordList.length > 0) {
                           for(var i =0; i< recordList.length; i++) {
                             const record: MediaRecordData = recordList[i] as MediaRecordData;
+							console.log("==================>", record)
 
                             // 获取各个字段的值
                             const senum = record.senum;
@@ -149,9 +156,22 @@ export const downloadDataFromAPI = async (productCode: string, callback ?: () =>
                             const createuser = record.createuser;
                             const updatetime = record.updatetime;
                             const updateuser = record.updateuser;
+							const photoFiles_example = record.photoFiles_example;
+							console.log(photoFiles_example);
+							let exampleList = record?.['photoFiles_example'] as UTSJSONObject[] ?? Array<UTSJSONObject>();
+							var exampleidArr = [] as string[]
+							if(exampleList!=null && exampleList.length > 0) {
+								for(var j =0; j < exampleList.length; j++) {
+									const example: PhotoFilesExample = exampleList[j] as PhotoFilesExample;
+									if(example._id != null) {
+										exampleidArr.push(example._id)
+									}
+								}
+							}
+							const exampleid = exampleidArr.join(",");
 
                             // 使用三目运算符判断,当值为null时直接插入null,否则用单引号括起来
-                            var values = `${senum === null ? '1' : `'${senum}'`}, ${photoitem === null ? 'null' : `'${photoitem}'`}, ${data?.['productcode'] === null ? 'null' : `'${data?.['productcode']}'`},${part === null ? 'null' : `'${part}'`},${partno === null ? 'null' : `'${partno}'`},${pk === null ? 'null' : `'${pk}'`},${descb === null ? 'null' : `'${descb}'`},${num === null ? 0 : num},1,'', ${urlspl === null ? 'null' : `'${urlspl}'`},${imgname === null ? 'null' : `'${imgname}'`},${urlpdt === null ? 'null' : `'${urlpdt}'`}, ${createtime === null ? 'null' : `'${createtime}'`}, ${createuser === null ? 'null' : `'${createuser}'`}, ${updatetime === null ? 'null' : `'${updatetime}'`}, ${updateuser === null ? 'null' : `'${updateuser}'`}, ${lastId === null ? 0 : lastId}`;
+                            var values = `${senum === null ? '1' : `'${senum}'`}, ${photoitem === null ? 'null' : `'${photoitem}'`}, ${data?.['productcode'] === null ? 'null' : `'${data?.['productcode']}'`},${part === null ? 'null' : `'${part}'`},${partno === null ? 'null' : `'${partno}'`},${pk === null ? 'null' : `'${pk}'`},${exampleid === null ? 'null' : `'${exampleid}'`},${descb === null ? 'null' : `'${descb}'`},${num === null ? 0 : num},1,'', ${urlspl === null ? 'null' : `'${urlspl}'`},${imgname === null ? 'null' : `'${imgname}'`},${urlpdt === null ? 'null' : `'${urlpdt}'`}, ${createtime === null ? 'null' : `'${createtime}'`}, ${createuser === null ? 'null' : `'${createuser}'`}, ${updatetime === null ? 'null' : `'${updatetime}'`}, ${updateuser === null ? 'null' : `'${updateuser}'`}, ${lastId === null ? 0 : lastId}`;
                             saveMediaRecord(values);
                           }
                           // 延迟显示完成提示,确保所有数据保存完成