package com.iscs.bozzys.api

import androidx.compose.ui.graphics.Color
import kotlinx.serialization.Serializable

/**
 * 任务统计
 *
 * @param inProgressCount   进行中
 * @param completedCount    本月已完成
 */
data class TaskStatistics(
    val inProgressCount: Int,
    val completedCount: Int
)

/**
 * 任务表单信息
 */
@Serializable
data class TaskFormInfo(
    val id: Int = 0,
    val name: String? = null,
    val conf: String? = null,
    val fields: List<String>? = null,
    val status: Int? = null,
    val remark: String? = null,
    val createTime: Long? = null
)

/**
 * Task任务
 */
@Serializable
data class Task(
    val workId: Int,
    val nodeId: Int,
    val orderNo: String,
    val name: String,
    val urgencyLevel: String,
    val completionTime: Long?,
    val cancellationTime: Long?,
    val cancellationReason: String?,
    val initiatorName: String?,     // 发起人
    val workerUserName: String?,    // 当前执行人
    val workTime: Long?,
    val currentNodeId: String?,
    val currentNodeName: String?,
    val approvalStatus: String
) : java.io.Serializable {

    /**
     * 获取等级名称和背景色
     */
    fun getLevelNameAndColor(): Pair<String, Color> {
        return when (urgencyLevel) {
            "1" -> "紧急" to Color(0xFFFF9800)
            "2" -> "非常紧急" to Color(0xFFFF4500)
            else -> "正常" to Color(0xFF1E90FF)
        }
    }

    /**
     * 获取任务状态名称
     */
    fun getTaskStatusName(): String {
        return when (approvalStatus) {
            "approved" -> "已完成"
            "running" -> "进行中"
            "pending" -> "待处理"
            else -> approvalStatus
        }
    }
}