<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="base-info company">
			<view class="info-item" v-for="item in companyInfoList">
				<view class="info-item-description">{{item.description}}</view>
				<view class="info-item-name">{{item.value}}</view>
			</view>
		</view>

		<view class="base-info project">
			<view class="info-item" v-for="item in projectInfoList">
				<view class="info-item-description">{{item.description}}</view>
				<view class="info-item-name">{{item.value}}</view>
			</view>
		</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 companyInfoList = ref([{
		description: '申请单位',
		key: "unitName",
		value: ''
	}, {
		description: '主体单位',
		key: "mainName",
		value: ''
	}, {
		description: '监管单位',
		key: "manageName",
		value: ''
	}, {
		description: '审批单位',
		key: "approveName",
		value: ''
	}])

	let projectInfoList = ref([{
		description: '项目名称',
		key: "sub_name",
		value: ''
	}, {
		description: '建设性质',
		key: "propKindName",
		value: ''
	}, {
		description: '行业分类',
		key: "indusName",
		value: ''
	}, {
		description: '投资性质',
		key: "kindNature",
		value: ''
	}, {
		description: '总投资金额',
		key: "amt_total",
		value: ''
	}, {
		description: '年度计划投资金额',
		key: "amt_year",
		value: ''
	}])

	function filterData(obj) {
		for (let i in companyInfoList.value) {
			companyInfoList.value[i].value = obj[companyInfoList.value[i].key] || "--"
		}

		for (let i in projectInfoList.value) {
			projectInfoList.value[i].value = obj[projectInfoList.value[i].key] || "--"
		}
	}

	onLoad((option) => {
		getProjectInfoDetail({
			subId: option.id
		}).then(res => {
			filterData(res.data.projectsInfo)
		})
	})
</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;
			}
		}
	}

	.base-info {
		position: absolute;
		left: 4%;
		width: 92%;
		padding: 40rpx;
		border-radius: 40rpx;
		box-sizing: border-box;
		background-color: #fff;

		.info-item {
			display: flex;
			justify-content: space-between;
			width: 100%;
			height: 64rpx;

			.info-item-description {
				display: flex;
				flex-direction: column;
				justify-content: center;
				font-size: 32rpx;
				color: #9E9E9E;
			}

			.info-item-name {
				display: flex;
				flex-direction: column;
				justify-content: center;
				font-size: 32rpx;
				color: #343437;
			}
		}
	}

	.company {
		top: 14%;
		height: 336rpx;
	}

	.project {
		top: 37%;
		height: 484rpx
	}
</style>