Browse Source

声像数据下载添加输入框和二维码扫描功能

zhangxike 15 giờ trước cách đây
mục cha
commit
61d9c78445
3 tập tin đã thay đổi với 419 bổ sung331 xóa
  1. 307 249
      pages/work/record/InfoList.uvue
  2. 25 0
      utils/auth.uts
  3. 87 82
      utils/dataProcessor.uts

+ 307 - 249
pages/work/record/InfoList.uvue

@@ -1,285 +1,343 @@
 <template>
-	<view class="info-row btn-panel">
-		<button class="btn btn-first" @click="download">
-			下载数据
-		</button>
-		<button class="btn btn-second" @click="upload">
-			上传数据
-		</button>
-	</view>
-	<!-- #ifdef APP -->
-	<scroll-view style="flex:1">
-	<!-- #endif -->
-		<view class="download-card" v-for="(item, index) in downloads" :key="index" @click="enterItem(item.pdid)">
-			<view class="info-row">
-				<text class="label">工作令:</text>
-				<text class="value">{{ item.workorder }}</text>
-			</view>
-			<view class="info-row">
-				<text class="label">产品名称:</text>
-				<text class="value">{{ item.invname }}</text>
-			</view>
-			<view class="info-row">
-				<text class="label">物料编码:</text>
-				<text class="value">{{ item.productno }}</text>
-			</view>
-			<view class="info-row">
-				<text class="label">路卡号:</text>
-				<text class="value">{{ item.cardno }}</text>
-			</view>
-			<view class="info-row">
-				<text class="label">产品码:</text>
-				<text class="value">{{ item.processno }}</text>
-			</view>
-			<view class="info-row">
-				<text class="label">最近更新时间:</text>
-				<text class="value">{{ item.updatetime == "" ? item.createtime : item.updatetime }}</text>
-			</view>
-			<view class="info-row">
-				<text class="label">进度:</text>
-				<text class="process-value" :class="{
-					'bg-green': item.statusRecordCount === item.totalRecord,
-					'bg-yellow': item.statusRecordCount < item.totalRecord,
-					'bg-black': item.statusRecordCount === 0
-				  }">{{ item.statusRecordCount}} / {{item.totalRecord}} </text>
-			</view>
-		</view>
-	<!-- #ifdef APP -->
-	</scroll-view>
-	<!-- #endif -->
+  <view class="container">
+    <!-- 搜索栏 -->
+    <view class="info-row btn-panel search-bar">
+      <view class="search-input">
+		  <input type="text" v-model="productNo" placeholder="请输入产品号"/>
+	  </view>
+      <view class="scan-btn" @click="scanQRCode">
+        <uni-icons type="scan" size="32" color="#00aaff"></uni-icons>
+      </view>
+    </view>
+    <!-- 按钮面板 -->
+    <view class="info-row btn-panel">
+      <button class="btn btn-first" @click="download">
+        下载数据
+      </button>
+      <button class="btn btn-second" @click="upload">
+        上传数据
+      </button>
+    </view>
+    <!-- 列表内容 -->
+    <!-- #ifdef APP -->
+    <scroll-view style="flex:1">
+    <!-- #endif -->
+      <view class="download-card" v-for="(item, index) in downloads" :key="index" @click="enterItem(item.pdid)">
+        <view class="info-row">
+          <text class="label">工作令:</text>
+          <text class="value">{{ item.workorder }}</text>
+        </view>
+        <view class="info-row">
+          <text class="label">产品名称:</text>
+          <text class="value">{{ item.invname }}</text>
+        </view>
+        <view class="info-row">
+          <text class="label">物料编码:</text>
+          <text class="value">{{ item.productno }}</text>
+        </view>
+        <view class="info-row">
+          <text class="label">路卡号:</text>
+          <text class="value">{{ item.cardno }}</text>
+        </view>
+        <view class="info-row">
+          <text class="label">产品码:</text>
+          <text class="value">{{ item.processno }}</text>
+        </view>
+        <view class="info-row">
+          <text class="label">最近更新时间:</text>
+          <text class="value">{{ item.updatetime == "" ? item.createtime : item.updatetime }}</text>
+        </view>
+        <view class="info-row">
+          <text class="label">进度:</text>
+          <text class="process-value" :class="{
+            'bg-green': item.statusRecordCount === item.totalRecord,
+            'bg-yellow': item.statusRecordCount < item.totalRecord,
+            'bg-black': item.statusRecordCount === 0
+          }"> {{ item.statusRecordCount }} / {{ item.totalRecord }} </text>
+        </view>
+      </view>
+    <!-- #ifdef APP -->
+    </scroll-view>
+    <!-- #endif -->
+  </view>
 </template>
 
 <script setup>
