提交 a07eeab9 authored 作者: 王鹏飞's avatar 王鹏飞

feat: 编辑者选择的时候显示手机号

上级 b3a5b79c
......@@ -7,12 +7,12 @@ function DebounceSelect({ fetchOptions, debounceTimeout = 800, ...props }) {
const [options, setOptions] = useState([])
const fetchRef = useRef(0)
const debounceFetcher = useMemo(() => {
const loadOptions = value => {
const loadOptions = (value) => {
fetchRef.current += 1
const fetchId = fetchRef.current
setOptions([])
setFetching(true)
fetchOptions(value).then(newOptions => {
fetchOptions(value).then((newOptions) => {
if (fetchId !== fetchRef.current) {
// for fetch callback order
return
......@@ -39,12 +39,14 @@ function DebounceSelect({ fetchOptions, debounceTimeout = 800, ...props }) {
async function fetchUserList(username) {
console.log('fetching user', username)
return getTeacherList({ real_name: username, page_size: 40 }).then(res => {
return res.data.list
return getTeacherList({ real_name: username, page_size: 40 }).then((res) => {
return res.data.list.map((item) => {
return { ...item, label: `${item.real_name} (${item.tel})` }
})
})
}
const SelectTeacher = props => {
const SelectTeacher = (props) => {
const [value, setValue] = useState([])
return (
<DebounceSelect
......@@ -52,8 +54,8 @@ const SelectTeacher = props => {
value={value}
placeholder="Select users"
fetchOptions={fetchUserList}
fieldNames={{ label: 'real_name', value: 'id' }}
onChange={newValue => {
fieldNames={{ label: 'label', value: 'id' }}
onChange={(newValue) => {
setValue(newValue)
}}
style={{ width: '100%' }}
......
......@@ -8,7 +8,7 @@ const EditChapterEditors = ({ chapter = {}, onChange, ...props }) => {
const [value, setValue] = useState('')
useEffect(() => {
getChapterEditors({ book_id: chapter.book_id, chapter_id: chapter.id }).then(res => {
getChapterEditors({ book_id: chapter.book_id, chapter_id: chapter.id }).then((res) => {
setEditors(res.data.editors || [])
const value = res.data.selected_editor_ids[0] || ''
setValue(value)
......@@ -26,12 +26,12 @@ const EditChapterEditors = ({ chapter = {}, onChange, ...props }) => {
<Form labelCol={{ span: 8 }}>
<Form.Item label="当前章节">{chapter.title}</Form.Item>
<Form.Item label="编写者">
<Radio.Group value={value} onChange={e => setValue(e.target.value)} style={{ marginTop: '6px' }}>
<Radio.Group value={value} onChange={(e) => setValue(e.target.value)}>
<Space direction="vertical">
{editors.map(item => {
{editors.map((item) => {
return (
<Radio value={item.editor_id} key={item.editor_id}>
{item.real_name}
{item.real_name}({item.tel})
</Radio>
)
})}
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论