Browse Source

调拨生成代码测试

ZL 5 days ago
parent
commit
805344544d

+ 41 - 23
pages/direct-transfer/index.vue

@@ -80,7 +80,7 @@
 						</view>
 						<view class="table-cell2">{{ item["FCMKBarCode"] }}</view>
 						<view class="table-cell2">{{ item["FStockName"] }}</view>
-						<view class="table-cell2">{{ item["FStockId.FName"] }}</view>
+						<view class="table-cell2">{{ item["FDestStockLocId.FF102029.FNumber"] }}</view>
 
 					</view>
 				</view>
@@ -388,7 +388,13 @@
 				this.isFocus = true;
 				this.isStage = true
 			})
-
+			uni.$on('selectStock', (data) => {
+				const index = this.indexList.findIndex(item => item.FCMKBarCode === data.FCMKBarCode);
+				if (index !== -1) {
+					this.indexList[index] = data;
+				}
+				console.log(this.indexList)
+			})
 			this.$nextTick(() => {
 				console.log('dddd')
 				this.searchValue = ''
@@ -532,6 +538,13 @@
 				this.focusPoint()
 			},
 			submit() {
+				//检查仓位是否都已选择
+				const isOK = this.indexList.every(item => item['FDestStockLocId.FF102029.FNumber'] && item[
+					'FDestStockLocId.FF102029.FNumber'].trim() !== '');
+				if (!isOK) {
+					modal.showToast("存在未选择的调入仓位!")
+					return
+				}
 				let vm = this
 				uni.showModal({
 					title: "提示",
@@ -550,15 +563,7 @@
 						}
 					}
 				})
