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
792058ca
Commit
792058ca
authored
Mar 09, 2021
by
涂茜
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat: 设备树组件
parent
5fcc38dc
Pipeline
#24228
failed with stages
in 10 seconds
Changes
7
Pipelines
1
Show whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
223 additions
and
1 deletion
+223
-1
.umirc.js
.umirc.js
+1
-1
README.md
packages/DeviceTree/README.md
+20
-0
package.json
packages/DeviceTree/package.json
+26
-0
DeviceTree.md
packages/DeviceTree/src/DeviceTree.md
+35
-0
Basic.js
packages/DeviceTree/src/demos/Basic.js
+91
-0
index.js
packages/DeviceTree/src/index.js
+41
-0
index.less
packages/DeviceTree/src/index.less
+9
-0
No files found.
.umirc.js
View file @
792058ca
...
...
@@ -107,7 +107,7 @@ export default {
},
{
title
:
'数据展示'
,
children
:
[
'
Empty
'
],
children
:
[
'
DeviceTree
'
],
},
],
},
...
...
packages/DeviceTree/README.md
0 → 100644
View file @
792058ca
# `@wisdom-components/DeviceTree`
> TODO: description
## Usage
```
const devicetree = require('@wisdom-components/DeviceTree');
// TODO: DEMONSTRATE API
```
## API
api 参考 Antd Tree 组件 https://ant.design/components/tree-cn/
| 参数 | 说明 | 类型 | 默认值 |
| --- | --- | --- | --- |
| treeData | treeNodes 数据,如果设置则不需要手动构造 TreeNode 节点(key 在整个树范围内唯一) | array
<
{
key
,
title
,
children
,
[
disabled
,
selectable
]}
>
| - |
| onSearch | 搜索框输入事件的回调,会返回搜索框输入信息 | function(value){ } | - |
packages/DeviceTree/package.json
0 → 100644
View file @
792058ca
{
"name"
:
"@wisdom-components/devicetree"
,
"version"
:
"1.0.1"
,
"description"
:
"> TODO: description"
,
"author"
:
"tuqian <webtuqian@163.com>"
,
"homepage"
:
""
,
"license"
:
"ISC"
,
"main"
:
"lib/index.js"
,
"directories"
:
{
"lib"
:
"lib"
,
"test"
:
"__tests__"
},
"files"
:
[
"lib"
],
"publishConfig"
:
{
"registry"
:
"https://g.civnet.cn:4873/"
},
"repository"
:
{
"type"
:
"git"
,
"url"
:
"https://g.civnet.cn:8443/ReactWeb5/wisdom-components.git"
},
"scripts"
:
{
"test"
:
"echo
\"
Error: run tests from root
\"
&& exit 1"
}
}
packages/DeviceTree/src/DeviceTree.md
0 → 100644
View file @
792058ca
---
title
:
DeviceTree - 设备树
nav
:
title
:
组件
path
:
/components
group
:
path
:
/
---
# DeviceTree 设备树
基础业务组件
-
允许单设备选择
-
允许多设备选择
-
允许搜索设备树
## 何时使用
-
在设备树选择时。
## 代码演示
<code
src=
"./demos/Basic.js"
>
## API
api 参考 Antd Tree 组件 https://ant.design/components/tree-cn/
| 参数 | 说明 | 类型 | 默认值 |
| --- | --- | --- | --- |
| prefix | 搜索框的前置图标 | ReactNode | 搜索 icon |
| placeholder | 搜索框占位符 | string | 搜索设备名称 |
| treeData | treeNodes 数据,如果设置则不需要手动构造 TreeNode 节点(key 在整个树范围内唯一) | array
<
{
key
,
title
,
children
,
[
disabled
,
selectable
]}
>
| - |
| onSearch | 搜索框输入事件的回调,会返回搜索框输入信息 | function(value){ } | - |
packages/DeviceTree/src/demos/Basic.js
0 → 100644
View file @
792058ca
import
React
,
{
useEffect
,
useState
}
from
'react'
;
import
PandaDeviceTree
from
'../index'
;
import
request
from
'umi-request'
;
const
Demo
=
()
=>
{
const
[
treeData
,
setTreeData
]
=
useState
([]);
const
[
expandedKeys
,
setExpandedKeys
]
=
useState
(
null
);
const
[
checkedKeys
,
setCheckedKeys
]
=
useState
([]);
const
[
selectedKeys
,
setSelectedKeys
]
=
useState
([]);
const
[
autoExpandParent
,
setAutoExpandParent
]
=
useState
(
true
);
const
fetchData
=
(
params
=
{})
=>
{
request
(
baseUrl
+
'/Publish/Monitor/Device/DeviceTree'
,
{
method
:
'post'
,
data
:
{
PageIndex
:
1
,
PageSize
:
500
,
deviceTypes
:
'二供泵房,二供机组'
,
getChild
:
true
,
userID
:
1
,
queryInfo
:
params
.
queryInfo
||
''
,
sortFields
:
''
,
direction
:
''
,
isTop
:
true
,
},
}).
then
(
function
(
response
)
{
let
data
=
response
.
data
?
response
.
data
.
list
&&
response
.
data
.
list
.
length
>
0
?
response
.
data
.
list
[
0
].
DeviceList
:
[]
:
[];
setTreeData
(
handleData
(
data
));
});
};
const
handleData
=
(
data
)
=>
{
data
.
map
((
item
)
=>
{
item
.
title
=
item
.
DeviceName
;
item
.
key
=
item
.
StationID
;
item
.
children
=
handleData
(
item
.
children
);
});
return
data
;
};
useEffect
(()
=>
{
fetchData
();
},
[]);
const
onExpand
=
(
expandedKeysValue
)
=>
{
console
.
log
(
'onExpand'
,
expandedKeysValue
);
setExpandedKeys
(
expandedKeysValue
);
setAutoExpandParent
(
false
);
};
const
onCheck
=
(
checkedKeysValue
)
=>
{
console
.
log
(
'onCheck'
,
checkedKeysValue
);
setCheckedKeys
(
checkedKeysValue
);
};
const
onSelect
=
(
selectedKeysValue
,
info
)
=>
{
console
.
log
(
'onSelect'
,
info
);
setSelectedKeys
(
selectedKeysValue
);
};
const
onSearch
=
(
e
)
=>
{
if
(
e
.
type
==
'keydown'
)
{
fetchData
({
queryInfo
:
e
.
target
.
value
});
}
console
.
log
(
e
.
type
,
'e.type'
);
console
.
log
(
e
.
target
.
value
,
'e.target.value'
);
};
return
(
<
PandaDeviceTree
onSearch
=
{
onSearch
}
checkable
onExpand
=
{
onExpand
}
expandedKeys
=
{
expandedKeys
}
autoExpandParent
=
{
autoExpandParent
}
onCheck
=
{
onCheck
}
checkedKeys
=
{
checkedKeys
}
onSelect
=
{
onSelect
}
selectedKeys
=
{
selectedKeys
}
treeData
=
{
treeData
}
/
>
);
};
export
default
Demo
;
const
baseUrl
=
'http://192.168.10.150:8777'
;
packages/DeviceTree/src/index.js
0 → 100644
View file @
792058ca
import
React
from
'react'
;
import
PropTypes
from
'prop-types'
;
import
{
Input
,
Divider
,
Tree
}
from
'antd'
;
import
{
SearchOutlined
}
from
'@ant-design/icons'
;
import
Empty
from
'@wisdom-components/Empty'
;
import
styles
from
'./index.less'
;
const
DeviceTree
=
(
props
)
=>
{
const
{
prefix
,
placeholder
,
treeData
,
onSearch
}
=
props
;
return
(
<
div
className
=
{
styles
.
DeviceTree
}
>
<
Input
prefix
=
{
prefix
}
placeholder
=
{
placeholder
}
bordered
=
{
false
}
onChange
=
{
onSearch
}
onPressEnter
=
{
onSearch
}
/
>
<
Divider
/>
{
!!
treeData
.
length
&&
<
Tree
{...
props
}
/>
}
{
!
treeData
.
length
&&
<
Empty
/>
}
<
/div
>
);
};
DeviceTree
.
defaultProps
=
{
prefix
:
<
SearchOutlined
/>
,
placeholder
:
'搜索设备名称'
,
treeData
:
[],
onSearch
:
()
=>
{},
};
DeviceTree
.
propTypes
=
{
prefix
:
PropTypes
.
node
,
placeholder
:
PropTypes
.
string
,
treeData
:
PropTypes
.
array
,
onSearch
:
PropTypes
.
func
,
};
export
default
DeviceTree
;
packages/DeviceTree/src/index.less
0 → 100644
View file @
792058ca
.DeviceTree {
padding: 5px;
:global {
.ant-divider {
margin: 6px 0 12px 0;
}
}
}
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