<template>
	<view class="container">
		<!-- Project Header -->
		<u-navbar class="u-navbar" title="日计划详情" placeholder @leftClick="leftClick" leftIconColor="#fff"
			bgColor="#00337A" :titleStyle="{ color: '#FFF', fontSize: '32rpx' }" />
		<view class="project-header">
			<text class="project-title">{{proName}}</text>
			<!-- <view class="completion-rates">
				<text>作业计划完成率：70%</text>
				<text>月作业计划完成率：70%</text>
			</view> -->
		</view>

		<!-- Total Plan Input -->
		<view class="total-plan">
			<text>计划作业人数：</text>
			<text>{{planWorkNum}}</text>
		</view>

		<!-- Project Table -->
		<view class="table-container">
			<view class="table-header">
				<text class="col-index">序号</text>
				<text class="col-name">项目名称</text>
				<text class="col-desc">项目描述</text>
				<text class="col-completion">本日计划完成量</text>
				<text class="col-completion">本日实际完成量</text>
			</view>

			<view class="table-body">
				<view v-for="(item, index) in tableData" :key="index" class="table-row">
					<text class="col-index">{{ index + 1 }}</text>
					<text class="col-name">{{ item.taskName }}</text>
					<view class="col-desc">
						<text>{{ item.taskContent }}</text>
					</view>
					<view class="col-completion">
						<text>{{ item.completeNumDay }}</text>
					</view>
					<view class="col-completion">
						<text>{{ item.actualCompleteNumDay }}</text>
					</view>
				</view>
			</view>
		</view>

		<!-- Image Upload Section -->
		<view class="image-upload-section">
			<text class="upload-title">* 当天作业人员合照</text>
			<view class="upload-area" >
				<image :src="imageUrl"  class="preview-image"></image>
			</view>
		</view>
	</view>
</template>

<script>
	import config from '@/config'
	
	export default {
		onLoad(options) {
			this.dayId = decodeURIComponent(options.dayId);
			this.proName = decodeURIComponent(options.proName);
			this.id = decodeURIComponent(options.id);
			this.getListTable()
		},

		data() {
			return {
				dayId:'',
				proName:'',
				id:'',
				totalPlan: '',
				tableData: [],
				imageUrl: '',
				uploadStatus: '',
				uploadStatusText: '',
				planWorkNum:'',
			}
		},
		methods: {
			getListTable() {
				let param = {
					dayId: this.dayId,
					id: this.id
				}
				
				uni.request({
					url: config.lpBmwUrl + '/bmw/workPlanDay/getPlanDetailByIdEdit',
					method: 'post',
					data: JSON.stringify(param),
					header: {
						'content-type': 'application/json',
						'Authorization': uni.getStorageSync('realNameToken')
					},
					success: res => {
						console.log('日计划详情', res)
						if (res.data.code == 200) {
							this.tableData = res.data.data.contentList;
							this.imageUrl = config.lpBmwUrl +"/bmw/"+  res.data.data.path;
							// this.imageUrl = "http://192.168.0.14:31912/bmw/"+  res.data.data.path;
							console.log(this.imageUrl)
							this.planWorkNum = res.data.data.planWorkNum
						} else {
							uni.$u.toast(res.data.msg);
						}
					},
					fail: err => {
						console.log(err)
					}
				})
			},

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

<style>
	.container {
		padding: 30rpx;
		background-color: #fff;
	}

	.project-header {
		margin-bottom: 30rpx;
	}

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

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

	.total-plan {
		display: flex;
		align-items: center;
		margin-bottom: 30rpx;
		font-size: 28rpx;
	}

	.total-input {
		width: 200rpx;
		height: 60rpx;
		border: 1px solid #ddd;
		padding: 0 20rpx;
		margin-left: 20rpx;
	}

	.table-container {
		border: 1px solid #ddd;
		margin-bottom: 30rpx;
	}

	.table-header,
	.table-row {
		display: flex;
		font-size: 24rpx;
		padding: 15rpx 10rpx;
		border-bottom: 1px solid #ddd;
		align-items: center;
	}

	.table-header {
		background-color: #f5f5f5;
		font-weight: bold;
	}

	.table-body {
		background-color: #fff;
	}

	.table-row:nth-child(even) {
		background-color: #fafafa;
	}

	.table-row:last-child {
		border-bottom: none;
	}

	.table-row>* {
		display: flex;
		align-items: center;
	}

	.col-index {
		width: 60rpx;
		flex-shrink: 0;
	}

	.col-name {
		width: 140rpx;
		flex-shrink: 0;
	}

	.col-desc {
		flex: 1;
		min-width: 200rpx;
		flex-direction: column;
		align-items: flex-start;
	}

	.col-completion {
		width: 160rpx;
		flex-shrink: 0;
		box-sizing: border-box;
		padding: 0 5rpx;
		text-align: center;
		justify-content: center;
	}

	.completion-input {
		width: 100%;
		height: 50rpx;
		border: 1px solid #ddd;
		padding: 0 5rpx;
		box-sizing: border-box;
		font-size: 24rpx;
	}

	input {
		background-color: #fff;
	}

	.image-upload-section {
		margin-top: 30rpx;
	}

	.upload-title {
		font-size: 28rpx;
		color: #333;
		margin-bottom: 20rpx;
	}

	.upload-area {
		width: 100%;
		height: 300rpx;
		border: 2rpx dashed #ddd;
		display: flex;
		justify-content: center;
		align-items: center;
		cursor: pointer;
	}

	.upload-text {
		color: #999;
		font-size: 28rpx;
	}

	.preview-image {
		width: 100%;
		height: 100%;
		object-fit: cover;
	}

	.upload-status {
		font-size: 24rpx;
		margin-top: 10rpx;
	}

	.upload-status.success {
		color: #52c41a;
	}

	.upload-status.error {
		color: #ff4d4f;
	}
</style>