SettingModal.tsx
1.42 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
import React, { useEffect, useMemo } from "react";
import { Modal, Skeleton } from "antd";
import { queryThresholds, Item, InterveneVO, ListVO, queryInterveneSettingList } from "../api";
import useInitial from "@/hooks/useInitail";
import SettingList from "./SettingList";
interface Props {
visible: boolean;
onCancel: () => void;
item?: ListVO;
}
export default ({ visible, onCancel, item }: Props) => {
const { data, loading, setParams, setData } = useInitial<Item[], any>(
queryThresholds,
[],
{ id: item?.id },
!item?.id
);
const {
data: interList,
loading: interLoading,
setParams: setParams2,
} = useInitial<InterveneVO[], any>(queryInterveneSettingList, [], { interveneId: item?.interveneId }, !item?.id);
useEffect(() => {
if (visible && item?.id) {
setParams({ id: item?.id }, true);
setParams2({ interveneId: item?.interveneId }, true);
}
if (!visible) {
setData([]);
}
}, [visible]);
const interveneVO = useMemo(() => interList.find((t) => t.code == item?.code), [interList]);
return (
<Modal open={visible} onCancel={onCancel} cancelButtonProps={{ hidden: true }} onOk={onCancel} title="待办超时干预条件" width="55%">
<Skeleton active loading={loading || interLoading}>
<SettingList disabled value={data || []} valueDesc={interveneVO?.valueDesc} valueUnit={interveneVO?.valueUnit} />
</Skeleton>
</Modal>
);
};