Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
C
CivManage
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
CivManage
Commits
f889c07f
Commit
f889c07f
authored
Nov 30, 2020
by
陈前坚
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
perf: dictionary
parent
61e4e69a
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
20 additions
and
25 deletions
+20
-25
WebDic.js
src/pages/platformCenter/dictionary/WebDic.js
+20
-25
No files found.
src/pages/platformCenter/dictionary/WebDic.js
View file @
f889c07f
...
...
@@ -18,13 +18,13 @@ import styles from './WebDic.less';
const
WebDic
=
()
=>
{
const
[
loading
,
setLoading
]
=
useState
(
false
);
const
[
level
,
setLevel
]
=
useState
(
0
);
// 设置
基本
,一级1,二级2
const
[
level
,
setLevel
]
=
useState
(
0
);
// 设置
级别
,一级1,二级2
const
[
addVisible
,
setAddVisible
]
=
useState
(
false
);
const
[
editVisible
,
setEditVisible
]
=
useState
(
false
);
const
[
data
,
setData
]
=
useState
([]);
// 一级条目
const
[
subData
,
setSubData
]
=
useState
([]);
// 二级条目
const
[
select
,
setSelect
]
=
useState
({});
// 当前选中
一级条目,
修改/删除时设置
const
[
s
ubSelect
,
setSubSelect
]
=
useState
({});
// 当前选中二级条目
,修改/删除时设置
const
[
select
,
setSelect
]
=
useState
({});
// 当前选中
条目,可以是一级/二级,
修改/删除时设置
const
[
s
electColor
,
setSelectColor
]
=
useState
({});
// 当前选中一级条目颜色
,修改/删除时设置
const
[
selectID
,
setSelectID
]
=
useState
(
'-1'
);
// 当前选中一级条目的ID,添加二级条目时使用
const
[
first
,
setFirst
]
=
useState
(
true
);
// 是否第一次加载
const
[
addForm
]
=
Form
.
useForm
();
...
...
@@ -59,10 +59,9 @@ const WebDic = () => {
size
=
"small"
onClick
=
{
e
=>
{
e
.
stopPropagation
();
setSelect
(
record
);
if
(
record
.
parentID
===
'-1'
)
{
setSelect
(
record
);
}
else
{
setSubSelect
(
record
);
setSelectColor
(
record
);
}
setEditVisible
(
true
);
editForm
.
setFieldsValue
({
...
...
@@ -84,10 +83,9 @@ const WebDic = () => {
danger
onClick
=
{
e
=>
{
e
.
stopPropagation
();
setSelect
(
record
);
if
(
record
.
parentID
===
'-1'
)
{
setSelect
(
record
);
}
else
{
setSubSelect
(
record
);
setSelectColor
(
record
);
}
}}
>
...
...
@@ -132,12 +130,6 @@ const WebDic = () => {
getData
(
res
[
0
].
nodeID
);
}
}
// if (level === 0) {
// setSelect(res[0]); // 默认当前选中一级条目第一条
// setSelectID(res[0].nodeID); // 设置选中的一级条目ID,用于添加二级条目
// } else if (level === 1) {
// setSelect({ nodeID: value2 });
// }
}
else
if
(
value
)
{
setSubData
(
res
);
// 设置二级条目,res为空[]时也要设置
}
...
...
@@ -155,7 +147,7 @@ const WebDic = () => {
});
};
const
setRowClassName
=
record
=>
record
.
nodeID
===
select
.
nodeID
?
styles
.
clickRowStyle
:
''
;
record
.
nodeID
===
select
Color
.
nodeID
?
styles
.
clickRowStyle
:
''
;
// 提交-添加
const
submitAdd
=
value
=>
{
...
...
@@ -174,8 +166,13 @@ const WebDic = () => {
setAddVisible
(
false
);
if
(
level
===
1
)
{
getData
(
'-1'
);
getData
(
res
.
message
);
// res.message为添加成功返回的一级条目ID
// 设置添加二级条目的父级ID及父级ID选中状态
setSelect
({
nodeID
:
res
.
message
,
parentID
:
'-1'
});
setSelectID
(
res
.
message
);
setSelectColor
({
nodeID
:
res
.
message
});
}
else
{
getData
(
selectID
);
getData
(
value
);
}
notification
.
success
({
message
:
'提交成功'
,
...
...
@@ -201,17 +198,11 @@ const WebDic = () => {
const
submitEdit
=
()
=>
{
const
nodeName1
=
editForm
.
getFieldValue
(
'nodeName1'
);
const
nodeValue
=
editForm
.
getFieldValue
(
'nodeValue'
);
let
nodeID
=
''
;
if
(
select
.
parentID
===
'-1'
)
{
nodeID
=
{
...
select
};
}
else
{
nodeID
=
{
...
subSelect
};
}
if
(
nodeName1
)
{
get
(
`/Cityinterface/rest/services/OMS.svc/D_EditDataDictionary`
,
{
_version
:
9999
,
_dc
:
new
Date
().
getTime
(),
nodeID
,
nodeID
:
select
.
nodeID
,
nodeName
:
nodeName1
,
nodeValue
,
})
...
...
@@ -248,6 +239,10 @@ const WebDic = () => {
})
.
then
(
res
=>
{
if
(
res
.
success
)
{
// 删除一级条目时要重新设置first为true,默认并选中一级条目第一条纪录
if
(
select
.
parentID
===
'-1'
)
{
// setFirst(true);
}
getData
(
select
.
parentID
);
notification
.
success
({
message
:
'删除成功'
,
...
...
@@ -300,7 +295,7 @@ const WebDic = () => {
onClick
:
()
=>
{
getData
(
record
.
nodeID
);
setSelect
(
record
);
//
setSelectColor(record);
setSelectColor
(
record
);
setSelectID
(
record
.
nodeID
);
},
})}
...
...
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