valentichu преди 1 година
родител
ревизия
0179f4485e
променени са 5 файла, в които са добавени 21 реда и са изтрити 9 реда
  1. 0 0
      lib/index.js
  2. 1 0
      package.json
  3. 3 3
      src/App.jsx
  4. 14 4
      src/entry.jsx
  5. 3 2
      src/pages/Alarm/components/easy.jsx

Файловите разлики са ограничени, защото са твърде много
+ 0 - 0
lib/index.js


+ 1 - 0
package.json

@@ -40,6 +40,7 @@
   },
   "dependencies": {
     "@reduxjs/toolkit": "^1.9.5",
+    "ahooks": "^3.8.1",
     "antd": "^5.15.4",
     "axios": "^1.4.0",
     "dayjs": "^1.11.9",

+ 3 - 3
src/App.jsx

@@ -6,16 +6,16 @@ function Home(props) {
 
   return (
     <>
-      <Alarm.ComplexConfig
+      <Alarm.EasyConfig
         ref={compRef}
         editId={-1}
         onConfirm={() => {
           console.log(1);
         }}
-      ></Alarm.ComplexConfig>
+      ></Alarm.EasyConfig>
       <button
         onClick={() => {
-          console.log(compRef);
+          compRef.current.ok();
         }}
       >
         测试

+ 14 - 4
src/entry.jsx

@@ -19,7 +19,7 @@ import dayjs from "dayjs";
 dayjs.locale("zh-cn");
 
 const EasyConfig = forwardRef((props, ref) => {
-  const { editId = -1, onConfirm } = props;
+  const { editId = -1, onConfirm, groupList } = props;
   const compRef = useRef(null);
 
   const [themeName, setThemeName] = useState();
@@ -45,7 +45,12 @@ const EasyConfig = forwardRef((props, ref) => {
           autoInsertSpaceInButton={false}
         >
           <App className={styles.App}>
-            <Easy ref={compRef} alarmId={editId} onConfirm={onConfirm} />
+            <Easy
+              ref={compRef}
+              alarmId={editId}
+              onConfirm={onConfirm}
+              groupList={groupList}
+            />
           </App>
         </ConfigProvider>
       )}
@@ -54,7 +59,7 @@ const EasyConfig = forwardRef((props, ref) => {
 });
 
 const ComplexConfig = forwardRef((props, ref) => {
-  const { editId = -1, onConfirm } = props;
+  const { editId = -1, onConfirm, groupList } = props;
   const compRef = useRef(null);
 
   const [themeName, setThemeName] = useState();
@@ -82,7 +87,12 @@ const ComplexConfig = forwardRef((props, ref) => {
           autoInsertSpaceInButton={false}
         >
           <App className={styles.App}>
-            <Complex ref={compRef} alarmId={editId} onConfirm={onConfirm} />
+            <Complex
+              ref={compRef}
+              alarmId={editId}
+              onConfirm={onConfirm}
+              groupList={groupList}
+            />
           </App>
         </ConfigProvider>
       )}

+ 3 - 2
src/pages/Alarm/components/easy.jsx

@@ -8,6 +8,7 @@ import { Form, Input, Select, message, Switch, Space, Col } from "antd";
 import { Modal, Button, Radio } from "antd";
 import styles from "./easy.module.less";
 import API2 from "../../../api/alarm";
+import { useMemoizedFn } from "ahooks";
 
 function TranslateText(arr) {
   const dtLanguage = localStorage.getItem("dtLanguage");
@@ -45,7 +46,7 @@ const Easy = (props, ref) => {
   const [alEnable, setAlEnable] = useState(false);
   const [allEnable, setAllEnable] = useState(false);
 
-  const onModalOk = async () => {
+  const onModalOk = useMemoizedFn(async () => {
     const isNull = (val, bool) => {
       if (bool) {
         return Number(val);
@@ -237,7 +238,7 @@ const Easy = (props, ref) => {
           setLoading(false);
         });
     }
-  };
+  });
 
   useImperativeHandle(ref, () => {
     return {

Някои файлове не бяха показани, защото твърде много файлове са промени