package com.haha.common.enums;

import com.haha.common.vo.StatusLabel;

/**
 * 补货单状态枚举
 */
public enum ReplenishmentOrderStatusEnum {

    DRAFT(0, "草稿", "info"),
    SUBMITTED(1, "已提交", "warning"),
    SYNCED_TO_ERP(2, "已同步ERP", "primary"),
    COMPLETED(3, "已完成", "success"),
    CANCELLED(4, "已取消", "danger");

    private final int code;
    private final String label;
    private final String color;

    ReplenishmentOrderStatusEnum(int code, String label, String color) {
        this.code = code;
        this.label = label;
        this.color = color;
    }

    public int getCode() {
        return code;
    }

    public String getLabel() {
        return label;
    }

    public String getColor() {
        return color;
    }

    public StatusLabel getStatusLabel() {
        return new StatusLabel(label, color);
    }

    public static StatusLabel getLabelByCode(Integer code) {
        if (code == null) {
            return StatusLabel.info("未知");
        }
        for (ReplenishmentOrderStatusEnum status : values()) {
            if (status.code == code) {
                return status.getStatusLabel();
            }
        }
        return StatusLabel.info("未知");
    }
}
