<template>
	<view class="container">
		<view class="back-btn" @click="backToBefore()">
			<u-icon name="arrow-left" color="#fff" size="20" customStyle="margin:0 auto"></u-icon>

			<text class="back-text">施工阶段计划</text>
		</view>

		<view class="table-area">
			<uni-table stripe emptyText="暂无更多数据">
				<uni-tr>
					<uni-th width="90" align="center">开始日期</uni-th>
					<uni-th width="90" align="center">结束日期</uni-th>
					<uni-th width="90" align="center">当前阶段</uni-th>
					<uni-th width="90" align="center">计划状态</uni-th>
				</uni-tr>

				<uni-tr v-for="(item, index) in tableData" :key="index">
					<uni-td align="center" width="100">{{ item.beginDate || "--"}}</uni-td>
					<uni-td align="center" width="100">{{ item.endDate || "--" }}</uni-td>
					<uni-td align="center">{{ item.content || "--" }}</uni-td>
					<uni-td align="center">
						<view class="uni-group">
							<text v-if="item.statusSp === '未开工'" class="wait">未开工</text>
							<text v-if="item.statusSp === '进行中'" class="new">进行中</text>
							<text v-if="item.statusSp === '已完工'" class="done">已完工</text>
						</view>
					</uni-td>
				</uni-tr>
			</uni-table>
		</view>
	</view>
</template>

<script setup>
	import {
		ref
	} from 'vue'

	import {
		onLoad
	} from "@dcloudio/uni-app"

	import {
		getProjectInfoDetail,
	} from "@/api/work/projectInfo.js"

	function backToBefore() {
		uni.navigateBack({})
	};

	let tableData = ref([])

	onLoad((option) => {
		getProjectInfoDetail({
			subId: option.id
		}).then(res => {
			tableData.value = res.data.planInfo
		})
	})
</script>

<style lang="scss" scoped>
	page {
		height: 100%;
		background-color: #EAF0FA;
	}

	.container {
		position: relative;
		width: 100%;
		height: 100%;
		background: linear-gradient(180deg, #1869F6 0%, #EAF0FA 64%, #EAF0FA 100%);

		.back-btn {
			position: absolute;
			top: 8%;
			left: 4%;
			display: flex;
			font-size: 40rpx;
			font-weight: 500;
			color: #FFF;

			.back-text {
				margin-left: 28rpx;
			}
		}

		.table-area {
			position: absolute;
			top: 14%;
			left: 0;
			width: 100%;
			height: 86%;
			background-color: #fff;
			border-radius: 28rpx 28rpx 0rpx 0rpx;
			overflow: hidden;

			.new {
				color: #1869F6;
			}

			.wait {
				color: #FF813E;
			}

			.done {
				color: #06BC43;
			}
		}
	}

	::v-deep .uni-table {

		.uni-table-th,
		.uni-table-th-content {
			height: 112rpx;
			color: #343437;
			font-size: 32rpx;
			font-weight: 500;
			background-color: #EAF0FA;
		}

		.uni-table-td {
			color: #343437;
			font-size: 28rpx
		}
	}
</style>