<template>
	<view class="container">
		<cu-custom :isBack="true">
			<block slot="backText"></block>
			<block slot="content">空容器出库</block>
			</cu-custom>
			<view class="example">
				<uni-forms ref="form" :model="formData" labelWidth="80px">

					<uni-forms-item label="空容器" name="palletCode">
						<view class="fromItem">
							<uni-easyinput v-model="ktpCode" disabled />
							<image style="width: 28rpx;" src="/static/images/right.png" mode="widthFix"></image>
						</view>
					</uni-forms-item>
					<uni-forms-item label="货位编号" name="locCode">
						<view class="fromItem">
							<uni-easyinput v-model="formData.locCode" placeholder="请扫描货位编号" @blur="trimLocInput" />
							<image style="width: 28rpx;" src="/static/images/right.png" mode="widthFix"></image>
						</view>
					</uni-forms-item>
					<uni-forms-item label="容器数量" name="skuQty">
						<view class="fromItem">
							<uni-easyinput v-model="formData.skuQty" disabled type="number" placeholder="请输入物料数量" />
							<image style="width: 28rpx;" src="/static/images/right.png" mode="widthFix"></image>
						</view>
					</uni-forms-item>


				</uni-forms>

			<!-- 	<view class="button-group">
					<button type="primary" style="width: 200px;" :disabled="isButtonDisabled"
						@click="submitPallet">呼叫出库</button>

				</view> -->

			</view>
			<bottomBtn  :isSubmit="true" :isWhite="false" position="fixed" :disable="isButtonDisabled"
			                :texts="['呼叫出库']"  @onSubmit="submitPallet"></bottomBtn>
			<view class="cu-modal" :class="msgModalName=='Modal'?'show':''">
				<view class="cu-dialog">
					<view class="cu-bar bg-white justify-end">
						<view class="content">{{msgTitleName}}</view>
						<view class="action" @tap="hideMsgModal">
							<text class="cuIcon-close text-red"></text>
						</view>
					</view>
					<view class="padding-xl">
						{{msg}}
					</view>
				</view>
			</view>
	</view>

</template>

<script>
	import {
		getSkuDictionary,
		getSkuTypes
	} from "@/api/wms/sku.js"
	import {
		callEmptyOut
	} from "@/api/wms/bill.js"
	import {
		getDictionary
	} from "@/api/wms/dictData.js"
	import {
		formatDate
	} from 'tough-cookie';
	import {bottomBtn} from '@/components/bottomBtn/bottomBtn.vue'
	export default {
		data() {
			return {
				isButtonDisabled: false,
				autoCall: true,
				ktpCode: "KTP0001",
				msgTitleName: '标题',
				msg: '消息',
				msgModalName: "",
				//表单中的数据信息	
				formData: {
					locCode: "",
					skuQty: "1"
				},
				rules: {
					locCode: {
						rules: [{
							required: true,
							errorMessage: '请扫码货位号'
						}]
					},
					skuQty: {
						rules: [{
							required: true,
							errorMessage: '请输入物料数量'
						}]
					}
				},

			};
		},
		onLoad() {

		},
		onReady() {
			this.$refs.form.setRules(this.rules)
		},
component:{
			bottomBtn
		},
		watch: {

		},
		methods: {

			//去除空格
			trimLocInput(event) {
				this.formData.locCode = event.target.value.trim();
			},
			//呼叫AGV
			submitPallet: function() {
				//this.msgModalName='Modal'
				this.isButtonDisabled = true;
				this.$modal.loading("请等待...")
				if (!this.formData.locCode) {
					this.$modal.closeLoading()
				}
				const whcode = this.$store.state.user.warehouse[0]?.warehouseCode;
				var data = {
					locCode: this.formData.locCode,
					userCode: this.$store.state.user.name,
					warehouseCode: whcode
				}
				callEmptyOut(data).then(response => {
					console.log("response", response)
					this.$modal.msgSuccess("呼叫入库成功")
				}).finally(() => {
					this.isButtonDisabled = false; // 恢复按钮可用
					this.$modal.closeLoading()
				});
			},
			hideMsgModal(e) {
				//关闭信息模态框
				this.msgModalName = null;
			},

		}
	}
</script>

<style lang="scss">
	.container {
		background: rgb(242, 243, 245);
		height: 100vh;
	}
	
	.uni-forms-item {
		border-bottom: 1px solid #E5E6EB;
		margin-bottom: 0;
		padding: 24rpx 0;
	}
	
	::v-deep .uni-forms-item__label {
		color: #1D2129;
		font-size: 28rpx;
		font-weight: 400;
	}
	
	::v-deep .uni-select {
		border: 0px;
	}
	
	::v-deep.uni-select__input-placeholder {
		font-size: 28rpx;
		font-weight: 400;
		color: #86909C;
	}
	.textarea{
		background-color: #F2F3F5;
		width: 100%;
	}
	::v-deep.full-width-textarea{
		width: 100%!important;
		border: unset!important;
	}
	::v-deep .is-input-border{
		border: unset;
	}
	::v-deep .uni-easyinput__placeholder-class{
		font-size: 28rpx;
		color: #86909C;
	}
	::v-deep .uni-input-input{
		font-size: 28rpx;
	}
	::v-deep .uni-select__input-placeholder{
		font-size: 28rpx;
		color: #86909C;
	}
	::v-deep .uniui-bottom{
		display: none;
	}
	::v-deep .uniui-top{
		display: none;
	}
	.fromItem{
		display: flex;
		align-items: center;
	}
	.example {
		padding: 0 24rpx;
		background-color: #fff;
		width: 702rpx;
		border-radius: 24rpx;
		margin: 24rpx auto;
	
	}
	.cu-form-group .title {
		min-width: calc(4em + 15px);
	}

	page {
		background-color: #ffffff;
	}

	

	.segmented-control {
		margin-bottom: 15px;
	}

	.button-group {
		margin-top: 15px;
		display: flex;
		justify-content: space-around;
	}

	.form-item {
		display: flex;
		align-items: center;
		flex: 1;
	}

	.button {
		display: flex;
		align-items: center;
		height: 35px;
		line-height: 35px;
		margin-left: 10px;
	}

	.switch-item {
		display: flex;
		align-items: center;
		justify-content: space-between;
		padding: 10px;
		border-bottom: 1px solid #eee;
	}
</style>