<!--<template>
    <div class="layout-padding">
        <div class="layout-padding-auto layout-padding-view">
            <el-row class="header-summary mb10">
                <div class="title">{{ t('postInvestmentEvaluation.title') }}</div>
            </el-row>

            <el-row class="toolbar-row mb10">
                <div class="toolbar-right">
                    <el-form class="search-form" :inline="true" :model="queryForm" @submit.prevent>
                        <el-form-item :label="t('postInvestmentEvaluation.form.projectName')">
                            <el-input v-model="queryForm.projectName"
                                :placeholder="t('postInvestmentEvaluation.placeholder.input')" style="width: 180px" />
                        </el-form-item>
                        <el-form-item :label="t('postInvestmentEvaluation.form.projectMainUnit')">
                            <el-input v-model="queryForm.projectMainUnit"
                                :placeholder="t('postInvestmentEvaluation.placeholder.input')" style="width: 180px" />
                        </el-form-item>
                        <el-form-item :label="t('postInvestmentEvaluation.form.majorInvestmentProject')">
                            <el-select v-model="queryForm.majorInvestmentProject"
                                :placeholder="t('postInvestmentEvaluation.placeholder.select')" clearable
                                style="width: 160px">
                                <el-option label="是" value="是" />
                                <el-option label="否" value="否" />
                            </el-select>
                        </el-form-item>
                        <el-form-item :label="t('postInvestmentEvaluation.form.projectNature')">
                            <el-input v-model="queryForm.projectNature"
                                :placeholder="t('postInvestmentEvaluation.placeholder.input')" style="width: 160px" />
                        </el-form-item>
                        <el-form-item>
                            <el-button type="primary" icon="Search" @click="handleSearch">{{
                                t('common.queryBtn')
                            }}</el-button>
                            <el-button icon="Refresh" @click="handleReset">{{ t('common.resetBtn') }}</el-button>
                        </el-form-item>
                    </el-form>
                </div>
            </el-row>

            <el-table :data="tableData" style="width: 100%" border @selection-change="handleSelectionChange">
                <el-table-column type="selection" width="48" />
                <el-table-column type="index" :label="t('postInvestmentEvaluation.table.index')" width="60" />
                <el-table-column prop="projectName" :label="t('postInvestmentEvaluation.table.projectName')"
                    min-width="200" />
                <el-table-column prop="projectMainUnit" :label="t('postInvestmentEvaluation.table.projectMainUnit')"
                    min-width="200" />
                <el-table-column prop="projectOwnerUnit" :label="t('postInvestmentEvaluation.table.projectOwnerUnit')"
                    min-width="200" />
                <el-table-column prop="investmentCategory"
                    :label="t('postInvestmentEvaluation.table.investmentCategory')" min-width="140" />
                <el-table-column prop="projectNature" :label="t('postInvestmentEvaluation.table.projectNature')"
                    min-width="140" />
                <el-table-column prop="projectDirection" :label="t('postInvestmentEvaluation.table.projectDirection')"
                    min-width="160" />
                <el-table-column prop="projectImplementationStart"
                    :label="t('postInvestmentEvaluation.table.projectImplementationStart')" min-width="160" />
                <el-table-column prop="projectImplementationEnd"
                    :label="t('postInvestmentEvaluation.table.projectImplementationEnd')" min-width="160" />
                <el-table-column prop="investmentRegion" :label="t('postInvestmentEvaluation.table.investmentRegion')"
                    min-width="140" />
                <el-table-column prop="majorInvestmentProject"
                    :label="t('postInvestmentEvaluation.table.majorInvestmentProject')" min-width="160" />
                <el-table-column prop="keyProject" :label="t('postInvestmentEvaluation.table.keyProject')"
                    min-width="120" />
                <el-table-column prop="lastUpdater" :label="t('postInvestmentEvaluation.table.lastUpdater')"
                    min-width="140" />
                <el-table-column prop="lastUpdateTime" :label="t('postInvestmentEvaluation.table.lastUpdateTime')"
                    min-width="180" />
                <el-table-column prop="evaluationStatus" :label="t('postInvestmentEvaluation.table.evaluationStatus')"
                    min-width="160">
                    <template #default="{ row }">
                        <el-tag :type="getEvaluationStatusTagType(row.evaluationStatus)" effect="light">
                            {{ getEvaluationStatusLabel(row.evaluationStatus) }}
                        </el-tag>
                    </template>
                </el-table-column>
                <el-table-column prop="lastPushStatus" :label="t('postInvestmentEvaluation.table.lastPushStatus')"
                    min-width="180">
                    <template #default="{ row }">
                        <el-tag :type="getPushStatusTagType(row.lastPushStatus)" effect="light">
                            {{ getPushStatusLabel(row.lastPushStatus) }}
                        </el-tag>
                    </template>
                </el-table-column>
                <el-table-column :label="t('postInvestmentEvaluation.table.action')" width="280" fixed="right">
                    <template #default="{ row }">
                        <el-button link type="primary" @click="handleView(row)">{{ t('common.viewBtn') || '查看'
                        }}</el-button>
                        <el-button link type="warning" @click="handleEvaluation(row)">{{
                            t('postInvestmentEvaluation.action.evaluation')
                        }}</el-button>
                        <el-button link type="success" @click="handleSubmit(row)">{{
                            t('postInvestmentEvaluation.action.submit')
                        }}</el-button>
                    </template>
                </el-table-column>
            </el-table>

            <div class="mt15 flex justify-end pagination-wrapper">
                <el-pagination background layout="sizes, prev, pager, next, jumper, total" :total="total"
                    :page-sizes="[10, 20, 50, 100]" v-model:page-size="queryForm.pageSize"
                    v-model:current-page="queryForm.page" @size-change="handlePageSizeChange"
                    @current-change="handlePageChange" />
            </div>
        </div>
    </div>
