在这里插入图片描述
欢迎加入开源鸿蒙跨平台社区:https://openharmonycrossplatform.csdn.net

项目概述

员工薪资评估系统是一个基于Kotlin Multiplatform (KMP)和OpenHarmony平台开发的综合性人力资源管理和薪资评估解决方案。该系统通过实时收集和分析员工的关键绩效指标,包括工作表现、技能水平、工作年限、团队贡献和创新能力等,为企业人力资源部门提供科学的薪资评估决策支持和薪酬优化建议。

员工薪资评估是现代企业人力资源管理的重要环节,直接影响到员工激励和企业竞争力。传统的薪资评估往往依赖主观判断和定期审查,存在评估不公平、数据不透明、激励效果不佳等问题。本系统通过引入先进的员工数据分析和评估技术,实现了对员工薪资的全面、实时、科学的评估和分析。该系统采用KMP技术栈,使得核心的薪资评估算法可以在Kotlin中编写,然后编译为JavaScript在Web端运行,同时通过ArkTS在OpenHarmony设备上调用,实现了跨平台的统一解决方案。

核心功能特性

1. 多维度员工绩效指标监测

系统能够同时监测工作表现、技能水平、工作年限、团队贡献和创新能力五个关键员工绩效指标。这些指标的组合分析可以全面反映员工的综合价值。工作表现衡量工作质量;技能水平反映专业能力;工作年限体现经验积累;团队贡献关系到协作能力;创新能力影响到发展潜力。

2. 智能薪资评估算法

系统采用多维度评估算法,综合考虑各个绩效指标的相对重要性,给出客观的员工薪资评分。通过建立绩效指标与薪资等级之间的映射关系,系统能够快速识别高价值员工和需要关注的员工。这种算法不仅考虑了单个指标的影响,还充分考虑了指标之间的相互关系和员工的发展潜力。

3. 分级薪资改进建议

系统根据当前的员工绩效状况,生成分级的薪资建议。对于高绩效员工,系统建议提升薪资和职位;对于需要改进的员工,系统会提出具体的发展方案,包括培训建议、改进方向等。这种分级方式确保了薪资建议的公平性和激励效果。

4. 员工价值评估支持

系统能够计算员工的综合价值指数,包括薪资等级、发展潜力、优先级等。通过这种量化的评估,企业人力资源部门可以清晰地了解员工的价值水平,为薪酬管理提供有力支撑。

技术架构

Kotlin后端实现

使用Kotlin语言编写核心的员工薪资分析算法和评估模型。Kotlin的简洁语法和强大的类型系统使得复杂的算法实现既易于维护又能保证运行时的安全性。通过@JsExport注解,将Kotlin函数导出为JavaScript,实现跨平台调用。

JavaScript中间层

Kotlin编译生成的JavaScript代码作为中间层,提供了Web端的数据处理能力。这一层负责接收来自各种数据源的输入,进行数据验证和转换,然后调用核心的分析算法。

ArkTS前端展示

在OpenHarmony设备上,使用ArkTS编写用户界面。通过调用JavaScript导出的函数,实现了与后端逻辑的无缝集成。用户可以通过直观的界面输入员工绩效数据,实时查看分析结果和薪资建议。

应用场景

本系统适用于各类企业运营机构,特别是:

  • 企业的人力资源管理部门
  • 薪酬管理部门的薪资评估工作
  • 员工发展部门的绩效评价
  • 企业管理层的决策支持

Kotlin实现代码

员工薪资评估系统核心算法