-	import {
-		ref
-	} from 'vue'
-	import { getRecordInfoList } from '@/api/work';
-	import { downloadDataFromAPI } from '@/utils/dataProcessor';
+  import { ref, reactive } from 'vue'
+  import { getRecordInfoList } from '@/api/work';
+  import { downloadDataFromAPI } from '@/utils/dataProcessor';
 
-	const backPressOptions = reactive({
-		from: 'backbutton'
-	} as OnBackPressOptions)
+  // 产品号输入框数据
+  const productNo = ref('');
+  
+  const backPressOptions = reactive({
+    from: 'backbutton'
+  } as OnBackPressOptions)
 
-	onBackPress((options : OnBackPressOptions) : boolean | null => {
-		console.log('onBackPress', options)
-		// 使用reLaunch代替switchTab,避免多层跳转时的闪回问题
-		// reLaunch会关闭所有页面并打开到目标页面,适合需要完全重置导航栈的场景
-		uni.reLaunch({
-			url: `/pages/work/index`,
-		})
-		// 返回true表示拦截默认返回行为
-		return true
-	})
+  onBackPress((options : OnBackPressOptions) : boolean | null => {
+    console.log('onBackPress', options)
+    // 使用reLaunch代替switchTab,避免多层跳转时的闪回问题
+    // reLaunch会关闭所有页面并打开到目标页面,适合需要完全重置导航栈的场景
+    uni.reLaunch({
+      url: `/pages/work/index`,
+    })
+    // 返回true表示拦截默认返回行为
+    return true
+  })
 
-	type Download = {
-		pdid : number,
-		workorder : string,
-		invname : string,
-		productno : string,
-		cardno : string,
-		processno : string,
-		updatetime : string,
-		createtime: string,
-		progress : string,
-		status : number,
-		totalRecord : number,
-		statusRecordCount : number,
-		status4RecordCount : number
-	}
+  type Download = {
+    pdid : number,
+    workorder : string,
+    invname : string,
+    productno : string,
+    cardno : string,
+    processno : string,
+    updatetime : string,
+    createtime: string,
+    progress : string,
+    status : number,
+    totalRecord : number,
+    statusRecordCount : number,
+    status4RecordCount : number
+  }
 
-	var initDownloads = [] as Download[]
-	var downloads = ref<Download[]>([]);
-	const map = ref(new Map<number, string>([[1, '未执行'], [2, '执行中'], [3, '执行完'], [4, '有错误']]))
+  var initDownloads = [] as Download[]
+  var downloads = ref<Download[]>([]);
+  const map = ref(new Map<number, string>([[1, '未执行'], [2, '执行中'], [3, '执行完'], [4, '有错误']]))
 
