chensibo hace 2 semanas
padre
commit
ac9eec279b

+ 1 - 1
pages/workbranch/warehouse/Inventory/inventoryPage.vue

@@ -19,7 +19,7 @@
 						<view class="search-select">
 							<picker @change="onBusinessTypeChange" :range="businessTypeList" range-key="text" :value="businessTypeIndex">
 								<view class="picker-text">{{ businessTypeList[businessTypeIndex]?.text || '请选择业务类型' }}</view>
-							</picker>
+							</picker>	
 						</view>
 					</view> -->
 					<view class="search-item">

+ 117 - 193
pages/workbranch/warehouse/materialRegister/Scan/materialScanRegister.vue

@@ -5,14 +5,10 @@
 		<template #gHeader>
 			<view :style="[isLandscapeScreen?'height:44px;width: 100vmax':'height:44px;']"
 				class="gui-flex gui-nowrap gui-rows gui-align-items-center">
-				<!-- 使用组件实现返回按钮及返回首页按钮 -->
 				<text style="font-size:44rpx;" class="gui-header-leader-btns gui-color-white font-icons"
 					@tap="goBack">&#xe6c5;</text>
-				<!-- 导航文本此处也可以是其他自定义内容 -->
 				<text
 					class="gui-h4 gui-blod gui-flex1 gui-text-center gui-color-white gui-ellipsis gui-primary-text">来料登记</text>
-				<!-- 此处加一个右侧展位元素与左侧同宽,实现标题居中 -->
-				<!-- 实际宽度请根据自己情况设置 -->
 				<view style="width:40px;" />
 			</view>
 		</template>
@@ -54,20 +50,11 @@
 						<text class="font-icons" @click="handleMapass"></text>
 					</view>
 				</view>
-				<!-- <view v-if="scanParams.deliveryOrderNo" class="row">
-					<view class="row-card">
-						<uni-easyinput ref="easyinput2" v-model="scanParams.deliverBatch" :input-border="false"
-							:clearable="false" type="text" @focus="handleInputFocus" placeholder="扫描物料条码"
-							@confirm="confirmMaterial" />
-						<text class="font-icons" @click="handleScanMaterial"></text>
-					</view>
-				</view> -->
 				<view class="table-title">
 					<span>需求清单</span>
 				</view>
 				<view class="custom-table">
 					<uni-table border stripe empty-text="暂无更多数据">
-						<!-- 表头行 -->
 						<uni-tr class="custom-table-head">
 							<uni-th align="center" width="80px">箱数</uni-th>
 							<uni-th align="center" width="80px">每箱数量</uni-th>
@@ -78,11 +65,9 @@
 							<uni-th align="center" width="140px">送货批次</uni-th>
 							<uni-th align="center" width="180px">生产日期</uni-th>
 						</uni-tr>
-						<!-- 表格数据行 -->
 						<uni-tr v-for="(item, key) in scanParams.detail" :key="key">
 							<uni-td align="center"
 								:style="item.state? 'background-color: rgba(109, 205, 50, 1);color: white;': ''">
-								<!-- 不可修改:disabled="true" -->
 								<uni-easyinput v-model="item.bagQty" type="number" :input-border="false" placeholder="请输入箱数" @input="handleBagQtyChange" :disabled="true" />
 							</uni-td>
 							<uni-td align="center"
@@ -99,12 +84,6 @@
 								:style="item.state? 'background-color: rgba(109, 205, 50, 1);color: white;': ''">{{ item.deliverBatch }}</uni-td>
 							<uni-td align="center"
 								:style="item.state? 'background-color: rgba(109, 205, 50, 1);color: white;': ''">
-								<!-- 时间选择功能,暂时注释掉 -->
-								<!-- <uni-datetime-picker 
-        							v-model="item.produceDate" 
-        							type="datetime" 
-        							:border="false"
-        							placeholder="选择日期时间" /> -->
 								<uni-datetime-picker 
         							v-model="item.produceDate" 
         							type="date" 
@@ -115,7 +94,6 @@
 					</uni-table>
 				</view>
 				<gui-right-menus>
