From 668590b860e572990b357747f39810e955823caf Mon Sep 17 00:00:00 2001 From: skyouc Date: 星期一, 19 五月 2025 20:16:53 +0800 Subject: [PATCH] Merge branch 'devlop' of http://47.97.1.152:5880/r/wms-master into devlop --- rsf-admin/src/page/components/DictionarySelect.jsx | 60 +++++++++++++++++++++++++++++++++++++++++------------------- 1 files changed, 41 insertions(+), 19 deletions(-) diff --git a/rsf-admin/src/page/components/DictionarySelect.jsx b/rsf-admin/src/page/components/DictionarySelect.jsx index 43dc811..0825280 100644 --- a/rsf-admin/src/page/components/DictionarySelect.jsx +++ b/rsf-admin/src/page/components/DictionarySelect.jsx @@ -2,41 +2,63 @@ import { useState, useEffect } from 'react'; import { Button, useListContext, SelectInput, - required, + required, SelectArrayInput, useTranslate, useNotify } from 'react-admin'; import request from '@/utils/request'; const DictionarySelect = (props) => { - const { dictTypeCode, name, ...parmas } = props; - const { selectedIds } = useListContext(); + 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.value - } - })) - } 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 ( - <SelectInput + <InputComponent source={name} choices={list} + isLoading={loading} {...parmas} /> ); -- Gitblit v1.9.1