在这里插入图片描述

项目概述

供应商评估系统是一个基于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 supplierEvaluationSystem(inputData: String): String {
    val parts = inputData.trim().split(" ")
    if (parts.size != 5) {
        return "格式错误\n请输入: 产品质量(%) 交付及时率(%) 价格竞争力(%) 服务水平(%) 合作稳定性(%)\n例如: 92 90 85 88 90"
    }
    
    val productQuality = parts[0].toDoubleOrNull()
    val deliveryTimeliness = parts[1].toDoubleOrNull()
    val priceCompetitiveness = parts[2].toDoubleOrNull()
    val serviceLevel = parts[3].toDoubleOrNull()
    val cooperationStability = parts[4].toDoubleOrNull()
    
    if (productQuality == null || deliveryTimeliness == null || priceCompetitiveness == null || serviceLevel == null || cooperationStability == null) {
        return "数值错误\n请输入有效的数字"
    }
    
    // 参数范围验证
    if (productQuality < 0 || productQuality > 100) {
        return "产品质量应在0-100%之间"
    }
    if (deliveryTimeliness < 0 || deliveryTimeliness > 100) {
        return "交付及时率应在0-100%之间"
    }
    if (priceCompetitiveness < 0 || priceCompetitiveness > 100) {
        return "价格竞争力应在0-100%之间"
    }
    if (serviceLevel < 0 || serviceLevel > 100) {
        return "服务水平应在0-100%之间"
    }
    if (cooperationStability < 0 || cooperationStability > 100) {
        return "合作稳定性应在0-100%之间"
    }
    
    // 计算各指标的评分
    val qualityScore = productQuality.toInt()
    val deliveryScore = deliveryTimeliness.toInt()
    val priceScore = priceCompetitiveness.toInt()
    val serviceScore = serviceLevel.toInt()
    val stabilityScore = cooperationStability.toInt()
    
    // 加权综合评分
    val overallScore = (qualityScore * 0.30 + deliveryScore * 0.25 + priceScore * 0.20 + serviceScore * 0.15 + stabilityScore * 0.10).toInt()
    
    // 供应商等级判定
    val supplierLevel = when {
        overallScore >= 90 -> "🟢 A级(优秀)"
        overallScore >= 80 -> "🟡 B级(良好)"
        overallScore >= 70 -> "🟠 C级(一般)"
        overallScore >= 60 -> "🔴 D级(较差)"
        else -> "⚫ E级(不合格)"
    }
    
    // 计算合作潜力
    val cooperationPotential = when {
        overallScore >= 90 -> "极高"
        overallScore >= 80 -> "高"
        overallScore >= 70 -> "中等"
        overallScore >= 60 -> "低"
        else -> "极低"
    }
    
    // 计算推荐订单量
    val recommendedOrderVolume = when {
        overallScore >= 90 -> 1000
        overallScore >= 80 -> 500
        overallScore >= 70 -> 200
        overallScore >= 60 -> 50
        else -> 10
    }
    
    // 计算供应商改进空间
    val qualityGap = 100 - productQuality
    val deliveryGap = 100 - deliveryTimeliness
    val priceGap = 100 - priceCompetitiveness
    val serviceGap = 100 - serviceLevel
    val stabilityGap = 100 - cooperationStability
    
    // 生成详细报告
    return buildString {
        appendLine("╔════════════════════════════════════════╗")
        appendLine("║    🏭 供应商评估系统报告              ║")
        appendLine("╚════════════════════════════════════════╝")
        appendLine()
        appendLine("📊 供应商指标监测")
        appendLine("━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━")
        appendLine("产品质量: ${(productQuality * 100).toInt() / 100.0}%")
        appendLine("交付及时率: ${(deliveryTimeliness * 100).toInt() / 100.0}%")
        appendLine("价格竞争力: ${(priceCompetitiveness * 100).toInt() / 100.0}%")
        appendLine("服务水平: ${(serviceLevel * 100).toInt() / 100.0}%")
        appendLine("合作稳定性: ${(cooperationStability * 100).toInt() / 100.0}%")
        appendLine()
        appendLine("⭐ 指标评分")
        appendLine("━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━")
        appendLine("质量评分: $qualityScore/100")
        appendLine("交付评分: $deliveryScore/100")
        appendLine("价格评分: $priceScore/100")
        appendLine("服务评分: $serviceScore/100")
        appendLine("稳定评分: $stabilityScore/100")
        appendLine()
        appendLine("🎯 综合评估")
        appendLine("━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━")
        appendLine("综合评分: $overallScore/100")
        appendLine("供应商等级: $supplierLevel")
        appendLine("合作潜力: $cooperationPotential")
        appendLine("推荐订单量: $recommendedOrderVolume万元")
        appendLine()
        appendLine("📈 改进空间分析")
        appendLine("━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━")
        appendLine("质量改进空间: ${(qualityGap * 100).toInt() / 100.0}%")
        appendLine("交付改进空间: ${(deliveryGap * 100).toInt() / 100.0}%")
        appendLine("价格改进空间: ${(priceGap * 100).toInt() / 100.0}%")
        appendLine("服务改进空间: ${(serviceGap * 100).toInt() / 100.0}%")
        appendLine("稳定改进空间: ${(stabilityGap * 100).toInt() / 100.0}%")
        appendLine()
        appendLine("💡 供应商管理建议")
        appendLine("━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━")
        
        // 质量建议
        if (productQuality < 85) {
            appendLine("  ⚠️ 产品质量偏低")
            appendLine("     - 加强质量管理")
            appendLine("     - 提升产品标准")
            appendLine("     - 改进生产工艺")
        } else if (productQuality >= 95) {
            appendLine("  ✅ 产品质量处于优秀水平")
            appendLine("     - 继续保持高质量")
            appendLine("     - 深化质量管理")
        }
        
        // 交付建议
        if (deliveryTimeliness < 85) {
            appendLine("  🔴 交付及时率偏低")
            appendLine("     - 优化交付流程")
            appendLine("     - 提升交付能力")
            appendLine("     - 改进物流管理")
        } else if (deliveryTimeliness >= 95) {
            appendLine("  ✅ 交付及时率处于优秀水平")
            appendLine("     - 继续保持高及时")
            appendLine("     - 深化交付优化")
        }
        
        // 价格建议
        if (priceCompetitiveness < 80) {
            appendLine("  💰 价格竞争力偏低")
            appendLine("     - 优化成本结构")
            appendLine("     - 提升价格竞争力")
            appendLine("     - 改进定价策略")
        } else if (priceCompetitiveness >= 90) {
            appendLine("  ✅ 价格竞争力处于优秀水平")
            appendLine("     - 继续保持低价格")
            appendLine("     - 深化成本优化")
        }
        
        // 服务建议
        if (serviceLevel < 80) {
            appendLine("  📞 服务水平偏低")
            appendLine("     - 提升服务质量")
            appendLine("     - 改进服务流程")
            appendLine("     - 加强客户沟通")
        } else if (serviceLevel >= 90) {
            appendLine("  ✅ 服务水平处于优秀水平")
            appendLine("     - 继续保持高服务")
            appendLine("     - 深化服务优化")
        }
        
        // 稳定建议
        if (cooperationStability < 80) {
            appendLine("  🔗 合作稳定性偏低")
            appendLine("     - 加强合作沟通")
            appendLine("     - 提升合作稳定性")
            appendLine("     - 改进合作机制")
        } else if (cooperationStability >= 90) {
            appendLine("  ✅ 合作稳定性处于优秀水平")
            appendLine("     - 继续保持稳定")
            appendLine("     - 深化战略合作")
        }
        
        appendLine()
        appendLine("📋 采购策略建议")
        appendLine("━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━")
        when {
            overallScore < 60 -> {
                appendLine("⚫ 供应商评分严重不足 - 建议立即采取行动")
                appendLine("  1. 进行全面的供应商审计")
                appendLine("  2. 制定改进计划")
                appendLine("  3. 加强供应商管理")
                appendLine("  4. 考虑寻找替代供应商")
                appendLine("  5. 建立预警机制")
            }
            overallScore < 70 -> {
                appendLine("🔴 供应商评分存在问题 - 建议逐步改进")
                appendLine("  1. 加强供应商沟通")
                appendLine("  2. 提升管理要求")
                appendLine("  3. 优化合作方式")
                appendLine("  4. 准备备选方案")
            }
            overallScore < 80 -> {
                appendLine("🟠 供应商评分一般 - 继续优化")
                appendLine("  1. 微调合作策略")
                appendLine("  2. 持续改进管理")
                appendLine("  3. 定期供应商审查")
            }
            overallScore < 90 -> {
                appendLine("🟡 供应商评分良好 - 保持现状")
                appendLine("  1. 维持现有合作")
                appendLine("  2. 定期供应商审核")
                appendLine("  3. 持续创新优化")
            }
            else -> {
                appendLine("🟢 供应商评分优秀 - 重点合作")
                appendLine("  1. 提升订单量")
                appendLine("  2. 优化合作条件")
                appendLine("  3. 深化战略合作")
            }
        }
        
        appendLine()
        appendLine("━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━")
        appendLine("✅ 评估完成 | 时间戳: ${System.currentTimeMillis()}")
    }
}

