import type {INumberValueTagStyle} from "@/interface/app/ITagStyle.ts";

// 报警等级
export default class ErrorLevelFormatter {

    errorLevel: INumberValueTagStyle[] = [
        {value: 0, label: '普通', type: 'info'},
        {value: 1, label: '注意', type: 'primary'},
        {value: 2, label: '紧急', type: 'warning'},
        {value: 3, label: '致命', type: 'danger'},
    ];

    errorLevelTagStyleFormatter(value: any): INumberValueTagStyle {
        if(!value) {
            return {value: -1, label: '?', type: 'danger'};
        }
        const findResult = this.errorLevel.find(f => f.value == value);
        if (findResult) {
            return findResult;
        }
        return {value: value.toString(), label: '？' + value.toString(), type: 'danger'};
    }
}