<template>
	<view class="index">
		<Nav :navs="navs" :loading="loading" @change="navChange" />
		<scroll-view scroll-y="true" @scrolltolower="scrolltolower">
			<view class="list">
				<view class="item" @tap="toDetail(item)" v-for="(item,index) in auditDetailsList" :key="index">
					<view class="top">
						<view>
							姓名:{{item.submitterName?item.submitterName:item.stuName}}
						</view>
						<view style="background-color: aqua;">
							<DictStatus :types="audius_detail_type" :type="item.statusCode?item.statusCode:item.auditStatus" />
						</view>
						<!-- <DictType :types="rt_penalty_status" :type="item.penaltyStatus" /> -->
						<!-- <uni-icons type="right" size="18" color="#202020"></uni-icons> -->
					</view>
					<view class="content">
						<view v-show="Toggleindex==1">项目大类：{{item.projectName}}</view>
						<view v-show="Toggleindex==1">项目子类：{{item.ruleName}}</view>
						<view  v-show="Toggleindex==1">分数：{{item.operateScore > 0 ? "+" + item.operateScore.toString() : item.operateScore}}</view>
						<view>班级：{{item.className}}</view>
						<view>学号：{{item.stuNo}}</view>
						<view>项目名称：{{item.projectName}}</view>
						<!-- <view>分数：{{item.operateScore > 0 ? "+" + item.operateScore.toString() : item.operateScore}}</view> -->
						<view>提交时间：{{item.createTime?item.createTime:item.submitTime}}</view>
					</view>
				</view>
			</view>
			<view class="empty" v-if="auditDetailsList.length==0&&topLoading==false">
				<image src="@/static/empty.png" mode="widthFix"></image>
				暂时没有数据
			</view>
			<view class="loading-more-top" v-if="topLoading">
				<uni-load-more style="padding-top: 90px;" status="loading" />
			</view>
			<view class="loading-more" v-if="loading">
				<uni-load-more status="loading" />
			</view>
			<view class="no-more" v-if="!loading&&auditDetailsList.length!=0">
				到底啦~~
			</view>
		</scroll-view>
	</view>
</template>

<script>
	import {
		getDicts,
	} from '@/api/system/dict/data.js';
	import {
		myReview,listOwnProcessed
	} from '@/api/comprehensive/instructor.js';
	import Nav from "@/components/navs/navs.vue"
	import DictStatus from "@/components/comprehensive-dict-type/dict-type.vue"
	export default {
		components: {
			Nav,
			DictStatus
		},
		data() {
			return {
				navs: [{
						text: "待办",
						val: ""
					},
					{
						text: "已处理",
						val: "0"
					}
				],
				audius_detail_type: [],
				queryParams: {
				  pageNum: 1,
				  pageSize: 10,
				  projectName: null,
				  submitterId: null,
				  submitterName: null,
				  reviewedById: null,
				  projectId: null,
				  projectTypeId: null,
				  statusCode: null,
				  remarks: null
				},
				auditDetailsList:[],
				loading: false,
				topLoading: true,
				Toggleindex:2
			}
		},
		onShow() {
			if(this.Toggleindex==2){
				this.getList()
			}else{
				this.getOwnProcessedList()
			}
			// this.getList();
			this.get_audius_detail_type();
		},
		methods: {
			toDetail(item){
				if(this.Toggleindex==2){
					uni.navigateTo({
						url:`./audit?item=`+JSON.stringify(item)
					})
				}else{
					uni.navigateTo({
						url:`./detail?item=`+JSON.stringify(item)
					})
				}
				
			},
			navChange(newVal,oldVal) {
				if (this.loading) return;
				if(newVal.indexOf(0)!=-1){
					this.Toggleindex=1
					this.queryParams.pageNum = 1
					this.auditDetailsList=[]
					this.getOwnProcessedList()
				}else{
					this.Toggleindex=2
					this.queryParams.pageNum = 1
					this.auditDetailsList=[]
					this.getList()
					
				}
				
			},
			scrolltolower() {
				if (this.queryParams.pageNum < this.totalPages) {
					this.queryParams.pageNum++;
					this.loading = true;
					if(this.Toggleindex==1){
						setTimeout(() => {
							this.getOwnProcessedList()
						}, 1000)
					}else{
						setTimeout(() => {
							this.getList()
						}, 1000)
					}
					
				} else {
			
				}
			},
			async get_audius_detail_type() {
				let res = await getDicts('audius_detail_type');
				this.audius_detail_type = res.data;
			},
			async getList() {
				let res = await myReview(this.queryParams);
				if (res.code == 200) {
					this.loading = false;
					if (this.queryParams.pageNum == 1) {
						this.auditDetailsList=[]
						this.auditDetailsList = res.rows; // 如果是第一页，直接显示新数据
					} else {
						this.auditDetailsList = this.auditDetailsList.concat(res.rows); // 否则追加新数据到列表中
					}
					this.totalPages = Math.ceil(res.total / this.queryParams.pageSize);
					this.topLoading = false;
			
				}
			},
			async getOwnProcessedList() {
				let res = await listOwnProcessed(this.queryParams);
				if (res.code == 200) {
					this.loading = false;
					if (this.queryParams.pageNum == 1) {
						this.auditDetailsList=[]
						this.auditDetailsList = res.rows; // 如果是第一页，直接显示新数据
					} else {
						this.auditDetailsList = this.auditDetailsList.concat(res.rows); // 否则追加新数据到列表中
					}
					this.totalPages = Math.ceil(res.total / this.queryParams.pageSize);
					this.topLoading = false;
			
				}
			},
		}
	}
