中英文切换 初始化
This commit is contained in:
@@ -4,6 +4,7 @@ import Cookies from 'js-cookie'
|
||||
import type { MessageInstance } from 'antd/es/message/interface';
|
||||
import type { ModalStaticFunctions } from 'antd/es/modal/confirm';
|
||||
import type { NotificationInstance } from 'antd/es/notification/interface';
|
||||
import i18n from '../i18n';
|
||||
|
||||
let message: MessageInstance;
|
||||
let notification: NotificationInstance;
|
||||
@@ -41,13 +42,13 @@ export function cn(...inputs: ClassValue[]) {
|
||||
|
||||
export const getLocationQuality = (value) => {
|
||||
const map = {
|
||||
0: { text: '无效', color: '#ff4d4f' },
|
||||
1: { text: 'GPS 单点定位', color: '#999' },
|
||||
2: { text: 'DGPS 伪距差分/SBAS', color: '#1890ff' },
|
||||
4: { text: 'RTK 固定解', color: '#52c41a' }, // 最优
|
||||
5: { text: 'RTK 浮点解', color: '#faad14' },
|
||||
0: { get text() { return i18n.t('constants.locationInvalid') }, color: '#ff4d4f' },
|
||||
1: { get text() { return i18n.t('constants.locationGPS') }, color: '#999' },
|
||||
2: { get text() { return i18n.t('constants.locationDGPS') }, color: '#1890ff' },
|
||||
4: { get text() { return i18n.t('constants.locationRTKFixed') }, color: '#52c41a' }, // 最优
|
||||
5: { get text() { return i18n.t('constants.locationRTKFloat') }, color: '#faad14' },
|
||||
};
|
||||
return map[value] || { text: '未知', color: '#999' };
|
||||
return map[value] || { get text() { return i18n.t('constants.locationUnknown') }, color: '#999' };
|
||||
};
|
||||
|
||||
|
||||
@@ -175,14 +176,14 @@ export const fix2 = (val) => {
|
||||
return Number(val).toFixed(2);
|
||||
};
|
||||
|
||||
export const getVal = (val) => val == "no_rain" ? "无" : (val || '-');
|
||||
export const getVal = (val) => val == "no_rain" ? i18n.t("constants.none") : (val || '-');
|
||||
|
||||
|
||||
|
||||
// ==============================================
|
||||
// 通用导出表格为 CSV / Excel(通用版,不写死任何字段)
|
||||
// ==============================================
|
||||
export const exportTable = (columns, dataSource, fileName = "导出数据") => {
|
||||
export const exportTable = (columns, dataSource, fileName = i18n.t("constants.exportData")) => {
|
||||
// 1. 从 columns 自动提取表头(过滤掉不显示的列)
|
||||
const headers = columns
|
||||
.filter(col => col.title && col.dataIndex) // 只取有标题+有字段的列
|
||||
@@ -249,9 +250,9 @@ export const errorSourceOptions: Array<{
|
||||
value: ErrorSourceType;
|
||||
label: string;
|
||||
}> = [
|
||||
{ label: '无人机', value: ERROR_SOURCE.UAV },
|
||||
{ label: '割草机', value: ERROR_SOURCE.MOWER },
|
||||
{ label: '其他', value: ERROR_SOURCE.OTHERS },
|
||||
{ value: ERROR_SOURCE.UAV, get label() { return i18n.t('constants.uav') } },
|
||||
{ value: ERROR_SOURCE.MOWER, get label() { return i18n.t('constants.mower') } },
|
||||
{ value: ERROR_SOURCE.OTHERS, get label() { return i18n.t('constants.others') } },
|
||||
];
|
||||
|
||||
export const getErrorSourceText = (source?: ErrorSourceType | string): string => {
|
||||
@@ -262,9 +263,9 @@ export const getErrorSourceText = (source?: ErrorSourceType | string): string =>
|
||||
|
||||
// 错误等级
|
||||
export const errorLevelOptions = [
|
||||
{ label: '信息', value: 'INFO' },
|
||||
{ label: '警告', value: 'WARNING' },
|
||||
{ label: '错误', value: 'ERROR' },
|
||||
{ value: 'INFO', get label() { return i18n.t('constants.infoLevel') } },
|
||||
{ value: 'WARNING', get label() { return i18n.t('constants.warning') } },
|
||||
{ value: 'ERROR', get label() { return i18n.t('constants.error') } },
|
||||
];
|
||||
// 文本 → 数字(提交接口用)
|
||||
export const levelText2Num = {
|
||||
@@ -287,16 +288,16 @@ export const LEVEL_TAG_COLOR = {
|
||||
|
||||
|
||||
export const CompareEnumOptions = [
|
||||
{ value: 'EQ', label: '等于', symbol: '=' },
|
||||
{ value: 'NEQ', label: '不等于', symbol: '!=' },
|
||||
{ value: 'GT', label: '大于', symbol: '>' },
|
||||
{ value: 'LT', label: '小于', symbol: '<' },
|
||||
{ value: 'GTE', label: '大于等于', symbol: '>=' },
|
||||
{ value: 'LTE', label: '小于等于', symbol: '<=' },
|
||||
{ value: 'BETWEEN', label: '在之间', symbol: 'between', range: true },
|
||||
{ value: 'NOT_BETWEEN', label: '不在之间', symbol: 'notBetween', range: true },
|
||||
{ value: 'CONTAIN', label: '包含', symbol: 'contain' },
|
||||
{ value: 'NOT_CONTAIN', label: '不包含', symbol: 'notContain' },
|
||||
{ value: 'EQ', get label() { return i18n.t('constants.eq') }, symbol: '=' },
|
||||
{ value: 'NEQ', get label() { return i18n.t('constants.neq') }, symbol: '!=' },
|
||||
{ value: 'GT', get label() { return i18n.t('constants.gt') }, symbol: '>' },
|
||||
{ value: 'LT', get label() { return i18n.t('constants.lt') }, symbol: '<' },
|
||||
{ value: 'GTE', get label() { return i18n.t('constants.gte') }, symbol: '>=' },
|
||||
{ value: 'LTE', get label() { return i18n.t('constants.lte') }, symbol: '<=' },
|
||||
{ value: 'BETWEEN', get label() { return i18n.t('constants.between') }, symbol: 'between', range: true },
|
||||
{ value: 'NOT_BETWEEN', get label() { return i18n.t('constants.notBetween') }, symbol: 'notBetween', range: true },
|
||||
{ value: 'CONTAIN', get label() { return i18n.t('constants.contain') }, symbol: 'contain' },
|
||||
{ value: 'NOT_CONTAIN', get label() { return i18n.t('constants.notContain') }, symbol: 'notContain' },
|
||||
];
|
||||
|
||||
// 工单类型常量
|
||||
@@ -320,14 +321,14 @@ export const workOrderTypeOptions: Array<{
|
||||
value: WorkOrderType;
|
||||
label: string;
|
||||
}> = [
|
||||
{ value: WORK_ORDER_TYPE.MOWER_ERROR, label: "割草机故障" },
|
||||
{ value: WORK_ORDER_TYPE.UAV_ERROR, label: "无人机故障" },
|
||||
{ value: WORK_ORDER_TYPE.INSPECTION_TASK, label: "巡检" },
|
||||
{ value: WORK_ORDER_TYPE.COMPONENT_DEFECT, label: "光伏组件故障" },
|
||||
{ value: WORK_ORDER_TYPE.CLEAN_TASK, label: "清洗" },
|
||||
{ value: WORK_ORDER_TYPE.MAINTAIN_TASK, label: "维护" },
|
||||
{ value: WORK_ORDER_TYPE.REPAIR_TASK, label: "维修" },
|
||||
{ value: WORK_ORDER_TYPE.OTHER, label: "其他" },
|
||||
{ value: WORK_ORDER_TYPE.MOWER_ERROR, get label() { return i18n.t('workOrder.mowerError') } },
|
||||
{ value: WORK_ORDER_TYPE.UAV_ERROR, get label() { return i18n.t('workOrder.uavError') } },
|
||||
{ value: WORK_ORDER_TYPE.INSPECTION_TASK, get label() { return i18n.t('workOrder.typeInspection') } },
|
||||
{ value: WORK_ORDER_TYPE.COMPONENT_DEFECT, get label() { return i18n.t('workOrder.componentDefect') } },
|
||||
{ value: WORK_ORDER_TYPE.CLEAN_TASK, get label() { return i18n.t('workOrder.typeCleaning') } },
|
||||
{ value: WORK_ORDER_TYPE.MAINTAIN_TASK, get label() { return i18n.t('workOrder.maintainTask') } },
|
||||
{ value: WORK_ORDER_TYPE.REPAIR_TASK, get label() { return i18n.t('workOrder.typeRepair') } },
|
||||
{ value: WORK_ORDER_TYPE.OTHER, get label() { return i18n.t('workOrder.other') } },
|
||||
];
|
||||
|
||||
/**
|
||||
@@ -351,10 +352,10 @@ export const levelColorMap = {
|
||||
|
||||
// 告警处理结果枚举(和后端AlarmHandleResult保持一致)
|
||||
export const alarmHandleResultOptions = [
|
||||
{ value: "Handled", label: "已处理" },
|
||||
{ value: "Restored", label: "已恢复" },
|
||||
{ value: "Ignored", label: "已忽略" },
|
||||
{ value: "UnableToHandle", label: "无法处理" },
|
||||
{ value: "ManufacturerHandling", label: "厂家处理中" },
|
||||
{ value: "FalseAlarm", label: "误报" },
|
||||
{ value: "Handled", get label() { return i18n.t("constants.handled") } },
|
||||
{ value: "Restored", get label() { return i18n.t("constants.restored") } },
|
||||
{ value: "Ignored", get label() { return i18n.t("constants.ignored") } },
|
||||
{ value: "UnableToHandle", get label() { return i18n.t("constants.unableToHandle") } },
|
||||
{ value: "ManufacturerHandling", get label() { return i18n.t("constants.manufacturerHandling") } },
|
||||
{ value: "FalseAlarm", get label() { return i18n.t("constants.falseAlarm") } },
|
||||
];
|
||||
|
||||
Reference in New Issue
Block a user