<template>
	<view class="teaching">
		<view @click="itemClick(item,index)" class="teaching-item" v-for="(item,index) in list" :key="index">
			<view class="teaching-item-title">
				{{item.title}}
			</view>
			<view class="teaching-item-img">
				<view v-for="(item1,index1) in item.fileList" :key="index1" class="teaching-item-img-item">
					<view class="teaching-item-img-item-top">
						<image style="width: 100%;height: 100%;" :src="item1.img" mode=""></image>
					</view>
					<view class="teaching-item-img-item-bottom">
						{{item1.title}}
					</view>
					<view v-if="show" class="teaching-item-img-item-text">
						
						<view @click.stop='upload(item1)' style="margin-left: 20rpx;" class="">
							下载
						</view>
						<view @click.stop='preview(item1)' style="margin-right: 20rpx;" class="">
							预览
						</view>
					</view>
				</view>
			</view>
			<view class="teaching-item-text">
				<view class="teaching-item-text-left">
					上传者 {{item.user}}
				</view>
				<view class="teaching-item-text-right">
					上传时间 {{ item.date}}
				</view>
			</view>
		</view>
	</view>
</template>

<script>
	export default {
		name: "teachingList",
		props: {
			list: {
				default: () => [],
				type: Array
			},
			show: {
				type: Boolean,
				default: () => false,
			}
		},
		data() {
			return {

			};
		},
		methods: {
			itemClick(item, index) {
				this.$emit('itemClick', item)
			},
			upload(item) {
				this.$emit('upload', item)
			},
			preview(item){
				this.$emit('preview', item)
			}
		}
	}
</script>

<style lang="scss" scoped>
	.teaching {
		width: 100%;

		.teaching-item {
			padding: 32rpx;
			background-color: #fff;

			border-radius: 5.33px;
			box-shadow: 0px 0px 6.67px 0px rgba(147, 147, 147, 0.20);
			box-sizing: border-box;
			margin-bottom: 32rpx;

			.teaching-item-title {
				font-size: 32rpx;
				color: #333;
				border-bottom: 1px solid #f2f2f2;
				padding-bottom: 20rpx;
			}

			.teaching-item-text {
				color: #999;
				display: flex;
				justify-content: space-between;
			}

			.teaching-item-img {
				display: flex;
				flex-wrap: wrap;
				margin: 32rpx 0;

				.teaching-item-img-item {
					width: 25%;
					display: flex;
					flex-direction: column;
					justify-content: center;
					align-items: center;

					.teaching-item-img-item-top {
						width: 66rpx;
						height: 74rpx;
						margin-bottom: 10rpx;
					}

					.teaching-item-img-item-text {
						display: flex;
						justify-content: space-between;
						width: 100%;
						color: #05CCA1;
						font-size: 24rpx;
						text-decoration: underline;
					}
				}
			}
		}
	}
</style>