From 5ef6c105aca5bd7c0c63ce3240fbe82c2e07e8f7 Mon Sep 17 00:00:00 2001
From: 1 <1@123>
Date: 星期三, 18 三月 2026 13:46:05 +0800
Subject: [PATCH] lsh#// rsf-server本机调用直通,不需要Token
---
rsf-admin/src/page/components/DictSelect.jsx | 50 ++++++++++++++++++++++++++------------------------
1 files changed, 26 insertions(+), 24 deletions(-)
diff --git a/rsf-admin/src/page/components/DictSelect.jsx b/rsf-admin/src/page/components/DictSelect.jsx
index d42a8ee..8f3531e 100644
--- a/rsf-admin/src/page/components/DictSelect.jsx
+++ b/rsf-admin/src/page/components/DictSelect.jsx
@@ -1,12 +1,12 @@
import { useState, useEffect } from 'react';
import {
- useTranslate, useNotify
+ useTranslate, useNotify, required
} from 'react-admin';
import request from '@/utils/request';
-import { Select, MenuItem, FormControl, InputLabel } from '@mui/material';
+import { Autocomplete, TextField, FormControl } from '@mui/material';
const DictSelect = (props) => {
- const { dictTypeCode, label, value, onChange, ...params } = props;
+ const { dictTypeCode, label, group, value, onChange, ...params } = props;
const translate = useTranslate();
const notify = useNotify();
const [list, setList] = useState([]);
@@ -16,7 +16,7 @@
}, [dictTypeCode]);
const http = async () => {
- const res = await request.post('/dictData/page', { dictTypeCode });
+ const res = await request.post('/dictData/page', { dictTypeCode, group });
if (res?.data?.code === 200) {
setList(res.data.data.records.map((item) => {
return {
@@ -29,33 +29,35 @@
}
};
- const handleChange = (event) => {
- const selectedValue = event.target.value;
+ const validValueObj = list.find(item => item.value === value) || null;
+
+ const handleChange = (event, newValue) => {
if (onChange) {
- onChange(event);
+ onChange({ target: { value: newValue ? newValue.value : '' } });
}
};
- const validValue = list.some(item => item.value === value) ? value : '';
-
return (
- <FormControl fullWidth>
- <InputLabel id="demo-select-small-label">{label}</InputLabel>
- <Select
- labelId="demo-select-small-label"
- value={validValue}
- variant="filled"
+ <FormControl fullWidth size="small">
+ <Autocomplete
+ value={validValueObj}
onChange={handleChange}
- size='small'
- >
- {list.map((item) => (
- <MenuItem key={item.value} value={item.value}>
- {item.label}
- </MenuItem>
- ))}
- </Select>
+ options={list}
+ getOptionLabel={(option) => option.label || ''}
+ isOptionEqualToValue={(option, val) => option.value === val.value}
+ size="small"
+ ListboxProps={{ style: { maxHeight: '200px' } }}
+ renderInput={(p) => (
+ <TextField
+ {...p}
+ label={label}
+ variant="filled"
+ />
+ )}
+ {...params}
+ />
</FormControl>
);
};
-export default DictSelect;
\ No newline at end of file
+export default DictSelect;
\ No newline at end of file
--
Gitblit v1.9.1