</template>
<script setup lang="ts">
import { reactive, ref } from 'vue';
import { useI18n } from 'vue-i18n';
import { useMessage } from '/@/hooks/message';
import { useRouter } from 'vue-router';

interface PostInvestmentEvaluationItem {
    id: number;
    projectName: string;
    projectMainUnit: string;
    projectOwnerUnit: string;
    investmentCategory: string;
    projectNature: string;
    projectDirection: string;
    projectImplementationStart: string;
    projectImplementationEnd: string;
    investmentRegion: string;
    majorInvestmentProject: string;
    keyProject: string;
    lastUpdater: string;
    lastUpdateTime: string;
    evaluationStatus: 'notEvaluated' | 'evaluated' | 'rectified';
    lastPushStatus: 'submitted' | 'failed' | 'pending';
}

const { t } = useI18n();
const message = useMessage();
const router = useRouter();

const queryForm = reactive({
    projectName: '',
    projectMainUnit: '',
    majorInvestmentProject: '',
    projectNature: '',
    page: 1,
    pageSize: 10,
});

const total = ref(6532);
const originData = ref<PostInvestmentEvaluationItem[]>([]);
const tableData = ref<PostInvestmentEvaluationItem[]>([]);
const selectedRows = ref<PostInvestmentEvaluationItem[]>([]);

