<template>
	<view >
		<view class="fixedheader">
			<headers  :showBack="true">
			<view class="headerName">
				{{pageTitle}}
			</view>
		</headers>
		</view>
		
		<scroll-view class="smallHeight" :style="{ 'padding-top': (statusBarHeight + 45) * 1.5 + 'rpx' }" scroll-y>
		<view class="formBox">
			<form @submit="formSubmit">
				<!-- <view class="uni-form-item">
					<view class="uni-form-label">
						混泥土标号<text class="star">*</text>
					</view>
					<view class="uni-form-input">
						<input class="uni-input" placeholder-class="cl" name="concreteTab" :value="form.concreteTab" placeholder="请输入" />
					</view>
				</view> -->
				<view class="uni-form-item">
					<view class="uni-form-label">
						实验室<text class="star">*</text>
					</view>
					<view class="uni-form-input">
						<picker disabled @change="bindPickerChange" :value="buildIndex" :range="buildList" range-key="buildName">
							<!-- <view class="uni-input uni-select cl" v-if="buildIndex==null">
								请选择 <image class="icon-down" src="/static/icon-down-black.png" mode=""></image>
							</view> -->
							<view class="uni-input uni-select" >{{form.laboratoryName}}
								<!-- <image class="icon-down" src="/static/icon-down-black.png" mode=""></image> -->
							</view>
						</picker>
					</view>
				</view>
				<view class="uni-form-item">
					<view class="uni-form-label">
						实验负责人<text class="star">*</text>
					</view>
					<view class="uni-form-input">
						<picker disabled @change="bindPickerChange2" :value="floorIndex" :range="floorList" range-key="floorName">
							<!-- <view class="uni-input uni-select cl" v-if="floorIndex==null">
								请选择 <image class="icon-down" src="/static/icon-down-black.png" mode=""></image>
							</view> -->
							<view class="uni-input uni-select" >{{form.laboratoryDirector}}
								<!-- <image class="icon-down" src="/static/icon-down-black.png" mode=""></image> -->
							</view>
						</picker>
					</view>
				</view>
				<!-- <view class="uni-form-item">
					<view class="uni-form-label">
						设计强度
					</view>
					<view class="uni-form-input">
						
					</view>
				</view>
				<view class="designBox">
					<checkbox-group @change="checkboxChange" class="designItem">
						<label class="uni-list-cell uni-list-cell-pd" v-for="item in selectList" :key="item.name">
							<checkbox :value="item.name" :checked="item.checked" />{{item.name}}
						</label>
					</checkbox-group>
				</view> -->
				<view class="uni-form-item">
					<view class="uni-form-label">
						试块/组名称<text class="star">*</text>
					</view>
					<view class="uni-form-input">
						<input class="uni-input" disabled placeholder-class="cl" name="concreteTab" :value="form.sampleName" />
					</view>
				</view>
				
				<view class="uni-form-item">
					<view class="uni-form-label">
						混凝土标号<text class="star">*</text>
					</view>
					<view class="uni-form-input">
						<input disabled class="uni-input" placeholder-class="cl" name="mixingPlant" :value="form.concreteLabel" />
					</view>
				</view>
				
				<view class="uni-form-item">
					<view class="uni-form-label">
						入库时间<text class="star">*</text>
					</view>
					<view class="uni-form-input">
						<picker disabled mode="date" :value="form.pourTime" @change="bindDateChange">
							<!-- <view class="uni-input uni-select cl" v-if="form.pourTime==''">
								请选择 <image class="icon-down" src="/static/icon-down-black.png" mode=""></image>
							</view> -->
							<view class="uni-input uni-select" >
								{{form.putStorageTime}}
							</view>
						</picker>
					</view>
				
				</view>
				<view class="uni-form-item">
					<view class="uni-form-label">
						是否需要按照标准28天养护周期<text class="star">*</text>
					</view>
					<radio-group disabled @change="radioChange">
						<label class="uni-list-cell uni-list-cell-pd" style="margin-right: 40px">
					        <view>
								<radio disabled value="2" :checked="form.standardCycleType == 2" />
					        </view>
					        <view>是</view>
					    </label>
						<label class="uni-list-cell uni-list-cell-pd">
						    <view>
								<radio disabled value="1" :checked="form.standardCycleType == 1" />
						    </view>
						    <view>否</view>
						</label>
					</radio-group>
				</view>
				<view class="uni-form-item" v-if="form.standardCycleType == 1">
					<view class="uni-form-label">
						养护周期(天)<text class="star">*</text>
					</view>
					<view class="uni-form-input">
						<input class="uni-input" disabled placeholder-class="cl" name="mixingPlant" :value="form.curingPeriod" />
					</view>
				</view>
				
				<view class="qrimg">
				    <tki-qrcode
				    ref="qrcode"
					:size="360"
				    cid="1001"
				    :val="qrUrl"
				    :onval="true"
				    :loadMake="true"
				    @result="qrR" />
				</view>
				
				<!-- <div class="submitBtn_warp">
					<button form-type="submit" type="primary" class="btn submitBtn big">打印二维码</button>
				</div> -->
				
			</form>
		</view>
		</scroll-view>
	</view>