@JsExport
fun employeeSalaryEvaluationSystem(inputData: String): String {
    val parts = inputData.trim().split(" ")
    if (parts.size != 5) {
        return "格式错误\n请输入: 工作表现(1-10) 技能水平(1-10) 工作年限(年) 团队贡献(1-10) 创新能力(1-10)\n例如: 8 8 5 9 7"
    }
    
    val workPerformance = parts[0].toDoubleOrNull()
    val skillLevel = parts[1].toDoubleOrNull()
    val workingYears = parts[2].toDoubleOrNull()
    val teamContribution = parts[3].toDoubleOrNull()
    val innovationAbility = parts[4].toDoubleOrNull()
    
    if (workPerformance == null || skillLevel == null || workingYears == null || teamContribution == null || innovationAbility == null) {
        return "数值错误\n请输入有效的数字"
    }
    
    // 参数范围验证
    if (workPerformance < 1 || workPerformance > 10) {
        return "工作表现应在1-10之间"
    }
    if (skillLevel < 1 || skillLevel > 10) {
        return "技能水平应在1-10之间"
    }
    if (workingYears < 0 || workingYears > 50) {
        return "工作年限应在0-50年之间"
    }
    if (teamContribution < 1 || teamContribution > 10) {
        return "团队贡献应在1-10之间"
    }
    if (innovationAbility < 1 || innovationAbility > 10) {
        return "创新能力应在1-10之间"
    }
    
    // 计算各指标的评分(0-100,分数越高薪资越高)
    val performanceScore = (workPerformance / 10.0 * 100).toInt()
    val skillScore = (skillLevel / 10.0 * 100).toInt()
    val yearsScore = (Math.min(workingYears / 5.0 * 100, 100.0)).toInt()
    val contributionScore = (teamContribution / 10.0 * 100).toInt()
    val innovationScore = (innovationAbility / 10.0 * 100).toInt()
    
    // 加权综合评分
    val overallScore = (performanceScore * 0.30 + skillScore * 0.25 + yearsScore * 0.20 + contributionScore * 0.15 + innovationScore * 0.10).toInt()
    
    // 员工薪资等级判定
    val salaryLevel = when {
        overallScore >= 90 -> "🟢 A级(高级员工)"
        overallScore >= 80 -> "🟡 B级(骨干员工)"
        overallScore >= 70 -> "🟠 C级(中级员工)"
        overallScore >= 60 -> "🔴 D级(初级员工)"
        else -> "⚫ E级(试用员工)"
    }
    
    // 计算发展潜力
    val developmentPotential = when {
        overallScore >= 90 -> "极高"
        overallScore >= 80 -> "高"
        overallScore >= 70 -> "中等"
        overallScore >= 60 -> "低"
        else -> "极低"
    }
    
    // 计算推荐薪资调整幅度
    val salaryAdjustment = when {
        overallScore >= 90 -> "提升20-30%"
        overallScore >= 80 -> "提升10-20%"
        overallScore >= 70 -> "提升5-10%"
        overallScore >= 60 -> "维持现状"
        else -> "考虑降级"
    }
    
    // 计算推荐改进措施数
    val recommendedMeasures = when {
        overallScore >= 90 -> 2
        overallScore >= 80 -> 4
        overallScore >= 70 -> 6
        overallScore >= 60 -> 8
        else -> 10
    }
    
    // 计算年度薪资增长潜力
    val annualSalaryGrowth = overallScore * 100
    
    // 生成详细报告
    return buildString {
        appendLine("╔════════════════════════════════════════╗")
        appendLine("║    💼 员工薪资评估系统报告            ║")
        appendLine("╚════════════════════════════════════════╝")
        appendLine()
        appendLine("📊 员工绩效指标监测")
        appendLine("━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━")
        appendLine("工作表现: ${workPerformance}/10")
        appendLine("技能水平: ${skillLevel}/10")
        appendLine("工作年限: ${workingYears}年")
        appendLine("团队贡献: ${teamContribution}/10")
        appendLine("创新能力: ${innovationAbility}/10")
        appendLine()
        appendLine("⭐ 指标评分")
        appendLine("━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━")
        appendLine("工作表现评分: $performanceScore/100")
        appendLine("技能水平评分: $skillScore/100")
        appendLine("工作年限评分: $yearsScore/100")
        appendLine("团队贡献评分: $contributionScore/100")
        appendLine("创新能力评分: $innovationScore/100")
        appendLine()
        appendLine("🎯 综合评估")
        appendLine("━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━")
        appendLine("综合绩效评分: $overallScore/100")
        appendLine("员工薪资等级: $salaryLevel")
        appendLine("发展潜力: $developmentPotential")
        appendLine("推荐薪资调整: $salaryAdjustment")
        appendLine("推荐改进措施: $recommendedMeasures项")
        appendLine()
        appendLine("💰 薪资分析")
        appendLine("━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━")
        appendLine("年度薪资增长潜力: ${String.format("%.0f", annualSalaryGrowth)}")
        appendLine("薪资竞争力: ${if (overallScore >= 80) "强" else "中等"}")
        appendLine("晋升潜力: ${if (overallScore >= 80) "高" else "中等"}")
        appendLine("推荐行动: ${if (overallScore >= 80) "晋升考虑" else "继续培养"}")
        appendLine()
        appendLine("📈 员工绩效分析")
        appendLine("━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━")
        
        // 工作表现建议
        if (workPerformance < 6) {
            appendLine("  📍 工作表现需要改进")
            appendLine("     - 加强工作指导")
            appendLine("     - 提升工作质量")
            appendLine("     - 改进工作方法")
        } else if (workPerformance >= 8) {
            appendLine("  ✅ 工作表现优秀")
            appendLine("     - 继续保持高度")
            appendLine("     - 深化工作创新")
        }
        
        // 技能水平建议
        if (skillLevel < 6) {
            appendLine("  🔧 技能水平需要提升")
            appendLine("     - 加强技能培训")
            appendLine("     - 参加专业课程")
            appendLine("     - 提升专业能力")
        } else if (skillLevel >= 8) {
            appendLine("  ✅ 技能水平优秀")
            appendLine("     - 继续保持高度")
            appendLine("     - 深化技能创新")
        }
        
        // 工作年限建议
        if (workingYears < 2) {
            appendLine("  📅 工作年限较短")
            appendLine("     - 加强入职培养")
            appendLine("     - 提升适应能力")
            appendLine("     - 建立职业规划")
        } else if (workingYears >= 5) {
            appendLine("  ✅ 工作年限充足")
            appendLine("     - 充分发挥经验")
            appendLine("     - 深化职业发展")
        }
        
        // 团队贡献建议
        if (teamContribution < 6) {
            appendLine("  🤝 团队贡献需要加强")
            appendLine("     - 加强团队意识")
            appendLine("     - 提升协作能力")
            appendLine("     - 改进工作流程")
        } else if (teamContribution >= 8) {
            appendLine("  ✅ 团队贡献优秀")
            appendLine("     - 继续保持高度")
            appendLine("     - 深化团队建设")
        }
        
        // 创新能力建议
        if (innovationAbility < 6) {
            appendLine("  💡 创新能力需要提升")
            appendLine("     - 鼓励创新思维")
            appendLine("     - 参加创新项目")
            appendLine("     - 提升创新意识")
        } else if (innovationAbility >= 8) {
            appendLine("  ✅ 创新能力优秀")
            appendLine("     - 继续保持高度")
            appendLine("     - 深化创新实践")
        }
        
        appendLine()
        appendLine("📋 薪资管理建议")
        appendLine("━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━")
        when {
            overallScore >= 90 -> {
                appendLine("🟢 员工优秀 - 重点培养")
                appendLine("  1. 提升薪资20-30%")
                appendLine("  2. 考虑职位晋升")
                appendLine("  3. 提供发展机会")
                appendLine("  4. 建立激励机制")
            }
            overallScore >= 80 -> {
                appendLine("🟡 员工良好 - 深化培养")
                appendLine("  1. 提升薪资10-20%")
                appendLine("  2. 提供培训机会")
                appendLine("  3. 明确发展路径")
            }
            overallScore >= 70 -> {
                appendLine("🟠 员工一般 - 逐步改进")
                appendLine("  1. 提升薪资5-10%")
                appendLine("  2. 制定改进计划")
                appendLine("  3. 加强管理指导")
            }
            overallScore >= 60 -> {
                appendLine("🔴 员工较差 - 重点改进")
                appendLine("  1. 维持现有薪资")
                appendLine("  2. 进行全面诊断")
                appendLine("  3. 制定改进方案")
                appendLine("  4. 定期跟进评估")
            }
            else -> {
                appendLine("⚫ 员工很差 - 立即改进")
                appendLine("  1. 考虑降级或离职")
                appendLine("  2. 进行深度沟通")
                appendLine("  3. 制定改进方案")
                appendLine("  4. 加强监督管理")
            }
        }
        
        appendLine()
        appendLine("━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━")
        appendLine("✅ 评估完成 | 时间戳: ${System.currentTimeMillis()}")
    }
}