-					<!-- 扩展按钮 -->
 					<template #menus-more>
 						<view hover-class="gui-tap"
 							class="menu-items gui-bg-green gui-flex gui-columns gui-justify-content-center"
@@ -128,7 +106,6 @@
 							<text class="menu-text gui-block gui-text-center gui-color-white">登记记录</text>
 						</view>
 					</template>
-					<!-- 核心按钮 -->
 					<template #menus-primary>
 						<view class="menu-items gui-bg-primary gui-flex gui-columns gui-justify-content-center">
 							<text class="menu-icon gui-color-white gui-block gui-text-center gui-icons"></text>
@@ -180,72 +157,43 @@
 		})
 		const scanTypeList = ref([])
 
+			// ========== 送货单扫码(改用 uni.scanCode)==========
 			const handleMapass = function() {
-				// uni.$reqGet("scanDeliveryOrderNo", {
-				// 		deliveryOrderNo: "CGSH230907000007"
-				// 	})
-				// 	.then(({
-				// 		code,
-				// 		data,
-				// 		msg
-				// 	}) => {
-				// 		if (code === 0) {
-				// 			Object.assign(scanParams.value, data);
-				// 			// 给箱数补默认值
-				// 			scanParams.value.detail.forEach(item => {
-				// 				if (item.bagQty == null || item.bagQty === '') item.bagQty = 1
-				// 			})
-				// 			setInputFocus2();
-				// 		} else {
-				// 			// #ifdef APP-PLUS
-				// 			plus.device.beep(2);
-				// 			// #endif
-				// 			errorTipMessage.value = msg;
-				// 			errorTip.value.open();
-				// 			errorState.value = 0;
-				// 		}
-				// 	})
-				// #ifdef APP-PLUS
-				const mpaasScanModule = uni.requireNativePlugin('Mpaas-Scan-Module')
-				mpaasScanModule.mpaasScan({
-						// 扫码识别类型,参数可多选,qrCode、barCode,不设置,默认识别所有
-						'scanType': ['qrCode', 'barCode'],
-						// 是否隐藏相册,默认false不隐藏
-						'hideAlbum': false
+				if (!scanParams.value.scanType) {
+					uni.showToast({ title: '请先选择扫码类型', icon: 'none' });
+					return;
+				}
+				
+				uni.scanCode({
+					success: function(res) {
+						const deliveryOrderNo = res.result;
+						
+						uni.$reqGet('scanDeliveryOrderNo', {
+							deliveryOrderNo: deliveryOrderNo,
+							tableName: scanParams.value.scanType
+						})
+						.then(({ code, data, msg }) => {
+							if (code === 0) {
+								Object.assign(scanParams.value, data);
+								scanParams.value.detail.forEach(item => {
+									if (item.bagQty == null || item.bagQty === '') item.bagQty = 1;
+								});
+								setInputFocus2();
+							} else {
+								// #ifdef APP-PLUS
+								plus.device.beep(2);
+								// #endif
+								errorTipMessage.value = msg;
+								errorTip.value.open();
+								errorState.value = 0;
+							}
+						});
 					},
-					(ret) => {
-						// errorTipMessage.value = ret.resp_code + "-" + ret.resp_result;
-						// errorTip.value.open();
-						// errorState.value = -1;
-						if (ret.resp_code === 1000) {
-							uni.$reqGet('scanDeliveryOrderNo', {
-									deliveryOrderNo: ret.resp_result,
-									tableName: scanParams.value.scanType
-								})
-								.then(({
-									code,
-									data,
-									msg
-								}) => {
-									if (code === 0) {
-									Object.assign(scanParams.value, data)
-									// 给箱数补默认值
-									scanParams.value.detail.forEach(item => {
-										if (item.bagQty == null || item.bagQty === '') item.bagQty = 1
-									})
-									setInputFocus2()
-									} else {
-										// #ifdef APP-PLUS
-										plus.device.beep(2)
-										// #endif
-										errorTipMessage.value = msg
-										errorTip.value.open()
-										errorState.value = 0
-									}
-								})
-						}
-					})
-				// #endif
+					fail: function(err) {
+						console.log('扫码失败', err);
+						uni.showToast({ title: '扫码失败', icon: 'none' });
+					}
+				});
 			}
 
 			// 扫描送货单输入框回车事件
@@ -260,12 +208,11 @@
 						msg
 					}) => {
 						if (code === 0) {
-											Object.assign(scanParams.value, data)
-											// 给箱数补默认值
-											scanParams.value.detail.forEach(item => {
-												if (item.bagQty == null || item.bagQty === '') item.bagQty = 1
-											})
-											setInputFocus2()
+							Object.assign(scanParams.value, data)
+							scanParams.value.detail.forEach(item => {
+								if (item.bagQty == null || item.bagQty === '') item.bagQty = 1
+							})
+							setInputFocus2()
 						} else {
 							// #ifdef APP-PLUS
 							plus.device.beep(2)
@@ -277,58 +224,47 @@
 					})
 			}
 
