<template>
	<view class="cmain">
		<view class="form_group">
			<view class="lable re">监管商品类型</view>
			<input type="text" placeholder="请输入" v-model="item.declareOdd" />
		</view>
		<view class="form_group">
			<view class="lable re">商品名称</view>
			<input type="text" placeholder="请输入" v-model="item.goodsName" />
		</view>
		<view class="form_group">
			<view class="lable re">商品产地</view>
			<input type="text" placeholder="请输入" v-model="item.placeOrigin" />
		</view>
		<view class="form_group">
			<view class="lable re">商品类型</view>
			<input type="text" placeholder="请输入" v-model="item.goodsType" />
			<!-- <u-input type="select" v-model="item.goodsType" border="false" placeholder="请选择商品类型" @click="show = true"/>
			<u-action-sheet :list="goodsTypes" v-model="show" @click="actionSheetCallback"/> -->
		</view>
		<view class="form_group">
			<view class="lable re">商品单位</view>
			<input type="text" placeholder="请输入" v-model="item.goodsUnits" />
		</view>
		<view class="form_group">
			<view class="lable re">商品价格</view>
			<input type="text" placeholder="请输入" v-model="item.price" />
		</view>
		<view class="form_group">
			<view class="lable re">商品数量</view>
			<input type="text" placeholder="请输入" v-model="item.stock" />
		</view>
		<view class="form_group">
			<view class="lable re">净重</view>
			<input type="text" placeholder="请输入" v-model="item.netWeight" />
		</view>
		<view class="form_group">
			<view class="lable re">毛重</view>
			<input type="text" placeholder="请输入" v-model="item.grossWeight" />
		</view>
		<view class="form_group">
			<view class="lable re">商品状态</view>
			<input type="text" placeholder="请输入" v-model="item.goodsStatus" />
		</view>
		<view class="form_group">
			<view class="lable re">商品描述</view>
			<input type="text" placeholder="请输入" v-model="item.description" />
		</view>
		<view class="form_group">
			<view class="lable re">商品图片</view>
			<card v-model="item.goodsImg" pic="../../static/images/yyzz.png"></card>
		</view>
		<button class="btn" @click="save()">修改商品提交</button>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				id: 0,
				item: {goodsType:''},
				goodsTypes: [
					{label:'水果'},
					{label:'药品'},
					{label:'茶叶'},
				],
				show: false,
			}
		},
		onLoad(option) {
			console.log('111111',option.id)
			this.id = option.id
			if(undefined != this.id && null != this.id && 0 != this.id) {
				this.getGoodsTransitDetail();
			}
		},
		methods: {
			// 获取商品详情
			getGoodsTransitDetail(){
				this.http.request({
					url: '/level-one-server/app/TbGoodsTransit/update',
					method:'POST',
					data: {id:this.id},
					success: res => {
						this.item = res.data.data;
						//uni.showToast({ title: '操作成功' });
						
					}
				});
			},
			// 点击actionSheet回调
			actionSheetCallback(index) {
				console.log('index',index)
				this.item.goodsType = this.goodsTypes[index].label;
			},
			save() {
				/* let rule = [
					{ name: 'typeCode', checkType: 'notnull', errorMsg: '请输入编码' },
					{ name: 'typeName', checkType: 'notnull', errorMsg: '请输入名称' },
					{ name: 'status', checkType: 'notnull', errorMsg: '请选择状态' }
				]; */
				/* if (!this.verify.check(this.item, rule)) {
					uni.showModal({ content: this.verify.error, showCancel: false });
					return false;
				} */
				this.http.request({
					url: '/level-one-server/app/TbGoodsTransit/transactionGoods',
					method:'POST',
					data: this.item,
					success: res => {
						uni.showToast({ title: '操作成功' });
						setTimeout(() => {
							uni.$emit('ctype');
							uni.navigateBack();
						}, 1000);
					}
				});
			}

		}
	}
</script>

<style lang="scss">
.btn {
	margin-top: 25px;
}
</style>
