<template>
	<view>
		<view style="display: flex;justify-content: space-around;">
			<uni-forms ref="form" :modelValue="formData" >
				<uni-forms-item label="隔离点" name="IsolationPiontName" >
					<uni-data-select
						v-model="formData.valueIsolationPiont"
						:localdata="IsolationPiont"
						@change="changeIsolationPiont"
						:clear="false"
					></uni-data-select>
					<!-- <input type="text" v-model="formData.IsolationPiontName" placeholder="请输入隔离点" /> -->
				</uni-forms-item>
				<uni-forms-item label="批次" name="SamplingBatch">
					<uni-data-select style="width: 100%;"
						v-model="formData.valueSamplingBatch"
						:localdata="dataSamplingBatch"
						@change="changeSamplingBatch"
						:clear="false"
					></uni-data-select>
				</uni-forms-item>
			</uni-forms>
			<button @click="search()" style="margin: 10rpx;background-color: #1296db;color: white;text-align: center;">搜索</button>
		</view>
		<view>
			<text style="margin: 20rpx 60rpx;font-weight: bold;font-size: 40rpx;">样品列表</text>
			<ul class="samList-ul">
				<li class="samList-li" v-for="data in sampleList" :key="data.id">
					<span>{{data.name}}</span>
					<span style="width: 30%;text-align: right;" v-if="data.state==1">合格</span>
					<span style="width: 30%;text-align: right;" v-if="data.state==2">不合格</span>
					<span style="width: 30%;text-align: right;" v-if="data.state==0">未检测</span>
				</li>
			</ul>
		</view>
	</view>
</template>

<script>
	import { getSampleList,getIsolationpointsList} from "../../api/sampling.js"
	export default {
		data() {
			return {
				formData: {
					valueIsolationPiont:'',
					valueSamplingBatch:''
				},
				sampleList:[],
				dataSamplingBatch:[
					{ value: 1, text: "第一批" },
					{ value: 2, text: "第二批" },
					{ value: 3, text: "第三批" }
				],
				IsolationPiont:[],
			};
		},
		methods:{
			search(){
				console.log(this.formData)
				getSampleList(this.formData).then(res=>{
					this.sampleList = res
					for(let i = 0 ;i<this.sampleList.length;i++){
						this.sampleList[i].value = this.sampleList.state
					}
				})
			},
		},
		onLoad() {
			getIsolationpointsList().then(res=>{
			  // console.log(res.data)
			  const arr = res.map(item=>{
				return {"text":item.IsolationPiontName,"value":item.Code}
			  })
			  console.log(arr)
			  this.IsolationPiont = arr
			})
		}
	}
</script>
<style>
	page{
		background-color: #Faf8f8;
	}
</style>
<style lang="scss" scoped>
/deep/ .uni-forms-item{
	display: flex;
	align-items: center;
	margin: 0 40rpx;
	font-size: 35rpx;
}
/deep/ .uni-forms{
	flex-grow: 1;
}
.samList-ul{
	margin: 20rpx 40rpx;
	background-color: white;
	padding: 20rpx;
	line-height: 100rpx;
}
.samList-li{
	display: flex;
	justify-content: space-between;
}
</style>