const mockData: PostInvestmentEvaluationItem[] = [
    {
        id: 1,
        projectName: 'XXX工业园区扩建项目',
        projectMainUnit: 'XX市产业投资集团',
        projectOwnerUnit: 'XX市产业投资集团',
        investmentCategory: '产业投资',
        projectNature: '新增投资',
        projectDirection: '先进制造业',
        projectImplementationStart: '2025-01-01',
        projectImplementationEnd: '2025-06-30',
        investmentRegion: '西南地区',
        majorInvestmentProject: '是',
        keyProject: '是',
        lastUpdater: '王小明',
        lastUpdateTime: '2025-02-01 09:30:00',
        evaluationStatus: 'notEvaluated',
        lastPushStatus: 'submitted',
    },
    {
        id: 2,
        projectName: 'XXX科技成果转化中心',
        projectMainUnit: 'XX省科技集团',
        projectOwnerUnit: 'XX省科技集团',
        investmentCategory: '产业投资',
        projectNature: '技术改造',
        projectDirection: '科技服务',
        projectImplementationStart: '2025-03-15',
        projectImplementationEnd: '2025-12-31',
        investmentRegion: '华东地区',
        majorInvestmentProject: '否',
        keyProject: '是',
        lastUpdater: '李晓华',
        lastUpdateTime: '2025-04-10 14:20:00',
        evaluationStatus: 'evaluated',
        lastPushStatus: 'failed',
    },
    {
        id: 3,
        projectName: 'XXX物流枢纽升级项目',
        projectMainUnit: 'XX市物流集团',
        projectOwnerUnit: 'XX市物流集团',
        investmentCategory: '基础设施',
        projectNature: '存量优化',
        projectDirection: '现代物流',
        projectImplementationStart: '2025-05-01',
        projectImplementationEnd: '2025-11-30',
        investmentRegion: '华北地区',
        majorInvestmentProject: '否',
        keyProject: '否',
        lastUpdater: '赵敏',
        lastUpdateTime: '2025-05-20 17:45:00',
        evaluationStatus: 'rectified',
        lastPushStatus: 'pending',
    },
];

const getDataList = () => {
    const list = originData.value.filter(item =>
        (!queryForm.projectName || item.projectName.includes(queryForm.projectName)) &&
        (!queryForm.projectMainUnit || item.projectMainUnit.includes(queryForm.projectMainUnit)) &&
        (!queryForm.majorInvestmentProject || item.majorInvestmentProject === queryForm.majorInvestmentProject) &&
        (!queryForm.projectNature || item.projectNature.includes(queryForm.projectNature)),
    );
    total.value = list.length;
    const start = (queryForm.page - 1) * queryForm.pageSize;
    tableData.value = list.slice(start, start + queryForm.pageSize);
};

const handleSearch = () => {
    queryForm.page = 1;
    getDataList();
};

const handleReset = () => {
    queryForm.projectName = '';
    queryForm.projectMainUnit = '';
    queryForm.majorInvestmentProject = '';
    queryForm.projectNature = '';
    queryForm.page = 1;
    getDataList();
};

const handleSelectionChange = (rows: PostInvestmentEvaluationItem[]) => {
    selectedRows.value = rows;
};

const handleView = (row: PostInvestmentEvaluationItem) => {
    message.info(`${t('common.viewBtn')}: ${row.projectName}`);
};

const handleEvaluation = (row: PostInvestmentEvaluationItem) => {
    // 跳转到投后评价表单页面，传递项目ID
    router.push({
        path: '/invBid/postInvestmentEvaluation/form',
        query: { id: row.id.toString(), projectName: row.projectName },
    });
};

const handleSubmit = (row: PostInvestmentEvaluationItem) => {
    message.info(`${t('postInvestmentEvaluation.action.submit')}: ${row.projectName}`);
};

const handlePageChange = (page: number) => {
    queryForm.page = page;
    getDataList();
};

const handlePageSizeChange = (size: number) => {
    queryForm.pageSize = size;
    queryForm.page = 1;
    getDataList();
};

const getEvaluationStatusTagType = (status: PostInvestmentEvaluationItem['evaluationStatus']) => {
    if (status === 'notEvaluated') return 'info';
    if (status === 'evaluated') return 'info';
    if (status === 'rectified') return 'success';
    return 'info';
};

const getEvaluationStatusLabel = (status: PostInvestmentEvaluationItem['evaluationStatus']) => {
    if (status === 'notEvaluated') return t('postInvestmentEvaluation.status.notEvaluated');
    if (status === 'evaluated') return t('postInvestmentEvaluation.status.evaluated');
    if (status === 'rectified') return t('postInvestmentEvaluation.status.rectified');
    return '';
};

const getPushStatusTagType = (status: PostInvestmentEvaluationItem['lastPushStatus']) => {
    if (status === 'submitted') return 'success';
    if (status === 'failed') return 'danger';
    return 'info';
};

