Ver código fonte

更改detail获取列表的方式

valentichu 1 ano atrás
pai
commit
b67d57dea6
3 arquivos alterados com 15 adições e 12 exclusões
  1. 0 0
      lib/index.js
  2. 2 2
      src/api/alarm.js
  3. 13 10
      src/pages/Alarm/components/detail.jsx

Diferenças do arquivo suprimidas por serem muito extensas
+ 0 - 0
lib/index.js


+ 2 - 2
src/api/alarm.js

@@ -23,11 +23,11 @@ export async function searchPoint(data) {
   return res.statusText ? res.data : res;
 }
 
-export async function getAlarmHistory(page, rule_id, size = 10) {
+export async function getAlarmHistory(page, rule_ids, size = 10) {
   const res = await axios.post(
     "/api/unialarm/get_alarm_history",
     {
-      rule_id,
+      rule_ids,
       page_num: page,
       page_size: size,
       types: [1],

+ 13 - 10
src/pages/Alarm/components/detail.jsx

@@ -19,21 +19,24 @@ const Detail = (props) => {
   const [tags, setTags] = useState([]);
   const [current, setCurrent] = useState("history");
   const [ruleId, setRuleId] = useState(-1);
-  const getRuleIdByPointId = useMemoizedFn(async (pointId) => {
-    const res = await API.getRuleIdByPointId(pointId);
-    setRuleId(res?.data?.[0]?.id);
+  const getRuleIdByPointId = useMemoizedFn(async (ruleId, pointId) => {
+    const ids = [];
+    if (options.pointId) {
+      const res = await API.getRuleIdByPointId(pointId);
+      ids.push(res?.data?.[0]?.id);
+    }
+    if (options.ruleId) {
+      ids.push(ruleId);
+    }
+    setRuleId(ids);
     setCurrent("history");
     setTags([]);
   });
   useEffect(() => {
-    if (options.ruleId) {
-      setRuleId(options.ruleId);
-      setCurrent("history");
-      setTags([]);
-    } else if (options.pointId) {
-      getRuleIdByPointId(options.pointId);
+    if (options.ruleId || options.pointId) {
+      getRuleIdByPointId(options.ruleId, options.pointId);
     } else if (options.detail) {
-      setRuleId(options.detail.rule_id);
+      setRuleId([options.detail.rule_id]);
       setTags([
         {
           id: options.detail.id,

Alguns arquivos não foram mostrados porque muitos arquivos mudaram nesse diff