Commit 057deff0 authored by 田翔's avatar 田翔

fix: 增加人员机构显示

parent 9ad10e6f
{
"name": "panda-xform",
"version": "6.0.7",
"description": "6.0.7 上传空文件禁止上传",
"version": "6.0.8",
"description": "6.0.8 增加人员机构显示",
"keywords": [
"panda-xform"
],
......
......@@ -9,6 +9,24 @@ const UserSelect = (props) => {
const { disabled, presetValue, isMultiple, placeholder, role, isStoreID, isMySite } = schema
const property = isStoreID ? 'userID' : 'userName'
const [pullDown, setPullDown] = useState([])
const [searchValue, setSearchValue] = useState('')
const options = useMemo(() => {
let array = []
pullDown.forEach(v => {
if (searchValue) {
if (v?.label?.includes(searchValue)) {
array.push(v)
}
} else {
array.push(v)
}
})
if (array.length > 200) {
return array.slice(0, 199)
}
return array
}, [pullDown, searchValue])
const valueShow = useMemo(() => {
if (isMultiple) {
......@@ -17,12 +35,16 @@ const UserSelect = (props) => {
return value || null
}, [value, isMultiple])
const onSearch = (value) => {
setSearchValue(value)
}
const selectFocus = async () => {
let time = new Date().getTime() + Math.random()
const { code, data, msg } = await getUserSelector(role, isMySite ? userID : false, time)
if (code === 0) {
if (data) {
setPullDown(data.dropdownList.map(v => { return { label: v.userName, value: v[property] } }))
setPullDown(data.dropdownList.map(v => { return { label: v.userName, value: v[property], groupName: v.groupName } }))
} else {
setPullDown([])
}
......@@ -51,6 +73,8 @@ const UserSelect = (props) => {
}
}, [])
console.log('options', options)
return (
<Select
mode={isMultiple ? 'multiple' : null}
......@@ -59,12 +83,25 @@ const UserSelect = (props) => {
disabled={disabled}
showArrow={!disabled}
showSearch={true}
onSearch={onSearch}
searchValue={searchValue}
style={{ width: '100%' }}
onFocus={selectFocus}
onChange={selectChange}
options={pullDown}
// getPopupContainer={(targterNode) => targterNode.parentElement || document.body}
>
{
options.map((v, i) => {
let length = v.groupName?.length
return (
<Select.Option key={v.value + i} value={v.value}>
<div style={{ display: 'flex', justifyContent: 'space-between' }}>
<span>{v.label}</span>
<span style={{ fontSize: '12px', color: '#b4b1b1', }}>{v.groupName?.length > 20 ? `...${v.groupName.slice(v.groupName.length - 20, length)}` : v.groupName}</span>
</div>
</Select.Option>
)
})
}
</Select>
)
......
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