</script>

<style lang="scss" scoped>
.index{
	background-color: #F5F5F7;	
	scroll-view {
		height: calc(100vh - 10px);
		padding-top:100rpx;
		.list {
			padding: 20rpx 40rpx 15rpx 40rpx;
		
			.item {
				background-color: white;
				margin-bottom: 20rpx;
				padding: 40rpx;
				border-radius:16px;
				border-bottom-right-radius: 0;
				position: relative;
		
				.top {
					display: flex;
					justify-content: space-between;
					border-bottom: 1px solid #F5F5F7;
					padding-bottom: 20rpx;
		
					.uni-icons {
						opacity: 0.5;
					}
				}
		
				.content {
					padding-top: 20rpx;
		
		
					&>view:not(:last-child) {
						margin-bottom: 15rpx;
		
						.progress {
							color: #1890FF;
						}
					}
		
					.status {
						position: absolute;
						bottom: 0;
						right: 0;
						color: white;
		
						.status-text {
							position: absolute;
							bottom: 15px;
							right: 8%;
							font-size: 35rpx;
						}
		
						.triangle-right {
							width: 0;
							height: 0;
							/* 上边框设置为透明 */
							border-left: 120px solid transparent;
						}
		
						&.submit {
							color: #202020;
		
							.triangle-right {
								/* 左边框设置为与文本相同的颜色 */
								border-bottom: 100px solid #D7D7D7;
							}
						}
		
						&.agree {
							.triangle-right {
								/* 左边框设置为与文本相同的颜色 */
								border-bottom: 100px solid #2FB15B;
							}
						}
		
						&.refuse {
							.triangle-right {
								/* 左边框设置为与文本相同的颜色 */
								border-bottom: 100px solid #FF759F;
							}
						}
					}
				}
			}
		}
		.no-more {
			text-align: center;
			color: gray;
			padding-bottom: 10px;
		}
		.empty{
			display: flex;
			flex-direction: column;
			align-items: center;
			margin-top: 200rpx;
			color: #9E9E9E;
			font-size: 36rpx;
			image{
				width: 250rpx;
				margin-bottom: 50rpx;
			}
		}
	}
}
</style>