const getPushStatusLabel = (status: PostInvestmentEvaluationItem['lastPushStatus']) => {
    if (status === 'submitted') return t('postInvestmentEvaluation.status.submitted');
    if (status === 'failed') return t('postInvestmentEvaluation.status.failed');
    return t('postInvestmentEvaluation.status.pending');
};

originData.value = [...mockData];
getDataList();
</script>

<style scoped>
.header-summary .title {
    margin: 0 auto;
    font-size: 20px;
    font-weight: 600;
    text-align: center;
}

.toolbar-row {
    display: flex;
    align-items: center;
    justify-content: flex-end;
}

.toolbar-right {
    display: flex;
    align-items: center;
}

.search-form :deep(.el-form-item) {
    margin-bottom: 0;
}

.pagination-wrapper {
    width: 100%;
}
</style>-->
<template>
	<div class="layout-padding">
		<div class="layout-padding-auto layout-padding-view">
			<el-row class="header-summary mb10">
				<div class="title">{{ t('postInvestmentEvaluation.title') }}</div>
			</el-row>

			<el-row class="toolbar-row mb10">
				<div class="toolbar-right">
					<el-form class="search-form" :inline="true" :model="queryForm" @submit.prevent>
						<el-form-item :label="t('projectLibrary.form.projectName')">
							<el-input v-model="queryForm.projectName" :placeholder="t('projectLibrary.placeholder.input')" style="width: 180px" />
						</el-form-item>
						<el-form-item :label="t('projectLibrary.form.projectMainUnit')">
							<el-input v-model="queryForm.projectMainUnit" :placeholder="t('projectLibrary.placeholder.input')" style="width: 180px" />
						</el-form-item>
						<el-form-item :label="t('projectLibrary.form.projectNature')">
							<el-select v-model="queryForm.projectNature" :placeholder="t('projectLibrary.placeholder.select')" style="width: 160px" clearable>
								<el-option v-for="item in projectNatureOptions" :key="item.value" :value="item.value" :label="item.label" />
							</el-select>
						</el-form-item>
						<el-form-item>
							<el-button type="primary" icon="Search" @click="handleSearch">{{ t('common.queryBtn') }}</el-button>
							<el-button icon="Refresh" @click="handleReset">{{ t('common.resetBtn') }}</el-button>
						</el-form-item>
					</el-form>
				</div>
			</el-row>

			<el-table :data="tableData" style="width: 100%" border @selection-change="handleSelectionChange">
				<el-table-column type="selection" width="48" />
				<el-table-column type="index" :label="t('projectLibrary.table.index')" width="60" />
				<el-table-column prop="projectName" :label="t('projectLibrary.table.projectName')" min-width="200" />
				<el-table-column prop="projectMainEntity" :label="t('projectLibrary.table.projectMainUnit')" min-width="200" />
				<el-table-column prop="projectOwnerUnit" :label="t('projectLibrary.table.projectOwnerUnit')" min-width="200" />
				<el-table-column prop="constructionStage" :label="t('projectLibrary.table.constructionStage')" min-width="120" />
				<el-table-column prop="investmentCategory" :label="t('projectLibrary.table.investmentCategory')" min-width="140">
					<template #default="{ row }">
						{{ getInvestmentCategoryLabel(row.investmentCategory) }}
					</template>
				</el-table-column>
				<el-table-column prop="projectNature" :label="t('projectLibrary.table.projectNature')" min-width="140">
					<template #default="{ row }">
						{{ projectNatureOptions.find((item: Enums) => item.value === row.projectNature)?.label }}
					</template>
				</el-table-column>
				<el-table-column prop="projectInvestmentDirection" :label="t('projectLibrary.table.projectDirection')" min-width="160" />
				<el-table-column prop="projectStartTime" :label="t('projectLibrary.table.projectImplementationStart')" min-width="160" />
				<el-table-column prop="projectEndTime" :label="t('projectLibrary.table.projectImplementationEnd')" min-width="160" />
				<el-table-column prop="investmentArea" :label="t('projectLibrary.table.investmentRegion')" min-width="140">
					<template #default="{ row }">
						{{ investmentAreaOptions.find((item: Enums) => item.value === row.investmentArea)?.label }}
					</template>
				</el-table-column>
				<el-table-column prop="majorInvestmentProjects" :label="t('projectLibrary.table.majorInvestmentProject')" min-width="160" />
				<el-table-column prop="keyProject" :label="t('projectLibrary.table.keyProject')" min-width="120">
					<template #default="{ row }">
						{{ projectImportantOptions.find((item: Enums) => item.value === row.keyProject)?.label }}
					</template>
				</el-table-column>
				<el-table-column prop="updateTime" :label="t('projectLibrary.table.lastUpdateTime')" min-width="180" />
				<el-table-column prop="reportTime" :label="t('projectLibrary.table.lastReportTime')" min-width="180" />
				<el-table-column prop="createBy" :label="t('projectLibrary.table.lastReporter')" min-width="140" />
				<el-table-column prop="lastPushStatus" :label="t('projectLibrary.table.lastPushStatus')" min-width="160">
					<template #default="{ row }">
						<el-tag type="primary" effect="light">
							{{ row.lastPushStatus }}
						</el-tag>
					</template>
				</el-table-column>
				<el-table-column :label="t('projectLibrary.table.action')" width="250" fixed="right">
					<template #default="{ row }">
						<el-button link type="primary" @click="handleView(row)">{{ t('common.viewBtn') || '查看' }}</el-button>
						<el-button link type="primary" @click="handleEdit(row)">{{ t('postInvestmentEvaluationForm.title') || '投后评价' }}</el-button>
						<el-button link type="primary" @click="handleReportCurrentYear(row)">{{ t('progressReportRecord.action.submit') }}</el-button>
					</template>
				</el-table-column>
			</el-table>

			<div class="mt15 flex justify-end pagination-wrapper">
				<el-pagination
					background
					layout="sizes, prev, pager, next, jumper, total"
					:total="total"
					:page-sizes="[10, 20, 50, 100]"
					v-model:page-size="queryForm.pageSize"
					v-model:current-page="queryForm.page"
					@size-change="handlePageSizeChange"
					@current-change="handlePageChange"
				/>
			</div>
		</div>

		<el-drawer
			v-model="detailDrawerVisible"
			class="project-detail-drawer"
			direction="rtl"
			size="70%"
			:with-header="false"
			:close-on-click-modal="false"
		>
			<div class="detail-header">
				<span class="detail-title">{{ t('postInvestmentEvaluation.title') }}</span>
				<el-button class="close-btn" link icon="Close" @click="detailDrawerVisible = false" />
			</div>
			<div class="detail-content">
				<ProjectPlanApplyFormDetails v-model="detailFormData" :isEdit="false"/>
			</div>
		</el-drawer>
	</div>
