<template>
	<view class="content">
		<statusNav returnColor="#c2c2c2" navBarTitle="(备品)查询结果"></statusNav>

		<container-subgroup-two>
			<view class="dataQuery-content" slot="content" style="margin: 0 -30rpx;">
				<view class="li animated fadeIn" v-for="(item,index) in dataList" :key="index">
					<view class="title mar-y120 clips1">项目名称：{{item.name}}</view>
					<view class="text-content">
						<view class="left">
							<view class="text clips1">核心品牌：{{item.brand}}</view>
							<view class="text clips1">规格型号：{{item.model}}</view>
							<view class="text clips1">批 次 号：{{item.batch_number}}</view>
						</view>
						<view class="rigth">
							<view class="text">备品数量：<text class="cor">{{item.quantity}}张</text></view>
							<view class="text cor1">备品尺寸：{{item.size}}</view>
							<view class="text cor1">入库时间：{{item.time}}</view>
						</view>
					</view>
					<view class="icon1" :class="['icon','icon1']"><text class="icon-text">{{['正常','待维保'][item.status]}}</text></view>
				</view>
				<pitera v-if="total==dataList.length && !ifLoading" textStr="查询数据加载完毕~" textFontSize="30rpx" textColor="#b5b2b2"></pitera>
			</view>
		</container-subgroup-two>
	</view>
</template>

<script>
	import containerSubgroupTwo from '@/components/containers/container-subgroup-two.vue';
	import statusNav from '../../components/status-nav.vue';
	import {
		queryFun
	} from '../../jsFile/public-api.js';
	import pitera from '@/components/nothing/pitera.vue';
	export default {
		components: {
			statusNav,
			containerSubgroupTwo,
			pitera
		},
		data() {
			return {
				dataList: [
					// {
					// 	id:1,
					// 	name:'湖南工业大学生化学院三楼会议室湖南工业大学生化学院三楼会议室',//项目名称
					// 	brand:'海康威视',//核心品牌
					// 	quantity: 0,//备品数量
					// 	model:'DS-CK18FI-H',//规格型号
					// 	size:'320*160',//产品尺寸
					// 	batch_number:'2210122',//批次号
					// 	time:'2021-04-06 16:45:45',//入库时间
					// 	status:0
					// },
				],
				list_rows: 20,
				page: 1,
				total: 0,
				key_word: '' ,//关键词
				ifLoading:true
			}
		},
		onReachBottom() {
			if (this.total != this.dataList.length) {
				this.page++;
				this.queryFunEv();
			}
		},
		onLoad(op) {
			if (op.key_word != undefined) {
				this.key_word = op.key_word;
				// 调用查询(备品)列表事件
				this.queryFunEv();
			}
		},
		methods: {
			// 查询(备品)列表事件
			queryFunEv() {
				uni.showLoading({
					title:'加载中...',
					mask:true
				})
				let params = {
					type_id: 3,
					keyword: this.key_word,
					list_rows: this.list_rows,
					page: this.page
				}
				queryFun(params).then(res => {
					console.log(res,'备品列表')
					if (res.code) {
						this.total = res.data.total; //设置总条数
						if (this.page == 1) this.dataList = [];
						if(res.data.data.length) {
							res.data.data.forEach(item=>{
								let obj = {
									id:item.spare_id,
									name:item.project_name,//项目名称
									brand:item.brand,//核心品牌
									quantity: item.quantity,//备品数量
									model:item.product_model,//规格型号
									size:item.size,//产品尺寸
									batch_number:item.batch_number,//批次号
									time:item.warehousing_time,//入库时间
									status:item.status //0：正常		1：待维修
								}
								this.dataList.push(obj);
							})
						}
					} else {
						this.$toolAll.tools.showToast(res.msg);
					}
					uni.hideLoading();
					this.ifLoading = false;
				})
			}
		}
	}
</script>

<style>
	.dataQuery-content {
		font-size: 24rpx;
		color: #333333;
		margin-top: 15rpx;
	}

	.dataQuery-content .li {
		background-color: #FFFFFF;
		padding: 26rpx 28rpx;


		margin-bottom: 14rpx;
	}

	.dataQuery-content .li {
		position: relative;
	}

	.dataQuery-content .li .text-content {
		display: flex;
		border-bottom: 2rpx solid #EEEEEE;
		padding-bottom: 10rpx;

	}

	.dataQuery-content .li .text-content .left {
		width: 48%;
	}

	.dataQuery-content .li .text-content .text {
		margin-top: 20rpx;
	}

	.cor {
		color: #ff9000;
	}

	.cor1 {
		color: #999999;
	}

	.dataQuery-content .li .icon {
		background-image: url(../../static/iocn/zc.png);
		width: 125rpx;
		height: 91rpx;
		display: flex;
		align-items: center;
		box-sizing: border-box;
		background-size: 100%;
		padding-left: 30rpx;
		right: 20rpx;
		top: 20rpx;
		position: absolute;
	}

	.dataQuery-content .li .icon .icon-text {
		transform: rotateZ(20deg);
		color: #53e5d0;

	}

	.dataQuery-content .li .icon1 {
		background-image: url(../../static/iocn/dwx.png);
		width: 125rpx;
		height: 91rpx;
		display: flex;
		align-items: center;
		box-sizing: border-box;
		background-size: 100%;
		padding-left: 30rpx;
		right: 20rpx;
		top: 20rpx;
		position: absolute;
	}

	.dataQuery-content .li .icon1 .icon-text {
		transform: rotateZ(20deg);
		color: #ff0006;

	}
</style>