代码说明

上述Kotlin代码实现了员工薪资评估系统的核心算法。employeeSalaryEvaluationSystem函数是主入口,接收一个包含五个员工绩效指标的字符串输入。函数首先进行输入验证,确保数据的有效性和范围的合理性。

然后,它计算各指标的评分。工作表现、技能水平、工作年限、团队贡献和创新能力都转换为0-100的评分。系统采用标准的员工薪资评估方法。

系统使用加权平均法计算综合评分,其中工作表现的权重为30%,因为它是员工薪资的核心指标。技能水平的权重为25%,工作年限的权重为20%,团队贡献的权重为15%,创新能力的权重为10%。

最后,系统根据综合评分判定员工薪资等级,并生成详细的评估报告。同时,系统还计算了发展潜力和推荐改进措施数,为人力资源部门提供量化的薪资管理支持。


JavaScript编译版本

// 员工薪资评估系统 - JavaScript版本
function employeeSalaryEvaluationSystem(inputData) {
    const parts = inputData.trim().split(" ");
    if (parts.length !== 5) {
        return "格式错误\n请输入: 工作表现(1-10) 技能水平(1-10) 工作年限(年) 团队贡献(1-10) 创新能力(1-10)\n例如: 8 8 5 9 7";
    }
    
    const workPerformance = parseFloat(parts[0]);
    const skillLevel = parseFloat(parts[1]);
    const workingYears = parseFloat(parts[2]);
    const teamContribution = parseFloat(parts[3]);
    const innovationAbility = parseFloat(parts[4]);
    
    // 数值验证
    if (isNaN(workPerformance) || isNaN(skillLevel) || isNaN(workingYears) || 
        isNaN(teamContribution) || isNaN(innovationAbility)) {
        return "数值错误\n请输入有效的数字";
    }
    
    // 范围检查
    if (workPerformance < 1 || workPerformance > 10) {
        return "工作表现应在1-10之间";
    }
    if (skillLevel < 1 || skillLevel > 10) {
        return "技能水平应在1-10之间";
    }
    if (workingYears < 0 || workingYears > 50) {
        return "工作年限应在0-50年之间";
    }
    if (teamContribution < 1 || teamContribution > 10) {
        return "团队贡献应在1-10之间";
    }
    if (innovationAbility < 1 || innovationAbility > 10) {
        return "创新能力应在1-10之间";
    }
    
    // 计算各指标评分
    const performanceScore = Math.floor(workPerformance / 10.0 * 100);
    const skillScore = Math.floor(skillLevel / 10.0 * 100);
    const yearsScore = Math.floor(Math.min(workingYears / 5.0 * 100, 100.0));
    const contributionScore = Math.floor(teamContribution / 10.0 * 100);
    const innovationScore = Math.floor(innovationAbility / 10.0 * 100);
    
    // 加权综合评分
    const overallScore = Math.floor(
        performanceScore * 0.30 + skillScore * 0.25 + yearsScore * 0.20 + 
        contributionScore * 0.15 + innovationScore * 0.10
    );
    
    // 员工薪资等级判定
    let salaryLevel;
    if (overallScore >= 90) {
        salaryLevel = "🟢 A级(高级员工)";
    } else if (overallScore >= 80) {
        salaryLevel = "🟡 B级(骨干员工)";
    } else if (overallScore >= 70) {
        salaryLevel = "🟠 C级(中级员工)";
    } else if (overallScore >= 60) {
        salaryLevel = "🔴 D级(初级员工)";
    } else {
        salaryLevel = "⚫ E级(试用员工)";
    }
    
    // 计算发展潜力
    let developmentPotential;
    if (overallScore >= 90) {
        developmentPotential = "极高";
    } else if (overallScore >= 80) {
        developmentPotential = "高";
    } else if (overallScore >= 70) {
        developmentPotential = "中等";
    } else if (overallScore >= 60) {
        developmentPotential = "低";
    } else {
        developmentPotential = "极低";
    }
    
    // 计算推荐薪资调整幅度
    let salaryAdjustment;
    if (overallScore >= 90) {
        salaryAdjustment = "提升20-30%";
    } else if (overallScore >= 80) {
        salaryAdjustment = "提升10-20%";
    } else if (overallScore >= 70) {
        salaryAdjustment = "提升5-10%";
    } else if (overallScore >= 60) {
        salaryAdjustment = "维持现状";
    } else {
        salaryAdjustment = "考虑降级";
    }
    
    // 计算推荐改进措施数
    let recommendedMeasures;
    if (overallScore >= 90) {
        recommendedMeasures = 2;
    } else if (overallScore >= 80) {
        recommendedMeasures = 4;
    } else if (overallScore >= 70) {
        recommendedMeasures = 6;
    } else if (overallScore >= 60) {
        recommendedMeasures = 8;
    } else {
        recommendedMeasures = 10;
    }
    
    // 计算年度薪资增长潜力
    const annualSalaryGrowth = overallScore * 100;
    
    // 生成报告
    let report = "";
    report += "╔════════════════════════════════════════╗\n";
    report += "║    💼 员工薪资评估系统报告            ║\n";
    report += "╚════════════════════════════════════════╝\n\n";
    
    report += "📊 员工绩效指标监测\n";
    report += "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\n";
    report += `工作表现: ${workPerformance}/10\n`;
    report += `技能水平: ${skillLevel}/10\n`;
    report += `工作年限: ${workingYears}年\n`;
    report += `团队贡献: ${teamContribution}/10\n`;
    report += `创新能力: ${innovationAbility}/10\n\n`;
    
    report += "⭐ 指标评分\n";
    report += "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\n";
    report += `工作表现评分: ${performanceScore}/100\n`;
    report += `技能水平评分: ${skillScore}/100\n`;
    report += `工作年限评分: ${yearsScore}/100\n`;
    report += `团队贡献评分: ${contributionScore}/100\n`;
    report += `创新能力评分: ${innovationScore}/100\n\n`;
    
    report += "🎯 综合评估\n";
    report += "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\n";
    report += `综合绩效评分: ${overallScore}/100\n`;
    report += `员工薪资等级: ${salaryLevel}\n`;
    report += `发展潜力: ${developmentPotential}\n`;
    report += `推荐薪资调整: ${salaryAdjustment}\n`;
    report += `推荐改进措施: ${recommendedMeasures}项\n\n`;
    
    report += "💰 薪资分析\n";
    report += "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\n";
    report += `年度薪资增长潜力: ${annualSalaryGrowth.toFixed(0)}\n`;
    report += `薪资竞争力: ${overallScore >= 80 ? "强" : "中等"}\n`;
    report += `晋升潜力: ${overallScore >= 80 ? "高" : "中等"}\n`;
    report += `推荐行动: ${overallScore >= 80 ? "晋升考虑" : "继续培养"}\n\n`;
    
    report += "📈 员工绩效分析\n";
    report += "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\n";
    
    // 工作表现建议
    if (workPerformance < 6) {
        report += "  📍 工作表现需要改进\n";
        report += "     - 加强工作指导\n";
        report += "     - 提升工作质量\n";
        report += "     - 改进工作方法\n";
    } else if (workPerformance >= 8) {
        report += "  ✅ 工作表现优秀\n";
        report += "     - 继续保持高度\n";
        report += "     - 深化工作创新\n";
    }
    
    // 技能水平建议
    if (skillLevel < 6) {
        report += "  🔧 技能水平需要提升\n";
        report += "     - 加强技能培训\n";
        report += "     - 参加专业课程\n";
        report += "     - 提升专业能力\n";
    } else if (skillLevel >= 8) {
        report += "  ✅ 技能水平优秀\n";
        report += "     - 继续保持高度\n";
        report += "     - 深化技能创新\n";
    }
    
    // 工作年限建议
    if (workingYears < 2) {
        report += "  📅 工作年限较短\n";
        report += "     - 加强入职培养\n";
        report += "     - 提升适应能力\n";
        report += "     - 建立职业规划\n";
    } else if (workingYears >= 5) {
        report += "  ✅ 工作年限充足\n";
        report += "     - 充分发挥经验\n";
        report += "     - 深化职业发展\n";
    }
    
    // 团队贡献建议
    if (teamContribution < 6) {
        report += "  🤝 团队贡献需要加强\n";
        report += "     - 加强团队意识\n";
        report += "     - 提升协作能力\n";
        report += "     - 改进工作流程\n";
    } else if (teamContribution >= 8) {
        report += "  ✅ 团队贡献优秀\n";
        report += "     - 继续保持高度\n";
        report += "     - 深化团队建设\n";
    }
    
    // 创新能力建议
    if (innovationAbility < 6) {
        report += "  💡 创新能力需要提升\n";
        report += "     - 鼓励创新思维\n";
        report += "     - 参加创新项目\n";
        report += "     - 提升创新意识\n";
    } else if (innovationAbility >= 8) {
        report += "  ✅ 创新能力优秀\n";
        report += "     - 继续保持高度\n";
        report += "     - 深化创新实践\n";
    }
    
    report += "\n📋 薪资管理建议\n";
    report += "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\n";
    
    if (overallScore >= 90) {
        report += "🟢 员工优秀 - 重点培养\n";
        report += "  1. 提升薪资20-30%\n";
        report += "  2. 考虑职位晋升\n";
        report += "  3. 提供发展机会\n";
        report += "  4. 建立激励机制\n";
    } else if (overallScore >= 80) {
        report += "🟡 员工良好 - 深化培养\n";
        report += "  1. 提升薪资10-20%\n";
        report += "  2. 提供培训机会\n";
        report += "  3. 明确发展路径\n";
    } else if (overallScore >= 70) {
        report += "🟠 员工一般 - 逐步改进\n";
        report += "  1. 提升薪资5-10%\n";
        report += "  2. 制定改进计划\n";
        report += "  3. 加强管理指导\n";
    } else if (overallScore >= 60) {
        report += "🔴 员工较差 - 重点改进\n";
        report += "  1. 维持现有薪资\n";
        report += "  2. 进行全面诊断\n";
        report += "  3. 制定改进方案\n";
        report += "  4. 定期跟进评估\n";
    } else {
        report += "⚫ 员工很差 - 立即改进\n";
        report += "  1. 考虑降级或离职\n";
        report += "  2. 进行深度沟通\n";
        report += "  3. 制定改进方案\n";
        report += "  4. 加强监督管理\n";
    }
    
    report += "\n━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\n";
    report += `✅ 评估完成 | 时间戳: ${Date.now()}\n`;
    
    return report;
}