</template>

<script setup lang="ts">
import { reactive, ref } from 'vue';
import { useI18n } from 'vue-i18n';
import { useMessage } from '/@/hooks/message';
import { ProjectPlanApplyFormData, ProjectPlanApplyFormItem } from '/@/components/investment/interface/types';
import type { Enums } from '/@/hooks/enums';
import type { investmentProjectsPlanList, ProjectLibraryDetailT } from '/@/views/invMid/projectLibrary/interface/types';
import {  investmentProjectsPlanGetById, investmentProjectsPlanPage } from '/@/api/investment/investmentManagement';
import {useRouter} from "vue-router"
import { investmentCategoryOptions, projectNatureOptions, investmentAreaOptions, projectImportantOptions } from '/@/hooks/enums';
import ProjectPlanApplyFormDetails from '/@/components/investment/common/ProjectPlanApplyFormDetails.vue';
const router = useRouter()
/**
 * 创建空的详情表单对象
 * @returns {ProjectPlanApplyFormData} 返回初始化的表单数据对象
 */
const createEmptyDetail = (): ProjectPlanApplyFormData => ({
	entity: {
		projectName: '',
		projectNature: '',
		groupCompany: '',
		projectOwnerUnit: '',
		projectMainEntity: '',
		projectDepartment: '',
		investmentCategory: '',
		investmentArea: '',
		projectAddress: '',
		projectAddressDetail: '',
		projectInvestmentDirection: '',
		totalInvestment: '',
		investmentDirectionSegmentation: '',
		projectBackground: '',
		constructionNature: '',
		constructionStage: '',
		keyProject: '',
		isMainBusiness: '',
		mainBusinessTypes: '',
		mainBusinessCode: '',
		isManufacturingIndustry: '',
		isStuckIndustry: '',
		urbanStrategy: '',
		projectSource: '',
		majorInvestmentProjects: '',
		isStrategicEmergingIndustries: '',
		projectStartTime: '',
		projectEndTime: '',
		projectConstructionContent: '',
		planInvestmentYear: '',
		annualPlanTotal: '',
		annualPlanInvestment: '',
		planPaymentLimit: '',
		plannedImageAmount: '',
		ownedFunds: '',
		financialFunds: '',
		externalFunding: '',
		externalRaisedCapital: '',
		otherFunds: '',
		governmentFundSourceDesc: '',
		otherFundSourceDesc: '',
		projectTotalAmount: '',
		lastYearCompleted: '',
		ourInvestmentTotalAmount: '',
		ourLastYearCompleted: '',
		projectDesc: '',
		promotionPlan: '',
		projectPreliminaryPlan: '',
		projectPreliminaryPlanAttachment: '',
		attachments: [],
		remark: '',
		decisionType: '',
		isProjectApprovalCompleted: '',
		isDecisionProcedureCompleted: '',
		projectApprovalFileNo: '',
		projectApprovalFileInfo: '',
		decisionProcedureFileNo: '',
		decisionFileInfo: '',
		submitUnitOpinion: '',
		groupInvestmentDeptOpinion: '',
		submitUnitLeadershipOpinion: '',
		submitUnitMainLeadershipOpinion: '',
		planImageQuota:'',
		deptId:0,
		status:0,
		processInstanceId:'',
	},
	investmentProjects: [
		{
			plannedInvestmentYear: '',
			plannedImageAmount: '',
			plannedPaymentAmount: '',
			selfFunding: '',
			externalFunding: '',
			fiscalFunding: '',
			otherFunding: '',
			fiscalFundingSource: '',
			otherFundingSource: '',
		},
	],
});

