<template>
	<view class="mainBox">
		<uni-nav-bar fixed="true" statusBar="true" left-icon="back" title="质检工单" @clickLeft="back">
		</uni-nav-bar>

		<view class="top-wrapper">
			<uni-section>
				<uni-easyinput prefixIcon="search" style="width: 460rpx" v-model="searchVal" placeholder="名称、批次号">
				</uni-easyinput>
			</uni-section>
			<button class="search_btn" @click="doSearch">搜索</button>
		</view>
		<div style="height:100rpx;width: 475rpx;"></div>
		<view class="wrapper">
			<u-list @scrolltolower="scrolltolower" class="listContent">
				<view v-for="(item, index) in tableList" :key="item.id" style="position: relative;">
					<view class="item">
						<view class="herder_item">
							<view class="herder_text"></view>
							<view class="herder_view">
								{{ getDictValue('质检计划类型', item.qualityType+'')}}/{{item.code}}/{{item.productCode}}/{{item.productName}}
							</view>
						</view>
						<view class="text">检验项目：</view>
						<view class="item_value">
							<view @click="goTo(item.id,row.id)" v-for="(row,_index) in item.templateList"
								:key="index+'_'+_index"
								:style="{background:row.status==1?'#19be6b':row.status==2?'#ff9900':row.status==3?'#ff9900':'#909399'}">
								{{row.inspectionName}}
							</view>
						</view>
					</view>
				</view>
				<view style="width:100%;height:40rpx"></view>
				<view style='margin-top: 20vh;' v-if="tableList.length==0">
					<u-empty iconSize='150' textSize='32' text='暂无数据'>
					</u-empty>
				</view>
			</u-list>

		</view>




		<u-toast ref="uToast"></u-toast>

	</view>
</template>

<script>
	import dictMixns from '@/mixins/dictMixins'
	import {
		getList,
	} from '@/api/inspectionWork/index.js'
	export default {
		components: {},
		mixins: [dictMixns],
		data() {
			return {


				tableList: [],
				page: 1,
				size: 10,
				isEnd: false,
				searchVal: ''

			}
		},
		computed: {

		},
		onLoad() {
			this.requestDict('质检计划类型')
			this.getList()
		},

		onShow() {
			this.isEnd = false
			this.page = 1
			this.getList()
		},
		methods: {
			doSearch() {
				this.isEnd = false
				this.page = 1
				this.getList()
			},
			//获取列表信息
			getList() {
				if (this.isEnd) {
					return
				}
				uni.showLoading({
					title: '加载中'
				})

				let data = {
					pageNum: this.page,
					size: this.size,
					partaName: this.searchVal,
					recordingMethod: 1
				}
				getList(data).then(res => {
					if (this.page === 1) {
						this.tableList = res.list
					} else {
						this.tableList.push(...res.list)
					}
					this.page += 1
					this.isEnd = this.tableList.length >= res.count
				}).then(() => {
					uni.hideLoading()
				})
			},
			goTo(workId, projectId) {

				uni.navigateTo({
					url: '/pages/qms/inspectionWork/inspectionProjectReport?workId='+workId+'&projectId='+projectId
				})
			},

			scrolltolower() {
				if (this.isEnd) {
					return
				}
				this.getList();
			},
		}
	}
</script>

<style lang="scss" scoped>
	.mainBox {
		background-color: #f3f8fb
	}

	// .wrapper{

	// }
	.top-wrapper {
		background-color: #fff;
		display: flex;
		width: 750rpx;
		height: 88rpx;
		padding: 16rpx 32rpx;
		align-items: center;
		gap: 16rpx;
		position: fixed;
		z-index: 999;

		/deep/.uni-section {
			margin-top: 0px;
		}

		/deep/.uni-section-header {
			padding: 0px;

		}

		.search_btn {
			width: 120rpx;
			height: 70rpx;
			line-height: 70rpx;
			padding: 0 24rpx;
			background: $theme-color;
			font-size: 32rpx;
			color: #fff;
			margin: 0;
			margin-left: 26rpx;
		}

		.menu_icon {
			width: 44rpx;
			height: 44rpx;
			margin-left: 14rpx;
		}
	}

	.item {
		width: 720rpx;
		// height:400rpx;
		margin: 20rpx auto 0;
		padding: 26rpx;
		border-radius: 30rpx;

		.text {
			margin-top: 20rpx;
		}

		background: #fff;
	}

	.item_value {
		width: 100%;
		display: flex;
		flex-wrap: wrap;
		margin-left: -10rpx;

		>view {
			font-size: 24rpx;
			color: #fff;
			padding: 12rpx;
			border-radius: 10rpx;
			background: #979797;
			margin-left: 10rpx;
			margin-top: 20rpx;
		}
	}

	.herder_item {
		display: flex;
		// align-items: center;
		font-size: 28rpx;
		font-weight: bold;

		.herder_view {
			width: calc(100% - 20rpx);
			word-break: break-all;

		}

		.herder_text {
			min-width: 10rpx;
			height: 32rpx;
			border-radius: 10rpx;
			background: #00c0a1;
			margin-right: 12rpx;
			margin-top: 5rpx;
		}
	}
</style>