<template>
	<view>
		<view class="search-bar">
			<uni-easyinput suffixIcon="search" v-model="centerIpt" placeholder="请输入关键字" @iconClick="searchKeyword"></uni-easyinput>
		</view>
		<view 
			class="single-fetch"
			v-for="(list, index) in centerExamList"
			:key="list.id"
		>
			<view class="fetch-upper">
				<!-- <checkbox-group 
					v-show="pre.taskStatus == 58" 
					style="margin-right: 15rpx;"
					@change="checkClick(pre)"
				>
					<checkbox :checked="pre.checked" />
				</checkbox-group> -->
				<view class="upper-lef">
					{{ list.createBy == null ? '' : list.createBy.slice(0, 1) }}
				</view>
				<view class="upper-rig">
					<h4 style="font-size: 16px;">{{ list.createBy }}</h4>
					<!-- <h4 style="color: #989898;">{{ list.unitName }}</h4> -->
				</view>
			</view>
			<view class="fetch-lower">
				<view>
					<span>采购单号</span>
					<h4>{{ list.code }}</h4>
				</view>
				<view>
					<span>采购日期</span>
					<h4>{{ list.purchaseTime }}</h4>
				</view>
				<view>
					<span>到货日期</span>
					<h4>{{ list.arrivalTime }}</h4>
				</view>
				<view>
					<span>采购机具设备</span>
					<h4>{{ list.purchasingTypeName }}</h4>
				</view>
				<view>
					<span>采购员</span>
					<h4>{{ list.purchaserName == null ? '-' : list.purchaserName }}</h4>
				</view>
				<view>
					<span>提交时间</span>
					<h4>{{ list.createTime }}</h4>
				</view>
				<view>
					<span>备注</span>
					<h4>{{ list.remark }}</h4>
				</view>
			</view>
			<view class="fetch-btns">
				<view 
					style="background-color: #3788FF;" 
					@click="seeCenterDetail(list.taskId)"
				>
					<uni-icons style="color: #fff;" type="eye"></uni-icons>
					查看
				</view>
				<view 
					style="background-color: #FCA30D;" 
					v-show="list.taskStatus == 122"
					@click="examCenterDetail(list.taskId)"
				>
					<uni-icons style="color: #fff;" type="auth"></uni-icons>
					审核
				</view>
				<!-- <view
					style="background-color: #FCA30D;" 
					v-show="pre.taskStatus == '121' && ifRole"
					@click="examPreDetail(pre.taskId)"
				>
					<uni-icons style="color: #fff;" type="auth"></uni-icons>
					审核
				</view> -->
			</view>
			<view class="sticky-area">
				<h4
					:class="[
						{ red: list.taskStatus == 106 || list.taskStatus == 107 },
						{ green: list.taskStatus == 28 }
					]"
				>
					{{ list.taskMark }}
				</h4>
			</view>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				centerIpt: '',
				centerExamList: []
			}
		},
		methods: {
			searchKeyword () {
				this.getCenterList(this.centerIpt)
			},
			seeCenterDetail (taskId) {
				console.log(taskId);
				uni.navigateTo({
					url: `/pages/serviceCenterExamDetail/serviceCenterExamDetail?taskId=${taskId}`
				})
			},
			examCenterDetail (taskId) {
				console.log(taskId);
				uni.navigateTo({
					url: `/pages/serviceCenterExamDetail/serviceCenterExamDetail?taskId=${taskId}&showExam=0`
				})
			},
			getCenterList (keyWord) {
				let that = this
				that.$api.serviceCenterExam.fetchCenterList({
					flag: 1,
					keyWord
				}).then(res => {
					console.log(res);
					if (res.data.code == 200) {
						res.data.data.forEach(item => {
							switch (item.taskStatus) {
								case 26:
									item.taskMark = '待审核'
									break;
								case 28:
									item.taskMark = '已全部入库'
									break;
								case 105:
									item.taskMark = '入库审核中'
									break;
								case 106:
									item.taskMark = '综合服务中心未通过'
									break;
								case 107:
									item.taskMark = '入库审核未通过'
									break;
								case 122:
									item.taskMark = '待审核'
									break;
								case 123:
									item.taskMark = '部分已入库'
									break;
							}
						})
						that.centerExamList = res.data.data
					} else {
						uni.showToast({
							icon: 'none',
							title: res.data.msg
						})
					}
				}).catch(err => {
					console.log(err);
				})
			}
		},
		onShow() {
			this.centerIpt = ''
			this.getCenterList('')
		}
	}
</script>

<style lang="scss">
	body{
		background-color: #f8f8f8;
		box-sizing: border-box;
		padding-bottom: 10vh;
	}
	.search-bar{
		width: 95%;
		margin: 20rpx auto;
	}
	.single-fetch{
		width: 95%;
		margin: 20rpx auto;
		background-color: #fff;
		border-radius: 15rpx;
		box-sizing: border-box;
		padding: 15rpx;
		position: relative;
		.fetch-upper{
			width: 100%;
			box-sizing: border-box;
			padding: 15rpx;
			border-bottom: 1px solid #D7D7D7;
			display: flex;
			align-items: center;
			.upper-lef{
				width: 12%;
				height: 5vh;
				border-radius: 15rpx;
				overflow: hidden;
				display: flex;
				justify-content: center;
				align-items: center;
				font-size: 24px;
				background-color: #3788FF;
				color: #fff;
			}
			.upper-rig{
				flex: 1;
				box-sizing: border-box;
				padding: 10rpx 20rpx;
				display: flex;
				flex-direction: column;
				justify-content: space-around;
				h4{
					font-weight: normal;
					font-size: 14px;
				}
			}
		}
		.fetch-lower{
			width: 100%;
			box-sizing: border-box;
			padding: 15rpx;
			border-bottom: 1px solid #D7D7D7;
			view{
				width: 100%;
				display: flex;
				align-items: center;
				margin-bottom: 15rpx;
				font-size: 14px;
				span{
					color: #9D9D9D;
					padding-right: 20rpx;
				}
				h4{
					color: #000;
					font-size: 14px;
					font-weight: normal;
				}
			}
			view:last-child{
				margin-bottom: 0;
			}
		}
		.fetch-btns{
			width: 100%;
			box-sizing: border-box;
			padding: 15rpx;
			display: flex;
			justify-content: flex-end;
			view{
				box-sizing: border-box;
				padding: 8rpx 25rpx;
				border-radius: 15rpx;
				margin-right: 15rpx;
				color: #fff;
				font-size: 14px;
			}
		}
		.sticky-area{
			position: absolute;
			top: 20rpx;
			right: 20rpx;
			/* width: 11vh;
			height: 10vh;
			image{
				width: 100%;
				height: 100%;
			} */
			h4{
				box-sizing: border-box;
				padding: 8rpx 20rpx;
				border-radius: 15rpx;
				font-size: 14px;
				font-weight: normal;
				background-color: #fff;
				border: 1px solid #3788FF; 
				color: #3788FF;
			}
			.red{
				border-color: #FF4141;
				color: #FF4141;
			}
			.green{
				border-color: #1BD30B;
				color: #1BD30B;
			}
		}
	}
</style>
