From 1e479e493542e77240625b9100eb14cda1fe9041 Mon Sep 17 00:00:00 2001 From: zjj <3272660260@qq.com> Date: 星期二, 29 四月 2025 17:19:00 +0800 Subject: [PATCH] # --- rsf-admin/src/page/components/DictionarySelect.jsx | 55 ++++++++++++++++++++++++++++++++++++++----------------- 1 files changed, 38 insertions(+), 17 deletions(-) diff --git a/rsf-admin/src/page/components/DictionarySelect.jsx b/rsf-admin/src/page/components/DictionarySelect.jsx index 0eb2fab..0825280 100644 --- a/rsf-admin/src/page/components/DictionarySelect.jsx +++ b/rsf-admin/src/page/components/DictionarySelect.jsx @@ -8,38 +8,59 @@ import request from '@/utils/request'; const DictionarySelect = (props) => { - const { dictTypeCode, name, multiple = false, ...parmas } = props; + const { + dictTypeCode, + name, + multiple = false, + perPage = 100, // 榛樿姣忛〉鏄剧ず100鏉℃暟鎹� + page = 1, // 榛樿绗竴椤� + ...parmas + } = props; const translate = useTranslate(); const notify = useNotify(); - const [list, setList] = useState([]) + const [list, setList] = useState([]); + const [loading, setLoading] = useState(false); useEffect(() => { - http() - }, [dictTypeCode]); + http(); + }, [dictTypeCode, page, perPage]); const http = async () => { - const res = await request.post('/dictData/page', { dictTypeCode }); - if (res?.data?.code === 200) { - - setList(res.data.data.records.map((item) => { - return { - id: item.value, - name: item.label - } - })) - } else { - notify(res.data.msg); + setLoading(true); + try { + const res = await request.post('/dictData/page', { + dictTypeCode, + current: page, + pageSize: perPage + }); + + if (res?.data?.code === 200) { + setList(res.data.data.records.map((item) => { + return { + id: item.value, + name: item.label + } + })); + } else { + notify(res.data.msg); + } + } catch (error) { + notify('鍔犺浇瀛楀吀鏁版嵁澶辫触', 'error'); + console.error('鍔犺浇瀛楀吀鏁版嵁澶辫触:', error); + } finally { + setLoading(false); } - } + }; + const InputComponent = multiple ? SelectArrayInput : SelectInput; return ( <InputComponent source={name} choices={list} + isLoading={loading} {...parmas} /> - ); }; -- Gitblit v1.9.1