JavaScript版本说明

JavaScript版本是由Kotlin代码编译而来的,提供了完全相同的功能。在Web环境中,这个JavaScript函数可以直接被调用,用于处理来自前端表单的数据。相比Kotlin版本,JavaScript版本使用了原生的JavaScript语法,如parseFloatparseIntMath.floor等,确保了在浏览器环境中的兼容性。

该版本保留了所有的业务逻辑和计算方法,确保了跨平台的一致性。通过这种方式,开发者只需要维护一份Kotlin代码,就可以在多个平台上运行相同的业务逻辑。


ArkTS调用实现

import { employeeSalaryEvaluationSystem } from './hellokjs'

@Entry
@Component
struct EmployeeSalaryEvaluationPage {
  @State workPerformance: string = "8"
  @State skillLevel: string = "8"
  @State workingYears: string = "5"
  @State teamContribution: string = "9"
  @State innovationAbility: string = "7"
  @State result: string = ""
  @State isLoading: boolean = false

  build() {
    Column() {
      // 顶部标题栏
      Row() {
        Text("💼 员工薪资评估系统")
          .fontSize(20)
          .fontWeight(FontWeight.Bold)
          .fontColor('#FFFFFF')
      }
      .width('100%')
      .height(60)
      .backgroundColor('#5E35B1')
      .justifyContent(FlexAlign.Center)
      .padding({ left: 16, right: 16 })

      // 主体内容
      Scroll() {
        Column() {
          // 参数输入部分
          Column() {
            Text("📊 员工绩效指标输入")
              .fontSize(16)
              .fontWeight(FontWeight.Bold)
              .fontColor('#5E35B1')
              .margin({ bottom: 12 })
              .padding({ left: 12, top: 12 })

            // 2列网格布局
            Column() {
              // 第一行
              Row() {
                Column() {
                  Text("工作表现(1-10)")
                    .fontSize(12)
                    .fontWeight(FontWeight.Bold)
                    .margin({ bottom: 4 })
                  TextInput({ placeholder: "8", text: this.workPerformance })
                    .height(40)
                    .width('100%')
                    .onChange((value: string) => { this.workPerformance = value })
                    .backgroundColor('#FFFFFF')
                    .border({ width: 1, color: '#5E35B1' })
                    .borderRadius(4)
                    .padding(8)
                    .fontSize(12)
                }.width('48%').padding(6)
                Blank().width('4%')
                Column() {
                  Text("技能水平(1-10)")
                    .fontSize(12)
                    .fontWeight(FontWeight.Bold)
                    .margin({ bottom: 4 })
                  TextInput({ placeholder: "8", text: this.skillLevel })
                    .height(40)
                    .width('100%')
                    .onChange((value: string) => { this.skillLevel = value })
                    .backgroundColor('#FFFFFF')
                    .border({ width: 1, color: '#5E35B1' })
                    .borderRadius(4)
                    .padding(8)
                    .fontSize(12)
                }.width('48%').padding(6)
              }.width('100%').justifyContent(FlexAlign.SpaceBetween)

              // 第二行
              Row() {
                Column() {
                  Text("工作年限(年)")
                    .fontSize(12)
                    .fontWeight(FontWeight.Bold)
                    .margin({ bottom: 4 })
                  TextInput({ placeholder: "5", text: this.workingYears })
                    .height(40)
                    .width('100%')
                    .onChange((value: string) => { this.workingYears = value })
                    .backgroundColor('#FFFFFF')
                    .border({ width: 1, color: '#5E35B1' })
                    .borderRadius(4)
                    .padding(8)
                    .fontSize(12)
                }.width('48%').padding(6)
                Blank().width('4%')
                Column() {
                  Text("团队贡献(1-10)")
                    .fontSize(12)
                    .fontWeight(FontWeight.Bold)
                    .margin({ bottom: 4 })
                  TextInput({ placeholder: "9", text: this.teamContribution })
                    .height(40)
                    .width('100%')
                    .onChange((value: string) => { this.teamContribution = value })
                    .backgroundColor('#FFFFFF')
                    .border({ width: 1, color: '#5E35B1' })
                    .borderRadius(4)
                    .padding(8)
                    .fontSize(12)
                }.width('48%').padding(6)
              }.width('100%').justifyContent(FlexAlign.SpaceBetween).margin({ top: 8 })

              // 第三行
              Row() {
                Column() {
                  Text("创新能力(1-10)")
                    .fontSize(12)
                    .fontWeight(FontWeight.Bold)
                    .margin({ bottom: 4 })
                  TextInput({ placeholder: "7", text: this.innovationAbility })
                    .height(40)
                    .width('100%')
                    .onChange((value: string) => { this.innovationAbility = value })
                    .backgroundColor('#FFFFFF')
                    .border({ width: 1, color: '#5E35B1' })
                    .borderRadius(4)
                    .padding(8)
                    .fontSize(12)
                }.width('48%').padding(6)
                Blank().width('52%')
              }.width('100%').margin({ top: 8 })
            }
            .width('100%')
            .padding({ left: 6, right: 6, bottom: 12 })
          }
          .width('100%')
          .padding(12)
          .backgroundColor('#EDE7F6')
          .borderRadius(8)
          .margin({ bottom: 12 })

          // 按钮区域
          Row() {
            Button("开始评估")
              .width('48%')
              .height(44)
              .fontSize(14)
              .fontWeight(FontWeight.Bold)
              .backgroundColor('#5E35B1')
              .fontColor(Color.White)
              .borderRadius(6)
              .onClick(() => {
                this.executeEvaluation()
              })

            Blank().width('4%')

            Button("重置数据")
              .width('48%')
              .height(44)
              .fontSize(14)
              .fontWeight(FontWeight.Bold)
              .backgroundColor('#512DA8')
              .fontColor(Color.White)
              .borderRadius(6)
              .onClick(() => {
                this.workPerformance = "8"
                this.skillLevel = "8"
                this.workingYears = "5"
                this.teamContribution = "9"
                this.innovationAbility = "7"
                this.result = ""
              })
          }
          .width('100%')
          .justifyContent(FlexAlign.Center)
          .padding({ left: 12, right: 12, bottom: 12 })

          // 结果显示部分
          Column() {
            Text("📋 评估结果")
              .fontSize(16)
              .fontWeight(FontWeight.Bold)
              .fontColor('#5E35B1')
              .margin({ bottom: 12 })
              .padding({ left: 12, right: 12, top: 12 })

            if (this.isLoading) {
              Column() {
                LoadingProgress()
                  .width(50)
                  .height(50)
                  .color('#5E35B1')
                Text("正在评估...")
                  .fontSize(14)
                  .fontColor('#5E35B1')
                  .margin({ top: 16 })
              }
              .width('100%')
              .height(200)
              .justifyContent(FlexAlign.Center)
              .alignItems(HorizontalAlign.Center)
            } else if (this.result.length > 0) {
              Scroll() {
                Text(this.result)
                  .fontSize(11)
                  .fontColor('#5E35B1')
                  .fontFamily('monospace')
                  .width('100%')
                  .padding(12)
                  .lineHeight(1.6)
              }
              .width('100%')
              .height(400)
            } else {
              Column() {
                Text("💼")
                  .fontSize(64)
                  .opacity(0.2)
                  .margin({ bottom: 16 })
                Text("暂无评估结果")
                  .fontSize(14)
                  .fontColor('#5E35B1')
                Text("请输入员工绩效指标后点击开始评估")
                  .fontSize(12)
                  .fontColor('#512DA8')
                  .margin({ top: 8 })
              }
              .width('100%')
              .height(200)
              .justifyContent(FlexAlign.Center)
              .alignItems(HorizontalAlign.Center)
            }
          }
          .layoutWeight(1)
          .width('100%')
          .padding(12)
          .backgroundColor('#F5F5F5')
          .borderRadius(8)
        }
        .width('100%')
        .padding(12)
      }
      .layoutWeight(1)
    }
    .width('100%')
    .height('100%')
    .backgroundColor('#FAFAFA')
  }

