valentichu 1 年之前
父節點
當前提交
74a4b2d2f7

File diff suppressed because it is too large
+ 0 - 0
lib/index.js


+ 7 - 6
src/App.jsx

@@ -7,21 +7,22 @@ function Home(props) {
 
   return (
     <>
-      <Alarm.DetailModal
+      {/* <Alarm.DetailModal
         open={open}
         onCancel={() => setOpen(false)}
         options={{ ruleId: 25 }}
         // options={{
         //   pointId: "ABC123_AAA_chr1_AEff_MIN_H",
         // }}
-      ></Alarm.DetailModal>
+      ></Alarm.DetailModal> */}
       {/* <Alarm.ComplexConfig ref={compRef} editId={50}></Alarm.ComplexConfig> */}
-      {/* <button onClick={() => compRef?.current?.ok()}>测试</button> */}
-      {/* <Alarm.EasyConfig
+      <button onClick={() => compRef?.current?.ok()}>测试</button>
+      <Alarm.EasyConfig
+        ref={compRef}
         pointId="ZWB_ALARM_chr_5_AE"
         readonly
-        // editId={-1}
-      ></Alarm.EasyConfig> */}
+          // editId={-1}
+      ></Alarm.EasyConfig>
     </>
   );
 }

+ 10 - 12
src/pages/Alarm/components/components/AlarmDetail/index.jsx

@@ -108,8 +108,8 @@ const initialOption = {
   },
   grid: {
     top: 32,
-    left: 64,
-    right: 64,
+    left: 0,
+    right: 0,
     bottom: "0%",
     containLabel: true,
   },
