From 50c33b34f9e6ae19c003d305e4c0b86cea062bec Mon Sep 17 00:00:00 2001
From: skyouc
Date: 星期四, 03 七月 2025 16:30:26 +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 | 59 +++++++++++++++++++++++++++++++++++++++++------------------
1 files changed, 41 insertions(+), 18 deletions(-)
diff --git a/rsf-admin/src/page/components/DictionarySelect.jsx b/rsf-admin/src/page/components/DictionarySelect.jsx
index 2523c5d..0825280 100644
--- a/rsf-admin/src/page/components/DictionarySelect.jsx
+++ b/rsf-admin/src/page/components/DictionarySelect.jsx
@@ -2,40 +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 {
+ 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 (
- <SelectInput
+ <InputComponent
source={name}
choices={list}
+ isLoading={loading}
{...parmas}
/>
);
--
Gitblit v1.9.1