  private executeEvaluation() {
    const wpStr = this.workPerformance.trim()
    const slStr = this.skillLevel.trim()
    const wyStr = this.workingYears.trim()
    const tcStr = this.teamContribution.trim()
    const iaStr = this.innovationAbility.trim()

    if (!wpStr || !slStr || !wyStr || !tcStr || !iaStr) {
      this.result = "❌ 请填写全部员工绩效指标"
      return
    }

    this.isLoading = true

    setTimeout((): void => {
      try {
        const inputStr = `${wpStr} ${slStr} ${wyStr} ${tcStr} ${iaStr}`
        const result = employeeSalaryEvaluationSystem(inputStr)
        this.result = result
        console.log("[EmployeeSalaryEvaluationSystem] 评估完成")
      } catch (error) {
        this.result = `❌ 执行出错: ${error}`
        console.error("[EmployeeSalaryEvaluationSystem] 错误:", error)
      } finally {
        this.isLoading = false
      }
    }, 500)
  }
}

ArkTS调用说明

ArkTS是OpenHarmony平台上的主要开发语言,它基于TypeScript进行了扩展,提供了更好的性能和类型安全。在上述代码中,我们创建了一个完整的UI界面,用于输入员工绩效指标并显示评估结果。

页面采用了分层设计:顶部是标题栏,中间是参数输入区域,下方是评估结果显示区。参数输入区使用了2列网格布局,使得界面紧凑而不失清晰。每个输入框都有对应的标签和默认值,方便用户快速操作。

