<template>
	<view>
		<view 
			class="single-fetch"
			v-for="(fetch, index) in fetchList"
			:key="index"
		>
			<view>
				<span>类型名称</span>
				<h4>{{ fetch.typeName }}</h4>
			</view>
			<view>
				<span>规格型号</span>
				<h4>{{ fetch.typeModelName }}</h4>
			</view>
			<view>
				<span>申请数量</span>
				<h4>{{ fetch.preNum }}</h4>
			</view>
			<!-- <button v-show="fetch.manageType == 2">sss</button> -->
			<text 
				v-show="fetch.manageType == 2"
				class="see-item"
				@click="openPopup(fetch.maTypeDetails)"
			>
				查看配件
			</text>
		</view>
		<uni-popup
			ref="popup" 
			type="center"
			:mask-click="false"
		>
			<view class="popup">
				<view class="pop-top">
					<h4>查看配件</h4>
					<uni-icons 
						style="color: #AAAAAA; font-weight: bold;" 
						type="closeempty" 
						size="20"
						@click="closePopup"
					>
					</uni-icons>
				</view>
				<view class="item-detail">
					<view 
						class="single-item"
						v-for="(item, index) in maList"
						:key="index"
					>
						<view>
							<h4>序号</h4>
							<span>{{ index + 1 }}</span>
						</view>
						<view>
							<h4>类型名称</h4>
							<span>{{ item.typeName }}</span>
						</view>
						<view>
							<h4>规格型号</h4>
							<span>{{ item.typeModelName }}</span>
						</view>
						<view>
							<h4>单位</h4>
							<span>{{ item.unitName }}</span>
						</view>
						<view>
							<h4>预领数量</h4>
							<span>{{ item.partNum }}</span>
						</view>
					</view>
				</view>
			</view>
		</uni-popup>
		<!-- <view
			class="fetch-btns"
			style="background-color: #3788ff"
			@click="submit()"
			>
			<uni-icons style="color: #fff" ></uni-icons>
			确认
		</view> -->
		<div class="btn">
            <!-- <button class="btn-cont" @click="reject">取消</button> -->
            <button class="btn-cont" @click="submit">确认</button>
        </div>
	</view>
</template>

<script>
	import { basePath } from '../../public.js'
	export default {
		data() {
			return {
				fetchList: [],
				maList: [],
				taskIdTemp:undefined,
			}
		},
		methods: {
			openPopup (list) {
				this.maList = list
				this.$refs.popup.open()
			},
			closePopup () {
				this.$refs.popup.close()
			},
			submit (){
				let that = this
				let param = {
					taskId:this.taskIdTemp,
					taskStatus: 33,
				}
            that.$api.fetchExam.fetchConfirmByCq(param).then(res => { 
                console.log(res)
                if(res.data.code==200){
                    uni.showToast({ title: '确认成功', icon: 'none' })
					setTimeout(() => {
					uni.navigateBack();
				}, 500);
                }else{
                    uni.showToast({ title: '确认失败', icon: 'none' })
                }
			})
		},
		onLoad(params) {
			this.taskIdTemp = params.taskId;
			let that = this
			that.fetchList = []
			console.log(params.taskId);
			
			that.$api.fetchExam.fetchDetailList({
				taskId: params.taskId 
			}).then(res => {
				console.log(res);
				if (res.data.code == 200) {
					// that.fetchList = res.data.data.rows[0].leaseApplyInfoList[0].leaseApplyDetails
					/* for (let i = 0; i < res.data.rows[0].leaseApplyInfoList.length; i++) {
						for (let k = 0; k < res.data.rows[0].leaseApplyInfoList[i].leaseApplyDetails.length; k++) {
							that.fetchList.push(res.data.rows[0].leaseApplyInfoList[i].leaseApplyDetails[k])
						}
					} */
					that.fetchList = res.data.rows[0].leaseApplyDetails
					console.log(that.fetchList);
				}
			}).catch(err => {
				console.log(err);
			})
		}
	}
	}
</script>

<style lang="scss">
.btn {
    display: flex;
    justify-content: center;
    margin-top: 30px;
	
    .btn-cont {
        width: 20%;
        height: 35px;
        line-height: 40px;
        text-align: center;
        background-color: #3784fb;
        color: #fff;
        border: 20px;
    }
}
	.single-fetch{
		width: 100%;
		box-sizing: border-box;
		padding: 20rpx 35rpx;
		border-bottom: 1px solid #DDDDDD;
		view{
			display: flex;
			align-items: center;
			margin-bottom: 25rpx;
			span{
				color: #A7A7A7;
				padding-right: 20rpx;
			}
			h4{
				font-size: 14px;
				font-weight: normal;
			}
		}
		view:last-child{
			margin-bottom: 0;
		}
		.see-item{
			width: 30%;
			box-sizing: border-box;
			padding: 5rpx 10rpx;
			border-radius: 15rpx;
			display: flex;
			justify-content: center;
			align-items: center;
			background-color: #3788FF;
			color: #fff;
			font-size: 16px;
			font-weight: normal;
		}
	}
	.btm-exam{
		position: fixed;
		left: 0;
		bottom: 0;
		width: 100%;
		box-sizing: border-box;
		padding: 20rpx 40rpx;
		display: flex;
		justify-content: flex-end;
		border-top: 2px solid #F6F8FF;
		.exam{
			box-sizing: border-box;
			padding: 10rpx 50rpx;
			border-radius: 30rpx;
			background-color: #3788FF;
			font-size: 14px;
			color: #fff;
		}
	}
	.popup{
		width: 80vw;
		height: 60vh;
		background-color: #fff;
		border-radius: 15rpx;
		overflow: hidden;
		background: linear-gradient(#D9E7FE, #fff, #fff, #fff);
		display: flex;
		flex-direction: column;
		justify-content: space-between;
		.pop-top{
			width: 100%;
			height: 5vh;
			box-sizing: border-box;
			padding: 0 25rpx;
			display: flex;
			justify-content: space-between;
			align-items: center;
		}
		.item-detail{
			flex: 1;
			overflow-y: auto;
			font-size: 14px;
			box-sizing: border-box;
			padding: 25rpx;
			.single-item{
				border-bottom: 1px solid #DDDDDD;
				box-sizing: border-box;
				padding: 25rpx 0;
				view{
					width: 100%;
					margin-bottom: 10rpx;
					display: flex;
					align-items: center;
					h4{
						width: 35%;
						color: #A7A7A7;
						font-weight: normal;
					}
				}
				view:last-child{
					margin-bottom: 0;
				}
			}
			.single-item:last-child{
				border-bottom: none;
			}
		}
	}
</style>
