<template>
    <div>
        <div class="coentent">
            <div class="contents-area">
                <div class="areas">
                    <div v-if="active==0">
                        <div class="headers">
                            <div class="headers-name">项目工时及人工费情况｜</div>
                            <div>
                                <el-form :inline="true" :model="form" class="demo-form-inline">
                                    <el-form-item label="项目名称" size="small" style="position: relative;top: -3px;">
                                        <el-select v-model="form.projectName" placeholder="请选择" class="selects">
                                            <el-option v-for="item in projectOptions" :key="item.value" :label="item.label"
                                                :value="item.value">
                                            </el-option>
                                        </el-select>
                                    </el-form-item>
                                    <el-form-item label="年度选择" size="small" style="position: relative;top: -3px;">
                                        <el-select v-model="form.year" placeholder="请选择" class="selects">
                                            <el-option v-for="item in yearOptions" :key="item.value" :label="item.label"
                                                :value="item.value">
                                            </el-option>
                                        </el-select>
                                    </el-form-item>
                                    <el-form-item>
                                        <el-button type="primary" @click="btnAdd" size="small" class="tianjia">添加</el-button>
                                    </el-form-item>
                                </el-form>
                            </div>
                        </div>
                        <div class="content-table">
                            <el-table 
                                :data="tableData" 
                                :header-cell-style="{ background: '#EDEFFE', color: '#363636', textAlign: 'center' }"
                                border 
                                style="width: 100%">
                                <el-table-column prop="serial" label="序号" width="80" align="center"></el-table-column>
                                <el-table-column prop="projectCode" label="项目代号" align="center"></el-table-column>
                                <el-table-column prop="projectName" label="项目名称" align="center"></el-table-column>
                                <el-table-column prop="dateRange" label="项目起止日期" align="center"></el-table-column>
                                <el-table-column prop="status" label="项目状态" width="120" align="center">
                                    <template slot-scope="scope">
                                        <span :class="scope.row.status === '已结束' ? 'status-completed' : 'status-pending'">
                                            {{ scope.row.status }}
                                        </span>
                                    </template>
                                </el-table-column>
                                <el-table-column prop="totalHours" label="合计工时(天)" align="center"></el-table-column>
                                <el-table-column prop="monthlyLaborCost" label="本月人工费(元)" align="center"></el-table-column>
                                <el-table-column fixed="right" label="操作" align="center" width="100">
                                    <template slot-scope="scope">
                                        <el-button @click="handleDetail(scope.row)" type="text" size="small" style="color: #5165f7;">详情</el-button>
                                    </template>
                                </el-table-column>
                            </el-table>
                            <div class="footer">
                                <el-pagination 
                                    @size-change="handleSizeChange" 
                                    @current-change="handleCurrentChange"
                                    :current-page="currentPage" 
                                    :page-sizes="[100, 200, 300, 400]" 
                                    :page-size="100"
                                    layout="total, sizes, prev, pager, next, jumper" 
                                    :total="400">
                                </el-pagination>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
        
        <!-- 详情弹窗 -->
        <el-dialog
            :title="dialogTitle"
            :visible.sync="dialogVisible"
            width="90%"
            :close-on-click-modal="false"
            class="detail-dialog">
            <div class="dialog-subtitle">项目工时薪资分配情况|</div>
            <div class="dialog-table-wrapper">
                <el-table 
                    :data="detailTableData" 
                    :header-cell-style="{ background: '#EDEFFE', color: '#363636', textAlign: 'center' }"
                    border 
                    style="width: 100%">
                    <el-table-column prop="serial" label="序号" width="80" align="center"></el-table-column>
                    <el-table-column prop="name" label="姓名" align="center"></el-table-column>
                    <el-table-column prop="projectHours" label="项目工时" align="center"></el-table-column>
                    <el-table-column prop="hoursPercentage" label="工时占比" align="center"></el-table-column>
                    <el-table-column prop="salary" label="工资" align="center"></el-table-column>
                    <el-table-column prop="bonus" label="奖金" align="center"></el-table-column>
                    <el-table-column prop="performance" label="绩效" align="center"></el-table-column>
                    <el-table-column prop="providentFund" label="公积金" align="center"></el-table-column>
                    <el-table-column prop="pensionInsurance" label="养老保险" align="center"></el-table-column>
                    <el-table-column prop="medicalInsurance" label="医疗保险" align="center"></el-table-column>
                    <el-table-column prop="unemploymentInsurance" label="失业保险" align="center"></el-table-column>
                    <el-table-column prop="workInjuryInsurance" label="工伤保险" align="center"></el-table-column>
                    <el-table-column prop="maternityInsurance" label="生育保险" align="center"></el-table-column>
                </el-table>
            </div>
        </el-dialog>
    </div>