</template>

<script>
	import tkiQrcode from "@/components/tki-qrcode/tki-qrcode.vue"
	export default {
		components: {
			tkiQrcode,
		},
		data() {
			return {
				pageTitle: '试块详情',
				buildIndex: null,
				floorIndex:null,
				selectList: [{name:'C15'}, {name:'C20'}, {name:'C25'}, {name:'C30'}, {name:'C35'}, 
				{name:'C40'}, {name:'C45'}, {name:'C50'}, {name:'C55'}, {name:'C60'}],
				selectArr:[],
				buildList:[],
				floorList:[],
				tableData:[{
					num: '',
					No: '',
					type: ''
				}],
				form: {},
				personList: [],
				projectDetail: {},
				isAdd: true,
				statusBarHeight: 0,
				qrUrl: ''
			}
		},
		onLoad(options) {
			this.projectDetail = JSON.parse(uni.getStorageSync('projectDetail'))
			this.detailId = options.id
			// this.qrUrl = 'http://192.168.34.230:8081/#/blockDetails?id=' + options.id + '&userId=' + JSON.parse(uni.getStorageSync('userInfo')).userId
			this.qrUrl = this.url_config +'doc/h5/index.html#/blockDetails?id=' + options.id + '&userId=' + JSON.parse(uni.getStorageSync('userInfo')).userId
			console.log(this.qrUrl)
			this.loadData()
		},
		onShow() {
			this.statusBarHeight = uni.getStorageSync('systemInfo').statusBarHeight;
		},
		methods: {
			loadData(){
				let that = this
				this.sendRequest({
					url: 'xmgl/massReboundSampleStorageRecord/queryById',
					data: {
						id: this.detailId
					},
					method: "POST",
					success:(res)=> {
						console.log(res)
						that.form = res.result
					}
				})
			},
			qrR(e){
				// console.log(e)
			},
			radioChange(e){
				console.log(e)
				this.form.status = e.detail.value
			},
			deleteTableData(index){
				if(this.tableData.length>1){
					this.tableData.splice(index,1)
				}
			},
			addTableData(val){
				this.tableData.push({
					num: '',
					No: '',
					type: ''
				})
			},
			loadBuildData(id){
				this.sendRequest({
					url: 'xmgl/massReboundBuild/getBuildFloorList',
					data: {projectSn:this.projectDetail.projectSn},
					method: "POST",
					success:(res)=>{
						this.buildList=res.result
						if(id){
							for (var i = 0; i < this.buildList.length; i++) {
								var item = this.buildList[i];
								if(item.id==this.form.buildId){
									this.buildIndex=i
									this.floorList=item.floorList;
									for (var j = 0; j < this.floorList.length; j++) {
										if(this.floorList[j].floorId==this.form.floorId){
											this.floorIndex=j
										}
									}
								}
							}
						}
					}
				})
			},
			goSelectPersonFn() {
				uni.navigateTo({
					url: './personList'
					// url:'../../selectPerson/selectPerson2'
				})
			},
			
			bindPickerChange: function(e) {
				this.buildIndex = e.target.value
				this.floorList=this.buildList[e.target.value].floorList
				this.floorIndex=null
			},
			bindPickerChange2: function(e) {
				this.floorIndex = e.target.value
			},
			bindDateChange: function(e) {
				this.form.pourTime = e.target.value
			},
			checkboxChange: function (e) {
				// var items = this.selectList,
				// 	values = e.detail.value;
				this.selectArr=e.detail.value;
				// for (var i = 0, lenI = items.length; i < lenI; ++i) {
				// 	const item = items[i]
				// 	if(values.includes(item.value)){
				// 		this.$set(item,'checked',true)
				// 	}else{
				// 		this.$set(item,'checked',false)
				// 	}
				// }
			},
			formSubmit(e) {
				
			}
		}
	}