代码说明

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

然后,它计算各指标的评分,其中所有指标都直接使用输入值作为评分。这种设计使得系统能够灵活处理不同类型的供应商数据。

系统使用加权平均法计算综合评分,其中产品质量的权重最高(30%),因为它是供应商价值的核心体现。交付及时率的权重为25%,价格竞争力的权重为20%,服务水平的权重为15%,合作稳定性的权重为10%。

最后,系统根据综合评分判定供应商等级,并生成详细的评估报告。同时,系统还计算了合作潜力和推荐订单量,为采购部门提供量化的决策支持。


JavaScript编译版本

// 供应商评估系统 - JavaScript版本
function supplierEvaluationSystem(inputData) {
    const parts = inputData.trim().split(" ");
    if (parts.length !== 5) {
        return "格式错误\n请输入: 产品质量(%) 交付及时率(%) 价格竞争力(%) 服务水平(%) 合作稳定性(%)\n例如: 92 90 85 88 90";
    }
    
    const productQuality = parseFloat(parts[0]);
    const deliveryTimeliness = parseFloat(parts[1]);
    const priceCompetitiveness = parseFloat(parts[2]);
    const serviceLevel = parseFloat(parts[3]);
    const cooperationStability = parseFloat(parts[4]);
    
    // 数值验证
    if (isNaN(productQuality) || isNaN(deliveryTimeliness) || isNaN(priceCompetitiveness) || 
        isNaN(serviceLevel) || isNaN(cooperationStability)) {
        return "数值错误\n请输入有效的数字";
    }
    
    // 范围检查
    if (productQuality < 0 || productQuality > 100) {
        return "产品质量应在0-100%之间";
    }
    if (deliveryTimeliness < 0 || deliveryTimeliness > 100) {
        return "交付及时率应在0-100%之间";
    }
    if (priceCompetitiveness < 0 || priceCompetitiveness > 100) {
        return "价格竞争力应在0-100%之间";
    }
    if (serviceLevel < 0 || serviceLevel > 100) {
        return "服务水平应在0-100%之间";
    }
    if (cooperationStability < 0 || cooperationStability > 100) {
        return "合作稳定性应在0-100%之间";
    }
    
    // 计算各指标评分
    const qualityScore = Math.floor(productQuality);
    const deliveryScore = Math.floor(deliveryTimeliness);
    const priceScore = Math.floor(priceCompetitiveness);
    const serviceScore = Math.floor(serviceLevel);
    const stabilityScore = Math.floor(cooperationStability);
    
    // 加权综合评分
    const overallScore = Math.floor(
        qualityScore * 0.30 + deliveryScore * 0.25 + priceScore * 0.20 + 
        serviceScore * 0.15 + stabilityScore * 0.10
    );
    
    // 供应商等级判定
    let supplierLevel;
    if (overallScore >= 90) {
        supplierLevel = "🟢 A级(优秀)";
    } else if (overallScore >= 80) {
        supplierLevel = "🟡 B级(良好)";
    } else if (overallScore >= 70) {
        supplierLevel = "🟠 C级(一般)";
    } else if (overallScore >= 60) {
        supplierLevel = "🔴 D级(较差)";
    } else {
        supplierLevel = "⚫ E级(不合格)";
    }
    
    // 计算合作潜力
    let cooperationPotential;
    if (overallScore >= 90) {
        cooperationPotential = "极高";
    } else if (overallScore >= 80) {
        cooperationPotential = "高";
    } else if (overallScore >= 70) {
        cooperationPotential = "中等";
    } else if (overallScore >= 60) {
        cooperationPotential = "低";
    } else {
        cooperationPotential = "极低";
    }
    
    // 计算推荐订单量
    let recommendedOrderVolume;
    if (overallScore >= 90) {
        recommendedOrderVolume = 1000;
    } else if (overallScore >= 80) {
        recommendedOrderVolume = 500;
    } else if (overallScore >= 70) {
        recommendedOrderVolume = 200;
    } else if (overallScore >= 60) {
        recommendedOrderVolume = 50;
    } else {
        recommendedOrderVolume = 10;
    }
    
    // 计算供应商改进空间
    const qualityGap = 100 - productQuality;
    const deliveryGap = 100 - deliveryTimeliness;
    const priceGap = 100 - priceCompetitiveness;
    const serviceGap = 100 - serviceLevel;
    const stabilityGap = 100 - cooperationStability;
    
    // 生成报告
    let report = "";
    report += "╔════════════════════════════════════════╗\n";
    report += "║    🏭 供应商评估系统报告              ║\n";
    report += "╚════════════════════════════════════════╝\n\n";
    
    report += "📊 供应商指标监测\n";
    report += "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\n";
    report += `产品质量: ${(Math.round(productQuality * 100) / 100).toFixed(2)}%\n`;
    report += `交付及时率: ${(Math.round(deliveryTimeliness * 100) / 100).toFixed(2)}%\n`;
    report += `价格竞争力: ${(Math.round(priceCompetitiveness * 100) / 100).toFixed(2)}%\n`;
    report += `服务水平: ${(Math.round(serviceLevel * 100) / 100).toFixed(2)}%\n`;
    report += `合作稳定性: ${(Math.round(cooperationStability * 100) / 100).toFixed(2)}%\n\n`;
    
    report += "⭐ 指标评分\n";
    report += "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\n";
    report += `质量评分: ${qualityScore}/100\n`;
    report += `交付评分: ${deliveryScore}/100\n`;
    report += `价格评分: ${priceScore}/100\n`;
    report += `服务评分: ${serviceScore}/100\n`;
    report += `稳定评分: ${stabilityScore}/100\n\n`;
    
    report += "🎯 综合评估\n";
    report += "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\n";
    report += `综合评分: ${overallScore}/100\n`;
    report += `供应商等级: ${supplierLevel}\n`;
    report += `合作潜力: ${cooperationPotential}\n`;
    report += `推荐订单量: ${recommendedOrderVolume}万元\n\n`;
    
    report += "📈 改进空间分析\n";
    report += "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\n";
    report += `质量改进空间: ${(Math.round(qualityGap * 100) / 100).toFixed(2)}%\n`;
    report += `交付改进空间: ${(Math.round(deliveryGap * 100) / 100).toFixed(2)}%\n`;
    report += `价格改进空间: ${(Math.round(priceGap * 100) / 100).toFixed(2)}%\n`;
    report += `服务改进空间: ${(Math.round(serviceGap * 100) / 100).toFixed(2)}%\n`;
    report += `稳定改进空间: ${(Math.round(stabilityGap * 100) / 100).toFixed(2)}%\n\n`;
    
    report += "💡 供应商管理建议\n";
    report += "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\n";
    
    // 质量建议
    if (productQuality < 85) {
        report += "  ⚠️ 产品质量偏低\n";
        report += "     - 加强质量管理\n";
        report += "     - 提升产品标准\n";
        report += "     - 改进生产工艺\n";
    } else if (productQuality >= 95) {
        report += "  ✅ 产品质量处于优秀水平\n";
        report += "     - 继续保持高质量\n";
        report += "     - 深化质量管理\n";
    }
    
    // 交付建议
    if (deliveryTimeliness < 85) {
        report += "  🔴 交付及时率偏低\n";
        report += "     - 优化交付流程\n";
        report += "     - 提升交付能力\n";
        report += "     - 改进物流管理\n";
    } else if (deliveryTimeliness >= 95) {
        report += "  ✅ 交付及时率处于优秀水平\n";
        report += "     - 继续保持高及时\n";
        report += "     - 深化交付优化\n";
    }
    
    // 价格建议
    if (priceCompetitiveness < 80) {
        report += "  💰 价格竞争力偏低\n";
        report += "     - 优化成本结构\n";
        report += "     - 提升价格竞争力\n";
        report += "     - 改进定价策略\n";
    } else if (priceCompetitiveness >= 90) {
        report += "  ✅ 价格竞争力处于优秀水平\n";
        report += "     - 继续保持低价格\n";
        report += "     - 深化成本优化\n";
    }
    
    // 服务建议
    if (serviceLevel < 80) {
        report += "  📞 服务水平偏低\n";
        report += "     - 提升服务质量\n";
        report += "     - 改进服务流程\n";
        report += "     - 加强客户沟通\n";
    } else if (serviceLevel >= 90) {
        report += "  ✅ 服务水平处于优秀水平\n";
        report += "     - 继续保持高服务\n";
        report += "     - 深化服务优化\n";
    }
    
    // 稳定建议
    if (cooperationStability < 80) {
        report += "  🔗 合作稳定性偏低\n";
        report += "     - 加强合作沟通\n";
        report += "     - 提升合作稳定性\n";
        report += "     - 改进合作机制\n";
    } else if (cooperationStability >= 90) {
        report += "  ✅ 合作稳定性处于优秀水平\n";
        report += "     - 继续保持稳定\n";
        report += "     - 深化战略合作\n";
    }
    
    report += "\n📋 采购策略建议\n";
    report += "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\n";
    
    if (overallScore < 60) {
        report += "⚫ 供应商评分严重不足 - 建议立即采取行动\n";
        report += "  1. 进行全面的供应商审计\n";
        report += "  2. 制定改进计划\n";
        report += "  3. 加强供应商管理\n";
        report += "  4. 考虑寻找替代供应商\n";
        report += "  5. 建立预警机制\n";
    } else if (overallScore < 70) {
        report += "🔴 供应商评分存在问题 - 建议逐步改进\n";
        report += "  1. 加强供应商沟通\n";
        report += "  2. 提升管理要求\n";
        report += "  3. 优化合作方式\n";
        report += "  4. 准备备选方案\n";
    } else if (overallScore < 80) {
        report += "🟠 供应商评分一般 - 继续优化\n";
        report += "  1. 微调合作策略\n";
        report += "  2. 持续改进管理\n";
        report += "  3. 定期供应商审查\n";
    } else if (overallScore < 90) {
        report += "🟡 供应商评分良好 - 保持现状\n";
        report += "  1. 维持现有合作\n";
        report += "  2. 定期供应商审核\n";
        report += "  3. 持续创新优化\n";
    } else {
        report += "🟢 供应商评分优秀 - 重点合作\n";
        report += "  1. 提升订单量\n";
        report += "  2. 优化合作条件\n";
        report += "  3. 深化战略合作\n";
    }
    
    report += "\n━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\n";
    report += `✅ 评估完成 | 时间戳: ${Date.now()}\n`;
    
    return report;
}

