feat: 告警列表、告警设置模块静态交互完善,算力分配交互完成
parent
5aae5031cc
commit
52c3301571
@ -0,0 +1,52 @@
|
||||
import { alarmLevelStatusEnum } from '@/enums/status';
|
||||
import { localStorageKeyEnums } from '@/enums/storage';
|
||||
|
||||
/*
|
||||
* @Author: zhoux zhouxia@supervision.ltd
|
||||
* @Date: 2023-12-22 16:39:33
|
||||
* @LastEditors: zhoux zhouxia@supervision.ltd
|
||||
* @LastEditTime: 2023-12-22 16:49:36
|
||||
* @FilePath: \general-ai-platform-web\src\hooks\useAlarmSettingLevel.ts
|
||||
* @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
|
||||
*/
|
||||
type selectAlarmLevel = {
|
||||
label: string;
|
||||
value: string;
|
||||
};
|
||||
|
||||
interface useAlarmSettingLevelProps {
|
||||
fetchAlarmSettingLevel: () => selectAlarmLevel[];
|
||||
}
|
||||
|
||||
export const useAlarmSettingLevel = (): useAlarmSettingLevelProps => {
|
||||
function fetchAlarmSettingLevel() {
|
||||
const finalArr: selectAlarmLevel[] = [];
|
||||
const currData = localStorage.getItem(
|
||||
localStorageKeyEnums.alarmSetting_model_alarmStatusSetting,
|
||||
);
|
||||
if (currData) {
|
||||
const currFormData = JSON.parse(currData) as Record<string, any>;
|
||||
// eslint-disable-next-line guard-for-in
|
||||
for (let key in currFormData) {
|
||||
finalArr.push({
|
||||
label: currFormData[key],
|
||||
value: key,
|
||||
});
|
||||
}
|
||||
} else {
|
||||
// eslint-disable-next-line array-callback-return
|
||||
alarmLevelStatusEnum.map((item) => {
|
||||
if (['1', '2', '3'].includes(item.value)) {
|
||||
finalArr.push({
|
||||
label: item.label,
|
||||
value: item.value,
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
return finalArr;
|
||||
}
|
||||
return {
|
||||
fetchAlarmSettingLevel,
|
||||
};
|
||||
};
|
@ -1,12 +1,12 @@
|
||||
import { DictValueEnumObj } from "@/components/DictTag";
|
||||
import { ProSchemaValueEnumObj, ProSchemaValueEnumType } from "@ant-design/pro-components";
|
||||
|
||||
export function getValueEnumLabel(options: DictValueEnumObj | ProSchemaValueEnumObj, val: string | number | undefined, defaultValue?: string) {
|
||||
export function getValueEnumLabel(options: DictValueEnumObj | ProSchemaValueEnumObj, val: string | number | undefined, value?: string) {
|
||||
if (val !== undefined) {
|
||||
const data = options[val] as ProSchemaValueEnumType;
|
||||
if(data) {
|
||||
return data.text;
|
||||
}
|
||||
}
|
||||
return defaultValue?defaultValue:val;
|
||||
return value?value:val;
|
||||
}
|
||||
|
Loading…
Reference in New Issue