Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
W
wisdom-components
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
ReactWeb5
wisdom-components
Commits
45b11bfc
Commit
45b11bfc
authored
Mar 20, 2024
by
徐乐
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
perf: 修改设备树组件支持台账字段过滤
parent
bceea713
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
61 additions
and
6 deletions
+61
-6
index.js
...es/extend-components/EC_DeviceTreeGroup/src/apis/index.js
+8
-0
index.js
packages/extend-components/EC_DeviceTreeGroup/src/index.js
+53
-6
No files found.
packages/extend-components/EC_DeviceTreeGroup/src/apis/index.js
View file @
45b11bfc
...
@@ -12,3 +12,11 @@ export function getEquipmentInfo(data) {
...
@@ -12,3 +12,11 @@ export function getEquipmentInfo(data) {
data
,
data
,
});
});
}
}
export
function
GetFieldValueFromTable
(
params
)
{
return
request
({
url
:
`/PandaWorkFlow/WorkFlow/AccountManage/GetFieldValueFromTable`
,
method
:
REQUEST_METHOD_GET
,
params
:
params
,
});
}
packages/extend-components/EC_DeviceTreeGroup/src/index.js
View file @
45b11bfc
import
PropTypes
from
'prop-types'
;
import
PropTypes
from
'prop-types'
;
import
{
Input
,
Layout
,
Spin
,
Tree
,
ConfigProvider
,
Skeleton
}
from
'antd'
;
import
{
Input
,
Layout
,
Spin
,
Tree
,
ConfigProvider
,
Skeleton
,
Select
}
from
'antd'
;
// import { SearchOutlined } from '@ant-design/icons';
// import { SearchOutlined } from '@ant-design/icons';
import
React
,
{
useCallback
,
useEffect
,
useMemo
,
useRef
,
useState
,
useContext
}
from
'react'
;
import
React
,
{
useCallback
,
useEffect
,
useMemo
,
useRef
,
useState
,
useContext
}
from
'react'
;
import
PandaEmpty
from
'@wisdom-components/empty'
;
import
PandaEmpty
from
'@wisdom-components/empty'
;
import
classNames
from
'classnames'
;
import
classNames
from
'classnames'
;
import
_
from
'lodash'
;
import
_
from
'lodash'
;
import
{
getEquipmentInfo
}
from
'./apis'
;
import
{
getEquipmentInfo
,
GetFieldValueFromTable
}
from
'./apis'
;
import
'./index.less'
;
import
'./index.less'
;
import
classnames
from
'classnames'
;
// 生成树的数据格式
// 生成树的数据格式
const
treeDataGenerator
=
(
origin
,
currentType
,
ref
)
=>
{
const
treeDataGenerator
=
(
origin
,
currentType
,
ref
)
=>
{
...
@@ -101,7 +100,7 @@ const DeviceTree = (props) => {
...
@@ -101,7 +100,7 @@ const DeviceTree = (props) => {
const
prefixCls
=
getPrefixCls
(
'ec-device-tree-group'
);
const
prefixCls
=
getPrefixCls
(
'ec-device-tree-group'
);
const
cusProps
=
_
.
pick
(
props
,
[
'onSelect'
,
'onCheck'
,
'selectable'
,
'checkable'
]);
const
cusProps
=
_
.
pick
(
props
,
[
'onSelect'
,
'onCheck'
,
'selectable'
,
'checkable'
]);
const
{
onSelect
,
onCheck
,
keepChecked
,
singleType
=
false
,
selectable
,
checkable
}
=
props
;
const
{
onSelect
,
onCheck
,
keepChecked
,
singleType
=
false
,
selectable
,
checkable
,
filterName
}
=
props
;
const
[
data
,
setData
]
=
useState
([]);
const
[
data
,
setData
]
=
useState
([]);
const
[{
pageIndex
,
pageSize
},
setPagination
]
=
useState
({
const
[{
pageIndex
,
pageSize
},
setPagination
]
=
useState
({
...
@@ -111,6 +110,8 @@ const DeviceTree = (props) => {
...
@@ -111,6 +110,8 @@ const DeviceTree = (props) => {
const
[
searchs
,
setSearchs
]
=
useState
(
''
);
const
[
searchs
,
setSearchs
]
=
useState
(
''
);
const
[
loading
,
setLoading
]
=
useState
(
true
);
const
[
loading
,
setLoading
]
=
useState
(
true
);
const
[
hasMore
,
setHasMore
]
=
useState
(
true
);
const
[
hasMore
,
setHasMore
]
=
useState
(
true
);
const
[
filterFieldEntries
,
setFilterFieldEntries
]
=
useState
([]);
// "筛选字段"可选列表
const
[
filterValue
,
setFilterValue
]
=
useState
(
''
);
const
ref
=
useRef
();
const
ref
=
useRef
();
const
dataRef
=
useRef
({
const
dataRef
=
useRef
({
...
@@ -123,7 +124,24 @@ const DeviceTree = (props) => {
...
@@ -123,7 +124,24 @@ const DeviceTree = (props) => {
const
{
currentType
,
flatData
}
=
dataRef
.
current
;
const
{
currentType
,
flatData
}
=
dataRef
.
current
;
const
[
checkedKeys
,
setCheckedKeys
]
=
useState
([]);
const
[
checkedKeys
,
setCheckedKeys
]
=
useState
([]);
const
[
selectedKeys
,
setSelectedKeys
]
=
useState
([]);
const
[
selectedKeys
,
setSelectedKeys
]
=
useState
([]);
const
[
first
,
setFirst
]
=
useState
(
true
);
useEffect
(()
=>
{
if
(
filterName
)
{
let
device
=
deviceTypes
.
split
(
','
)[
0
];
GetFieldValueFromTable
({
tableName
:
'设备_台账_'
+
device
,
fieldName
:
filterName
,
})
.
then
((
res
)
=>
{
if
(
res
.
code
==
'0'
)
{
setFilterFieldEntries
(
res
.
data
);
}
})
.
catch
((
err
)
=>
{
setFilterFieldEntries
([]);
});
}
},
[
filterName
]);
const
requestQuery
=
useMemo
(()
=>
{
const
requestQuery
=
useMemo
(()
=>
{
return
{
return
{
...
@@ -138,6 +156,12 @@ const DeviceTree = (props) => {
...
@@ -138,6 +156,12 @@ const DeviceTree = (props) => {
classField
,
classField
,
direction
,
direction
,
customerName
,
customerName
,
queryWhereParams
:
[{
column
:
filterName
,
isString
:
true
,
matchingRule
:
"等于"
,
columnValue
:
filterValue
}]
};
};
},
[
},
[
customerName
,
customerName
,
...
@@ -149,6 +173,7 @@ const DeviceTree = (props) => {
...
@@ -149,6 +173,7 @@ const DeviceTree = (props) => {
searchs
,
searchs
,
sortFields
,
sortFields
,
classField
,
classField
,
filterValue
,
]);
]);
useEffect
(()
=>
{
useEffect
(()
=>
{
...
@@ -195,6 +220,10 @@ const DeviceTree = (props) => {
...
@@ -195,6 +220,10 @@ const DeviceTree = (props) => {
}
}
},
[
loading
,
pageIndex
,
pageSize
,
hasMore
]);
},
[
loading
,
pageIndex
,
pageSize
,
hasMore
]);
const
onChangeFilter
=
(
val
)
=>
{
setFilterValue
(
val
?
val
:
''
);
}
const
onSearch
=
useCallback
(
const
onSearch
=
useCallback
(
(
value
)
=>
{
(
value
)
=>
{
setSearchs
(
value
);
setSearchs
(
value
);
...
@@ -247,8 +276,26 @@ const DeviceTree = (props) => {
...
@@ -247,8 +276,26 @@ const DeviceTree = (props) => {
return
(
return
(
<
div
className
=
{
classNames
(
prefixCls
,
'wkt-scroll-light'
)}
>
<
div
className
=
{
classNames
(
prefixCls
,
'wkt-scroll-light'
)}
>
{
filterName
?
<
div
style
=
{{
display
:
'flex'
,
alignItems
:
'center'
,
marginBottom
:
'10px'
}}
>
<
div
>
{
filterName
}
:
<
/div
>
<
Select
style
=
{{
width
:
140
}}
placeholder
=
""
onChange
=
{
onChangeFilter
}
allowClear
=
{
true
}
>
{
filterFieldEntries
.
map
((
item
)
=>
(
<
Option
key
=
{
item
}
>
{
item
}
<
/Option
>
))}
<
/Select
>
<
/div
>
:
''
}
<
Input
.
Search
placeholder
=
"搜索设备名称"
onSearch
=
{
onSearch
}
allowClear
/>
<
Input
.
Search
placeholder
=
"搜索设备名称"
onSearch
=
{
onSearch
}
allowClear
/>
<
div
className
=
{
class
names
(
`
${
prefixCls
}
-tree-wrap`
,
'wkt-scroll-light-plus'
)
}
ref
=
{
ref
}
>
<
div
className
=
{
class
Names
(
`
${
prefixCls
}
-tree-wrap`
,
'wkt-scroll-light-plus'
)}
style
=
{{
height
:
filterName
?
'calc(100% - 90px)'
:
'calc(100% - 48px)'
}
}
ref
=
{
ref
}
>
{
/* <Spin spinning={loading}> */
}
{
/* <Spin spinning={loading}> */
}
{
loading
||
(
data
&&
data
.
length
)
?
(
{
loading
||
(
data
&&
data
.
length
)
?
(
<
Skeleton
loading
=
{
loading
}
active
>
<
Skeleton
loading
=
{
loading
}
active
>
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment