<template>
	<view class="projectList">
		<headers class="fixedheader" :themeType="true" :showBack="true">
			<view class="headerName">
				材料入场管理
			</view>
		</headers>
		<view v-if="dataList.length > 0">
			<view class="ukashList" v-for="item in dataList" :key="item.id">
				<!--  @click="jobLookDetails(item.id)"  暂时不跳详情页 -->
				<view class="ukashList-what">
					<span style="font-size: 14px;font-weight: 700;">材料名称: {{item.name}}</span>
					<!-- <span class="ukashList-look">查看明细</span> -->
				</view>
				<view class="ukashList-time">型号: {{item.model}}</view>
				<view class="ukashList-time">规格: {{item.specifications}}</view>
				<view class="ukashList-time">单位: {{item.unit}}</view>
				<view class="ukashList-time">数量: {{item.num}}</view>
				<view class="ukashList-time">备注: {{item.remark}}</view>
				<!-- url_config+'image/'+item.imageUrl -->
				<!-- <image v-if="item.imageUrl"
				       :src="JSON.parse(item.imageUrl)[0]?url_config+'image/'+JSON.parse(item.imageUrl)[0].url:''"
				       class="profile_photo"
				       @click="previewImg(url_config+'image/'+JSON.parse(item.imageUrl)[0].url)"></image> -->
				<!-- <view class="ukashList-time">图片: {{JSON.parse(item.imageUrl).length > 0 ? JSON.parse(item.imageUrl)[0].url : '无'}}</view> -->
				<view class="ukashList-time"><text style="width: 38px;">图片:</text>
					<view class="" v-if="item.imageUrl" style="display: flex;flex-wrap: wrap;">
						<view class="" v-for="(imgItem,imgIndex) in JSON.parse(item.imageUrl)" :key="imgIndex">
							
							<!-- <image :src="imgItem?url_config+'image/'+imgItem.url:''" -->
							<image :src="imgItem?url_config+'image/'+imgItem.url:''"
								   class="profile_photo"
								   @click="previewImg(url_config+'image/'+imgItem.url)"></image>
								   
						</view>
					</view>
				</view>
			</view>
		</view>
		<view class="no-data" v-else>
			<image class="img" src="/static/noData.png"></image>
			<text class="txt">暂无数据</text>
		</view>
		<levitatedsphere :x="100" :y="80"></levitatedsphere>
	</view>
</template>

<script>
	import levitatedsphere from "@/components/levitatedsphere/levitatedsphere.vue"
	import headers from '../../../components/headers/headers.vue'

	export default {
		data() {
			return {
				search: '',
				pageNo: 1,
				pageSize: 10,
				isLoadMore: false,
				dataList: [],
				id: ''
			}
		},
		onLoad(vai) {
			console.log(vai.itemS);
			this.id = vai.itemS
			this.queryList()
		},
		onReachBottom() {
			console.log(99999);
			// if (!this.isLoadMore) {
			//   this.isLoadMore = true
			//   this.pageNo + 1
			//   this.queryList()
			// }
		},
		onPullDownRefresh() {
			console.log(222);
			this.pageNo = 1
			this.dataList = []
			this.queryList()
		},
		methods: {
			queryList() {
				let data = {
					materialId: this.id
				}
				let _this = this
				this.sendRequest({
					url: 'xmgl/xzMaterialDetail/list',
					method: 'post',
					data: data,
					success: res => {
						console.log(res);
						this.dataList = res.result
						if (res.result.length < this.pageSize) {
							//判断接口返回数据量小于请求数据量，则表示此为最后一页
							this.isLoadMore = true
							this.loadStatus = 'nomore'
						} else {
							this.isLoadMore = false
							// that.loadStatus='more'
						}
						uni.stopPullDownRefresh()
						// console.log(res.result)
					}
				})
			},
			jobLookDetails(id){
				uni.navigateTo({
					url: './lookDetails?itemS=' + id
				})
			},
			previewImg(url) {
			  uni.previewImage({
			    urls: [url]
			  })
			},
		}
	}
</script>

<style lang="scss" scoped>
	.projectList {
		min-height: 100%;
		background: #f4f5fd;

		.uni-input {
			border-radius: 10px;
			margin: 10px 10px;
			background-color: #e6e7ef;
			height: 35px;
			line-height: 30px;
			padding: 0 20px;
			font-size: 14px;
		}

		.ukashList {
			// height: 193px;
			height: auto;
			background-color: #fff;
			margin: 10px 10px;
			border-radius: 15px;
			padding-bottom: 10px;

			.ukashList-what {
				display: flex;
				justify-content: space-between;
				margin: 0 15px;
				padding-top: 10px;

				.ukashList-look {
					width: 300px;
					background-color: #5081f7;
					border-radius: 10px;
					padding: 0 4px;
					font-size: 12px;
					text-align: center;
					color: #fff;
				}
			}

			.ukashList-time {
				// margin-top: 15px;
				// margin-left: 15px;
				margin: 15px 15px 10px 15px;
				// padding-bottom: 5px;
				font-size: 12px;
				color: #b9bbc9;
				display: flex;
				.profile_photo {
					width: 30px;
					height: 30px;
					margin-right:5px;
					border-radius: 5px;
				}
			}
		}

		.no-data {
			text-align: center;
			margin-top: 50%;

			.img {
				display: block;
				height: 200rpx;
				width: 200rpx;
				margin: 0 auto;
				margin-top: 60rpx;
				margin-bottom: 60rpx;
			}

			.txt {
				color: #C0C4CC;
			}
		}
	}
</style>