-	// #ifdef APP-ANDROID
-	getRecordInfoList(null).then((res : UTSJSONObject) => {
-		console.log(res)
-		let dataList = res?.['data'] as UTSJSONObject[] ?? Array<UTSJSONObject>()
-		if (dataList != null && dataList.length > 0) {
-			dataList.forEach(item => {
-				if (item != null) {
-					let download = JSON.parse<Download>(item.toJSONString());
-					if (download != null) {
-						initDownloads.push(download)
-					}
-				}
-			});
-		}
-		downloads.value = initDownloads
-		console.log(initDownloads)
-	})
-	// #endif
+  // #ifdef APP-ANDROID
+  getRecordInfoList(null).then((res : UTSJSONObject) => {
+    console.log(res)
+    let dataList = res?.['data'] as UTSJSONObject[] ?? Array<UTSJSONObject>()
+    if (dataList != null && dataList.length > 0) {
+      dataList.forEach(item => {
+        if (item != null) {
+          let download = JSON.parse<Download>(item.toJSONString());
+          if (download != null) {
+            initDownloads.push(download)
+          }
+        }
+      });
+    }
+    downloads.value = initDownloads
+    console.log(initDownloads)
+  })
+  // #endif
 
-	// #ifdef H5
-	downloads = [{
-		pdid: 1,
-		workorder: "632-P-01",
-		invname: "箱间段",
-		productno: "1CFA1040-00#S",
-		cardno: "LK20230707070012",
-		processno: "Pb/XXX-E11",
-		updatetime: "2025-06-23",
-		progress: "3/3",
-		status: 3
+  // #ifdef H5
+  downloads = [{
+    pdid: 1,
+    workorder: "632-P-01",
+    invname: "箱间段",
+    productno: "1CFA1040-00#S",
+    cardno: "LK20230707070012",
+    processno: "Pb/XXX-E11",
+    updatetime: "2025-06-23",
+    progress: "3/3",
+    status: 3
 
-	}, {
-		pdid: 2,
-		workorder: "712-SY-10-6",
-		invname: "级间架",
-		productno: "1XA1020-00A",
-		cardno: "LK20250215003",
-		processno: "Pb/XXX-E11",
-		updatetime: "2025-08-25",
-		progress: "2/4",
-		status: 2
-	}, {
-		pdid: 3,
-		workorder: "712-SY-10-6",
-		invname: "级间架",
-		productno: "1XA1020-00A",
-		cardno: "LK20250215003",
-		processno: "Pb/XXX-E11",
-		updatetime: "2025-08-25",
-		progress: "0/4",
-		status: 1
-	}] as Download[];
+  }, {
+    pdid: 2,
+    workorder: "712-SY-10-6",
+    invname: "级间架",
+    productno: "1XA1020-00A",
+    cardno: "LK20250215003",
+    processno: "Pb/XXX-E11",
+    updatetime: "2025-08-25",
+    progress: "2/4",
+    status: 2
+  }, {
+    pdid: 3,
+    workorder: "712-SY-10-6",
+    invname: "级间架",
+    productno: "1XA1020-00A",
+    cardno: "LK20250215003",
+    processno: "Pb/XXX-E11",
+    updatetime: "2025-08-25",
+    progress: "0/4",
+    status: 1
+  }] as Download[];
 
-	// #endif
+  // #endif
 
-	const download = async (e : any) => {
-		console.log("开始下载...")
-		// 调用数据处理工具中的方法下载数据
-		// 调用数据处理工具中的方法下载数据
-		await downloadDataFromAPI(() => {
-			
-		}).then((res) => {
-			// 刷新整个页面
-			uni.reLaunch({ url: '/pages/work/record/InfoList' })
-		})
-	}
-	const upload = (e : any) => {
-		console.log("开始上传...")
+  const download = async (e : any) => {
+    console.log("开始下载...")
+    // 调用数据处理工具中的方法下载数据
+    await downloadDataFromAPI(() => {
+      
+    }).then((res) => {
+      // 刷新整个页面
+      uni.reLaunch({ url: '/pages/work/record/InfoList' })
+    })
+  }
+  
+  const upload = (e : any) => {
+    console.log("开始上传...")
 
-	}
-	const enterItem = (id : number) => {
-		uni.navigateTo({
-			url: `/pages/work/record/InfoDetail?id=${id}`
-		});
-	}
+  }
+  
+  const enterItem = (id : number) => {
+    uni.navigateTo({
+      url: `/pages/work/record/InfoDetail?id=${id}`
+    });
+  }
+  
+  // 扫描二维码功能
+  const scanQRCode = () => {
+    uni.scanCode({
+      success: (res) => {
+        // 扫描成功,将结果填充到输入框
+        productNo.value = res.result;
+        console.log('扫描结果:', res.result);
+      },
+      fail: (err) => {
+        console.error('扫描失败:', err);
+        uni.showToast({
+          title: '扫描失败,请重试',
+          icon: 'error'
+        });
+      }
+    });
+  }
 
