diff --git a/inlong-dashboard/src/ui/pages/ModuleAudit/AuditModule/config.tsx b/inlong-dashboard/src/ui/pages/ModuleAudit/AuditModule/config.tsx index 81d05bd15d0..a4c0ef394d3 100644 --- a/inlong-dashboard/src/ui/pages/ModuleAudit/AuditModule/config.tsx +++ b/inlong-dashboard/src/ui/pages/ModuleAudit/AuditModule/config.tsx @@ -158,7 +158,7 @@ export const getSourceDataWithCommas = sourceData => { let endTimeVisible = true; -export const getFormContent = (initialValues, onSearch, onDataStreamSuccess) => [ +export const getFormContent = (initialValues, onSearch, onDataStreamSuccess, auditData) => [ { type: 'select', label: i18n.t('pages.ModuleAudit.config.InlongGroupId'), @@ -303,34 +303,16 @@ export const getFormContent = (initialValues, onSearch, onDataStreamSuccess) => allowClear: true, showSearch: true, dropdownMatchSelectWidth: false, - options: { - requestAuto: true, - requestTrigger: ['onOpen'], - requestService: () => { - return request({ - url: '/audit/getAuditBases', - params: { - isMetric: true, - }, + options: auditData?.reduce((accumulator, item) => { + const existingItem = accumulator.find((i: { value: any }) => i.value === item.auditId); + if (!existingItem) { + accumulator.push({ + label: i18n?.language === 'cn' ? item.nameInChinese : item.nameInEnglish, + value: item.auditId, }); - }, - requestParams: { - formatResult: result => { - return result?.reduce((accumulator, item) => { - const existingItem = accumulator.find( - (i: { value: any }) => i.value === item.auditId, - ); - if (!existingItem) { - accumulator.push({ - label: i18n?.language === 'cn' ? item.nameInChinese : item.nameInEnglish, - value: item.auditId, - }); - } - return accumulator; - }, []); - }, - }, - }, + } + return accumulator; + }, []), filterOption: (keyword: string, option: { label: any }) => { return (option?.label ?? '').toLowerCase().includes(keyword.toLowerCase()); }, diff --git a/inlong-dashboard/src/ui/pages/ModuleAudit/AuditModule/index.tsx b/inlong-dashboard/src/ui/pages/ModuleAudit/AuditModule/index.tsx index 5dbed68dd75..8a4491b5e25 100644 --- a/inlong-dashboard/src/ui/pages/ModuleAudit/AuditModule/index.tsx +++ b/inlong-dashboard/src/ui/pages/ModuleAudit/AuditModule/index.tsx @@ -32,9 +32,10 @@ import { } from './config'; import { Table } from 'antd'; import i18n from '@/i18n'; +import { AuditProps } from '@/ui/pages/ModuleAudit'; export const auditModule = 'audit'; -const Comp: React.FC = () => { +const Comp: React.FC = ({ auditData }) => { const [form] = useForm(); const [query, setQuery] = useState({ @@ -114,7 +115,7 @@ const Comp: React.FC = () => { setQuery({ diff --git a/inlong-dashboard/src/ui/pages/ModuleAudit/IdModule/config.tsx b/inlong-dashboard/src/ui/pages/ModuleAudit/IdModule/config.tsx index c65e0ecdff2..cd868b67972 100644 --- a/inlong-dashboard/src/ui/pages/ModuleAudit/IdModule/config.tsx +++ b/inlong-dashboard/src/ui/pages/ModuleAudit/IdModule/config.tsx @@ -47,7 +47,7 @@ export const toTableData = (source, sourceDataMap) => { })); }; -export const getFormContent = (initialValues, onSearch) => [ +export const getFormContent = (initialValues, onSearch, auditData) => [ { type: 'select', label: i18n.t('pages.ModuleAudit.config.InlongGroupId'), @@ -138,29 +138,16 @@ export const getFormContent = (initialValues, onSearch) => [ allowClear: true, showSearch: true, dropdownMatchSelectWidth: false, - options: { - requestAuto: true, - requestTrigger: ['onOpen'], - requestService: () => { - return request('/audit/getAuditBases'); - }, - requestParams: { - formatResult: (result: any[]) => { - return result?.reduce((accumulator, item) => { - const existingItem = accumulator.find( - (i: { value: any }) => i.value === item.auditId, - ); - if (!existingItem) { - accumulator.push({ - label: i18n?.language === 'cn' ? item.nameInChinese : item.nameInEnglish, - value: item.auditId, - }); - } - return accumulator; - }, []); - }, - }, - }, + options: auditData?.reduce((accumulator, item) => { + const existingItem = accumulator.find((i: { value: any }) => i.value === item.auditId); + if (!existingItem) { + accumulator.push({ + label: i18n?.language === 'cn' ? item.nameInChinese : item.nameInEnglish, + value: item.auditId, + }); + } + return accumulator; + }, []), filterOption: (keyword: string, option: { label: any }) => (option?.label ?? '').toLowerCase().includes(keyword.toLowerCase()), }, @@ -173,29 +160,16 @@ export const getFormContent = (initialValues, onSearch) => [ allowClear: true, showSearch: true, dropdownMatchSelectWidth: false, - options: { - requestAuto: true, - requestTrigger: ['onOpen'], - requestService: () => { - return request('/audit/getAuditBases'); - }, - requestParams: { - formatResult: (result: any[]) => { - return result?.reduce((accumulator, item) => { - const existingItem = accumulator.find( - (i: { value: any }) => i.value === item.auditId, - ); - if (!existingItem) { - accumulator.push({ - label: i18n?.language === 'cn' ? item.nameInChinese : item.nameInEnglish, - value: item.auditId, - }); - } - return accumulator; - }, []); - }, - }, - }, + options: auditData?.reduce((accumulator, item) => { + const existingItem = accumulator.find((i: { value: any }) => i.value === item.auditId); + if (!existingItem) { + accumulator.push({ + label: i18n?.language === 'cn' ? item.nameInChinese : item.nameInEnglish, + value: item.auditId, + }); + } + return accumulator; + }, []), filterOption: (keyword: string, option: { label: any }) => (option?.label ?? '').toLowerCase().includes(keyword.toLowerCase()), }, diff --git a/inlong-dashboard/src/ui/pages/ModuleAudit/IdModule/index.tsx b/inlong-dashboard/src/ui/pages/ModuleAudit/IdModule/index.tsx index b6fa51a9b68..65fb7bd0534 100644 --- a/inlong-dashboard/src/ui/pages/ModuleAudit/IdModule/index.tsx +++ b/inlong-dashboard/src/ui/pages/ModuleAudit/IdModule/index.tsx @@ -22,10 +22,10 @@ import HighTable, { useForm } from '@/ui/components/HighTable'; import { useRequest } from '@/ui/hooks'; import { timestampFormat } from '@/core/utils'; import { getFormContent, toTableData, getTableColumns } from './config'; +import { AuditProps } from '@/ui/pages/ModuleAudit'; export const idModule = 'id'; - -const Comp: React.FC = () => { +const Comp: React.FC = ({ auditData }) => { const [form] = useForm(); const [query, setQuery] = useState({ @@ -101,7 +101,7 @@ const Comp: React.FC = () => { <> { })); }; -export const getFormContent = (initialValues, onSearch) => [ +export const getFormContent = (initialValues, onSearch, auditData) => [ { type: 'input', label: i18n.t('pages.ModuleAudit.config.Ip'), @@ -92,29 +92,16 @@ export const getFormContent = (initialValues, onSearch) => [ allowClear: true, showSearch: true, dropdownMatchSelectWidth: false, - options: { - requestAuto: true, - requestTrigger: ['onOpen'], - requestService: () => { - return request('/audit/getAuditBases'); - }, - requestParams: { - formatResult: (result: any[]) => { - return result?.reduce((accumulator, item) => { - const existingItem = accumulator.find( - (i: { value: any }) => i.value === item.auditId, - ); - if (!existingItem) { - accumulator.push({ - label: i18n?.language === 'cn' ? item.nameInChinese : item.nameInEnglish, - value: item.auditId, - }); - } - return accumulator; - }, []); - }, - }, - }, + options: auditData?.reduce((accumulator, item) => { + const existingItem = accumulator.find((i: { value: any }) => i.value === item.auditId); + if (!existingItem) { + accumulator.push({ + label: i18n?.language === 'cn' ? item.nameInChinese : item.nameInEnglish, + value: item.auditId, + }); + } + return accumulator; + }, []), filterOption: (keyword: any, option: { label: any }) => (option?.label ?? '').toLowerCase().includes(keyword.toLowerCase()), }, @@ -127,29 +114,16 @@ export const getFormContent = (initialValues, onSearch) => [ allowClear: true, showSearch: true, dropdownMatchSelectWidth: false, - options: { - requestAuto: true, - requestTrigger: ['onOpen'], - requestService: () => { - return request('/audit/getAuditBases'); - }, - requestParams: { - formatResult: (result: any[]) => { - return result?.reduce((accumulator, item) => { - const existingItem = accumulator.find( - (i: { value: any }) => i.value === item.auditId, - ); - if (!existingItem) { - accumulator.push({ - label: i18n?.language === 'cn' ? item.nameInChinese : item.nameInEnglish, - value: item.auditId, - }); - } - return accumulator; - }, []); - }, - }, - }, + options: auditData?.reduce((accumulator, item) => { + const existingItem = accumulator.find((i: { value: any }) => i.value === item.auditId); + if (!existingItem) { + accumulator.push({ + label: i18n?.language === 'cn' ? item.nameInChinese : item.nameInEnglish, + value: item.auditId, + }); + } + return accumulator; + }, []), filterOption: (keyword: string, option: { label: any }) => (option?.label ?? '').toLowerCase().includes(keyword.toLowerCase()), }, diff --git a/inlong-dashboard/src/ui/pages/ModuleAudit/IpModule/index.tsx b/inlong-dashboard/src/ui/pages/ModuleAudit/IpModule/index.tsx index 7e97bad15b5..ef24a3e7ddd 100644 --- a/inlong-dashboard/src/ui/pages/ModuleAudit/IpModule/index.tsx +++ b/inlong-dashboard/src/ui/pages/ModuleAudit/IpModule/index.tsx @@ -23,10 +23,10 @@ import HighTable from '@/ui/components/HighTable'; import { useRequest } from '@/ui/hooks'; import { timestampFormat } from '@/core/utils'; import { getFormContent, toTableData, getTableColumns } from './config'; +import { AuditProps } from '@/ui/pages/ModuleAudit'; export const ipModule = 'ip'; - -const Comp: React.FC = () => { +const Comp: React.FC = ({ auditData }) => { const [form] = useForm(); const [query, setQuery] = useState({ @@ -100,7 +100,7 @@ const Comp: React.FC = () => { <> { const history = useHistory(); const { type } = useParams>(); @@ -63,7 +66,20 @@ const Comp: React.FC = () => { pathname: `/system/${value}`, }); }; - + const [auditData, setAuditData] = useState([]); + useEffect(() => { + request('/audit/getAuditBases').then(res1 => { + request({ + url: '/audit/getAuditBases', + params: { + isMetric: true, + }, + }).then(res2 => { + res1.push(...res2); + setAuditData(res1); + }); + }); + }, []); return ( @@ -76,7 +92,7 @@ const Comp: React.FC = () => { headStyle={{ border: 'none' }} tabProps={{ size: 'middle' }} > - {tabListMap[module]} + {React.cloneElement(tabListMap[module], { auditData: auditData })}