<template>
	<view>
		<view class="title">检测申请方填写</view>
		<view class="form_group">
			<view class="label">委托单编号</view>
			<view class="tag" @click="qr()">
				<text class="icon more">&#xe631;</text>
				<text class="icon span code">&#xe621;</text>
				<text class="span" style="padding-right: 5px;">{{ item.code }}</text>
			</view>
		</view>
		<view class="form_group">
			<view class="label">委托单编号</view>
			<view class="tag">
				<text class="icon more">&#xe631;</text>
				<text class="span">W000003496</text>
			</view>
		</view>
		<view class="form_group">
			<view class="label">结果形式</view>
			<view class="tag"><u-subsection :list="radio" :current="current" @change="change"></u-subsection></view>
		</view>
		<view class="title">设置审批人员</view>
		<view class="form_group" @click="select()">
			<view class="label omit" style="width: 200px;">需求审核-产品经理或主管人员</view>
			<view class="tag">
				<text class="icon more">&#xe631;</text>
				<text class="span"></text>
			</view>
		</view>
		<view class="form_group" @click="select()">
			<view class="label omit" style="width: 200px;">试验审核-试验对接人</view>
			<view class="tag">
				<text class="icon more">&#xe631;</text>
				<text class="span"></text>
			</view>
		</view>
		<view class="title">样机</view>
		<view class="form_group">
			<view class="label">委托单编号</view>
			<view class="tag">
				<text class="icon more">&#xe631;</text>
				<text class="span">W000003496</text>
			</view>
		</view>
	</view>
</template>

<script>
let qrcode = require('@/common/code.js');
export default {
	data() {
		return {
			item: {},
			current: 0,
			radio: [{ name: '正式报告' }, { name: '仅原始数据' }, { name: '协助试验' }]
		};
	},
	onLoad(e) {
	console.log('eeee:' + JSON.stringify(e));
		//传过来的id
		if (e.id) {
			/* this.http.request({
				url: this.http.urls.xxxx + e.id,
				success: res => {
					this.item = res.data.data;
				}
			}); */
		}
		//选中审批人员监听函数,其它类型的参考这个
		uni.$on('select', res => {
			console.log('asd:' + JSON.stringify(res));
		});
	},
	methods: {
		qr() {
			// 调用uni提供的调用相机api
			uni.chooseImage({
				sizeType: ['original'],
				sourceType:['camera'],
				count: 1,
				success: res => {
					const tempFilePaths = res.tempFilePaths[0]; // 获取到二维码图片的链接
					qrcode.decode(tempFilePaths); // 解析二维码图片
					qrcode.callback = r => {
						this.item.code = r;
						console.log("asd:"+r);
						this.$forceUpdate();
					};
				}
			});
		},
		//选择结果形式
		change(e) {
			this.current = e;
			console.log('aa:' + this.radio[this.current].name);
		},
		//选择审批人员
		select() {
			uni.navigateTo({
				url: '/pages/index/select'
			});
		},
		//提交
		add() {
			this.http.request({
				url: this.http.urls.user_task_add,
				data: this.item,
				method: 'POST',
				success: res => {
					uni.showModal({
						title: '提示',
						content: '提交成功',
						showCancel: false,
						success: res => {
							if (res.confirm) {
								uni.navigateBack();
							}
						}
					});
				}
			});
		}
	}
};
</script>

<style lang="scss">
.title {
	padding: 12px;
	font-weight: bold;
	font-size: 16px;
}
.tag {
	float: right;
	margin-top: -18px;
	width: 70%;
	text-align: left;
	.span {
		float: right;
		color: #545555;
	}
	.code {
		font-size: 25px;
	}
	.more {
		float: right;
		margin-top: 2px;
		color: darkgray;
	}

	.uni-label-pointer {
		padding: 5px;
	}
}
</style>
