|
@@ -5,7 +5,7 @@ import React, {
|
|
|
forwardRef,
|
|
forwardRef,
|
|
|
useImperativeHandle,
|
|
useImperativeHandle,
|
|
|
} from "react";
|
|
} from "react";
|
|
|
-import { Form, Input, Select, message } from "antd";
|
|
|
|
|
|
|
+import { Form, Input, Select, Switch, Checkbox, App } from "antd";
|
|
|
import { Modal, Button, Table, Radio } from "antd";
|
|
import { Modal, Button, Table, Radio } from "antd";
|
|
|
import Formular from "./components/Formular";
|
|
import Formular from "./components/Formular";
|
|
|
import API2 from "../../../api/alarm";
|
|
import API2 from "../../../api/alarm";
|
|
@@ -33,7 +33,10 @@ function TranslateText(arr) {
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
const Complex = (props, ref) => {
|
|
const Complex = (props, ref) => {
|
|
|
|
|
+ const { message } = App.useApp();
|
|
|
const { editId, groupList = [], showList, formula } = props;
|
|
const { editId, groupList = [], showList, formula } = props;
|
|
|
|
|
+ const [status, setStatus] = useState(2);
|
|
|
|
|
+ const [dateTime, setDateTime] = useState(null);
|
|
|
|
|
|
|
|
const [form] = Form.useForm();
|
|
const [form] = Form.useForm();
|
|
|
const formuRef = useRef();
|
|
const formuRef = useRef();
|
|
@@ -70,7 +73,10 @@ const Complex = (props, ref) => {
|
|
|
async function run() {
|
|
async function run() {
|
|
|
if (alarmId && alarmId != -1) {
|
|
if (alarmId && alarmId != -1) {
|
|
|
const { state, data } = await API2.detailAlarm(Number(alarmId));
|
|
const { state, data } = await API2.detailAlarm(Number(alarmId));
|
|
|
|
|
+ setStatus(data.defer_seconds > 0 ? 1 : 2);
|
|
|
|
|
+ setDateTime(data.defer_seconds);
|
|
|
form.setFieldsValue({
|
|
form.setFieldsValue({
|
|
|
|
|
+ status: data.status === 1,
|
|
|
name: data.name,
|
|
name: data.name,
|
|
|
alarm_level: data.alarm_level,
|
|
alarm_level: data.alarm_level,
|
|
|
group_id: data.group_id,
|
|
group_id: data.group_id,
|
|
@@ -102,8 +108,9 @@ const Complex = (props, ref) => {
|
|
|
is_complex: true,
|
|
is_complex: true,
|
|
|
type: 1,
|
|
type: 1,
|
|
|
sub_type: 12,
|
|
sub_type: 12,
|
|
|
- status: 1,
|
|
|
|
|
|
|
+ status: value.status ? 1 : 2,
|
|
|
defer_unit: 2,
|
|
defer_unit: 2,
|
|
|
|
|
+ defer_seconds: Number(dateTime) ?? 0,
|
|
|
};
|
|
};
|
|
|
|
|
|
|
|
const { state, data, state_info } = await API2.addRule(obj);
|
|
const { state, data, state_info } = await API2.addRule(obj);
|
|
@@ -383,6 +390,76 @@ const Complex = (props, ref) => {
|
|
|
</Select>
|
|
</Select>
|
|
|
</Form.Item>
|
|
</Form.Item>
|
|
|
|
|
|
|
|
|
|
+ <Form.Item
|
|
|
|
|
+ label={TranslateText(["告警开关", "Enable"])}
|
|
|
|
|
+ name="status"
|
|
|
|
|
+ >
|
|
|
|
|
+ <Switch size={"small"} />
|
|
|
|
|
+ </Form.Item>
|
|
|
|
|
+
|
|
|
|
|
+ <Form.Item
|
|
|
|
|
+ name={"defer_seconds"}
|
|
|
|
|
+ label={TranslateText(["延时告警", "Delayed alarm"])}
|
|
|
|
|
+ >
|
|
|
|
|
+ <div>
|
|
|
|
|
+ <div
|
|
|
|
|
+ style={{
|
|
|
|
|
+ display: "flex",
|
|
|
|
|
+ gap: 8,
|
|
|
|
|
+ alignItems: "center",
|
|
|
|
|
+ }}
|
|
|
|
|
+ >
|
|
|
|
|
+ <Checkbox
|
|
|
|
|
+ checked={status === 1}
|
|
|
|
|
+ onChange={(e) => {
|
|
|
|
|
+ setStatus(e.target.checked ? 1 : 2);
|
|
|
|
|
+ if (e.target.checked) {
|
|
|
|
|
+ setDateTime(null);
|
|
|
|
|
+ } else {
|
|
|
|
|
+ setDateTime(0);
|
|
|
|
|
+ }
|
|
|
|
|
+ }}
|
|
|
|
|
+ ></Checkbox>
|
|
|
|
|
+ <span
|
|
|
|
|
+ style={{
|
|
|
|
|
+ color: "var(--dt-text-color1)",
|
|
|
|
|
+ fontWeight: 400,
|
|
|
|
|
+ fontSize: 14,
|
|
|
|
|
+ }}
|
|
|
|
|
+ >
|
|
|
|
|
+ {TranslateText(["持续", "Alarm after"])}
|
|
|
|
|
+ </span>
|
|
|
|
|
+ <Input
|
|
|
|
|
+ disabled={status !== 1}
|
|
|
|
|
+ value={dateTime}
|
|
|
|
|
+ onChange={(e) => {
|
|
|
|
|
+ console.log(e.target.value);
|
|
|
|
|
+ setDateTime(e.target.value?.replace(/\D/g, ""));
|
|
|
|
|
+ }}
|
|
|
|
|
+ placeholder={TranslateText(["请输入", "Please input"])}
|
|
|
|
|
+ style={{ width: 100 }}
|
|
|
|
|
+ />
|
|
|
|
|
+ <span
|
|
|
|
|
+ style={{
|
|
|
|
|
+ color: "var(--dt-text-color1)",
|
|
|
|
|
+ fontWeight: 400,
|
|
|
|
|
+ fontSize: 14,
|
|
|
|
|
+ }}
|
|
|
|
|
+ >
|
|
|
|
|
+ {TranslateText(["分钟", "minutes"])}{" "}
|
|
|
|
|
+ {TranslateText(["后报警", "of duration"])}
|
|
|
|
|
+ </span>
|
|
|
|
|
+ </div>
|
|
|
|
|
+ {dateTime !== null &&
|
|
|
|
|
+ ["", undefined, null].indexOf(dateTime) !== -1 &&
|
|
|
|
|
+ status === 1 && (
|
|
|
|
|
+ <div style={{ color: "var(--dt-error-color1)" }}>
|
|
|
|
|
+ 请输入数字
|
|
|
|
|
+ </div>
|
|
|
|
|
+ )}
|
|
|
|
|
+ </div>
|
|
|
|
|
+ </Form.Item>
|
|
|
|
|
+
|
|
|
<Form.Item
|
|
<Form.Item
|
|
|
label={TranslateText(["条件符号", "Symbol"])}
|
|
label={TranslateText(["条件符号", "Symbol"])}
|
|
|
// name="symb"
|
|
// name="symb"
|
|
@@ -404,7 +481,7 @@ const Complex = (props, ref) => {
|
|
|
{">"}
|
|
{">"}
|
|
|
</Button>
|
|
</Button>
|
|
|
<Button type="primary" onClick={symbClick}>
|
|
<Button type="primary" onClick={symbClick}>
|
|
|
- =
|
|
|
|
|
|
|
+ ==
|
|
|
</Button>
|
|
</Button>
|
|
|
<Button type="primary" onClick={symbClick}>{`<`}</Button>
|
|
<Button type="primary" onClick={symbClick}>{`<`}</Button>
|
|
|
<Button type="primary" onClick={symbClick}>
|
|
<Button type="primary" onClick={symbClick}>
|