</script>

<style lang="scss" scoped>
	.personListBox {
		// background-color: #f7f7f7;
		border-radius: 4px;
		overflow: hidden;
		border-left: 1px dashed #e6e6e6;
		position: relative;

		.personLeft {
			width: calc(100% - 20rpx);
		}

		.personItem {
			float: left;
			width: calc(33.33% - 21px);
			height: 54px;
			text-align: center;
			font-size: 24rpx;
			border-bottom: 1px dashed #e6e6e6;
			padding: 0px 20rpx 0;
			border-right: 1px dashed #e6e6e6;
			border-top: 1px dashed #e6e6e6;
			background-color: #f7f7f7;

			.name {
				font-size: 30rpx;
				padding-top: 16rpx;
			}

			.txt {
				overflow: hidden;
				white-space: nowrap;
				text-overflow: ellipsis;
			}

			&.total {
				display: inline-flex;
				align-items: center;
				font-size: 30rpx;
				justify-content: center;
			}

			// &:nth-child(3n){
			// 	border-right: none;
			// }
		}

		.icon-right {
			position: absolute;
			right: 0;
			top: calc(50% - 7px);
			width: 16rpx;
			height: 28rpx;
		}
	}
	.designBox{
		background-color: #f9f9f9;
		border-radius: 4px;
		padding: 20rpx 20rpx 0;
		overflow: hidden;
		margin-bottom: 40rpx;
		.uni-list-cell{
			width: 20%;
			float: left;
			margin-bottom: 20rpx;
		}
	}
	.submitBtn{
		width: 90%;
		margin: 0 auto;
		font-size: 40rpx;
		// margin-top: 200rpx;
	}
	.formBox{
		margin: 0;
		.uni-form-item{
			padding: 0 30rpx;
			height: 90rpx;
			// border-bottom: 0.5rpx solid #E7E7E7;
			font-size: 28rpx;
			margin-bottom: 0;
			.uni-form-input .uni-input {
				border: 0;
				padding: 0;
			}
			.icon-down{
				transform: rotate(-90deg);
			}
			.uni-input-placeholder{
				font-size: 28rpx;
			}
			uni-radio-group{
				display: flex;
				flex: 1;
				padding-left: 80rpx;
				.uni-list-cell{
					display: flex;
					align-items: center;
					font-size: 28rpx;
					:deep(.uni-radio-input){
						height: 28rpx;
						width: 28rpx;
						font-size: 28rpx;
					}
				}
			}
		}
		.n-bottom{
			border-bottom: 0;
		}
	}
	.tables{
		padding: 0 50rpx;
		font-size: 28rpx;
		margin-bottom: 32rpx;
		.t_header{
			display: flex;
			font-size: 24rpx;
			.t_title{
				flex: 1;
				text-align: center;
				line-height: 48rpx;
			}
		}
		.t_content{
			border-top: 1px solid #e7e7e7;
			border-left: 1px solid #e7e7e7;
			.t_td{
				display: flex;
				.t_input{
					flex: 1;
					height: 60rpx;
					text-align: center;
					border-right: 1px solid #e7e7e7;
					border-bottom: 1px solid #e7e7e7;
					uni-input{
						height: 100%;
						font-size: 28rpx;
					}
					.delete_btn{
						display: flex;
						align-items: center;
						justify-content: center;
						height: 100%;
						line-height: 60rpx;
						uni-text{
							margin-right: 10rpx;
						}
					}
				}
			}
		}
	}
	.add_btn{
		margin: 0 auto;
		width: 252rpx;
		height: 56rpx;
		border: 1px solid #5181F6;
		border-radius: 50rpx;
		text-align: center;
		font-size: 28rpx;
		color: #5181F6;
		line-height: 52rpx;
	}
	.fixedheader{
		position: fixed;
		top: 0;
		left: 0;
		width: 100%;
		z-index: 2;
	}
	.smallHeight{
		padding-bottom: 180rpx;
	}
	.submitBtn_warp{
		width: 100%;
		height: 130rpx;
		background: #fff;
		padding-top: 20rpx;
		position: fixed;
		bottom: 0rpx;
		left: 50%;
		transform: translateX(-50%);
	}
	.qrimg{
		// margin: 0 auto;
		margin-top: 80rpx;
		:deep(uni-image){
			display: block;
			margin: 0 auto;
		}
	}
</style>