-				//重置页面
-				// {
-				// 	this.depotList = []
-				// 	this.indexList = []
-				// 	this.searchValue = ""
-				// 	this.balance = 0
-				// 	this.isFocus = true
-				// 	playVoice(audioUrls.warningSuccessUrl)
-				// }
+
 			},
 			//跳转到查询页面
 			navigateToSearch() {
@@ -670,7 +675,15 @@
 				const FormId = uni.getStorageSync('formId')
 				try {
 					await submitHelper.createSubmit(FormId, this.indexList);
-					this.indexList = [];
+					//重置页面
+					{
+						this.depotList = []
+						this.indexList = []
+						this.searchValue = ""
+						this.balance = 0
+						this.isFocus = true
+						playVoice(audioUrls.warningSuccessUrl)
+					}
 					console.log("提交成功!this.indexList已清空");
 				} catch (error) {
 					this.handleError(error)
@@ -784,8 +797,6 @@
 			CreateScanSuccess(nowindex) {
 				console.log("扫描完成开始渲染------------", nowindex)
 				this.indexList[nowindex].smzt = 1
-				this.indexList[nowindex]['FStockId.FNumber'] = 'MLCK006'
-				this.indexList[nowindex]['FStockLocId.FF102029.FNumber'] = '301100206'
 				// this.$forceUpdate()
 				this.$nextTick(() => {
 					console.log("准备刷新---------------", this.indexList)
@@ -813,13 +824,19 @@
 				//校验是否重复扫码
 				const isDuplicate = this.indexList.some(item => item.FCMKBarCode === info.FCMKBarCode);
 				if (isDuplicate) {
-					this.$nextTick(() => {
-						console.log("重复扫码---------------", this.indexList)
-						this.searchValue = ''
-						playVoice(audioUrls.successVoiceUrl);
-						this.focusPoint()
+					uni.showModal({
+						title: '提示',
+						content: "该条形码已扫描!",
+						showCancel: false,
+						success: function(res) {
+							if (res.confirm) {
+								this.focusPoint()
+								vm.searchValue = ''
+								return
+							}
+						}.bind(this)
 					})
-
+					playVoice(audioUrls.successVoiceUrl)
 					return;
 				}
 				modal.loading('扫描数据中,请耐心等待...')
@@ -848,7 +865,7 @@
 					Object.assign(info, lot)
 					//根据编码批号找即时库存
 					const stockLoc = await this.getStockLoc(lot["FLot.FNumber"], lot["FMaterialId.FNumber"])
-					if (!stockLoc) {
+					if (!stockLoc || stockLoc.length == 0) {
 						uni.showModal({
 							title: '提示',
 							content: "未查询到即时库存信息!",
@@ -872,6 +889,7 @@
 						console.log("进行仓位选择--------------------", stockLoc)
 						this.depotList = [stockLoc]
 						this.showPicker = true
+						info.index = this.indexList.length
 						this.indexList.push(info)
 					} else {
 						info.index = this.indexList.length
@@ -983,12 +1001,12 @@
 			},
 			async getStockLoc(lot, material) {
 				const searchParam = getInventory(lot, material)
-				return getBillList(JSON.stringify(searchParam))
+				let ress = await getBillList(JSON.stringify(searchParam))
+				return ress
 
 			},
 			pickDepot(e) {
 				console.log('confirm', e)
-				this.Location = e.value[0]
 				const selectedValue = e.value[0];
 				if (this.indexList.length > 0) {
 					this.$set(this.indexList, this.indexList.length - 1, {

+ 0 - 14
pages/direct-transfer/search.vue

@@ -152,20 +152,6 @@
 						}
 					})
 				}
-				// getBillDetailList(JSON.stringify(billDetailListParam)).then(
-				// 	res => {
-				// 		console.log(res)
-				// 		this.BillDetailList = res
-				// 		uni.navigateBack({
-				// 			success: function() {
-				// 				// 传递数据给上一页
-				// 				uni.$emit('search', self.BillDetailList);
-				// 			}
-				// 		});
-
-				// 	}
-				// )
-
 			},
 			// 返回上一页并传递数据
 			navigateBack() {

+ 284 - 26
pages/direct-transfer/show.vue

@@ -1,37 +1,79 @@
 <template>
 	<view>
-		<uni-section title="">
-			<view class="example">
-				<uni-forms ref="form" :modelValue="item" labelWidth="80px" :rules="rules">
-					<uni-forms-item label="装箱单号" name="FBillNo" v-if="isCreate">
-						<uni-easyinput v-model="item['FENCHASENUM.LT']" disabled>
-						</uni-easyinput>
-					</uni-forms-item>
-
-					<uni-forms-item label="调拨数量" name="FQty" v-if="isCreate">
-						<uni-easyinput v-model="item['FQty']" />
-					</uni-forms-item>
-
-					<uni-forms-item label="调入仓位" name="FQty" v-if="!isCreate">
-						<uni-data-select v-model="destStock" :localdata="destStockList" ></uni-data-select>
-					</uni-forms-item>
-				</uni-forms>
-				<button type="primary" @click="submit()">确认</button>
+		<view v-if="!isCreate">
+			<uni-section title="">
+				<view class="example">
+					<uni-forms ref="form" :modelValue="item" labelWidth="80px" :rules="rules">
+						<uni-forms-item label="装箱单号" name="FBillNo">
+							<uni-easyinput v-model="item['FENCHASENUM.LT']" disabled>
+							</uni-easyinput>
+						</uni-forms-item>
+						<uni-forms-item label="调拨数量" name="FQty">
+							<uni-easyinput v-model="item['FQty']" />
+						</uni-forms-item>
+					</uni-forms>
+					<button type="primary" @click="submit()">确认</button>
+				</view>
+			</uni-section>
+		</view>
+
+		<view class="table-container" v-else>
+			<!-- 查询框 -->
+			<view class="container">
+				<view class="search-container">
+					<uni-easyinput prefixIcon="search" v-model="stockLocNum" placeholder="请输入仓位"
+						style="margin-right: 5px;">
+					</uni-easyinput>
+					<button class="search-button" @click="search">查询</button>
+				</view>
+				<!-- <view style="padding:0 5px 2px 5px;">
+						<uni-datetime-picker v-model="range" type="daterange" @maskClick="maskClick" />
+					</view> -->
+			</view>
+			<!-- 表格容器 -->
+			<scroll-view class="table-scroll" scroll-y @scroll="onScroll">
+				<!-- 表头 -->
+				<view class="table-header" ref="tableHeader">
+					<view class="table-cell1">仓位编号</view>
+				</view>
+				<!-- 表格内容 -->
+				<view class="table-body">
+					<view class="table-row" v-for="(item, index) in stockList" :key="item.FStockLocNum">
+						<view class="checkbox-container">
+							<checkbox :value="item.FStockLocNum" :checked="item.checked"
+								@tap="handleCheckboxClick(item.FStockLocNum)" />
+							<view style="display: flex; justify-content: center; align-items: center;">
+								{{ item.FStockLocNum}}({{item.FQty}})
+							</view>
+						</view>
+					</view>
+				</view>
+			</scroll-view>
+
+			<!-- 底部按钮 -->
+			<view class="bottom-bar">
+				<button class="mini-btn button" type="primary" size="default" @click="stockSubmit">确定</button>
+				<button class="mini-btn button" type="warn" size="default" @click="goBack">取消</button>
 			</view>
-		</uni-section>
+
+		</view>
+
+
 	</view>
 </template>
 
 <script>
 	import {
 		getInfoByBarcode,
-		getStockInfo
+		getStockInfo,
+		Querylocation
 	} from '../../api/production_replenishment';
+	import modal from '../../plugins/modal';
 	import {
 		playVoice,
 		audioUrls
 	} from '@/utils/audio.js'
-	import modal from '../../uni_modules/uview-ui/libs/config/props/modal';
+	// import modal from '../../uni_modules/uview-ui/libs/config/props/modal';
 	export default {
 		onLoad(option) {
 			this.formId = uni.getStorageSync("formId")
@@ -40,10 +82,7 @@
 			const index = JSON.parse(decodeURIComponent(option.index))
 			console.log(item)
 			console.log(index)
-			if(isCreate){
-				//加载仓位
-				
-			}
+			
 			this.isCreate = isCreate
 			this.item = item
 			this.index = index
@@ -51,8 +90,9 @@
 		data() {
 			return {
 				isCreate: false,
-				destStockList:[],
-				destStock:'',
+				stockList: [],
+				selectedItemId: '',
+				stockLocNum: '',
 				formId: '',
 				item: {},
 				index: '',
@@ -95,7 +135,98 @@
 				}).catch(err => {
 					console.log(err);
 				})
+
+			},
+			async stockSubmit() {
+				if (this.selectedItemId == null) {
+					modal.msgError("请选择仓位")
+					playVoice(audioUrls.failVoiceUrl)
+					return
+				}
+				this.item['FDestStockId.FNumber'] = this.item["FStockId.FNumber"]
+				this.item['FDestStockLocId.FF102029.FNumber'] = this.selectedItemId
+				let self = this
+				console.log(self.item)
+				uni.navigateBack({
+					success: () => {
+						uni.$emit('selectStock', self.item);
+					}
+				});
+			},
+			goBack() {
+				uni.navigateBack();
+			},
+			search() {
+				modal.loading('获取数据中,请耐心等待...')
+				let data = {
+					usertoken: "99302b4923aa42298c5922b7b68bcff9",
+					stockNum: this.item["FStockId.FNumber"],
+					stockLocNum: this.stockLocNum
+				}
+				Querylocation(data).then(res => {
+					console.log(res);
+					this.handleResponse(res)
+				})
+			},
+			onScroll(e) {
+				const scrollLeft = e.detail.scrollLeft;
+				this.headerLeft = -scrollLeft; // 更新表头左侧位置,实现横向滚动时的对齐效果
+			},
+			checkboxChange: function(e) {
+				console.log(e)
+				var items = this.BillList,
+					values = e.detail.value;
+				console.log(values)
+				this.selected = values
+				console.log(this.selected)
+				for (var i = 0, lenI = items.length; i < lenI; ++i) {
+					const item = items[i]
+					if (values.includes(item.FID)) {
+						this.$set(item, 'checked', true)
+					} else {
+						this.$set(item, 'checked', false)
+					}
+				}
+				console.log(items)
+			},
+			handleResponse(res) {
+				// 关闭加载提示
+				modal.closeLoading();
+				// 检查响应是否为空
+				if (res.length === 0) {
+					modal.msg("请确认输入条件有效!");
+					playVoice(audioUrls.failVoiceUrl);
+					return;
+				}
+				// 处理数据去重并更新状态
+				this.updateStockList(res);
+			},
+			updateStockList(data) {
+				
+				this.stockList = data.results;
+				console.log(this.stockList)
 			},
+			handleCheckboxClick(itemId) {
+				console.log(itemId)
+				// 取消之前选中的项
+				if (this.selectedItemId === itemId) {
+					this.selectedItemId = null;
+					this.stockList.forEach(item => {
+						item.checked = false;
+					});
+					console.log(this.stockList)
+				} else {
+					// 更新选中项
+					this.selectedItemId = itemId;
+					this.stockList.forEach(item => {
+						item.checked = (item.FStockLocNum === itemId);
+					});
+					console.log(this.stockList)
+				}
+				console.log(this.selectedItemId)
+				this.$forceUpdate()
+			},
+
 		}
 	};
 </script>
@@ -132,4 +263,131 @@
 		height: 35px;
 		margin-left: 10px;
 	}
+
+	.table-container {
+		width: 100%;
+		height: 100%;
+		display: flex;
+		flex-direction: column;
+
+
+
+	}
+
+	.search-container {
+		display: flex;
+		/* justify-content: flex-start; */
+		flex-direction: row;
+		align-items: center;
+		padding: 5px;
+		/* border-bottom: 1px solid #ccc; */
+		flex-wrap: wrap;
+	}
+
+	.search-button {
+		/* padding: 8px 16px; */
+		border: none;
+		border-radius: 4px;
+		background-color: #007bff;
+		color: #fff;
+		cursor: pointer;
+	}
+
+	.table-scroll {
+		/* position: absolute; */
+		flex: 1;
+		overflow-x: auto;
+		overflow-y: hidden;
+	}
+
+	.table-header {
+		position: sticky;
+		top: 0;
+		background-color: #f0f0f0;
+		font-weight: bold;
+		border-bottom: 1px solid #ccc;
+		display: flex;
+		z-index: 1;
+		/* 确保表头在内容之上 */
+	}
+
+	.table-cell1 {
+		width: 100%;
+		padding: 10px;
+		text-align: center;
+		border-right: 1px solid #ccc;
+	}
+
+	.table-cell1-1 {
+		min-width: 150px;
+		padding: 10px;
+		text-align: left;
+		border-right: 1px solid #ccc;
+	}
+
+	.table-cell {
+		min-width: 100px;
+		padding: 10px;
+		text-align: center;
+		border-right: 1px solid #ccc;
+	}
+
+	.header-cell {
+		border-right: none;
+		/* 取消最后一列的右边框 */
+	}
+
+	.table-body {
+		flex: 1;
+		/* width: fit-content; */
+		/* 使内容宽度适应内容的宽度 */
+	}
+
+	.table-row {
+		width: 100%;
+		/* display: flex; */
+		border-bottom: 1px solid #ccc;
+	}
+
+	.checkbox {
+		width: 100%;
+		height: 100%;
+		display: flex;
+		justify-content: center;
+		align-items: center;
+	}
+
+	.bottom-bar {
+		display: flex;
+		/* justify-content: center; */
+		justify-content: flex-end;
+		/* 将按钮靠右对齐 */
+		align-items: center;
+		/* padding: 10px; */
+		padding: 3px;
+		background-color: #f0f0f0;
+		position: fixed;
+		  bottom: 0;
+		  left: 0;
+		  width: 100%;
+		  box-shadow: 0 -2px 5px rgba(0, 0, 0, 0.1); /* 可选:添加阴影效果 */
+		  z-index: 1000; /* 确保按钮组在其他内容之上 */
+	}
+
+	.button {
+		margin: 0 10px;
+		/* padding: 10px 20px; */
+	}
+
+	.checkbox-container {
+		width: 100%;
+		padding: 10px;
+		/* text-align: center; */
+		border-right: 1px solid #ccc;
+		display: flex;
+		align-items: center;
+		/* 	margin-left: 10px;
+		margin-right: 10px; */
+		/* 可根据需要调整间距 */
+	}
 </style>

+ 2 - 2
pages/login/index.vue

@@ -65,8 +65,8 @@
 					// Env: 'http://10.200.0.222',
 					acctID: '5d5812913fe36c',
 					FStockOrgId: '100',
-					UserName: 'LT068633',
-					Password: 'sunj@123',
+					UserName: '',
+					Password: '',
 					// FacadeName: ''
 				},
 				rememberPsw: true, //复选框状态 默认勾选

+ 1 - 0
plugins/modal.js

@@ -73,6 +73,7 @@ export default {
 			icon: 'none'
 		})
 	},
+	//防止穿透
 	loadingMask(content) {
 		uni.showLoading({
 			title: content,

+ 4 - 3
utils/commonSubmitHelper.js

@@ -59,7 +59,7 @@ export default {
 	
 	async createSubmit(FormId,indexList) {
 		try {
-			modal.loading("提交中,请耐心等待...");
+			modal.loadingMask("提交中,请耐心等待...");
 			let saveParam; 
 			const username = uni.getStorageSync('HBusername')
 			saveParam = getCreateSaveParam(FormId,username,indexList)
@@ -74,14 +74,15 @@ export default {
 			if (!submitRes.IsSuccess) {
 				throw new Error(submitRes.Errors[0].Message);
 			}
-	
+			
 			const auditParam = getAuditParam(FormId,submitRes.SuccessEntitys[0].Id);
 			const auditRes = await this.auditData(auditParam);
 			if (!auditRes.IsSuccess) {
 				throw new Error(auditRes.Errors[0].Message);
 			}
+			const FNumber = auditRes.SuccessEntitys[0].Number;
 	
-			this.handleSuccess(FID, indexList);
+			this.handleSuccess(FNumber, indexList);
 	
 		} catch (error) {
 			// this.handleError(error);

+ 79 - 8
utils/transferparams.js

@@ -172,14 +172,14 @@ function createEntityObject(item, actualQtyKey) {
 }
 
 export function getCreateSaveParam(FormId, username, indexList) {
-	const targetFID = data;
+
 	const actualQtyKey = getActualQtyKey(FormId);
 
 	const FEntityObjects = indexList
-		.filter(item => item.FID === targetFID)
 		.map(item => createEntityObject(item, actualQtyKey));
-	
+
 	const datetime = new Date().toISOString();
+	const entry = indexList.map(getEntityParam);
 
 	return {
 		"parameters": [
@@ -199,7 +199,6 @@ export function getCreateSaveParam(FormId, username, indexList) {
 				"IsControlPrecision": "false",
 				"ValidateRepeatJson": "false",
 				"Model": {
-					"FID": 0,
 					"FBillTypeID": {
 						"FNUMBER": "ZJDB01_SYS"
 					},
@@ -243,16 +242,88 @@ export function getCreateSaveParam(FormId, username, indexList) {
 					"FExtTransType_LT": {
 						"FNumber": "ZCFX"
 					},
+					"FCreatorId": {
+						"FName": username
+					},
+					"FCreateDate": datetime,
 					"FWriteOffConsign": false,
-					"FBillEntry": FEntityObjects
+					"FBillEntry": entry
 				}
-
-
 			}
 		]
 	};
 }
 
+function getEntityParam(item) {
+	return {
+		"FENCHASENUM_LT": item.FCMKBarCode,
+		"FRowType": "Standard",
+		"FMaterialId": {
+			"FNumber": item["FMaterialId.FNumber"]
+		},
+		"FCMKBarCode": item.FCMKBarCode,
+		"FAuxPropId": {
+			"FAUXPROPID__FF101501": {
+				"FNumber": item["FAuxPropId.FF101501.FDataValue"]
+			}
+		},
+		"FSrcStockId": {
+			"FNumber": item["FStockId.FNumber"]
+		},
+		"FSrcStockLocId": {
+			"FSRCSTOCKLOCID__FF102029": {
+				"FNumber": item["FStockLocId.FF102029.FNumber"]
+			}
+		},
+		"FDestStockId": {
+			"FNumber": item["FDestStockId.FNumber"]
+		},
+		"FDestStockLocId": {
+			"FDESTSTOCKLOCID__FF102029": {
+				"FNumber": item["FDestStockLocId.FF102029.FNumber"]
+			}
+		},
+		"FLot": {
+			"FNumber": item["FLot.FNumber"]
+		},
+		"FUnitID": {
+			"FNumber": item["FUnitID.FNumber"] || item["FBaseUnitId.FNumber"]
+		},
+		"FDestLot": {
+			"FNumber": item["FLot.FNumber"]
+		},
+		"FQty": item.FQty || item.FBaseQty,
+		"FKeeperTypeOutId": item.FKeeperTypeId,
+		"FOwnerTypeId": item.FOwnerTypeId,
+		"FKeeperOutId": {
+			"FNumber": item["FKeeperId.FNumber"]
+		},
+		"FOwnerTypeOutId": item.FOwnerTypeId,
+		"FISFREE": false,
+		"FOwnerId": {
+			"FNumber": item["FOwnerId.FNumber"]
+		},
+		"FOwnerOutId": {
+			"FNumber": item["FOwnerId.FNumber"]
+		},
+		"FBaseUnitId": {
+			"FNumber": item["FBaseUnitId.FNumber"]
+		},
+		"FSrcStockStatusId": {
+			"FNumber": "KCZT01_SYS"
+		},
+		"FDestStockStatusId": {
+			"FNumber": "KCZT01_SYS"
+		},
+		"FBaseQty": item.FBaseQty,
+		"FKeeperTypeId": item.FKeeperTypeId,
+		"FKeeperId": {
+			"FNumber": item["FKeeperId.FNumber"]
+		}
+	};
+
+
+}
 
 export function getCreateSubmitParam(FormId, data) {
 	const params = {
@@ -317,7 +388,7 @@ export function getInventory(lot, material) {
 	return {
 		parameters: [{
 			FormId: "STK_Inventory",
-			FieldKeys: "FStockLocId.FF102029.FNumber,FStockLocId.FF102029.FName,FStockName,FMaterialName,FBaseQty,FOwnerName,FOwnerTypeId,FAuxPropId.FF101501.FDataValue,FModel",
+			FieldKeys: "FStockLocId.FF102029.FNumber,FStockLocId.FF102029.FName,FStockName,FStockId.FNumber,FKeeperId.FNumber,FKeeperTypeId,FMaterialName,FBaseQty,FOwnerName,FOwnerId.FNumber,FOwnerTypeId,FAuxPropId.FF101501.FDataValue,FModel,FBaseUnitId.FNumber",
 			FilterString: [{
 					"Left": "",
 					"FieldName": "FLot.FNumber",