<template>
	<view class="stu-punishment">
		<!-- <Nav :navs="navs" @change="navChange"/> -->
		<scroll-view scroll-y="true" @scrolltolower="scrolltolower">
			<view class="list">
				<view class="item" @tap="toDetail(item)" v-for="(item,index) in stuPunishmentList" :key="index">
					<view class="top">
						<view>
							姓名:{{item.stuName}}
						</view>
						<view style="background-color: aqua;">
							<DictStatus :types="audius_detail_type" :type="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>项目大类：{{item.projectName}}</view>
						<view>项目子类：{{item.ruleName}}</view>
						<view>分数：{{item.operateScore > 0 ? "+" + item.operateScore.toString() : item.operateScore}}</view>
						<view>班级：{{item.className}}</view>
						<view>提交时间：{{item.submitTime}}</view>
					</view>
				</view>
			</view>
			<view class="empty" v-if="stuPunishmentList.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&&stuPunishmentList.length!=0">
				到底啦~~
			</view>
		</scroll-view>
		<view class="add" @tap="addDisciplinaryApplication">
			+
		</view>
	</view>
</template>

<script>
	import {
		listOwnApply,
	} from '@/api/comprehensive/student.js';
	import DictStatus from "@/components/comprehensive-dict-type/dict-type.vue"
	import {
		getDicts,
	} from '@/api/system/dict/data.js';
	export default {
		components: {
				DictStatus
		},
		data() {
			return {
				stuPunishmentList: [],
				loading: false,
				topLoading: true,
				audius_detail_type: [],
				rt_penalty_status: [],
				queryParams: {
				  pageNum: 1,
				  pageSize: 10,
				  projectName: null,
				  submitterId: null,
				  submitterName: null,
				  reviewedById: null,
				  projectId: null,
				  projectTypeId: null,
				  statusCode: null,
				  remarks: null
				},
			}
		},
		onLoad(){
			
		},
		onShow() {
			this.getList();
			this.get_audius_detail_type();
		},
		methods: {
			addDisciplinaryApplication(){
				uni.navigateTo({
					url:"./add"
				})
			},
			scrolltolower() {
				if (this.queryParams.pageNum < this.totalPages) {
					this.queryParams.pageNum++;
					this.loading = true;
					setTimeout(() => {
						this.getList()
					}, 1000)
				} else {

				}
			},
			toDetail(item){
				uni.navigateTo({
					url:`./detail?item=`+JSON.stringify(item)
				})
			},
			navChange(index){
				this.stuPunishmentList=[];
				this.topLoading=true;
				this.queryParams={
					pageNum: 1,
					pageSize: 10,
					penaltyStatus:index
				};
				this.getList();
			},
			async getList() {
				let res = await listOwnApply(this.queryParams);
				if (res.code == 200) {
					this.loading = false;
					if (this.queryParams.pageNum == 1) {
						this.stuPunishmentList = res.rows; // 如果是第一页，直接显示新数据
					} else {
						this.stuPunishmentList = this.stuPunishmentList.concat(res.rows); // 否则追加新数据到列表中
					}
					this.totalPages = Math.ceil(res.total / this.queryParams.pageSize);
					this.topLoading = false;

				}
				console.log(res)
			},
			async get_audius_detail_type() {
				let res = await getDicts('audius_detail_type');
				this.audius_detail_type = res.data;
			},
		}
	}
</script>

<style scoped lang="scss">
	.stu-punishment {
		background-color: #F5F5F7;
		scroll-view {
			height: calc(100vh - 10px);
			// padding-top:100rpx;
			.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;
				}
			}
		}

		.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;
							}
						}
					}
				}
			}
		}
		.add {
			background-color: #1890FF;
			width: 90rpx;
			height: 90rpx;
			border-radius: 50%;
			color: white;
			display: flex;
			justify-content: center;
			align-items: center;
			font-size: 60rpx;
			position: fixed;
			bottom: 50px;
			right: 25px;
		}
	}
</style>