<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: {
					"id": "__4iXbTxbNmabPEfT6ewn1",
					"authorDeptIndex": "ZMMMGm5mnGCE4WvWFeI",
					
				
					"initiator": "__jFFZYvLIG6uFc7CdBMg",
					"audituser": "__jFFZYvLIG6uFc7CdBMg",
					"istmp": false,
					"versions": 9,
					"stateid": "__4iXbTxbNmabPEfT6ewn1-__NyhM8l0gFY9Y1llAFbF",
					"lastFlowOperation": "80",
					"auditorList": "{\"1649917430749\":[]}",
					"coAuditorList": "{\"1649917409179\":[]}",
					"stateInt": 1048576,
					"authorId": "__jFFZYvLIG6uFc7CdBMg",
					"formname": "检测主流程/examine",
					"formid": "__0FLGNncOS1lz0T9jsFn",
					
					"items": {
						"wt_num": "W100002553",
						"purpose": "667",
						"bg_template": null,
						"conclu_dept": null,
						"title": "1",
						"experiment_type": "整机性能",
						"rp_unstructured": null,
						"conclu_type": null,
						"test_ypmc": null,
						"WTXQSH": "__jFFZYvLIG6uFc7CdBMg",
						"WTRWFP": "__jFFZYvLIG6uFc7CdBMg",
						"unstructured": null,
						"b_inventory_wtnum": "W000002553",
						"test_conclusion": null,
						"test_ypnum": null,
						"NORO": "1",
						"tel": "15807800591",
						"conclu_wt_dept": "实验中心",
						"WTXQPZ": "__jFFZYvLIG6uFc7CdBMg",
						"test_template": null,
						"product": "装载机",
						"item": null,
						"conclu_remarks": null,
						"WTSYSH": "__jFFZYvLIG6uFc7CdBMg",
						"ste": "2",
						"conclu_sam_name": null,
						"test_factory": null,
						"wt_template": null,
						"report_type": "正式报告",
						"dept": "实验中心",
						"pro": null,
						"item_num": "1",
						"applicant": "__jFFZYvLIG6uFc7CdBMg",
						"OLDUSER": null,
						"WTSYPZ": "__jFFZYvLIG6uFc7CdBMg",
						"test_yptype": null,
						"appearance": null,
						"test_dept": "柳工",
						"b_inventory_title": "1",
						"teststa": null
					}
				},
				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>
