<template>
	<view class="metering">
		<!-- <uni-forms :modelValue="form">
			<uni-forms-item label="长" name="long">
				<uni-easyinput type="text" v-model="form.long" placeholder="请输入姓名" />
			</uni-forms-item>
		</uni-forms> -->
		<u-row gutter="16" class="itemRow">
			<u-col span="3">
				长(cm)：
			</u-col>
			<u-col span="6">
				<uni-easyinput v-model="form.long" @input="updateWeight"></uni-easyinput>
			</u-col>
		</u-row>
		<u-row gutter="16" class="itemRow">
			<u-col span="3">
				宽(cm)：
			</u-col>
			<u-col span="6">
				<uni-easyinput v-model="form.wide" @input="updateWeight"></uni-easyinput>
			</u-col>
		</u-row>
		<u-row gutter="16" class="itemRow">
			<u-col span="3">
				高(cm)：
			</u-col>
			<u-col span="6">
				<uni-easyinput v-model="form.high" @input="updateWeight"></uni-easyinput>
			</u-col>
		</u-row>
		<u-row gutter="16" class="itemRow">
			<u-col span="3">
				毛重(kg)：
			</u-col>
			<u-col span="6">
				<uni-easyinput v-model="form.brgew"></uni-easyinput>
			</u-col>
		</u-row>
		<u-row gutter="16" class="itemRow">
			<u-col span="3">
				箱重(kg)：
			</u-col>
			<u-col span="6">
				<uni-easyinput v-model="form.zxntgew" @input="updateWeight"></uni-easyinput>
			</u-col>
		</u-row>
		<u-row gutter="16" class="itemRow">
			<u-col span="3">
				净重(kg)：
			</u-col>
			<u-col span="6">
				<uni-easyinput v-model="weight" disabled></uni-easyinput>
			</u-col>
		</u-row>
		<u-row gutter="16" class="itemRow">
			<u-col span="3">
				装箱备注：
			</u-col>
			<u-col span="8">
				<u-input v-model="form.zxtext" type="textarea" :border="true" height="70" ></u-input>
			</u-col>
		</u-row>
		<u-row gutter="16" class="itemRow">
			<u-col span="3">
				备注：
			</u-col>
			<u-col span="8">
				<u-input v-model="form.ztext" type="textarea" :border="true" height="70" ></u-input>
			</u-col>
		</u-row>
		
	</view>
</template>

<script>
export default {
	components: {
	},
	data() {
		return {
			
		};
	},
	created() {
	},
	props:{
		form: {
			type: Object,
			default: function () {
				return {};
			}
		}
	},
	computed:{
		weight(){
			return (this.form.brgew-0) - (this.form.zxntgew-0)
		}
	},
	methods: {
		updateWeight(e) {
			console.log(e, '----')
			const reg = /^\d+\*\d+\*\d+\-\d+(\.\d+)+$/
			// 验证格式，判断是否是扫码
			if (reg.test(e)) {
				console.log('扫码11111');
				const arr = e.split('*')
				setTimeout(() => {
					this.form.long = arr[0]
					this.form.wide = arr[1]
					const data = arr[2].split('-')
					this.form.high = data[0]
					this.form.zxntgew = data[1]
				}, 500)
			}
		}
	}
};
</script>

<style lang="scss" scoped>
	.metering{
		border-radius: 20rpx;
		margin: 20rpx;
		padding: 20rpx;
		background: #fff;
	}
	.itemRow{
		margin-bottom: 10rpx;
	}
</style>