</template>
<script>
export default {
    data() {
        return {
            active: 0,
            currentPage: 1,
            dialogVisible: false,
            dialogTitle: '',
            currentProject: null,
            form: {
                projectName: '',
                year: '2025'
            },
            projectOptions: [
                {
                    value: '全部',
                    label: '全部'
                },
                {
                    value: '项目A',
                    label: '项目A'
                },
                {
                    value: '项目B',
                    label: '项目B'
                }
            ],
            yearOptions: [
                {
                    value: '2023',
                    label: '2023'
                },
                {
                    value: '2024',
                    label: '2024'
                },
                {
                    value: '2025',
                    label: '2025'
                },
                {
                    value: '2026',
                    label: '2026'
                }
            ],
            tableData: [
                {
                    serial: 1,
                    projectCode: 'Wu20249',
                    projectName: 'GPS车辆管理系统研发项目',
                    dateRange: '2022.2.12-未结束',
                    status: '进行中',
                    totalHours: '100.5',
                    monthlyLaborCost: '666.66'
                },
                {
                    serial: 2,
                    projectCode: 'Wu20249',
                    projectName: '高速公路低功耗可变信息情报板',
                    dateRange: '2022.2.12-2025.2.12',
                    status: '已结束',
                    totalHours: '0',
                    monthlyLaborCost: '0'
                },
                {
                    serial: 3,
                    projectCode: 'Wu20249',
                    projectName: '车辆管理系统研发项目',
                    dateRange: '2022.2.12-未结束',
                    status: '进行中',
                    totalHours: '112.5',
                    monthlyLaborCost: '666.66'
                },
                {
                    serial: 4,
                    projectCode: 'Wu20249',
                    projectName: '高速公路低功耗可变信息情报板',
                    dateRange: '2022.2.12-未结束',
                    status: '进行中',
                    totalHours: '无数据',
                    monthlyLaborCost: '无数据'
                },
                {
                    serial: 5,
                    projectCode: 'Wu20249',
                    projectName: '关于智慧管养平台开发及运用的研究',
                    dateRange: '2022.2.12-未结束',
                    status: '进行中',
                    totalHours: '190',
                    monthlyLaborCost: '无数据'
                },
                {
                    serial: 6,
                    projectCode: 'Wu20249',
                    projectName: '高速公路管道与光缆管理系统开发',
                    dateRange: '2022.2.12-2024.2.12',
                    status: '已结束',
                    totalHours: '0',
                    monthlyLaborCost: '0'
                },
                {
                    serial: 7,
                    projectCode: 'Wu20249',
                    projectName: '信息安全管理体系',
                    dateRange: '2022.2.12-2024.2.12',
                    status: '已结束',
                    totalHours: '0',
                    monthlyLaborCost: '0'
                },
                {
                    serial: 8,
                    projectCode: 'Wu20249',
                    projectName: '质量管理体系认证',
                    dateRange: '2022.2.12-2024.2.12',
                    status: '已结束',
                    totalHours: '0',
                    monthlyLaborCost: '0'
                }
            ],
            detailTableData: [
                {
                    serial: 1,
                    name: '徐蛟',
                    projectHours: '10.5',
                    hoursPercentage: '30.21%',
                    salary: '660.00',
                    bonus: '660.00',
                    performance: '660.00',
                    providentFund: '660.00',
                    pensionInsurance: '660.00',
                    medicalInsurance: '660.00',
                    unemploymentInsurance: '660.00',
                    workInjuryInsurance: '660.00',
                    maternityInsurance: '660.00'
                },
                {
                    serial: 2,
                    name: '陈翔',
                    projectHours: '6',
                    hoursPercentage: '30.21%',
                    salary: '660.00',
                    bonus: '660.00',
                    performance: '660.00',
                    providentFund: '660.00',
                    pensionInsurance: '660.00',
                    medicalInsurance: '660.00',
                    unemploymentInsurance: '660.00',
                    workInjuryInsurance: '660.00',
                    maternityInsurance: '660.00'
                },
                {
                    serial: 3,
                    name: '高超',
                    projectHours: '6',
                    hoursPercentage: '30.21%',
                    salary: '660.00',
                    bonus: '660.00',
                    performance: '660.00',
                    providentFund: '660.00',
                    pensionInsurance: '660.00',
                    medicalInsurance: '660.00',
                    unemploymentInsurance: '660.00',
                    workInjuryInsurance: '660.00',
                    maternityInsurance: '660.00'
                },
                {
                    serial: 4,
                    name: '陈建华 8776',
                    projectHours: '6',
                    hoursPercentage: '30.21%',
                    salary: '660.00',
                    bonus: '660.00',
                    performance: '660.00',
                    providentFund: '660.00',
                    pensionInsurance: '660.00',
                    medicalInsurance: '660.00',
                    unemploymentInsurance: '660.00',
                    workInjuryInsurance: '660.00',
                    maternityInsurance: '660.00'
                },
                {
                    serial: 5,
                    name: '陈建华 0590',
                    projectHours: '6',
                    hoursPercentage: '30.21%',
                    salary: '660.00',
                    bonus: '660.00',
                    performance: '660.00',
                    providentFund: '660.00',
                    pensionInsurance: '660.00',
                    medicalInsurance: '660.00',
                    unemploymentInsurance: '660.00',
                    workInjuryInsurance: '660.00',
                    maternityInsurance: '660.00'
                }
            ]
        }
    },
    methods: {
        getRowStyle({ row, rowIndex }) {
            return {}
        },
        handleDetail(row) {
            console.log('查看详情', row)
            this.currentProject = row
            // 生成弹窗标题：2025年11月: GPS车辆管理系统研发项目-工时工费情况
            const currentDate = new Date()
            const year = currentDate.getFullYear()
            const month = currentDate.getMonth() + 1
            this.dialogTitle = `${year}年${month}月: ${row.projectName}-工时工费情况`
            this.dialogVisible = true
        },
        handleEdit(row) {
            console.log('编辑', row)
            // 跳转到编辑页面
        },
        btnAdd() {
            console.log('添加')
            // 处理添加逻辑
        },
        handleSizeChange() {
            // 处理分页大小变化
        },
        handleCurrentChange() {
            // 处理当前页变化
        }
    }
}
</script>
<style>
.el-tooltip__popper.is-dark {
    color: #F04B4B !important;
    background: #FCF1EB !important;
}