+			// ========== 物料扫码(同样改用 uni.scanCode)==========
 			const handleScanMaterial = function() {
-				// #ifdef APP-PLUS
-				const mpaasScanModule = uni.requireNativePlugin('Mpaas-Scan-Module')
-				mpaasScanModule.mpaasScan({
-						// 扫码识别类型,参数可多选,qrCode、barCode,不设置,默认识别所有
-						'scanType': ['qrCode', 'barCode'],
-						// 是否隐藏相册,默认false不隐藏
-						'hideAlbum': false
-					},
-					(ret) => {
-						if (ret.resp_code === 1000) {
-							uni.$reqGet('scanRegisterMaterial', {
-									batchNumber: ret.resp_result
-								})
-								.then(({
-									code,
-									data,
-									msg
-								}) => {
-									scanParams.value.deliverBatch = data?.deliverBatch
-									if (code === 0) {
-										fdIndex.value = scanParams.value.detail.findIndex(item => item
-											?.deliverBatch ===
-											data?.deliverBatch)
-										if (fdIndex.value !== -1) {
-											if (data?.ifExpired === 1) {
-												// 物料超过保质期
-												modalForm.value.open()
-											} else {
-												setInputFocus2()
-												scanParams.value.detail[fdIndex.value].state = true
-											}
-										} else {
-											// #ifdef APP-PLUS
-											plus.device.beep(2)
-											// #endif
-											errorTipMessage.value = '请扫描正确的物料'
-											errorTip.value.open()
-											errorState.value = 1
-										}
+				uni.scanCode({
+					success: function(res) {
+						uni.$reqGet('scanRegisterMaterial', {
+							batchNumber: res.result
+						})
+						.then(({ code, data, msg }) => {
+							scanParams.value.deliverBatch = data?.deliverBatch
+							if (code === 0) {
+								fdIndex.value = scanParams.value.detail.findIndex(item => item?.deliverBatch === data?.deliverBatch)
+								if (fdIndex.value !== -1) {
+									if (data?.ifExpired === 1) {
+										modalForm.value.open()
 									} else {
-										// #ifdef APP-PLUS
-										plus.device.beep(2)
-										// #endif
-										errorTipMessage.value = msg
-										errorTip.value.open()
-										errorState.value = 1
+										setInputFocus2()
+										scanParams.value.detail[fdIndex.value].state = true
 									}
-								})
-						}
-					})
-				// #endif
+								} else {
+									// #ifdef APP-PLUS
+									plus.device.beep(2)
+									// #endif
+									errorTipMessage.value = '请扫描正确的物料'
+									errorTip.value.open()
+									errorState.value = 1
+								}
+							} else {
+								// #ifdef APP-PLUS
+								plus.device.beep(2)
+								// #endif
+								errorTipMessage.value = msg
+								errorTip.value.open()
+								errorState.value = 1
+							}
+						})
+					},
+					fail: function(err) {
+						console.log('扫码失败', err)
+						uni.showToast({ title: '扫码失败', icon: 'none' })
+					}
+				})
 			}
 
 			// 扫描物料输入框回车事件
@@ -348,7 +284,6 @@
 								data?.deliverBatch)
 							if (fdIndex.value !== -1) {
 								if (data?.ifExpired === 1) {
-									// 物料超过保质期
 									modalForm.value.open()
 								} else {
 									setInputFocus2()
@@ -404,12 +339,9 @@
 						mask: true
 					})
 
