package com.yzx.ebrand.model

import com.yzx.ebrand.config.Config

data class StuChangeType(
    val id: Int = 0,
    val label: String = "",
    val shortLabel: String = ""
) {
    fun getShortLabelVal(): String {
        if (shortLabel.isNotEmpty()) {
            return shortLabel
        }
        return label
    }
}

data class StuChange(
    val activities: List<ChangeActivity> = mutableListOf(),
    val add_time: Int = 0,
    val add_user_id: Int = 0,
    val add_user_name: String = "",
    val attachment: String = "",
    val attachments: List<Any> = listOf(),
    val can_reviewed: Int = 0,
    val class_id: Int = 0,
    val class_name: String = "",
    val end_time: Int = 0,
    val face_identity: String = "",
    val face_key: String = "",
    val grade_id: Int = 0,
    val grade_name: String = "",
    val headteacher_id: Int = 0,
    val id: Int = 0,
    val is_cancel_change: Int = 0,
    val is_delete: Int = 0,
    val is_resume_school: Int = 0,
    val new_todo_list_id: Int = 0,
    val school_id: Int = 0,
    val school_name: String = "",
    val sign_identity: String = "",
    val sign_key: String = "",
    val start_time: Int = 0,
    val status: Int = 0,
    val status_change_reason: String = "",
    val status_change_student_id: Int = 0,
    val status_change_student_name: String = "",
    val status_change_type: Int = 0,
    val status_change_type_name: String = "",
    val sub_status: Int = 0,
    val target_class_id: Int = 0,
    val target_class_name: String = "",
    val target_grade_id: Int = 0,
    val target_grade_name: String = "",
    val target_headteacher_id: Int = 0,
    val target_school_id: Int = 0,
    val target_school_name: String = "",
    val target_status: Int = 0,
    val todo_list_id: Int = 0,
    val type: Int = 0
) {
    fun getStatusImg(): String {
        return when {
            getSubStatusName().isNotEmpty() -> {
                "https://oa-edu-1259243469.cos.ap-chengdu.myqcloud.com/public/mini/statuschange/${getSubStatusIcon()}.png"
            }
            status == 1 -> "https://oa-edu-1259243469.cos.ap-chengdu.myqcloud.com/public/mini/stutakeleave_wait.png"
            status == 2 -> "https://oa-edu-1259243469.cos.ap-chengdu.myqcloud.com/public/mini/stutakeleave_pass.png"
            status == 3 -> "https://oa-edu-1259243469.cos.ap-chengdu.myqcloud.com/public/mini/stutakeleave_nopass.png"
            else -> ""
        }
    }

    fun getSubStatusIcon(
        changeType: Int = status_change_type,
        subStatus: Int = sub_status
    ): String {
        if (is_resume_school == 1) {
            return "resume_school"
        }
        return when (subStatus) {
            0 -> "change0"
            else -> {
                "${changeType}_${subStatus}"
            }
        }
    }

    fun getSubStatusName(
        changeType: Int = status_change_type,
        subStatus: Int = sub_status
    ): String {
        if (status != 2) {
            return ""
        }
        if (is_resume_school == 1) {
            return "恢复上学"
        }
        //其他type 无子状态
        when (changeType) {
            Config.STU_CHANGE_STATUS_LEAVE_SCHOOL -> {
                return when (subStatus) {
                    0 -> {
                        "未开始"
                    }
                    1 -> {
                        "休学中"
                    }
                    else -> {
                        "休学结束"
                    }
                }
            }
            Config.STU_CHANGE_STATUS_OUT_SCHOOL -> {
                return when (subStatus) {
                    0 -> {
                        "未开始"
                    }
                    else -> {
                        "已退学"
                    }
                }
            }
            Config.STU_CHANGE_STATUS_INTROSPECTION -> {
                return when (subStatus) {
                    0 -> {
                        "未开始"
                    }
                    1 -> {
                        "反省中"
                    }
                    else -> {
                        "反省结束"
                    }
                }
            }
            Config.STU_CHANGE_STATUS_INTERNSHIP -> {
                return when (subStatus) {
                    0 -> {
                        "未开始"
                    }
                    1 -> {
                        "实习中"
                    }
                    else -> {
                        "实习结束"
                    }
                }
            }
            Config.STU_CHANGE_STATUS_DROP_OUT -> {
                return when (subStatus) {
                    0 -> {
                        "未开始"
                    }
                    else -> {
                        "已辍学"
                    }
                }
            }
            Config.STU_CHANGE_STATUS_TRANSFER_OUT -> {
                return when (subStatus) {
                    0 -> {
                        "未开始"
                    }
                    else -> {
                        "已转出"
                    }
                }
            }
        }
        return ""
    }

    fun getStep(): List<ChangeActivity> {
        return activities.reversed()
    }

}

data class ChangeActivity(
    val activity_name: String = "",
    val add_time: Int = 0,
    val add_user_id: Int = 0,
    val add_user_name: String = "",
    val add_user_type: Int = 0,
    val approval_comments: String = "",
    val approval_status: Int = 0,
    val approve_node: Int = 0,
    val approve_sort: Int = 0,
    val approve_user_type: Int = 0,
    val approve_way: Int = 0,
    val id: Int = 0,
    val is_approve: Int = 0,
    val is_auto_pass: Int = 0,
    val related_id: Int = 0,
    val relation_id: Int = 0,
    val report_end_date: Int = 0,
    val report_start_date: Int = 0,
    val role_type: Int = 0,
    val school_name: String = "",
    val sign_identity: String = "",
    val sign_key: String? = "",
    val status: Int = 0,
    val sub_type: String = "",
    val type: Int = 0,
    val unit_id: Int = 0,
    val unit_name: String = "",
    val vacation_type: Int = 0
)