<template>
	<view class="container">
		<view class="example">
			<uni-forms ref="form" :model="dataForm" labelWidth="80px">
				<uni-forms-item label="借出数量" name="qty">
					<uni-data-checkbox v-model="dataForm.qty" :localdata="numData" />
				</uni-forms-item>
				<uni-forms-item label="借出人" name="borRetBy">
					<uni-easyinput v-model="dataForm.borRetBy" placeholder="请输入借出人" />
				</uni-forms-item>
				<uni-forms-item label="客人" name="custName">
					<uni-easyinput v-model="dataForm.custName" placeholder="请输入客人" />
				</uni-forms-item>
				<uni-forms-item label="时间" name="borRetTime">
					<uni-datetime-picker type="date" :clear-icon="false" v-model="dataForm.borRetTime" />
				</uni-forms-item>
				<uni-forms-item label="备注" name="remark">
					<uni-easyinput v-model="dataForm.remark" placeholder="是否会归还" />
				</uni-forms-item>
			</uni-forms>
			<button type="primary" @click="submit">提交</button>
		</view>
	</view>
</template>

<script>
	import {
		addOutRep
	} from "@/api/trade/shoe-style.js"
	import {
		updateUserProfile
	} from "@/api/system/user"

	export default {
		data() {
			return {
				dataForm: {
					type: 0,
					styleNum: '',
					version: '',
					qty: 0.5,
					borRetBy: "",
					custName: "",
					borRetTime: new Date(),
					remark: ""
				},
				numData: [{
					text: '1只',
					value: 0.5
				}, {
					text: '1双',
					value: 1
				}],
				rules: {
					nickName: {
						rules: [{
							required: true,
							errorMessage: '用户昵称不能为空'
						}]
					},
				
				}
			}
		},
		onLoad(options) {
			console.log(options,'options')
			if(options){
				this.dataForm.version=options.version
				this.dataForm.styleNum=options.styleNum
			}
			// this.getUser()
		},
		onReady() {
			this.$refs.form.setRules(this.rules)
		},
		methods: {
			
			submit(ref) {
				this.$refs.form.validate().then(res => {
					// this.dataForm.qty=Number(this.dataForm.qty)
					addOutRep(this.dataForm).then(response => {
						this.$modal.confirm('操作成功','',false).then(() => {
							uni.navigateBack()
						})
					})
				})
			}
		}
	}
</script>

<style lang="scss">
	page {
		background-color: #ffffff;
	}

	.example {
		padding: 15px;
		background-color: #fff;
	}

	.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;
	}
</style>