@@ -195,8 +195,8 @@ const initialOption = {
 const Index = (props) => {
   const [chartData, setChartData] = useState(null);
   const [range, setRange] = useState([
-    dayjs(props.data?.data?.created_time).subtract(3, "day"),
-    dayjs(props.data?.data?.created_time).add(3, "day"),
+    dayjs(props.data?.data?.created_time).subtract(20, "minute"),
+    dayjs(props.data?.data?.created_time).add(20, "minute"),
   ]);
   const fetchData = useMemoizedFn(async () => {
     if (
@@ -209,12 +209,12 @@ const Index = (props) => {
     const res = await API.getAlarmPointData(
       props.data?.data?.rule_id,
       range[0].unix(),
-      range[1].hour(23).minute(59).second(59).unix()
+      range[1].unix()
     );
     const newData = _.cloneDeep(initialOption);
     newData.series[0].data = res?.data?.point?.map((item) => item[1]);
     newData.xAxis.data = res?.data?.point?.map((item) =>
-      dayjs.unix(item[0]).format("YYYY-MM-DD HH:mm:ss")
+      dayjs.unix(item[0]).format("HH:mm")
     );
     if (res?.data?.hh) {
       newData.series.push({
@@ -309,11 +309,8 @@ const Index = (props) => {
   return (
     <>
       <div className={styles.desc}>
-        <Descriptions>
-          <Descriptions.Item
-            span={props.data?.data?.point_id ? 2 : 3}
-            label="告警名称"
-          >
+        <Descriptions column={4} style={{ margin: 20 }}>
+          <Descriptions.Item label="告警名称">
             {props.data?.data?.name}
           </Descriptions.Item>
           {props.data?.data?.point_id && (
@@ -355,9 +352,10 @@ const Index = (props) => {
         <>
           <div className={styles.range}>
             <RangePicker
+              showTime
               value={range}
               onChange={setRange}
-              style={{ width: 440, marginTop: 20 }}
+              style={{ width: 360, marginTop: 20 }}
             />
           </div>
 

+ 1 - 0
src/pages/Alarm/components/components/AlarmHistory/index.jsx

@@ -280,6 +280,7 @@ const Index = (props) => {
         rowKey="id"
         pagination={false}
         size="middle"
+        style={{ height: "60vh" }}
         scroll={{
           x: 1160,
           y: 432,

+ 49 - 43
src/pages/Alarm/components/detail.jsx

@@ -4,7 +4,7 @@ import React, {
   forwardRef,
   useImperativeHandle,
 } from "react";
-import { Form, Input, Select, message, Switch, Space, Col } from "antd";
+import { Form, Input, Select, message, Switch, Space, Col, Tabs } from "antd";
 import { Modal, Button, Radio } from "antd";
 import styles from "./detail.module.less";
 import API from "../../../api/alarm";
@@ -67,12 +67,13 @@ const Detail = (props) => {
     }
     setCurrent(record.id);
   };
+
   return (
     <>
       <Modal
         title="告警记录"
         open={props.open}
-        width={1200}
+        width="90vw"
         onCancel={() => {
           props.onCancel();
         }}
@@ -80,49 +81,54 @@ const Detail = (props) => {
         footer={null}
         destroyOnClose
       >
-        <div className={styles.header}>
-          <div className={styles.tags}>
-            <Radio.Group
-              value={current}
-              onChange={(e) => setCurrent(e.target.value)}
-              size="middle"
-            >
-              <Radio.Button value="history">告警记录</Radio.Button>
-              {tags.map((item, index) => (
-                <Radio.Button value={item.id}>
-                  <div className={styles.tagContainer}>
-                    <div className={styles.label}>详情{index + 1}</div>
-                    <CloseOutlined
-                      onClick={() => {
-                        if (current === item.id) {
-                          setCurrent("history");
-                        }
-                        onRemove(index);
-                      }}
-                    />
-                  </div>
-                </Radio.Button>
-              ))}
-            </Radio.Group>
-          </div>
-          <div className={styles.oper}>
+        {props.open && (
+          <>
+            <div className={styles.header}>
+              <div className={styles.tags}>
+                <Radio.Group
+                  value={current}
+                  onChange={(e) => setCurrent(e.target.value)}
+                  size="middle"
+                >
+                  <Radio.Button value="history">告警记录</Radio.Button>
+                  {tags.map((item, index) => (
+                    <Radio.Button value={item.id}>
+                      <div className={styles.tagContainer}>
+                        <div className={styles.label}>详情{index + 1}</div>
+                        <CloseOutlined
+                          style={{ fontSize: 10 }}
+                          onClick={() => {
+                            if (current === item.id) {
+                              setCurrent("history");
+                            }
+                            onRemove(index);
+                          }}
+                        />
+                      </div>
+                    </Radio.Button>
+                  ))}
+                </Radio.Group>
+              </div>
+              <div className={styles.oper}>
+                {current !== "history" && (
+                  <Button
+                    disabled={currentData?.data?.op_status === 1}
+                    onClick={() => setShowConfirm(true)}
+                  >
+                    {currentData?.data?.op_status === 1 ? "已确认" : "确认"}
+                  </Button>
+                )}
+                {/* <Button style={{ marginLeft: 10 }}>告警配置</Button> */}
+              </div>
+            </div>
+
+            {current === "history" && (
+              <AlarmHistory onSelect={onSelect} ruleId={ruleId}></AlarmHistory>
+            )}
             {current !== "history" && (
-              <Button
-                disabled={currentData?.data?.op_status === 1}
-                onClick={() => setShowConfirm(true)}
-              >
-                {currentData?.data?.op_status === 1 ? "已确认" : "确认"}
-              </Button>
+              <AlarmDetail data={currentData}></AlarmDetail>
             )}
-            {/* <Button style={{ marginLeft: 10 }}>告警配置</Button> */}
-          </div>
-        </div>
-
-        {current === "history" && (
-          <AlarmHistory onSelect={onSelect} ruleId={ruleId}></AlarmHistory>
-        )}
-        {current !== "history" && (
-          <AlarmDetail data={currentData}></AlarmDetail>
+          </>
         )}
       </Modal>
       <AlarmConfirm

+ 1 - 1
src/pages/Alarm/components/detail.module.less

@@ -1,5 +1,5 @@
 .label {
-  width: 60px;
+  width: 40px;
   overflow: hidden;
   text-overflow: ellipsis;
   white-space: nowrap;

+ 13 - 1
src/pages/Alarm/components/easy.jsx

@@ -128,7 +128,7 @@ const Easy = (props, ref) => {
         ext_notify_list: [],
         high_enabled: value.threshold_high?.toString().trim() ? true : false,
         low_enabled: value.threshold_low?.toString().trim() ? true : false,
-        status: 1,
+        status: value.status ? 1 : 2,
         defer_unit: deferUnit,
         defer_seconds: Number(dateTime) ?? 0,
         type: 1,
@@ -141,7 +141,10 @@ const Easy = (props, ref) => {
         .then((res) => {
           if (res?.state === 0) {
             form.resetFields();
+            message.success("保存成功");
             props.onConfirm();
+          } else {
+            message.error("保存失败");
           }
         })
         .finally(() => {
@@ -224,13 +227,17 @@ const Easy = (props, ref) => {
         sub_type: value?.sub_type,
         group_id: value?.group_id ?? 0,
         details,
+        status: value.status === true ? 1 : 2,
       };
 
       API2.editRule(obj)
         .then((res) => {
           if (res?.state === 0) {
             form.resetFields();
+            message.success("保存成功");
             props.onConfirm();
+          } else {
+            message.error("保存失败");
           }
         })
         .finally(() => {
@@ -287,6 +294,7 @@ const Easy = (props, ref) => {
         setAhEnable(data?.Details.ah_enable);
         setAhhEnable(data?.Details.ahh_enable);
         form.setFieldsValue({
+          status: data.status === 1,
           threshold_high: data.threshold_high,
           threshold_low: data.threshold_low,
           point_name: data.point_name,
@@ -340,6 +348,7 @@ const Easy = (props, ref) => {
             no_child: true,
           });
           form.setFieldsValue({
+            name: res?.data?.[0]?.name,
             point_name: res?.data?.[0]?.name,
             defer_unit: res?.data?.[0]?.defer_unit,
           });
@@ -730,6 +739,9 @@ const Easy = (props, ref) => {
           </Select.Option>
         </Select>
       </Form.Item>
+      <Form.Item label="告警开关" name="status">
+        <Switch size={"small"} />
+      </Form.Item>
 
       {!showMore && (
         <Form.Item

Some files were not shown because too many files changed in this diff