<template>
	<!-- 历史列表 -->
	<view>
		<view v-if="evaluations.length>0">
			<view class="content" v-for="(evaluation,index) in evaluations" :key="index" @tap="itemClick(evaluation)"
			 :data-taskid="evaluation.taskId">
				<view class="item-li">
					<view class="item-title">{{index + 1}}.{{evaluation.taskName}}</view>
					<view class="item-content">{{evaluation.evaluationName}}</view>
					<view class="item-bottom-box">
						<view class="item-tag-box">
							<view class="item-time">
								{{evaluation.taskStartTime.substring(0, 10)}}至{{evaluation.taskEndTime.substring(0, 10)}}
							</view>
							<view class="item-tag">
								<view v-if="evaluation.taskType === 1" style="display: flex;flex-direction: row;">
									<view style="color: #000000;">{{evaluation.taskTypeContent.split('|')[1]}} </view>
									<view style="color: #757575;"><text>&nbsp;</text>[被测评部门]</view>
								</view>
								<view v-if="evaluation.taskType === 2" style="display: flex;flex-direction: row;">
									<view style="color: #000000;">{{evaluation.taskTypeContent.split('|')[2]}}</view>
									<view style="color: #757575;"><text>&nbsp;</text>[被测评人员]</view>
								</view>
							</view>
							<!-- <view class="item-tag">
								<text v-if="evaluation.taskType === 1">{{evaluation.taskTypeContent.split('|')[1]}} [被测评部门]</text>
								<text v-if="evaluation.taskType === 2">{{evaluation.taskTypeContent.split('|')[2]}} [被测评人员]</text>
							</view> -->
						</view>
						<view class="item-count-tag">
							<view class="item-count-yet">{{evaluation.taskRecordSubmitCount.substring(0,evaluation.taskRecordSubmitCount.lastIndexOf('|'))}}
							</view>
							<text style="color: #FFFFFF;" space="emsp" decode="true">{{divider}}</text>
							<view class="item-count-not">
								{{evaluation.taskRecordSubmitCount.substring(evaluation.taskRecordSubmitCount.lastIndexOf('未'),evaluation.taskRecordSubmitCount.length)}}</view>
						</view>
					</view>
				</view>
			</view>
		</view>
		<view v-else>
			<emptyView></emptyView>
		</view>
	</view>
</template>

<script>
	import uniList from "@/components/uni-list/uni-list.vue"
	import uniListItem from "@/components/uni-list-item/uni-list-item.vue"
	import uniLoadMore from "@/components/uni-load-more/uni-load-more.vue"
	import common from '../../common/common.js'
	var _self;
	export default {
		components: {
			uniList,
			uniListItem,
			uniLoadMore
		},
		data() {
			return {
				token: '',
				evaluations: [],
				more: 'more',
				divider: '&nbsp;|&nbsp;',
				uploadContentText: {
					contentdown: '点击加载更多',
					contentrefresh: '正在加载...',
					contentnomore: '没有更多数据了'
				}
			}
		},
		onShow() {
			var appToken = uni.getStorageSync('appToken');
			if (!appToken) {
				uni.reLaunch({
					url: '../login/index'
				});
			}
			_self.token = appToken
			uni.startPullDownRefresh({

			});
			// _self.initData();
		},
		onLoad() {
			_self = this;
		},
		onPullDownRefresh() {
			var self = this;
			self.initData();
		},
		methods: {
			initData() {
				var self = this;
				var listUrl = common.evalutaionBaseUrl + '/app/apptask/listtasktoapp';
				uni.showLoading({
					title:'加载中...'
				})
				uni.request({
					url: listUrl,
					data: {
						taskRecordIsSubmit: '1'
					},
					header: {
						'token': _self.token
					},
					success(res) {
						uni.stopPullDownRefresh();
						uni.hideLoading()
						if (res.data != undefined && res.data.length > 0) {
							_self.evaluations = res.data
						} else {
							_self.evaluations = [];
							// uni.showToast({
							// 	title: '暂无数据',
							// 	duration: 2000
							// })
						}
					},
					fail(error) {
						uni.hideLoading()
						uni.stopPullDownRefresh();
						uni.showToast({
							title: '加载失败,请重试',
							duration: 2000
						})
						_self.evaluations = [];
					}
				})
			},
			itemClick(e) {
				// console.log(e.taskRecordId);
				uni.navigateTo({
					url: '../evaluation/missionDetail?taskId=' + e.taskId + '&rid=' + e.taskRecordId
				})
			},
			clickLoadMore(e) {
				var self = this;
				self.more = 'loading';
				setTimeout(() => {
					self.more = 'noMore';
					setTimeout(() => {
						self.more = 'more';
					}, 1000);
				}, 2000);
			}
		}
	}
</script>

<style>
	.content {
		width: 100%;
		display: flex;
		margin-top: 20rpx;
		flex-direction: column;
		align-items: center;
		justify-content: center;
	}

	.item-count {
		font-size: 15rpx;
		display: flex;
		flex-direction: row;
		justify-content: space-between;
		align-items: center;
	}

	.item-li {
		display: flex;
		flex-direction: column;
		height: auto;
		align-self: center;
		justify-content: space-between;
		align-items: flex-start;
		width: 92%;
		min-height: 180rpx;
		background: #FFFFFF;
		/* background: #008B8B; */
		padding: 15rpx;
		border-radius: 10rpx;
		box-shadow: 3rpx 3rpx 5rpx #d9d9d9;
	}

	.item-title {
		font-size: 28rpx;
		font-weight: bold;
		color: #000000;
	}

	.item-content {
		font-size: 30rpx;
		color: #000000;
	}

	.item-count-tag {
		display: flex;
		font-size: 20rpx;
		color: #000000;
		background: #008B8B;
		padding: 10rpx;
		height: 35rpx;
		align-items: center;
		text-align: center;
		border-radius: 10rpx;
		box-shadow: 8rpx 8rpx 10rpx #d9d9d9;
	}

	.item-count-yet {
		color: #FFFFFF;
	}

	.item-count-not {
		color: #f9e9c3;
	}

	.item-tag-box {
		display: flex;
		flex-direction: column;
		align-items: flex-start;
	}

	.item-bottom-box {
		display: flex;
		margin-top: 15rpx;
		flex-direction: row;
		align-items: center;
		justify-content: space-between;
		width: 100%;
	}

	.item-time {
		font-size: 25rpx;
		color: #000000;
	}

	.item-tag {
		display: flex;
		justify-content: center;
		align-items: flex-start;
		text-align: left;
		color: #888888;
		font-size: 25rpx;
	}
</style>
