<template>
	<view class="container">
		<!-- 返回按钮 -->
		<back text="作业详情"></back>
		<view class="detail-item">
			<view class="flex" style="width: 100%;height: 90rpx;">
				<view class="flex" style="margin: -30rpx 0 0 10rpx;">
					<view class="index" :style="{backgroundColor: singleDetail.work.progress === 'finish'? '#23b46c': '#ff8caf' }"></view>
					<view class="name">{{singleDetail.work.name}}</view>
				</view>
			
				<view class="t-icon t-icon-yiwancheng1" v-if="singleDetail.work.progress === 'finish'"
					style="margin-left: auto; width: 90rpx; height: 90rpx;"></view>
				<view class="t-icon t-icon-jinhangzhong-copy1" v-if="singleDetail.work.progress === 'going'"
					style="margin-left: auto; width: 90rpx; height: 90rpx;"></view>
			</view>
			<!-- 正文 -->
			<view class="content-box">
		
				<view class="flex-colum" style="padding: 0 30rpx;">
					<rich-text class="subtitle-info" style="margin-bottom: 15rpx;" :nodes="singleDetail.work.description"></rich-text>
					<view class="flex">
						<view class="subtitle">布置老师:</view>
						<view class="subtitle-info" style="margin-left: 10rpx;">{{singleDetail.work.creatorId}}</view>
						<view class="subtitle" style="margin-left: 20rpx;">截止时间:</view>
						<view class="subtitle-info" style="margin-left: 10rpx;">{{$timestampToTime(singleDetail.work.endTime)}}</view>
					</view>
					
				</view>
		
				<view class="content-detail-box" style="padding: 0 20rpx;">
					<view class="title-box" :style="{backgroundColor: singleDetail.work.progress === 'finish'? '#23b46c': '#ff8caf',top: -15 +'rpx' }">
						<view class="content-subtitle">作业附件</view>
					</view>
					<view v-for="(attachment,i) in singleDetail.work.attachments" :key="i" style="margin-bottom: 20rpx;">
						<view class="attachment-box" @click="openDocument(attachment.url)">
							<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 class="flex-colum" style="margin-left: 20rpx;">
								<view class="content-detail">文件名: {{attachment.name}}</view>
								<view class="content-subtitle" style="color: #aaa;">文件大小: {{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', ['singleDetail'])
		},
		data(){
			return{
			};
		},
		onLoad() {
		},
		methods:{
			fixNum(num){
				return num.toFixed(2)
			},
		}
	}
</script>

<style lang="scss">
	@import '@/subpkg/common/detailpage.scss';
	.attachment-box{
		display: flex;
		align-items: center;
		padding: 15rpx 20rpx;
		background-color: #FFF;
		border-radius: 10rpx;
	}
	.flex-colum{
		display: flex;
		flex-direction: column;
	}
</style>