.el-tooltip__popper .popper__arrow {
    border-top-color: #FCF1EB !important;
    /* 上方箭头 */
}

.el-tooltip__popper .popper__arrow::after {
    border-top-color: #FCF1EB !important;
}

/* 其他方向的箭头（按需添加） */
.el-tooltip__popper[x-placement^='bottom'] .popper__arrow {
    border-bottom-color: #FCF1EB !important;
}

.el-tooltip__popper[x-placement^='left'] .popper__arrow {
    border-left-color: #FCF1EB !important;
}

.el-tooltip__popper[x-placement^='right'] .popper__arrow {
    border-right-color: #FCF1EB !important;
}
</style>
<style scoped>
.areas {
    padding-bottom: 15px;
    width: 97%;
    margin: 0 auto;
    padding-top: 20px;
}

.active {
    color: #5165f7 !important;
}

.heng {
    width: 20px;
    height: 6px;
    background: #5165f7;
    margin: 0 auto;
    margin-top: 6px;
}

.header-table {
    cursor: pointer;
}

.contentss-header {
    width: 100%;
    display: flex;
    justify-content: space-between;
    width: 150px;
}

.contentss {
    width: 97%;
    margin: 0 auto;
    padding-top: 12px;
}

.contents-area {
    width: 100%;
    background: white;
    margin-top: 20px;
}

.header-title {
    position: relative;
    top: 20px;
    left: 25px;
}

.numbers {
    position: relative;
    top: -7px;
    color: #2AB95F;
}

.number-name2 {
    margin-top: 8px;
    font-size: 14px;
    color: #979BBC;
}

.number-name {
    font-weight: bold;
    font-size: 25px;
    color: #17192C;
}

.header-names {
    display: flex;
    width: 82%;
    justify-content: space-between;
    margin: 0 auto;
    padding-top: 20px;
}

.header-area {
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between;
    width: 97%;
    margin: 0 auto;
}

.content-header {
    width: 100%;
    background: white;
    padding-bottom: 22px;
}

.footer {
    display: flex;
    justify-content: end;
    margin-top: 20px;
}

.tianjia {
    position: relative;
    top: -9px;
    background-color: #5065F6;
}

.tianjia2 {
    position: relative;
    top: -9px;
    background-color: #EDEFFE;
    color: #5065F6;
}

::v-deep .el-table thead {
    background-color: #EDEFFE !important;
    color: #363636 !important;
}

::v-deep .el-table__header th {
    background-color: #EDEFFE !important;
    color: #363636 !important;
}

.formitem {
    position: relative;
    top: -5px;
}

::deep .el-form-item__label {
    font-size: 15px !important;
}

.selects {
    width: 100px;
    border: 1px solid #3333;
}

.headers-name {
    font-size: 15px;
    position: relative;
    top: 14px;
}

.headers {
    display: flex;
    justify-content: space-between;
}

.status-completed {
    color: #67C23A;
}

.status-pending {
    color: #E6A23C;
}

.status-pending::before {
    content: '';
    display: inline-block;
    width: 8px;
    height: 8px;
    background: #E6A23C;
    border-radius: 50%;
    margin-right: 5px;
}

::v-deep .el-table__body tr:hover > td {
    background-color: transparent !important;
}

::v-deep .el-table__body tr.el-table__row--striped td {
    background-color: transparent;
}

/* 详情弹窗样式 */
.detail-dialog ::v-deep .el-dialog__header {
    padding: 20px 20px 10px;
    border-bottom: 1px solid #EBEEF5;
}

.detail-dialog ::v-deep .el-dialog__title {
    font-size: 16px;
    font-weight: bold;
    color: #303133;
}

.detail-dialog ::v-deep .el-dialog__body {
    padding: 20px;
}

.dialog-subtitle {
    font-size: 14px;
    color: #606266;
    margin-bottom: 15px;
}

.dialog-table-wrapper {
    max-height: 500px;
    overflow-y: auto;
}

.dialog-table-wrapper ::v-deep .el-table {
    font-size: 13px;
}

.dialog-table-wrapper ::v-deep .el-table th {
    padding: 10px 0;
    font-weight: normal;
}

.dialog-table-wrapper ::v-deep .el-table td {
    padding: 10px 0;
}
</style>
