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

// 错误类型
export default class ErrorTypeFormatter {

    errorType: INumberValueTagStyle[] = [
        {value: 0, label: '通讯异常', type: 'info'},
        {value: 1, label: '电源异常', type: 'danger'},
        {value: 2, label: '硬件异常', type: 'warning'},
    ];

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