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
624cb4c1
Commit
624cb4c1
authored
Nov 26, 2020
by
陈前坚
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
perf: dictionary
parent
945c34ea
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
159 additions
and
18 deletions
+159
-18
WebDic.js
src/pages/platformCenter/dictionary/WebDic.js
+154
-16
WebDic.less
src/pages/platformCenter/dictionary/WebDic.less
+5
-2
No files found.
src/pages/platformCenter/dictionary/WebDic.js
View file @
624cb4c1
...
...
@@ -12,15 +12,17 @@ import {
}
from
'antd'
;
import
{
get
}
from
'@/services/index'
;
import
styles
from
'./WebDic.less'
;
import
AddForm
from
'@/pages/webConfig/menuconfig/AddForm'
;
const
WebDic
=
()
=>
{
const
[
loading
,
setLoading
]
=
useState
(
false
);
const
[
level
,
setLevel
]
=
useState
(
1
);
const
[
addVisible
,
setAddVisible
]
=
useState
(
false
);
const
[
editVisible
,
setEditVisible
]
=
useState
(
false
);
// const [editValue, setEditValue] = useState('');
// const [description, setDescription] = useState('');
const
[
data
,
setData
]
=
useState
([]);
const
[
subData
,
setSubData
]
=
useState
([]);
const
[
select
,
setSelect
]
=
useState
({});
const
[
data
,
setData
]
=
useState
([]);
// 一级条目
const
[
subData
,
setSubData
]
=
useState
([]);
// 二级条目
const
[
select
,
setSelect
]
=
useState
({});
// 当前选中条目
const
[
addForm
]
=
Form
.
useForm
();
const
[
editForm
]
=
Form
.
useForm
();
const
columns
=
[
...
...
@@ -34,6 +36,12 @@ const WebDic = () => {
title
:
'值'
,
dataIndex
:
'nodeValue'
,
key
:
'nodeValue'
,
render
:
record
=>
{
if
(
!
record
)
{
return
'-'
;
}
return
record
;
},
},
{
title
:
'操作'
,
...
...
@@ -61,7 +69,7 @@ const WebDic = () => {
title
=
"是否删除该数据?"
okText
=
"确认"
cancelText
=
"取消"
//
onConfirm={submitDelete}
onConfirm
=
{
submitDelete
}
>
<
Button
size
=
"small"
...
...
@@ -91,13 +99,14 @@ const WebDic = () => {
key
:
''
,
})
.
then
(
res
=>
{
if
(
res
.
length
>
0
)
{
if
(
res
&&
res
.
length
>
0
)
{
res
.
map
(
item
=>
{
item
.
key
=
item
.
nodeID
;
return
item
;
});
if
(
value
===
'-1'
)
{
setData
(
res
);
// 设置一级条目
setSelect
(
res
[
0
]);
// 默认当前选中一级条目第一条
}
else
if
(
value
)
{
setSubData
(
res
);
// 设置二级条目
}
...
...
@@ -121,13 +130,104 @@ const WebDic = () => {
const
setRowClassName
=
record
=>
record
.
nodeID
===
select
.
nodeID
?
styles
.
clickRowStyle
:
''
;
// 提交-添加
const
submitAdd
=
value
=>
{
const
nodeName
=
addForm
.
getFieldValue
(
'nodeName'
);
const
nodeValue
=
addForm
.
getFieldValue
(
'nodeValue'
);
get
(
`/Cityinterface/rest/services/OMS.svc/D_AddDataDictionary`
,
{
_version
:
9999
,
_dc
:
new
Date
().
getTime
(),
nodeID
:
value
,
nodeName
,
nodeValue
,
})
.
then
(
res
=>
{
if
(
res
.
success
)
{
setAddVisible
(
false
);
getData
(
'-1'
);
notification
.
success
({
message
:
'提交成功'
,
});
}
else
{
notification
.
error
({
message
:
'提交失败'
,
description
:
res
.
message
,
});
}
})
.
catch
(
err
=>
{
message
.
error
(
err
);
});
};
// 提交-编辑
const
submitEdit
=
()
=>
{
const
nodeName
=
editForm
.
getFieldValue
(
'nodeName'
);
const
nodeValue
=
editForm
.
getFieldValue
(
'nodeValue'
);
get
(
`/Cityinterface/rest/services/OMS.svc/D_EditDataDictionary`
,
{
_version
:
9999
,
_dc
:
new
Date
().
getTime
(),
nodeID
:
select
.
nodeID
,
nodeName
,
nodeValue
,
})
.
then
(
res
=>
{
if
(
res
.
success
)
{
setEditVisible
(
false
);
getData
(
select
.
parentID
);
notification
.
success
({
message
:
'提交成功'
,
});
}
else
{
notification
.
error
({
message
:
'提交失败'
,
description
:
res
.
message
,
});
}
})
.
catch
(
err
=>
{
message
.
error
(
err
);
});
};
const
submitDelete
=
()
=>
{
get
(
`/Cityinterface/rest/services/OMS.svc/D_DeleteDataDictionary`
,
{
_version
:
9999
,
_dc
:
new
Date
().
getTime
(),
nodeID
:
select
.
nodeID
,
})
.
then
(
res
=>
{
if
(
res
.
success
)
{
getData
(
select
.
parentID
);
notification
.
success
({
message
:
'删除成功'
,
});
}
else
{
notification
.
error
({
message
:
'删除失败'
,
description
:
res
.
message
,
});
}
})
.
catch
(
err
=>
{
message
.
error
(
err
);
});
};
return
(
<
div
className
=
{
styles
.
WebDic
}
>
<
div
style
=
{{
marginBottom
:
'10px'
,
fontSize
:
'16px'
}}
>
<
span
style
=
{{
padding
:
'0 10px'
}}
>
一级条目
<
/span
>
<
Button
type
=
"primary"
size
=
"small"
onClick
=
{()
=>
{
setLevel
(
1
);
setAddVisible
(
true
);
}}
>
添加
<
/Button
>
<
/div
>
<
Table
size
=
"small"
bordered
...
...
@@ -149,6 +249,20 @@ const WebDic = () => {
showSizeChanger
:
true
,
}}
/
>
<
hr
color
=
"#cfe7fd"
/>
<
div
style
=
{{
marginBottom
:
'10px'
,
fontSize
:
'16px'
}}
>
<
span
style
=
{{
padding
:
'0 10px'
}}
>
二级条目
<
/span
>
<
Button
type
=
"primary"
size
=
"small"
onClick
=
{()
=>
{
setLevel
(
2
);
setAddVisible
(
true
);
}}
>
添加
<
/Button
>
<
/div
>
<
Table
size
=
"small"
bordered
...
...
@@ -163,6 +277,36 @@ const WebDic = () => {
showSizeChanger
:
true
,
}}
/
>
{
/* 添加 */
}
<
Modal
title
=
{
level
===
1
?
'添加一级条目'
:
'添加二级条目'
}
visible
=
{
addVisible
}
onOk
=
{()
=>
{
if
(
level
===
1
)
{
submitAdd
(
'-1'
);
}
else
{
// submitAdd(select.nodeID);
}
}}
onCancel
=
{()
=>
{
setAddVisible
(
false
);
}}
okText
=
"确认"
cancelText
=
"取消"
>
<
Form
form
=
{
addForm
}
labelCol
=
{{
span
:
3
}}
>
<
Form
.
Item
name
=
"nodeName"
label
=
"名称"
rules
=
{[{
required
:
true
,
message
:
'不能为空'
}]}
>
<
Input
placeholder
=
"请输入名称"
/>
<
/Form.Item
>
<
Form
.
Item
name
=
"nodeValue"
label
=
"值"
>
<
Input
placeholder
=
"请输入值"
/>
<
/Form.Item
>
<
/Form
>
<
/Modal
>
{
/* 修改 */
}
<
Modal
title
=
{
select
.
parentID
===
'-1'
?
'修改一级条目'
:
'修改二级条目'
}
...
...
@@ -182,15 +326,9 @@ const WebDic = () => {
>
<
Input
placeholder
=
"请输入名称"
/>
<
/Form.Item
>
{
select
.
nodeID
!==
'-1'
&&
(
<
Form
.
Item
name
=
"nodeValue"
label
=
"值"
rules
=
{[{
required
:
true
,
message
:
'不能为空'
}]}
>
<
Input
placeholder
=
"请输入值"
/>
<
/Form.Item
>
)}
<
Form
.
Item
name
=
"nodeValue"
label
=
"值"
>
<
Input
placeholder
=
"请输入值"
/>
<
/Form.Item
>
<
/Form
>
<
/Modal
>
<
/div
>
...
...
src/pages/platformCenter/dictionary/WebDic.less
View file @
624cb4c1
...
...
@@ -13,11 +13,13 @@
}
.ant-table-tbody{
.clickRowStyle{
background: #
74bafc
;
background: #
cfe7fd
;
}
.clickRowStyle:hover>td{
background: #aed8fa;
}
}
.ant-card-body{
padding: 10px !important;
}
}
\ No newline at end of file
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