executeEvaluation方法是关键的交互逻辑。当用户点击"开始评估"按钮时,该方法会收集所有输入参数,组合成一个字符串,然后调用从JavaScript导出的employeeSalaryEvaluationSystem函数。函数返回的结果会被显示在下方的滚动区域中。同时,系统使用isLoading状态来显示加载动画,提升用户体验。


系统集成与部署

编译流程

  1. Kotlin编译:使用KMP的Gradle插件,将Kotlin代码编译为JavaScript
  2. JavaScript生成:生成的JavaScript文件包含了所有的业务逻辑
  3. ArkTS集成:在ArkTS项目中导入JavaScript文件,通过import语句引入函数
  4. 应用打包:将整个应用打包为OpenHarmony应用安装包

部署建议

  • 在企业人力资源管理系统中部署该系统的Web版本
  • 在HR管理人员的移动设备上部署OpenHarmony应用,运行该系统的移动版本
  • 建立数据同步机制,确保各设备间的数据一致性
  • 定期备份评估数据,用于后续的薪资分析和改进

总结

员工薪资评估系统通过整合Kotlin、JavaScript和ArkTS三种技术,提供了一个完整的、跨平台的员工薪资评估解决方案。该系统不仅能够实时收集和分析员工的关键绩效指标,还能够进行智能分析和薪资建议,为企业人力资源部门提供了强有力的技术支撑。

通过本系统的应用,企业可以显著提高员工薪资评估的效率和公平性,及时发现和改善员工问题,优化薪酬管理,实现员工激励效果的最大化。同时,系统生成的详细报告和建议也为薪资决策提供了数据支撑。

在未来,该系统还可以进一步扩展,集成更多的员工数据、引入人工智能算法进行更精准的薪资预测、建立与绩效管理系统的联动机制等,使其成为一个更加智能、更加完善的人力资源管理平台。

Logo

开源鸿蒙跨平台开发社区汇聚开发者与厂商,共建“一次开发,多端部署”的开源生态,致力于降低跨端开发门槛,推动万物智联创新。

更多推荐