JavaScript版本说明

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

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


ArkTS调用实现

import { supplierEvaluationSystem } from './hellokjs'

@Entry
@Component
struct SupplierEvaluationPage {
  @State productQuality: string = "92"
  @State deliveryTimeliness: string = "90"
  @State priceCompetitiveness: string = "85"
  @State serviceLevel: string = "88"
  @State cooperationStability: string = "90"
  @State result: string = ""
  @State isLoading: boolean = false

  build() {
    Column() {
      // 顶部标题栏
      Row() {
        Text("🏭 供应商评估系统")
          .fontSize(20)
          .fontWeight(FontWeight.Bold)
          .fontColor('#FFFFFF')
      }
      .width('100%')
      .height(60)
      .backgroundColor('#D32F2F')
      .justifyContent(FlexAlign.Center)
      .padding({ left: 16, right: 16 })

      // 主体内容
      Scroll() {
        Column() {
          // 参数输入部分
          Column() {
            Text("📊 供应商指标输入")
              .fontSize(16)
              .fontWeight(FontWeight.Bold)
              .fontColor('#D32F2F')
              .margin({ bottom: 12 })
              .padding({ left: 12, top: 12 })

            // 2列网格布局
            Column() {
              // 第一行
              Row() {
                Column() {
                  Text("产品质量(%)")
                    .fontSize(12)
                    .fontWeight(FontWeight.Bold)
                    .margin({ bottom: 4 })
                  TextInput({ placeholder: "92", text: this.productQuality })
                    .height(40)
                    .width('100%')
                    .onChange((value: string) => { this.productQuality = value })
                    .backgroundColor('#FFFFFF')
                    .border({ width: 1, color: '#D32F2F' })
                    .borderRadius(4)
                    .padding(8)
                    .fontSize(12)
                }.width('48%').padding(6)
                Blank().width('4%')
                Column() {
                  Text("交付及时率(%)")
                    .fontSize(12)
                    .fontWeight(FontWeight.Bold)
                    .margin({ bottom: 4 })
                  TextInput({ placeholder: "90", text: this.deliveryTimeliness })
                    .height(40)
                    .width('100%')
                    .onChange((value: string) => { this.deliveryTimeliness = value })
                    .backgroundColor('#FFFFFF')
                    .border({ width: 1, color: '#D32F2F' })
                    .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: "85", text: this.priceCompetitiveness })
                    .height(40)
                    .width('100%')
                    .onChange((value: string) => { this.priceCompetitiveness = value })
                    .backgroundColor('#FFFFFF')
                    .border({ width: 1, color: '#D32F2F' })
                    .borderRadius(4)
                    .padding(8)
                    .fontSize(12)
                }.width('48%').padding(6)
                Blank().width('4%')
                Column() {
                  Text("服务水平(%)")
                    .fontSize(12)
                    .fontWeight(FontWeight.Bold)
                    .margin({ bottom: 4 })
                  TextInput({ placeholder: "88", text: this.serviceLevel })
                    .height(40)
                    .width('100%')
                    .onChange((value: string) => { this.serviceLevel = value })
                    .backgroundColor('#FFFFFF')
                    .border({ width: 1, color: '#D32F2F' })
                    .borderRadius(4)
                    .padding(8)
                    .fontSize(12)
                }.width('48%').padding(6)
              }.width('100%').justifyContent(FlexAlign.SpaceBetween).margin({ top: 8 })

              // 第三行
              Row() {
                Column() {
                  Text("合作稳定性(%)")
                    .fontSize(12)
                    .fontWeight(FontWeight.Bold)
                    .margin({ bottom: 4 })
                  TextInput({ placeholder: "90", text: this.cooperationStability })
                    .height(40)
                    .width('100%')
                    .onChange((value: string) => { this.cooperationStability = value })
                    .backgroundColor('#FFFFFF')
                    .border({ width: 1, color: '#D32F2F' })
                    .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('#FFEBEE')
          .borderRadius(8)
          .margin({ bottom: 12 })

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

            Blank().width('4%')

            Button("重置数据")
              .width('48%')
              .height(44)
              .fontSize(14)
              .fontWeight(FontWeight.Bold)
              .backgroundColor('#F44336')
              .fontColor(Color.White)
              .borderRadius(6)
              .onClick(() => {
                this.productQuality = "92"
                this.deliveryTimeliness = "90"
                this.priceCompetitiveness = "85"
                this.serviceLevel = "88"
                this.cooperationStability = "90"
                this.result = ""
              })
          }
          .width('100%')
          .justifyContent(FlexAlign.Center)
          .padding({ left: 12, right: 12, bottom: 12 })

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

            if (this.isLoading) {
              Column() {
                LoadingProgress()
                  .width(50)
                  .height(50)
                  .color('#D32F2F')
                Text("正在评估...")
                  .fontSize(14)
                  .fontColor('#D32F2F')
                  .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('#D32F2F')
                  .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('#D32F2F')
                Text("请输入供应商指标后点击开始评估")
                  .fontSize(12)
                  .fontColor('#F44336')
                  .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 qualStr = this.productQuality.trim()
    const delivStr = this.deliveryTimeliness.trim()
    const priceStr = this.priceCompetitiveness.trim()
    const servStr = this.serviceLevel.trim()
    const stabStr = this.cooperationStability.trim()

    if (!qualStr || !delivStr || !priceStr || !servStr || !stabStr) {
      this.result = "❌ 请填写全部供应商指标"
      return
    }

    this.isLoading = true

    setTimeout((): void => {
      try {
        const inputStr = `${qualStr} ${delivStr} ${priceStr} ${servStr} ${stabStr}`
        const result = supplierEvaluationSystem(inputStr)
        this.result = result
        console.log("[SupplierEvaluationSystem] 评估完成")
      } catch (error) {
        this.result = `❌ 执行出错: ${error}`
        console.error("[SupplierEvaluationSystem] 错误:", error)
      } finally {
        this.isLoading = false
      }
    }, 500)
  }
}

ArkTS调用说明

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

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

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


系统集成与部署

编译流程

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

部署建议

  • 在企业的采购中心部署该系统的Web版本
  • 在各个采购部门部署OpenHarmony设备,运行该系统的移动版本
  • 建立数据同步机制,确保各设备间的数据一致性
  • 定期备份评估数据,用于后续的供应商分析和改进

总结

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

通过本系统的应用,企业可以显著提高供应商评估的效率和准确性,及时发现和优化供应商,提升供应链效率,降低采购风险。同时,系统生成的详细报告和建议也为企业的采购决策提供了数据支撑。

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

欢迎加入开源鸿蒙跨平台社区:https://openharmonycrossplatform.csdn.net

Logo

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

更多推荐