-	defineExpose({
-		backPressOptions
-	})
+  defineExpose({
+    backPressOptions
+  })
 </script>
 
 <style scope>
-	.container {
-		padding: 24rpx;
-		background-color: #f0f4f8;
-		flex: 1;
-		display: flex;
-		flex-direction: column;
-		font-family: "PingFang SC", "Helvetica Neue", Helvetica, Arial, sans-serif;
-		/* #ifndef APP-ANDROID */
-		min-height: 100vh;
-		/* #endif */
-		height: 120rpx;
-	}
+  .container {
+    padding: 24rpx;
+    background-color: #f0f4f8;
+    flex: 1;
+    display: flex;
+    flex-direction: column;
+    font-family: "PingFang SC", "Helvetica Neue", Helvetica, Arial, sans-serif;
+    /* #ifndef APP-ANDROID */
+    min-height: 100vh;
+    /* #endif */
+    height: 120rpx;
+  }
 
-	.download-card {
-		background: #ffffff;
-		border-radius: 20rpx;
-		padding: 24rpx 32rpx;
-		box-shadow: 0 8rpx 15rpx rgba(0, 43, 92, 0.1);
-		display: flex;
-		flex-direction: column;
-		margin-bottom: 20rpx;
-		margin-top: 40rpx;
-		margin-left: 20rpx;
-		margin-right: 20rpx;
-	}
+  .search-bar {
+	  background-color: #ffffff;
+	  border-radius: 10rpx;
+	  box-shadow: 0 2rpx 10rpx rgba(0, 0, 0, 0.1);
+}
 