-					// 深拷贝参数对象
 					const requestParams = JSON.parse(JSON.stringify(scanParams.value))
-					// 转换生产日期为时间戳
 					requestParams.detail.forEach(item => {
 						if (item.produceDate) {
-							// 将日期字符串转换为时间戳
 							item.produceDate = new Date(item.produceDate).getTime()
 						}
 					})
@@ -484,59 +416,51 @@
 				easyinput2.value.onFocus()
 			}
 
-			// 关闭错误信息弹窗
-		const handleCloseErrorTipsModal = async function() {
-		errorTip.value.close()
-		if (errorState.value === 0) {
-			await setInputFocus()
-		} else if (errorState.value === 1) {
-			await setInputFocus2()
-		}
-	}
+			const handleCloseErrorTipsModal = async function() {
+				errorTip.value.close()
+				if (errorState.value === 0) {
+					await setInputFocus()
+				} else if (errorState.value === 1) {
+					await setInputFocus2()
+				}
+			}
 
-		// 计算总数量
-		const calculateTotalQty = function(item) {
-			const bagQty = item.bagQty || 1
-			const receiptQty = item.receiptQty || 0
-			return bagQty * receiptQty
-		}
+			const calculateTotalQty = function(item) {
+				const bagQty = item.bagQty || 1
+				const receiptQty = item.receiptQty || 0
+				return bagQty * receiptQty
+			}
 
-		// 处理箱数变化
-		const handleBagQtyChange = function() {
-			// 当箱数变化时,Vue的响应式会自动触发calculateTotalQty的重新计算
-		}
+			const handleBagQtyChange = function() {}
 
-		// 禁用软键盘
-		const handleInputFocus = function() {
-			setTimeout(() => {
-				uni.hideKeyboard()
-			}, 100)
-		}
+			const handleInputFocus = function() {
+				setTimeout(() => {
+					uni.hideKeyboard()
+				}, 100)
+			}
 
-		// 计算属性:获取扫码类型的中文标签
-		const scanTypeLabel = computed(() => {
-			if (!scanParams.value.scanType) return '未选择'
-			const typeItem = scanTypeList.value.find(item => item.value === scanParams.value.scanType)
-			return typeItem ? typeItem.text : scanParams.value.scanType
-		})
+			const scanTypeLabel = computed(() => {
+				if (!scanParams.value.scanType) return '未选择'
+				const typeItem = scanTypeList.value.find(item => item.value === scanParams.value.scanType)
+				return typeItem ? typeItem.text : scanParams.value.scanType
+			})
 
-		onMounted(() => {
-			// 获取扫码类型字典数据
-			uni.$reqGet('getDictDataPage', {
-				dictType: 'srm_tablename_type', // 使用字典编码418
-				pageNo: 1,
-				pageSize: 100
-			}).then(({ data }) => {
-				scanTypeList.value = []
-				const dataList = data?.list || [];
-				for (var i = 0; i < dataList.length; i++) {
-					scanTypeList.value.push({
-						text: dataList[i].label,
-						value: dataList[i].value,
-					})
-				}
+			onMounted(() => {
+				uni.$reqGet('getDictDataPage', {
+					dictType: 'srm_tablename_type',
+					pageNo: 1,
+					pageSize: 100
+				}).then(({ data }) => {
+					scanTypeList.value = []
+					const dataList = data?.list || [];
+					for (var i = 0; i < dataList.length; i++) {
+						scanTypeList.value.push({
+							text: dataList[i].label,
+							value: dataList[i].value,
+						})
+					}
+				})
 			})
-		})
 
 			return {
 				goBack,

+ 1 - 1
pages/workbranch/warehouse/scanInOut/In/scannedMaterials.vue

@@ -1478,4 +1478,4 @@ onShow(() => {
 	//   line-height: 1.2;
 	//   padding: 4px 2px;          /* 上下留一点空隙,视觉更舒服 */
 	// }
-</style>
+</style>