<template>
	<view class="page_view">
		<top-return :color="'#FFF'" text="作业列表"></top-return>
		
		<view class="bg_card"></view>
		
		<!-- 页面标题内容 -->
		<view class="flex_cloumn">
			<view class="flex_baseline">
				<view class="content_title" style="font-size: 60rpx;">{{dayTime.split('月')[0]}}</view>
				<view class="content_title" style="margin-left: 10rpx;">月</view>
				<view class="content_title" style="font-size: 60rpx; margin-left: 10rpx;">{{dayTime.split('月')[1]}}</view>
				<view class="content_title" style="margin-left: 10rpx;">日</view>
				<view class="content_title" style="margin-left: 10rpx;font-size: 50rpx;">{{value}}</view>
								<view class="content_title" style="margin-left: 10rpx;">完成</view>
			</view>
			<view class="flex_baseline">
				<view class="content_subtitle" style="opacity: 0.8;">孩子共</view>
					<view class="content_subtitle" style="margin-left: 20rpx;font-size: 40rpx;transform: skew(-15deg);">{{workData.length}}</view>
				<view class="content_subtitle" style="margin-left: 20rpx;opacity: 0.8;">份作业</view>
			</view>
		</view>
		
		<view class="card_view">
			<view class="card_item" style="width: 100%;" v-for="(item,index) in workData" :key="index" @click="navWorkData(index)">
				<view class="card_title">
					<view class="front_tag" style="height: 40rpx;"></view>
					<view class="title" style="font-size: 36rpx;">{{item.work.name}}</view>
					<view :class="item.work.progress === 'finish'?'t-icon t-icon-yiwancheng1':'t-icon t-icon-jinhangzhong-copy1'" style="position: absolute; width: 100rpx; height: 100rpx;margin-left: 570rpx;margin-top: 50rpx;"></view>
				</view>
				<view class="cloumn">
					<view class="flex_row">
						<u-parse class="title" style="font-size: 30rpx;" :content="item.work.description" :selectable="true"></u-parse>
					</view>
					<view class="flex_baseline" style="margin-top: 20rpx;">
						<view class="subtitle">布置老师:</view>
						<view class="title" style="margin-left: 20rpx; font-size: 30rpx;">{{item.work.creatorId}}</view>
						<view class="subtitle" style="margin-left: 20rpx;">截至时间:</view>
						<view class="title" style="margin-left: 20rpx; font-size: 30rpx;">{{$timeStampToTime(item.work.endTime)}}</view>
					</view>
				</view>
				<!-- 正文 -->
				<view class="content_box">
					<view class="title_box" :style="{backgroundColor: item.work.progress === 'finish'? '#23b46c': '#f9c752' }">
						<view class="title_text">作业附件</view>
					</view>
					<view v-for="(attachment,i) in item.work.attachments" :key="i">
						<view class="attachment_box">
							<view v-if="attachment.type == 'word'" class="t-icon t-icon-WORD"></view>
							<view v-if="attachment.type == 'excel'" class="t-icon t-icon-ECEL"></view>
							<view v-if="attachment.type == 'pdf'" class="t-icon t-icon-PDF"></view>
							<view v-if="attachment.type == 'image'" class="t-icon t-icon-tupianziliao"></view>
							<view v-if="attachment.type == 'ppt'" class="t-icon t-icon-PPT"></view>
							<view class="cloumn" style="margin-left: 20rpx;">
								<view class="content_detail">文件名: {{attachment.name}}</view>
								<view class="content_subtitle">文件大小: {{fixNum(attachment.size/8/1024)}}KB</view>
							</view>
						</view>
					</view>
				</view>
				
			</view>
		</view>
	</view>
</template>

<script>
	import {
		mapState,
		mapMutations
	} from 'vuex'
	export default {
		computed: {
			...mapState('m_children',['workData'])
		},
		data(){
			return {
				value: '',
				dayTime: ''
			}
		},
		onLoad(parameter) {
			this.value = parameter.value
			this.dayTime = (new Date()).format('M-d').replace('-', '月')
		},
		methods: {
			fixNum(num){
				return num.toFixed(2)
			},
			navWorkData(index){
				uni.navigateTo({
					url: `/subpkg/datalist/workdata?index=${index}`
				})
			}
		}
	}
</script>

<style lang="scss">
	.subtitle{
		font-weight: 400;
		font-size: 26rpx;
	}
	.tag{
		border-radius: 6rpx;
		border: 1rpx solid $color-blue;
		padding: 5rpx 16rpx;
		.tag_text{
			font-size: 22rpx;
			color: $color-blue;
		}
	}
	.content_box{
		margin: 20rpx;
		padding: 0 20rpx;
		background-color: #f6f6f6;
		border-radius: 10rpx;
		.title_box{
			position: relative;
			top: -20rpx;
			width:fit-content;
			height: 36rpx;
			border-radius: 10rpx;
			padding: 5rpx 20rpx;
			.title_text{
				font-size: 25rpx;
				font-weight: bold;
				color: #FFF;
			}
		}
		.content_detail{
			font-size: 30rpx;
			font-weight: bold;
			color: $title;
			word-break: break-all;
		}
		.content_subtitle {
			font-size: 25rpx;
			font-weight: bold;
			color: $subtitle;
		}
	}
	.attachment_box{
		display: flex;
		margin-bottom: 20rpx;
		align-items: center;
		padding: 15rpx 20rpx;
		background-color: #FFF;
		border-radius: 10rpx;
		.t-icon{
			width: 60rpx;
			height: 60rpx;
		}
	}
	.flex_cloumn {
		margin: 140rpx 0 0 50rpx;
		height: 170rpx;
		justify-content: space-around;
	
		.content_title {
			font-size: 35rpx;
			font-weight: bold;
			transform: skew(-15deg);
			color: #FFF;
			z-index: 2;
		}
	
		.content_subtitle {
			font-size: 35rpx;
			color: #FFF;
			z-index: 2;
		}
	}
	.cloumn{
		display:flex;
		flex-direction: column;
		margin: 20rpx 50rpx;
	}
</style>