<template>
	<view class="metering">
		<view class="btn">
          <uni-easyinput
            prefixIcon="search"
            class="topSearch"
            v-model="blpl"
			:disabled="isEdit"
            placeholder="请扫描箱码"
            @change="handleInputNlpla"
          ></uni-easyinput>
        </view>
		<checkbox-group style="margin-top: 10rpx;" @change="checkedChange">
						<checkbox value="r1" :checked="value" />是否审核
					</checkbox-group>
		<u-row gutter="16" class="itemRow" style="margin-top: 10rpx;">
			<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: {
	},
	model: {prop: 'value', event: 'input'},
	data() {
		return {
			blpl: '',
		};
	},
	created() {
	},
	props:{
		form: {
			type: Object,
			default: function () {
				return {};
			}
		},
		value: [Boolean],
		isEdit: {
			type: Boolean,
			default: false
		},
		isBL: {
			type: Boolean,
			default: false
		}
	},
	watch: {
		form: {
			handler(nv) {
				if (this.isBL) {
					this.blpl = nv.ZCODE
				} else {
					this.blpl = nv.PLNR
				}
			},
			deep:true
		}
	},
	computed:{
		weight(){
			return ((this.form.BRGEW-0) - (this.form.ZXNTGEW-0)).toFixed(2)
		}
	},
	methods: {
		handleInputNlpla(e) {
			console.log(e, 'handleInputNlpla');
			if(!e) return
			this.$emit('plinput', e)
		},
		checkedChange() {
			this.$emit('input', !this.value)
		},
		setWeightEdit() {
			
		},
		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>
