Commit 1acdda1c by zhaochengxiang

bug fix

parent 00be8817
import React from 'react'
import { Button, Form, Descriptions, Input, Row, Col, Space, Select } from 'antd'
import { Button, Form, Descriptions, Input, Row, Col, Space, Select, Spin } from 'antd'
import { DownOutlined, UpOutlined } from '@ant-design/icons'
import { Subject } from 'rxjs'
import { useDebounceEffect } from 'ahooks'
......@@ -187,7 +187,7 @@ const UsersItem = ({ value, onChange }) => {
}
return (
<Select loading={loading} allowClear showSearch
<Select allowClear showSearch
placeholder='请选择用户'
value={value?`${value.dname}(${value.name})`:undefined}
searchValue={searchValue}
......@@ -198,6 +198,7 @@ const UsersItem = ({ value, onChange }) => {
setSearchValue()
}}
filterOption={false}
notFoundContent={loading ? <Spin size="small" /> : null}
options={options}
onChange={(val) => {
if (val) {
......
......@@ -175,7 +175,7 @@ const UsersItem = ({ modelId, value, onChange, readonly = false }) => {
return (
<>
{
readonly ? <span>{value?.map(item => `${item.dname}(${item.name})`).toString()}</span> : <Select loading={loading} mode='multiple' allowClear
readonly ? <span>{value?.map(item => `${item.dname}(${item.name})`).toString()}</span> : <Select mode='multiple' allowClear
placeholder='请选择用户'
value={(value??[]).map(item => `${item.dname}(${item.name})`)}
searchValue={searchValue}
......@@ -186,12 +186,22 @@ const UsersItem = ({ modelId, value, onChange, readonly = false }) => {
setSearchValue()
}}
filterOption={false}
notFoundContent={loading ? <Spin size="small" /> : null}
options={options}
onChange={(val) => {
onChange?.([
const newValue = [
...(value??[]).filter(item => (val??[]).indexOf(`${item.dname}(${item.name})`) !== -1),
...(options??[]).filter(item => (val??[]).indexOf(item.value) !== -1)
])
];
const uniqueValue = newValue.reduce((acc, current) => {
const index = acc.findIndex(item => `${item.dname}(${item.name})` === `${current.dname}(${current.name})`)
if (index === -1) {
acc.push(current);
}
return acc;
}, []);
onChange?.(uniqueValue)
}}
/>
}
......
......@@ -173,7 +173,7 @@ const UsersItem = ({ modelId, value, onChange }) => {
}
return (
<Select loading={loading} showSearch allowClear
<Select showSearch allowClear
placeholder='请选择用户'
value={value?`${value.dname}(${value.name})`:undefined}
searchValue={searchValue}
......@@ -184,6 +184,7 @@ const UsersItem = ({ modelId, value, onChange }) => {
setSearchValue()
}}
filterOption={false}
notFoundContent={loading ? <Spin size="small" /> : null}
options={options}
onChange={(val) => {
if (val) {
......
......@@ -266,7 +266,7 @@ const RuleReviewItem = ({ value = {}, onChange }) => {
</Radio.Group>
{
ruleReviewSelected && <Col span={16}>
<Select showSearch loading={loading} allowClear
<Select showSearch allowClear
placeholder='请选择规范评审人员'
searchValue={searchValue}
onSearch={(val) => {
......@@ -276,6 +276,7 @@ const RuleReviewItem = ({ value = {}, onChange }) => {
setSearchValue()
}}
filterOption={false}
notFoundContent={loading ? <Spin size="small" /> : null}
options={options}
onChange={(val) => {
triggerChange({
......@@ -400,6 +401,8 @@ const DesignUsersItem = ({ value, onChange }) => {
useDebounceEffect(() => {
if (searchValue) {
getUsers()
} else {
setOptions()
}
}, [searchValue], { wait: 300 })
......@@ -427,7 +430,7 @@ const DesignUsersItem = ({ value, onChange }) => {
}
return (
<Select showSearch loading={loading} allowClear
<Select showSearch allowClear
placeholder='请选择设计评审人员'
value={value?.map(item => item.name)}
searchValue={searchValue}
......@@ -438,6 +441,7 @@ const DesignUsersItem = ({ value, onChange }) => {
setSearchValue()
}}
filterOption={false}
notFoundContent={loading ? <Spin size="small" /> : null}
options={options}
onChange={(val) => {
onChange?.(
......
......@@ -292,7 +292,7 @@ const UsersItem = ({ value, onChange, readonly = false }) => {
return (
<>
{
readonly ? <span>{value?.map(item => `${item.dname}(${item.name})`).toString()}</span> : <Select loading={loading} mode='multiple' allowClear
readonly ? <span>{value?.map(item => `${item.dname}(${item.name})`).toString()}</span> : <Select mode='multiple' allowClear
placeholder='请选择用户'
value={(value??[]).map(item => `${item.dname}(${item.name})`)}
searchValue={searchValue}
......@@ -303,12 +303,22 @@ const UsersItem = ({ value, onChange, readonly = false }) => {
setSearchValue()
}}
filterOption={false}
notFoundContent={loading ? <Spin size="small" /> : null}
options={options}
onChange={(val) => {
onChange?.([
const newValue = [
...(value??[]).filter(item => (val??[]).indexOf(`${item.dname}(${item.name})`) !== -1),
...(options??[]).filter(item => (val??[]).indexOf(item.value) !== -1)
])
];
const uniqueValue = newValue.reduce((acc, current) => {
const index = acc.findIndex(item => `${item.dname}(${item.name})` === `${current.dname}(${current.name})`)
if (index === -1) {
acc.push(current);
}
return acc;
}, []);
onChange?.(uniqueValue)
}}
/>
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment