Commit 173c142e by zhaochengxiang

模型负责人

parent c940cb75
...@@ -15,8 +15,6 @@ const FC = (props) => { ...@@ -15,8 +15,6 @@ const FC = (props) => {
const { editable, form, modelerData, action, onChange } = props const { editable, form, modelerData, action, onChange } = props
const [isCollapse, setCollapse] = React.useState(true) const [isCollapse, setCollapse] = React.useState(true)
const [maintenanceRecords, setMaintenanceRecords] = React.useState() const [maintenanceRecords, setMaintenanceRecords] = React.useState()
const [loadingUsers, setLoadingUsers] = React.useState(false)
const [users, setUsers] = React.useState()
React.useEffect(() => { React.useEffect(() => {
const $importActionSubject = importActionSubject.subscribe((props) => { const $importActionSubject = importActionSubject.subscribe((props) => {
...@@ -31,10 +29,6 @@ const FC = (props) => { ...@@ -31,10 +29,6 @@ const FC = (props) => {
}, [action]) }, [action])
React.useEffect(() => { React.useEffect(() => {
getUsers()
}, [])
React.useEffect(() => {
if (modelerData?.id) { if (modelerData?.id) {
getMaintenanceRecords() getMaintenanceRecords()
} }
...@@ -125,12 +119,12 @@ const FC = (props) => { ...@@ -125,12 +119,12 @@ const FC = (props) => {
<Row gutter={10}> <Row gutter={10}>
<Col xs={24} sm={24} lg={12} xl={8}> <Col xs={24} sm={24} lg={12} xl={8}>
<Form.Item label='技术负责人' name='technicalManagerUser'> <Form.Item label='技术负责人' name='technicalManagerUser'>
<UsersItem loading={loadingUsers} users={users} /> <UsersItem />
</Form.Item> </Form.Item>
</Col> </Col>
<Col xs={24} sm={24} lg={12} xl={8}> <Col xs={24} sm={24} lg={12} xl={8}>
<Form.Item label='业务负责人' name='businessManagerUser'> <Form.Item label='业务负责人' name='businessManagerUser'>
<UsersItem loading={loadingUsers} users={users} /> <UsersItem />
</Form.Item> </Form.Item>
</Col> </Col>
<Col xs={24} sm={24} lg={12} xl={8}> <Col xs={24} sm={24} lg={12} xl={8}>
...@@ -145,10 +139,10 @@ const FC = (props) => { ...@@ -145,10 +139,10 @@ const FC = (props) => {
) : ( ) : (
<Descriptions column={3}> <Descriptions column={3}>
<Descriptions.Item label={<div style={{ textAlign: 'right', width: 106 }} >技术负责人</div>}> <Descriptions.Item label={<div style={{ textAlign: 'right', width: 106 }} >技术负责人</div>}>
{modelerData?.technicalManagerUser?.name} {`${modelerData?.technicalManagerUser?.dname}(${modelerData?.technicalManagerUser?.name})`}
</Descriptions.Item> </Descriptions.Item>
<Descriptions.Item label={<div style={{ textAlign: 'right', width: 106 }} >业务负责人</div>}> <Descriptions.Item label={<div style={{ textAlign: 'right', width: 106 }} >业务负责人</div>}>
{modelerData?.businessManagerUser?.name} {`${modelerData?.businessManagerUser?.dname}(${modelerData?.businessManagerUser?.name})`}
</Descriptions.Item> </Descriptions.Item>
<Descriptions.Item label={<div style={{ textAlign: 'right', width: 106 }} >维护历史</div>} > <Descriptions.Item label={<div style={{ textAlign: 'right', width: 106 }} >维护历史</div>} >
<div style={{ maxHeight: 70, overflow: 'auto' }}> <div style={{ maxHeight: 70, overflow: 'auto' }}>
...@@ -170,25 +164,46 @@ const FC = (props) => { ...@@ -170,25 +164,46 @@ const FC = (props) => {
export default FC export default FC
const UsersItem = ({ loading, users, value, onChange }) => { const UsersItem = ({ value, onChange }) => {
const [loading, setLoading] = React.useState(false)
const [searchValue, setSearchValue] = React.useState() const [searchValue, setSearchValue] = React.useState()
const [options, setOptions] = React.useState() const [options, setOptions] = React.useState()
useDebounceEffect(() => { useDebounceEffect(() => {
if (searchValue) {
getUsers()
} else {
setOptions()
}
}, [searchValue], { wait: 300 })
const getUsers = () => {
setLoading(true)
dispatch({
type: 'datamodel.getCooperationUsers',
payload: {
match: searchValue,
},
callback: data => {
setLoading(false)
setOptions( setOptions(
(users??[]) (data??[]).map(item => ({
.filter(item => !searchValue|| (item.name??'').indexOf(searchValue)!==-1 || (item.dname??'').indexOf(searchValue)!==-1) label: `${item.dname}(${item.name})`,
.map(item => ({ value: `${item.dname}(${item.name})`,
label: item.name, ...item
value: item.name,
})) }))
) )
}, [searchValue, users], { wait: 300 }) },
error: () => {
setLoading(false)
}
})
}
return ( return (
<Select loading={loading} allowClear showSearch <Select loading={loading} allowClear showSearch
placeholder='请选择用户' placeholder='请选择用户'
value={(options??[]).length>0?value?.name:undefined} value={value?`${value.dname}(${value.name})`:undefined}
searchValue={searchValue} searchValue={searchValue}
onSearch={(val) => { onSearch={(val) => {
setSearchValue(val) setSearchValue(val)
...@@ -200,9 +215,9 @@ const UsersItem = ({ loading, users, value, onChange }) => { ...@@ -200,9 +215,9 @@ const UsersItem = ({ loading, users, value, onChange }) => {
options={options} options={options}
onChange={(val) => { onChange={(val) => {
if (val) { if (val) {
const index = (users??[]).findIndex(item => item.name === val) const index = (options??[]).findIndex(item => item.value === val)
if (index !== -1) { if (index !== -1) {
onChange?.(users[index]) onChange?.(options[index])
} }
} else { } else {
onChange?.() onChange?.()
......
...@@ -220,6 +220,8 @@ const RuleReviewItem = ({ value = {}, onChange }) => { ...@@ -220,6 +220,8 @@ const RuleReviewItem = ({ value = {}, onChange }) => {
useDebounceEffect(() => { useDebounceEffect(() => {
if (searchValue) { if (searchValue) {
getUsers() getUsers()
} else {
setOptions()
} }
}, [searchValue], { wait: 300 }) }, [searchValue], { wait: 300 })
......
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