const { t } = useI18n();
const message = useMessage();

const queryForm = reactive<investmentProjectsPlanList>({
	page: 1,
	size: 10,
	projectName: '',
	projectMainEntity: '',
	projectNature: '',
	majorInvestmentProjects: '',
});

const total = ref(6532);
const tableData = ref<ProjectPlanApplyFormItem[]>([]);
const selectedRows = ref<ProjectLibraryDetailT[]>([]);
const detailDrawerVisible = ref(false);
const detailFormData = reactive<ProjectPlanApplyFormData>(createEmptyDetail());

const resetDetailForm = () => {
	const empty = createEmptyDetail();
	Object.assign(detailFormData, empty);
	if (detailFormData.investmentProjects) {
		detailFormData.investmentProjects.splice(0, detailFormData.investmentProjects.length);
		detailFormData.investmentProjects.push({
			plannedInvestmentYear: '',
			plannedImageAmount: '',
			plannedPaymentAmount: '',
			selfFunding: '',
			externalFunding: '',
			fiscalFunding: '',
			otherFunding: '',
			fiscalFundingSource: '',
			otherFundingSource: '',
		});
	}
};

/**
 * 获取列表数据
 * 发起请求获取投资项目计划分页数据
 */
const getDataList = async () => {
	const res = await investmentProjectsPlanPage(queryForm as any);
	tableData.value = res.data.records;
	total.value = res.data.total || 0;
};

/**
 * 处理搜索事件
 * 重置页码为第一页并重新获取数据
 */
const handleSearch = () => {
	queryForm.page = 1;
	getDataList();
};

/**
 * 处理重置事件
 * 清空查询条件并重新获取数据
 */
const handleReset = () => {
	queryForm.projectName = '';
	queryForm.projectMainEntity = '';
	queryForm.projectNature = '';
	queryForm.majorInvestmentProjects = '';
	queryForm.page = 1;
	getDataList();
};

/**
 * 处理选择变更事件
 * 当表格选择项发生变化时更新已选项状态
 * @param {ProjectLibraryDetailT[]} rows - 当前选中的行数据数组
 */
const handleSelectionChange = (rows: ProjectLibraryDetailT[]) => {
	selectedRows.value = rows;
};

/**
 * 处理查看详情事件
 * 根据指定行数据获取详细信息并显示在抽屉中
 * @param {ProjectLibraryDetailT} row - 当前行数据对象
 */
const handleView = (row: ProjectLibraryDetailT) => {
	resetDetailForm();
	investmentProjectsPlanGetById(row.id).then((res) => {
		Object.assign(detailFormData.investmentProjects, res.data.projectInvestmentEntities || []); // 年度投资计划
		Object.assign(detailFormData.entity, res.data); // 项目详情
	});
	detailDrawerVisible.value = true;
};
/**
 * 投后评价页面
 * */
const handleEdit = (row: ProjectLibraryDetailT) => {
	router.push({
		path: '/invBid/postInvestmentEvaluation/form',
		query: {
			id: row.id,
			projectName: row.projectName,
		},
	});
}
/**
 * 处理当前年度报告事件
 * 对指定项目执行当年报告操作
 * @param {ProjectLibraryDetailT} row - 当前行数据对象
 */
const handleReportCurrentYear = (row: ProjectLibraryDetailT) => {
	message.info(`${t('projectLibrary.message.reportHint')}: ${row.projectName}`);
};

/**
 * 处理页码变更事件
 * 切换页面时更新当前页码并重新获取数据
 * @param {number} page - 目标页码
 */
const handlePageChange = (page: number) => {
	queryForm.page = page;
	getDataList();
};

/**
 * 处理页面大小变更事件
 * 调整每页显示条数时更新页面设置并重新获取数据
 * @param {number} size - 每页显示条数
 */
const handlePageSizeChange = (size: number) => {
	queryForm.size = size;
	queryForm.page = 1;
	getDataList();
};
/**
 * 获取状态标签文本
 * 根据推送状态返回对应的显示文本
 * @param {any} status - 推送状态
 * @returns {string} 状态对应显示文本
 */
const getStatusLabel = (status: any) => {
	if (status === 'submitted') return t('projectLibrary.status.submitted');
	if (status === 'failed') return t('projectLibrary.status.failed');
	return t('projectLibrary.status.pending');
};
/**
 * 投资类别
 * getInvestmentCategoryLabel
 * */
const getInvestmentCategoryLabel = (num: number | string) => {
	if (typeof num === 'number') num = num.toString();
	return investmentCategoryOptions.find((item) => item.value === num)?.label || '';
};
getDataList();
</script>

<style scoped>
.header-summary .title {
	margin: 0 auto;
	font-size: 20px;
	font-weight: 600;
	text-align: center;
}

.toolbar-row {
	display: flex;
	align-items: center;
	justify-content: space-between;
}

.toolbar-left {
	display: flex;
	align-items: center;
	gap: 12px;
}

.toolbar-right {
	display: flex;
	align-items: center;
}

.search-form :deep(.el-form-item) {
	margin-bottom: 0;
}

.pagination-wrapper {
	width: 100%;
}

.project-detail-drawer {
	--el-drawer-border-radius: 0;
}

.project-detail-drawer .detail-header {
	display: flex;
	justify-content: space-between;
	align-items: center;
	padding: 12px 20px;
	border-bottom: 1px solid var(--el-border-color);
}

.detail-title {
	font-size: 18px;
	font-weight: 600;
	color: var(--el-text-color-primary);
}

.detail-content {
	padding: 0 20px 20px;
	overflow: auto;
	height: calc(100% - 48px);
}

.el-form-item--default {
	margin-bottom: 0;
}

.el-form.el-form--inline .el-form-item--default.el-form-item:last-of-type,
.el-form.el-form--inline .el-form-item--small.el-form-item:last-of-type {
	margin-bottom: 0 !important;
}
</style>