-	.download-card .view {
-		margin-bottom: 16rpx;
+/* 搜索输入框:占满容器剩余空间,放在按钮左侧 */
+	.search-input {
+	  /* 清除默认输入框样式 */
+	  border: none;
+	  background: transparent;
+	  width: 70%;
+	  margin-left: 10rpx;
 	}
 
-	/* 信息行 */
-	.info-row {
-		display: flex;
-		flex-direction: row;
-		font-size: 28rpx;
-		color: #33475b;
-		align-items: center;
+/* 扫描按钮:放在输入框右侧,距离最右10rpx */
+	.scan-btn {
+	  justify-content: center;
+	  align-items: center; /* 新增:按钮内部图标垂直居中 */
+	  /* 关键:右侧10rpx边距,实现"距离最右10rpx" */
+	  margin-left: auto; /* 自动推到flex容器最右侧 */
+	  margin-right: 10rpx; /* 与容器右边缘保持10rpx间距 */
 	}
 
-	.info-row>.label {
-		margin-left: 10rpx;
-	}
+  .download-card {
+    background: #ffffff;
+    border-radius: 20rpx;
+    padding: 24rpx 32rpx;
+    box-shadow: 0 8rpx 15rpx rgba(0, 43, 92, 0.1);
+    display: flex;
+    flex-direction: column;
+    margin-bottom: 20rpx;
+    margin-top: 40rpx;
+    margin-left: 20rpx;
+    margin-right: 20rpx;
+  }
 
-	.info-row>.value {
-		margin-left: 10rpx;
-	}
+  .download-card .view {
+    margin-bottom: 16rpx;
+  }
 
-	.btn-panel {
-		display: flex;
-		justify-content: space-between;
-		align-items: center;
-		margin-left: 5rpx;
-		margin-right: 5rpx;
-	}
+  /* 信息行 */
+  .info-row {
+    display: flex;
+    flex-direction: row;
+    font-size: 28rpx;
+    color: #33475b;
+    align-items: center;
+  }
 
-	.label {
-		font-weight: bold;
-		color: #102a43;
-		min-width: 100rpx;
-	}
+  .info-row>.label {
+    margin-left: 10rpx;
+  }
 
-	.value {
-		flex: 1;
-		white-space: nowrap;
-		overflow: hidden;
-		text-overflow: ellipsis;
-	}
+  .info-row>.value {
+    margin-left: 10rpx;
+  }
 
-	.btn {
-		align-self: flex-end;
-		background-color: #00aaff;
-		color: #fff;
-		border: none;
-		border-radius: 32rpx;
-		padding: 2rpx 30rpx;
-		font-size: 24rpx;
-		font-weight: bold;
-		/* #ifndef APP-ANDROID */
-		transition: background-color 0.3s ease;
-		/* #endif */
-		margin-top: 30rpx;
-	}
+  .btn-panel {
+    display: flex;
+    justify-content: space-between;
+    align-items: center;
+    margin-left: 5rpx;
+    margin-right: 5rpx;
+  }
 
-	.process-value {
-		width: 120rpx;
-		min-width: 100rpx;
-		text-align: center;
-		border-radius: 10rpx;
-	}
+  .label {
+    font-weight: bold;
+    color: #102a43;
+    min-width: 100rpx;
+  }
 
-	.bg-green {
-		background-color: seagreen;
-	}
+  .value {
+    flex: 1;
+    white-space: nowrap;
+    overflow: hidden;
+    text-overflow: ellipsis;
+  }
 
-	.bg-yellow {
-		background-color: yellow;
-	}
+  .btn {
+    align-self: flex-end;
+    background-color: #00aaff;
+    color: #fff;
+    border: none;
+    border-radius: 32rpx;
+    padding: 2rpx 30rpx;
+    font-size: 24rpx;
+    font-weight: bold;
+    /* #ifndef APP-ANDROID */
+    transition: background-color 0.3s ease;
+    /* #endif */
+    margin-top: 30rpx;
+  }
 
-	.bg-black {
-		background-color: #102a43;
-	}
+  .process-value {
+    width: 120rpx;
+    min-width: 100rpx;
+    text-align: center;
+    border-radius: 10rpx;
+  }
 
-	.btn-first {
-		margin-left: 5rpx;
-	}
+  .bg-green {
+    background-color: seagreen;
+  }
 
-	.btn-second {
-		margin-right: 5rpx;
-	}
+  .bg-yellow {
+    background-color: yellow;
+  }
+
+  .bg-black {
+    background-color: #102a43;
+  }
+
+  .btn-first {
+    margin-left: 5rpx;
+  }
+
+  .btn-second {
+    margin-right: 5rpx;
+  }
+  
 </style>

+ 25 - 0
utils/auth.uts

@@ -1,3 +1,5 @@
+import storage from '@/utils/storage';
+import {constant} from '@/utils/constant';
 const TokenKey = 'App-Token'
 
 export function getToken():string {
@@ -11,3 +13,26 @@ export function setToken(token:string):void {
 export function removeToken():void {
   return uni.removeStorageSync(TokenKey)
 }
+
+
+export function getTokenFromApi():Promise<string> {
+	console.log(`http://192.168.43.62:4523/m1/7190626-6915798-default/m1/getToken?username=${storage.getString(constant.name)}`)
+	return new Promise<string>((resolve) =>{
+		uni.request({
+			url: `http://192.168.43.62:4523/m1/7190626-6915798-default/m1/getToken?username=${storage.getString(constant.name)}`,
+			method: "GET",
+			timeout: 30000,
+			success: (res) => {
+				let tokenObj = res?.['data'] as UTSJSONObject ?? {} as UTSJSONObject
+				console.log(tokenObj?.['token']);
+				storage.set("ApiToken", tokenObj?.['token'])
+				resolve(tokenObj?.['token'] as string);
+			},
+			fail: (err) => {
+				console.error('获取Token失败:', err);
+				uni.showToast({ title: `获取Token失败: ${err.errMsg},请联系技术IT`, icon: 'error' });
+				resolve("");
+			},
+		})
+	})
+}

+ 87 - 82
utils/dataProcessor.uts

@@ -1,4 +1,4 @@
-import { getToken } from './auth'
+import { getToken, getTokenFromApi } from './auth'
 import { saveMediaInfo, saveMediaRecord } from '@/api/work'
 
 // 类型定义保持不变
@@ -43,87 +43,92 @@ export type MediaRecordData = {
 }
 
 export const downloadDataFromAPI = async (callback ?: () => void) : Promise<boolean> => {
-	try {
-		uni.showLoading({ title: '数据下载中...' })
+  try {
+    const apiToken = await getTokenFromApi();
+    uni.showLoading({ title: '数据下载中...' })
 
-		return new Promise<boolean>((resolve) => {
+    return new Promise<boolean>((resolve) => {
+      //http://127.0.0.1:4523/m1/7190626-6915798-default/m1/download
+      uni.request({
+        url: 'http://192.168.43.62:4523/m1/7190626-6915798-default/loadQmImagetask?prodcode=YH07202507000005',
+        method: 'GET',
+        header: {
+          'token': apiToken
+        },
+        success: (res) => {
+          console.log('请求成功:', res);
+          console.log('token', apiToken);
+          console.log(res.data);
+          let singleObject = res?.['data'] as UTSJSONObject ?? {} as UTSJSONObject
+          if (singleObject != null && singleObject.code == 666) {
+            let mediaInfoList = singleObject?.['data'] as UTSJSONObject[] ?? Array<UTSJSONObject>()
+            if (mediaInfoList != null && mediaInfoList.length > 0) {
+              mediaInfoList.forEach(item => {
+                if (item != null) {
+                  let data = JSON.parse<MediaInfoData>(item.toJSONString());
+                  if (data != null) {
+                    saveMediaInfo(item).then((res : UTSJSONObject) => {
+                      const lastIdStr = res?.['lastId'] as string | null;
+                      const lastId = lastIdStr != null ? parseInt(lastIdStr) : null;
+                      if (lastId != null) {
+                        let recordList = data?.['qmImageTaskClist'] as UTSJSONObject[] ?? Array<UTSJSONObject>()
+                        console.log(recordList)
+                        if (recordList != null && recordList.length > 0) {
+                          for(var i =0; i< recordList.length; i++) {
+                            // 将recordList[i]断言为MediaRecordData类型
+                            const record: MediaRecordData = recordList[i] as MediaRecordData;
+                            console.log('完整对象:', record);
+                             
+                            // 获取各个字段的值
+                            const senum = record.senum; // string类型
+                            const photoitem = record.photoitem; // string类型
+                            const part = record.part; // string类型
+                            const partno = record.partno; // string类型
+                            const descb = record.descb; // string类型
+                            const num = record.num; // number类型
+                            const urlspl = record.urlspl; // string类型
+                            const imgname = record.imgname; // string类型
+                            const urlpdt = record.urlpdt; // string类型
+                            const createtime = record.createtime; // string类型
+                            const createuser = record.createuser; // string类型
+                            const updatetime = record.updatetime; // string类型
+                            const updateuser = record.updateuser; // string类型
 
-			uni.request({
-				url: 'http://192.168.5.124:4523/m2/6802511-6516056-default/324225181',
-				method: 'GET',
-				success: (res) => {
-					console.log('请求成功:', res);
-					console.log(res.data);
-					let singleObject = res?.['data'] as UTSJSONObject ?? {} as UTSJSONObject
-					if (singleObject != null && singleObject.code == 666) {
-						let mediaInfoList = singleObject?.['data'] as UTSJSONObject[] ?? Array<UTSJSONObject>()
-						if (mediaInfoList != null && mediaInfoList.length > 0) {
-							mediaInfoList.forEach(item => {
-								if (item != null) {
-									let data = JSON.parse<MediaInfoData>(item.toJSONString());
-									if (data != null) {
-										saveMediaInfo(item).then((res : UTSJSONObject) => {
-											const lastIdStr = res?.['lastId'] as string | null;
-											const lastId = lastIdStr != null ? parseInt(lastIdStr) : null;
-											if (lastId != null) {
-												let recordList = data?.['qmImageTaskClist'] as UTSJSONObject[] ?? Array<UTSJSONObject>()
-												console.log(recordList)
-												if (recordList != null && recordList.length > 0) {
-													for(var i =0; i< recordList.length; i++) {
-														// 将recordList[i]断言为MediaRecordData类型
-														const record: MediaRecordData = recordList[i] as MediaRecordData;
-														console.log('完整对象:', record);
-														 
-														// 获取各个字段的值
-														const senum = record.senum; // string类型
-														const photoitem = record.photoitem; // string类型
-														const part = record.part; // string类型
-														const partno = record.partno; // string类型
-														const descb = record.descb; // string类型
-														const num = record.num; // number类型
-														const urlspl = record.urlspl; // string类型
-														const imgname = record.imgname; // string类型
-														const urlpdt = record.urlpdt; // string类型
-														const createtime = record.createtime; // string类型
-														const createuser = record.createuser; // string类型
-														const updatetime = record.updatetime; // string类型
-														const updateuser = record.updateuser; // string类型
-
-														//senum,photoitem,productno,part,partno,descb,num,status,date,urlspl,imgname,urlpdt,createtime,createuser,updatetime,updateuser,pid
-														// 使用三目运算符判断,当值为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}'`},${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)
-														uni.showToast({ title: `下载完成`, icon: 'success' });
-													}
-												}
-											} else {
-												console.log('保存媒体信息成功,但未获取到主键ID');
-											}
-										})
-									}
-								}
-							});
-						}
-					} else {
-						uni.showToast({ title: `请求失败: ${singleObject.msg}`, icon: 'error' });
-					}
-					resolve(true);
-				},
-				fail: (err) => {
-					console.error('请求失败:', err);
-					uni.showToast({ title: `请求失败: ${err.errMsg}`, icon: 'error' });
-					resolve(false);
-				},
-				complete: () => {
-					console.log('请求完成');
-					uni.hideLoading();
-				}
-			});
-		});
-	} catch (error) {
-		console.error('下载数据总异常:', error);
-		uni.showToast({ title: '下载失败,请重试', icon: 'error' });
-		uni.hideLoading();
-		return false;
-	}
+                            //senum,photoitem,productno,part,partno,descb,num,status,date,urlspl,imgname,urlpdt,createtime,createuser,updatetime,updateuser,pid
+                            // 使用三目运算符判断,当值为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}'`},${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)
+                            uni.showToast({ title: `下载完成`, icon: 'success' });
+                          }
+                        }
+                      } else {
+                        console.log('保存媒体信息成功,但未获取到主键ID');
+                      }
+                    })
+                  }
+                }
+              });
+            }
+          } else {
+            uni.showToast({ title: `请求失败: ${singleObject.msg}`, icon: 'error' });
+          }
+          resolve(true);
+        },
+        fail: (err) => {
+          console.error('请求失败:', err);
+          uni.showToast({ title: `请求失败: ${err.errMsg}`, icon: 'error' });
+          resolve(false);
+        },
+        complete: () => {
+          console.log('请求完成');
+          uni.hideLoading();
+        }
+      });
+    });
+  } catch (error) {
+    console.error('下载数据总异常:', error);
+    uni.showToast({ title: '下载失败,请重试', icon: 'error' });
+    uni.hideLoading();
+    return false;
+  }
 }