<template>
	<view>
		<view class="navbar">
			<view class="back">
				<text class="iconfont icon-fanhui " @click="backLast()"></text>
			</view>
			<text>提交申报</text>
		</view>
		<view class="shenbaoList">
			<view class="list_li" v-for="(item,index) in list" :key="index">
				<view class="title">{{item.name}}</view>
				<view class="li_bottom" v-if="item.is_one==1 && item.examine">
					<view>
						状态：<text  style="color: #19b83b;" v-if="item.examine.check_status==2">审核通过</text>
						<text  style="color: #007AFF;" v-else-if="item.examine.check_status==1">待审核</text>
						<text style="color: red;" v-else>审核失败</text>
					</view>
					<view style="display: flex;align-items: center;justify-content: flex-end;"
						v-if="item.examine && item.examine.check_status==1">
						得分：{{ item.examine ? item.examine.point : 0 }}
					</view>
					<view style="display: flex;align-items: center;justify-content: flex-end;"
						v-if="item.examine && item.examine.check_status==2">
						得分：{{ item.examine ? item.examine.check_point : 0 }}
					</view>
				</view>
				<view class="li_bottom">
					<view>状态：{{item.examine ? '已申报' : '未申报'}}</view>
					<view style="display: flex;align-items: center;justify-content: flex-end;">
						<view v-if="is_open" class="button upload" @click="upload(item)">
							<text>上传</text>
						</view>
						<view class="button none" @click="detail(item)" v-if="item.examine" style="margin-left: 20upx;">
							<text>详情</text>
						</view>
						<view class="button none" @click="deletes(item)" v-if="item.is_one==1 && is_open && item.examine && item.examine.check_status==1 "
							style="background: red;margin-left: 20upx;">
							<text>删除</text>
						</view>
					</view>
				</view>
			</view>
		</view>
	</view>
</template>

<script>
	var app = getApp()
	import navBar from '../../components/navBar/navbar.vue';
	export default {
		components: {
			navBar
		},
		data() {
			return {
				list: [],
				show: false,
				uploadPdf: '',
				is_open: false, //是否再上传时间段
			};
		},
		onLoad() {

		},
		onShow() {
			this.getList()
			this.getSettings()
		},
		methods: {
			//获取配置项
			async getSettings() {

				let params = {
					keys: ["EMAMINE_START_TIME", "EMAMINE_END_TIME"]
				}
				app.request('/setting/keys', params, 'post').then(res => {
					let data = res.data.data
					console.log(data, "配置项----");
					let now_time = new Date().valueOf();
					let start_time = data.EMAMINE_START_TIME;
					start_time = new Date(start_time).valueOf();
					let end_time = data.EMAMINE_END_TIME;
					end_time = new Date(end_time).valueOf();
					console.log(end_time, "-----", start_time, "======", now_time);
					if (now_time >= start_time && now_time <= end_time) {
						this.is_open = true
					} else {
						this.is_open = false
					}
					console.log(now_time >= start_time, 'this.is_openthis.is_openthis.is_open', now_time <=
						end_time)
				})

			},
			getList() {
				app.request('/examine/lists', 'get').then(res => {
					console.log(res)
					this.list = res.data.data.examine
				})
			},
			backLast: function() {
				uni.reLaunch({
					url: './index'
				})
			},
			upload: function(item) {
				console.log(item)
				uni.navigateTo({
					url: './upload?id=' + item.id + '&verification=' + JSON.stringify(item.verification) +
						'&number=' + item.is_one + '&extra=' + JSON.stringify(item.extra)
				})
			},
			detail(item) {
				// this.show = true
				// var obj = e.examine.resources
				// var arr = Object.values(obj);
				// console.log(arr)
				// this.uploadPdf = arr[0]
				if (item.type == 1) {
					uni.navigateTo({
						url: './shenbaoDetail?id=' + item.id
					})
				} else {
					uni.navigateTo({
						url: './fileList?id=' + item.id
					})
				}


			},
			deletes(item) {
				var data = {
					examine_question_id: item.id,
					id: item.examine.id,
					staff_id: item.examine.staff.id
				}
				app.request('/examine/delete', data, 'post').then(res => {
					console.log(res)
					uni.showToast({
						title: '删除成功',
						icon: 'none'
					})
					this.getList()
				})
			},
		}
	}
</script>

<style lang="scss">
	page {
		background: #f5f5f5;
	}

	.iframe {
		width: 100%;
		height: 100%;
		position: fixed;
		z-index: 222;
		top: 0;
		left: 0;
	}

	.title {
		font-size: 16px;
		font-weight: 550;
		color: #4d4d4d;
		border-bottom: dashed 1px #EFF1F6;
		padding-bottom: 10px;
	}

	.navbar {
		font-size: 32upx;
		height: 100upx;
		line-height: 100upx;
		color: #888888;
		position: relative;
		position: fixed;
		top: 0;
		z-index: 9999999;
		width: 100%;
		background-color: #FFFFFF;
		text-align: center;
		border-bottom: solid 2upx #EFF1F6;

		.back {
			height: 100upx;
			width: 100upx;
			text-align: center;
			// background-color: #007AFF;
			position: absolute;
			float: left;
			left: 0upx;
			font-size: 32upx;
		}
	}

	.shenbaoList {
		padding-top: 100upx;
		display: flex;
		flex-direction: column;
		width: 100%;
		align-items: center;

		.list_li {
			display: flex;
			flex-direction: column;
			width: 90%;
			margin-top: 20upx;
			padding: 20upx;
			font-size: 26upx;
			background: white;

			.text1 {
				padding-top: 10upx;
			}

			.li_bottom {
				display: flex;
				padding-top: 10px;
				align-items: center;
				justify-content: space-between;

				// padding-top: 10upx;
				.button {
					border-radius: 3px;
				}

				.none {
					background: #1c85f1;
					color: white;
					display: flex;
					align-items: center;
					justify-content: center;
					padding: 8upx 15upx;
				}

				.upload {
					background: #19b83b;
					color: white;
					display: flex;
					align-items: center;
					justify-content: center;
					padding: 8upx 15upx;
				}
			}
		}
	}
</style>
