<template>
	<view class="container">
		<u-navbar class="u-navbar" title="日计划管理" placeholder @leftClick="leftClick" leftIconColor="#fff"
			bgColor="#00337A" :titleStyle="{ color: '#FFF', fontSize: '32rpx' }" />
		<!-- Header -->
		<view class="header">
			<view class="date-section">
				<picker mode="date" fields="month" :value="currentDate" @change="onDateChange">
					<view class="date-picker">
						<image src="@/static/realName/attendance.png" class="calendar-icon"></image>
						<text>{{currentDate}}</text>
					</view>
				</picker>
			</view>
			<view class="progress-section">
				<text class="reminder-text">请于每日18:00前提交胡日计划</text>
				<button class="primary-btn" @click="developDailyPlan">制定日计划</button>
			</view>
			<view class="project-title">
				<text>XXXXXXXXXXXXXXXXXXXXXXXXX工程</text>
			</view>
			<view class="completion-rate">
				<text>作业计划完成率：70%</text>
				<text>月完成计划完成率：70%</text>
			</view>
		</view>

		<!-- Task List -->
		<view class="task-list">
			<!-- Task Item 1 -->
			<view class="task-item">
				<view class="task-header">
					<text class="timestamp">2022-09-09 17:56:55</text>
					<view class="status not-started">未开始</view>
				</view>
				<view class="metrics-container">
					<view class="metric-row">
						<text class="metric-item">总计划数量：2</text>
						<text class="metric-item">月计划数量：2</text>
						<text class="metric-item">计划数量：2</text>
					</view>
					<view class="metric-row">
						<text class="metric-item">累计完成作业量：3</text>
						<text class="metric-item">月累计完成作业量：3</text>
						<text class="metric-item">作业人数：3</text>
					</view>
				</view>
				<view class="actions">
					<button class="action-btn">详情</button>
					<button class="action-btn">修改</button>
					<button class="action-btn danger">提报</button>
				</view>
			</view>

			<!-- Task Item 2 -->
			<view class="task-item">
				<view class="task-header">
					<text class="timestamp">2022-09-09 17:56:55</text>
					<view class="status in-progress">进行中</view>
				</view>
				<view class="metrics-container">
					<view class="metric-row">
						<text class="metric-item">总计划数量：2</text>
						<text class="metric-item">月计划数量：2</text>
						<text class="metric-item">计划数量：2</text>
					</view>
					<view class="metric-row">
						<text class="metric-item">累计完成作业量：3</text>
						<text class="metric-item">月累计完成作业量：3</text>
						<text class="metric-item">作业人数：3</text>
					</view>
				</view>
				<view class="actions">
					<button class="action-btn" @click="detailsPlan">详情</button>
					<button class="action-btn" @click="uploadPlan">完成电子上传</button>
				</view>
			</view>

			<!-- Task Item 3 -->
			<view class="task-item">
				<view class="task-header">
					<text class="timestamp">2022-09-09 17:56:55</text>
					<view class="status completed">已结束</view>
				</view>
				<view class="metrics-container">
					<view class="metric-row">
						<text class="metric-item">总计划数量：2</text>
						<text class="metric-item">月计划数量：2</text>
						<text class="metric-item">计划数量：2</text>
					</view>
					<view class="metric-row">
						<text class="metric-item">累计完成作业量：3</text>
						<text class="metric-item">月累计完成作业量：3</text>
						<text class="metric-item">作业人数：3</text>
					</view>
				</view>
				<view class="actions">
					<button class="action-btn" @click="detailsPlan">详情</button>
					<button class="action-btn" @click="uploadPlan">完成电子上传</button>
				</view>
			</view>
		</view>
	</view>
</template>

<style>
	.container {
		padding: 20rpx;
		background-color: #f5f5f5;
	}

	.header {
		background-color: #fff;
		padding: 20rpx;
		border-radius: 10rpx;
		margin-bottom: 20rpx;
	}

	.date-section {
		display: flex;
		align-items: center;
		margin-bottom: 10rpx;
	}

	.date-picker {
		display: flex;
		align-items: center;
	}

	.calendar-icon {
		width: 32rpx;
		height: 32rpx;
		margin-right: 10rpx;
	}

	.progress-section {
		display: flex;
		justify-content: space-between;
		align-items: center;
		margin: 20rpx 0;
	}

	.reminder-text {
		color: #ff4d4f;
		font-size: 28rpx;
	}

	.primary-btn {
		background-color: #0099ff;
		color: #fff;
		padding: 0rpx 20rpx;
		border-radius: 20rpx;
		font-size: 28rpx;
	}

	.project-title {
		font-size: 32rpx;
		font-weight: bold;
		margin: 20rpx 0;
	}

	.completion-rate {
		display: flex;
		justify-content: space-between;
		color: #666;
		font-size: 28rpx;
	}

	.task-item {
		background-color: #fff;
		padding: 20rpx;
		border-radius: 10rpx;
		margin-bottom: 20rpx;
	}

	.task-header {
		display: flex;
		justify-content: space-between;
		align-items: center;
	}

	.timestamp {
		color: #999;
		font-size: 24rpx;
	}

	.status {
		display: inline-block;
		padding: 4rpx 20rpx;
		border-radius: 4rpx;
		font-size: 24rpx;
	}

	.not-started {
		background-color: #e6f7ff;
		color: #1890ff;
	}

	.in-progress {
		background-color: #fff7e6;
		color: #fa8c16;
	}

	.completed {
		background-color: #f6ffed;
		color: #52c41a;
	}

	.metrics-container {
		margin: 20rpx 0;
	}

	.metric-row {
		display: flex;
		justify-content: flex-start;
		font-size: 26rpx;
		color: #666;
		margin-bottom: 10rpx;
	}

	.metric-item {
		flex: 1;
		text-align: left;
		white-space: nowrap;
		overflow: hidden;
		text-overflow: ellipsis;
	}

	.actions {
		display: flex;
		gap: 20rpx;
	}

	.action-btn {
		font-size: 26rpx;
		padding: 0rpx 22rpx;
		border: 1px solid #ddd;
		border-radius: 20rpx;
		background-color: #f5f5f5;
		color: #333;
	}

	.action-btn.danger {
		color: #fff;
		background-color: #ff4d4f;
		border-color: #ff4d4f;
	}
</style>

<script>
	export default {
		data() {
			return {
				currentDate: '2022-09'
			}
		},
		methods: {
			onDateChange(e) {
				this.currentDate = e.detail.value
			},

			developDailyPlan() {
				uni.navigateTo({ //制定日计划
					url: `/pages/realName/workbench/dailyPlanManagement/develop`
				})
			},
			
			uploadPlan(){
				uni.navigateTo({ //完成情况上传
					url: `/pages/realName/workbench/dailyPlanManagement/upload`
				})
			},
			detailsPlan(){
				uni.navigateTo({ //日计划详情
					url: `/pages/realName/workbench/dailyPlanManagement/details`
				})
			},

			// 返回
			leftClick() {
				console.log('返回')
				uni.navigateBack({
					delta: 1 // 返回
				});
			}
		}
	}
</script>