Commit c17aca7b by zhaochengxiang

资产要素选用户 选部门

parent d113ca65
......@@ -20,4 +20,10 @@ export function* userGroups() {
}
export function* getGroupUsers(payload) {
return yield call(service.getGroupUsers, payload);
}
export function* getMcclUsers() {
return yield call(service.getMcclUsers);
}
export function* getMcclDepartments() {
return yield call(service.getMcclDepartments);
}
\ No newline at end of file
......@@ -29,4 +29,12 @@ export function userGroups() {
export function getGroupUsers(payload) {
return GetJSON(`/authservice/userGroups/${payload.id}/users`)
}
export function getMcclUsers() {
return PostJSON("/auth/peopleCenter/listMcclUser")
}
export function getMcclDepartments() {
return PostJSON("/auth/peopleCenter/getOrganMcclList")
}
\ No newline at end of file
......@@ -2,6 +2,7 @@ import React, { useEffect, useState, useContext, useMemo, useRef } from 'react';
import { Form, Spin, Input, Descriptions, Space, Button, Tooltip, Select, Cascader, Radio, Divider, Typography, Modal, Row, Col, Pagination, Dropdown, Menu, message } from 'antd';
import { DownOutlined, UpOutlined, QuestionCircleOutlined } from '@ant-design/icons';
import LocalStorage from 'local-storage';
import { useDebounceEffect } from 'ahooks';
import MetadataInfo from './MetadataInfo';
import { dispatch } from '../../../../model';
......@@ -280,7 +281,7 @@ const AssetAction = (props) => {
const getUsers = () => {
setLoadingUsers(true);
dispatch({
type: 'pds.getOwners',
type: 'user.getMcclUsers',
callback: (data) => {
setLoadingUsers(false);
setUsers(data);
......@@ -309,7 +310,7 @@ const AssetAction = (props) => {
const getDepartments = () => {
setLoadingDepartments(true);
dispatch({
type: 'pds.getDepartments',
type: 'user.getMcclDepartments',
callback: (data) => {
setLoadingDepartments(false);
setDepartments(data);
......@@ -680,23 +681,6 @@ const AssetAction = (props) => {
)
}
// if (element.name==='数据关键用户' || element.name?.toLowerCase()==='业务数据owner' || element.name?.toLowerCase()==='it责任人') {
// return <SelectUser
// type='edit'
// loading={loadingUsers}
// users={users}
// disabled={element.manualMaintain==='否'}
// />
// }
// if (element.name==='业务责任部门' || element.name?.toLowerCase()==='it责任部门') {
// return <SelectFilter
// loading={loadingDepartments}
// data={departments}
// disabled={element.manualMaintain==='否'}
// />
// }
if (element.name === '主题域分组') {
return (
<Select
......@@ -749,13 +733,23 @@ const AssetAction = (props) => {
}
if (element.selectMode==='单选') {
const tmp = (element.optional??'').split(',')
if ((tmp??[]).indexOf('部门列表')!==-1) {
return <DepartmentItem loading={loadingDepartments} departments={departments} />
}
if ((tmp??[]).indexOf('用户列表')!==-1) {
return <UserItem loading={loadingUsers} users={users} />
}
return (
<Select
allowClear
disabled={element.manualMaintain==='否'}
>
{
element.optional?.split(',').map((value, index) => {
tmp?.map((value, index) => {
return <Select.Option key={index} value={value}>
{value}
</Select.Option>
......@@ -779,15 +773,6 @@ const AssetAction = (props) => {
return <IndexCode value={item.value||''} terms={terms} />;
}
// if (item.name==='数据关键用户' || item.name?.toLowerCase()==='业务数据owner' || item.name?.toLowerCase()==='it责任人' || item.name==='创建人' || item.name==='更新人') {
// return <SelectUser
// type='detail'
// users={users}
// terms={terms}
// value={item.value||''}
// />
// }
return <span className='text-color'>{highlightSearchContentByTerms(item.value||'', terms)}</span>;
}
......@@ -850,20 +835,6 @@ const AssetAction = (props) => {
} else if (changedValues.hasOwnProperty('主题域')) {
setCurrentBussinessDomain(changedValues['主题域']);
form.setFieldsValue({'业务对象': ''});
} else if (changedValues.hasOwnProperty('业务数据Owner')) {
if (changedValues['业务数据Owner']) {
const index = (users||[]).findIndex(item => item.pernr === changedValues['业务数据Owner']);
if (index !== -1) {
form.setFieldsValue({'业务责任部门': users[index].orgtx});
}
}
} else if (changedValues.hasOwnProperty('IT责任人')) {
if (changedValues['IT责任人']) {
const index = (users||[]).findIndex(item => item.pernr === changedValues['IT责任人']);
if (index !== -1) {
form.setFieldsValue({'IT责任部门': users[index].orgtx});
}
}
}
}
......@@ -1216,4 +1187,92 @@ const CascaderItem = ({ value = null, data, onChange, ...restProps }) => {
{...restProps}
/>
)
}
\ No newline at end of file
}
const DepartmentItem = ({ loading, departments, value, onChange }) => {
const [searchValue, setSearchValue] = React.useState()
const [options, setOptions] = React.useState()
useDebounceEffect(() => {
setOptions(
(departments??[])
.filter(item => !searchValue || (item.organizationname??'').toLowerCase().indexOf(searchValue.toLowerCase())!==-1)
.map(item => ({
label: item.organizationname,
value: item.organizationname,
}))
)
}, [searchValue, departments], { wait: 300 })
return (
<Select loading={loading} showSearch allowClear
placeholder='请选择部门'
value={(options??[]).length>0?value:undefined}
searchValue={searchValue}
onSearch={(val) => {
setSearchValue(val)
}}
onClear={() => {
setSearchValue()
}}
filterOption={false}
options={options}
onChange={(val) => {
onChange?.(val)
}}
/>
)
}
const UserItem = ({ loading, users, value, onChange, readonly=false, terms = [] }) => {
const [searchValue, setSearchValue] = React.useState()
const [options, setOptions] = React.useState()
const userInfo = React.useMemo(() => {
if (value) {
const index = (users??[]).findIndex(item => item.username === value)
if (index !== -1) {
const currentUser = users[index]
return `${currentUser.username}(${currentUser.chinesename})`
}
}
return value
}, [value, users])
useDebounceEffect(() => {
setOptions(
(users??[])
.filter(item => !searchValue || (item.username??'').toLowerCase().indexOf(searchValue.toLowerCase())!==-1 || (item.chinesename??'').toLowerCase().indexOf(searchValue.toLowerCase())!==-1)
.map(item => ({
label: `${item.username}(${item.chinesename})`,
value: item.username,
}))
)
}, [searchValue, users], { wait: 300 })
return (
<React.Fragment>
{
readonly ? <Typography.Text>
{highlightSearchContentByTerms(userInfo, terms)}
</Typography.Text> : <Select loading={loading} showSearch allowClear
placeholder='请选择用户'
value={(options??[]).length>0?value:undefined}
searchValue={searchValue}
onSearch={(val) => {
setSearchValue(val)
}}
onClear={() => {
setSearchValue()
}}
filterOption={false}
options={options}
onChange={(val) => {
onChange?.(val)
}}
/>
}
</React.Fragment>
)
}
\ No newline at end of file
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