Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
S
szse
Overview
Overview
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
zhaochengxiang
szse
Commits
af362a02
Commit
af362a02
authored
Apr 06, 2021
by
zhaochengxiang
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
修改目录问题
parent
2c3406e1
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
117 additions
and
41 deletions
+117
-41
ImportAction.jsx
src/view/Manage/Model/Component/ImportAction.jsx
+1
-1
ImportActionTable.jsx
src/view/Manage/Model/Component/ImportActionTable.jsx
+26
-8
ModelTree.jsx
src/view/Manage/Model/Component/ModelTree.jsx
+23
-14
UpdateTreeItemModal.jsx
src/view/Manage/Model/Component/UpdateTreeItemModal.jsx
+67
-18
No files found.
src/view/Manage/Model/Component/ImportAction.jsx
View file @
af362a02
...
@@ -101,7 +101,7 @@ const ImportAction = (props) => {
...
@@ -101,7 +101,7 @@ const ImportAction = (props) => {
{
{
(
constraints
||
[]).
map
((
constraint
,
index
)
=>
{
(
constraints
||
[]).
map
((
constraint
,
index
)
=>
{
return
(
return
(
<
Option
key=
{
index
}
value=
{
constraint
.
id
}
>
{
constraint
.
n
ame
||
''
}
</
Option
>
<
Option
key=
{
index
}
value=
{
constraint
.
id
}
>
{
constraint
.
cnN
ame
||
''
}
</
Option
>
)
)
})
})
}
}
...
...
src/view/Manage/Model/Component/ImportActionTable.jsx
View file @
af362a02
...
@@ -13,7 +13,7 @@ const type = 'DragableTableBodyRow';
...
@@ -13,7 +13,7 @@ const type = 'DragableTableBodyRow';
const
DatatypeInput
=
({
value
=
{},
datatypes
,
onChange
})
=>
{
const
DatatypeInput
=
({
value
=
{},
datatypes
,
onChange
})
=>
{
const
[
name
,
setName
]
=
useState
(
value
.
name
||
''
);
const
[
name
,
setName
]
=
useState
(
value
.
name
||
''
);
const
[
parameter
Names
,
setParameterNames
]
=
useState
(
value
.
parameter
Names
||
[]);
const
[
parameter
CnNames
,
setParameterCnNames
]
=
useState
(
value
.
parameterCn
Names
||
[]);
const
[
parameterValues
,
setParameterValues
]
=
useState
(
value
.
parameterValues
||
[]);
const
[
parameterValues
,
setParameterValues
]
=
useState
(
value
.
parameterValues
||
[]);
const
onNameChange
=
(
value
)
=>
{
const
onNameChange
=
(
value
)
=>
{
...
@@ -26,12 +26,14 @@ const DatatypeInput = ({ value = {}, datatypes, onChange }) => {
...
@@ -26,12 +26,14 @@ const DatatypeInput = ({ value = {}, datatypes, onChange }) => {
}
}
})
})
setParameter
Names
(
currentDatatype
.
parameter
Names
);
setParameter
CnNames
(
currentDatatype
.
parameterCn
Names
);
setParameterValues
(
currentDatatype
.
parameterValues
);
setParameterValues
(
currentDatatype
.
parameterValues
);
triggerChange
({
triggerChange
({
name
:
value
,
name
:
value
,
cnName
:
currentDatatype
.
cnName
,
parameterNames
:
currentDatatype
.
parameterNames
,
parameterNames
:
currentDatatype
.
parameterNames
,
parameterCnNames
:
currentDatatype
.
parameterCnNames
,
parameterValues
:
currentDatatype
.
parameterValues
parameterValues
:
currentDatatype
.
parameterValues
});
});
}
}
...
@@ -40,7 +42,8 @@ const DatatypeInput = ({ value = {}, datatypes, onChange }) => {
...
@@ -40,7 +42,8 @@ const DatatypeInput = ({ value = {}, datatypes, onChange }) => {
const
newParameterValues
=
[...
parameterValues
];
const
newParameterValues
=
[...
parameterValues
];
newParameterValues
[
index
]
=
value
;
//默认为0
newParameterValues
[
index
]
=
value
||
0
;
setParameterValues
(
newParameterValues
);
setParameterValues
(
newParameterValues
);
triggerChange
({
parameterValues
:
newParameterValues
});
triggerChange
({
parameterValues
:
newParameterValues
});
}
}
...
@@ -67,7 +70,7 @@ const DatatypeInput = ({ value = {}, datatypes, onChange }) => {
...
@@ -67,7 +70,7 @@ const DatatypeInput = ({ value = {}, datatypes, onChange }) => {
{
{
(
datatypes
||
[])
&&
datatypes
.
map
((
_datatype
,
index
)
=>
{
(
datatypes
||
[])
&&
datatypes
.
map
((
_datatype
,
index
)
=>
{
return
(
return
(
<
Option
key=
{
_datatype
.
name
||
''
}
>
{
_datatype
.
n
ame
||
''
}
</
Option
>
<
Option
key=
{
_datatype
.
name
||
''
}
>
{
_datatype
.
cnN
ame
||
''
}
</
Option
>
);
);
})
})
}
}
...
@@ -75,11 +78,11 @@ const DatatypeInput = ({ value = {}, datatypes, onChange }) => {
...
@@ -75,11 +78,11 @@ const DatatypeInput = ({ value = {}, datatypes, onChange }) => {
</
Col
>
</
Col
>
</
Row
>
</
Row
>
{
{
(
parameter
Names
||
[]).
map
((
parameter
Name
,
index
)
=>
{
(
parameter
CnNames
||
[]).
map
((
parameterCn
Name
,
index
)
=>
{
return
(
return
(
<
Row
key=
{
index
}
className=
'mt-2'
align=
'middle'
>
<
Row
key=
{
index
}
className=
'mt-2'
align=
'middle'
>
<
Col
span=
{
12
}
>
<
Col
span=
{
12
}
>
<
span
>
{
`${parameterName||''}:`
}
</
span
>
<
span
>
{
`${parameter
Cn
Name||''}:`
}
</
span
>
</
Col
>
</
Col
>
<
Col
span=
{
12
}
>
<
Col
span=
{
12
}
>
<
InputNumber
<
InputNumber
...
@@ -268,7 +271,13 @@ const ImportActionTable = (props) => {
...
@@ -268,7 +271,13 @@ const ImportActionTable = (props) => {
const
save
=
async
()
=>
{
const
save
=
async
()
=>
{
try
{
try
{
const
row
=
await
form
.
validateFields
();
const
row
=
await
form
.
validateFields
();
console
.
log
(
'row'
,
row
);
(
row
.
datatype
.
parameterNames
||
[]).
forEach
((
parameterName
,
index
)
=>
{
if
(
!
row
.
datatype
.
parameterValues
[
index
])
{
row
.
datatype
.
parameterValues
[
index
]
=
0
;
}
})
// console.log('row', row);
const
newData
=
[...
data
];
const
newData
=
[...
data
];
const
index
=
newData
.
findIndex
((
item
)
=>
editingKey
===
item
.
iid
);
const
index
=
newData
.
findIndex
((
item
)
=>
editingKey
===
item
.
iid
);
...
@@ -341,7 +350,16 @@ const ImportActionTable = (props) => {
...
@@ -341,7 +350,16 @@ const ImportActionTable = (props) => {
dataIndex
:
'datatype'
,
dataIndex
:
'datatype'
,
editable
:
true
,
editable
:
true
,
render
:
(
datatype
,
record
,
index
)
=>
{
render
:
(
datatype
,
record
,
index
)
=>
{
return
datatype
?(
datatype
.
name
||
''
):
''
;
let
_text
=
''
;
if
(
datatype
)
{
_text
=
datatype
.
cnName
||
''
;
(
datatype
.
parameterCnNames
||
[]).
forEach
((
cnName
,
index
)
=>
{
_text
+=
' '
+
cnName
+
':'
+
(
datatype
.
parameterValues
[
index
]?
datatype
.
parameterValues
[
index
]:
0
);
})
}
return
_text
;
}
}
},
},
{
{
...
...
src/view/Manage/Model/Component/ModelTree.jsx
View file @
af362a02
...
@@ -15,6 +15,7 @@ const ModelTree = (props) => {
...
@@ -15,6 +15,7 @@ const ModelTree = (props) => {
const
[
item
,
setItem
]
=
useState
(
null
);
const
[
item
,
setItem
]
=
useState
(
null
);
const
[
visible
,
setVisible
]
=
useState
(
false
);
const
[
visible
,
setVisible
]
=
useState
(
false
);
const
[
type
,
setType
]
=
useState
(
null
);
const
[
type
,
setType
]
=
useState
(
null
);
const
[
rootId
,
setRootId
]
=
useState
(
''
);
const
[
modal
,
contextHolder
]
=
Modal
.
useModal
();
const
[
modal
,
contextHolder
]
=
Modal
.
useModal
();
...
@@ -48,14 +49,23 @@ const ModelTree = (props) => {
...
@@ -48,14 +49,23 @@ const ModelTree = (props) => {
recursion
(
data
.
subCatalogs
);
recursion
(
data
.
subCatalogs
);
setLoading
(
false
);
setLoading
(
false
);
setTreeData
([
data
||
{}
]);
setTreeData
(
data
.
subCatalogs
||
[]);
setItem
(
data
);
setRootId
(
data
.
id
||
''
);
onSelect
&&
onSelect
(
data
.
key
||
''
);
const
firstItem
=
(
data
.
subCatalogs
||
[]).
length
>
0
?
data
.
subCatalogs
[
0
]:
null
;
setItem
(
firstItem
);
firstItem
&&
onSelect
&&
onSelect
(
firstItem
.
key
||
''
);
}
}
})
})
}
}
const
onTreeSelect
=
(
keys
,
data
)
=>
{
const
onTreeSelect
=
(
keys
,
data
)
=>
{
if
((
keys
||
[]).
length
===
0
)
{
return
;
}
const
_item
=
{...
data
.
selectedNodes
[
0
]
||
[]};
const
_item
=
{...
data
.
selectedNodes
[
0
]
||
[]};
setItem
(
_item
);
setItem
(
_item
);
...
@@ -159,22 +169,21 @@ const ModelTree = (props) => {
...
@@ -159,22 +169,21 @@ const ModelTree = (props) => {
<
div
<
div
className=
'p-3'
className=
'p-3'
>
>
{
<
Spin
spinning=
{
loading
}
>
loading
?
<
Spin
/>
:
(
<
Tree
<
Tree
showLine
showLine
showIcon=
{
false
}
showIcon=
{
false
}
onSelect=
{
onTreeSelect
}
onSelect=
{
onTreeSelect
}
treeData=
{
treeData
}
treeData=
{
treeData
}
selectedKeys=
{
[
item
?
item
.
key
:
''
]
}
selectedKeys=
{
[
item
?
item
.
key
:
''
]
}
/>
/>
</
Spin
>
)
}
</
div
>
</
div
>
<
UpdateTreeItemModal
<
UpdateTreeItemModal
visible=
{
visible
}
visible=
{
visible
}
type=
{
type
}
type=
{
type
}
item=
{
item
}
item=
{
item
}
rootId=
{
rootId
}
onOk=
{
onUpdateTreeItemModalOk
}
onOk=
{
onUpdateTreeItemModalOk
}
onCancel=
{
onUpdateTreeItemModalCancel
}
onCancel=
{
onUpdateTreeItemModalCancel
}
/>
/>
...
...
src/view/Manage/Model/Component/UpdateTreeItemModal.jsx
View file @
af362a02
import
React
,
{
useState
}
from
'react'
;
import
React
,
{
useState
,
useEffect
}
from
'react'
;
import
{
Modal
,
Form
,
Input
}
from
'antd'
;
import
{
Modal
,
Form
,
Input
,
Radio
}
from
'antd'
;
import
{
dispatchLatest
}
from
'../../../../model'
;
import
{
dispatchLatest
}
from
'../../../../model'
;
class
UpdateTreeItemForm
extends
React
.
Component
{
class
UpdateTreeItemForm
extends
React
.
Component
{
constructor
(
props
){
super
(
props
);
this
.
state
=
{
radioDisable
:
false
}
}
componentDidMount
()
{
this
.
radioState
();
}
componentDidUpdate
(
preProps
,
preState
)
{
componentDidUpdate
(
preProps
,
preState
)
{
const
{
for
m
}
=
this
.
props
;
const
{
ite
m
}
=
this
.
props
;
if
(
form
&&
form
.
resetFields
)
{
if
(
item
!==
preProps
.
item
)
{
form
.
resetFields
([
'name'
,
'remark'
])
this
.
radioState
();
}
}
}
}
radioState
=
()
=>
{
const
{
item
}
=
this
.
props
;
this
.
setState
({
radioDisable
:
item
?
false
:
true
})
}
render
()
{
render
()
{
const
{
item
,
type
,
form
}
=
this
.
props
;
const
{
type
,
form
}
=
this
.
props
;
const
{
radioDisable
}
=
this
.
state
;
const
formItemLayout
=
{
const
formItemLayout
=
{
labelCol
:
{
labelCol
:
{
...
@@ -30,14 +47,15 @@ class UpdateTreeItemForm extends React.Component {
...
@@ -30,14 +47,15 @@ class UpdateTreeItemForm extends React.Component {
<
Form
<
Form
{
...
formItemLayout
}
{
...
formItemLayout
}
form=
{
form
}
form=
{
form
}
name=
"basic"
initialValues=
{
type
!==
'add'
?{
name
:
item
?
item
.
name
:
''
,
remark
:
item
?
item
.
remark
:
''
,
}:
null
}
>
>
{
type
===
'add'
&&
<
Form
.
Item
label=
"目录类型"
name=
"action"
>
<
Radio
.
Group
disabled=
{
radioDisable
}
>
<
Radio
value=
'root'
>
根目录
</
Radio
>
<
Radio
value=
'sub'
>
子目录
</
Radio
>
</
Radio
.
Group
>
</
Form
.
Item
>
}
<
Form
.
Item
<
Form
.
Item
label=
"名称"
label=
"名称"
name=
"name"
name=
"name"
...
@@ -59,26 +77,53 @@ class UpdateTreeItemForm extends React.Component {
...
@@ -59,26 +77,53 @@ class UpdateTreeItemForm extends React.Component {
const
UpdateTreeItemModal
=
(
props
)
=>
{
const
UpdateTreeItemModal
=
(
props
)
=>
{
const
{
onOk
,
type
,
item
,
onCancel
,
visible
}
=
props
;
const
{
onOk
,
type
,
item
,
onCancel
,
visible
,
rootId
}
=
props
;
const
[
confirmLoading
,
setConfirmLoading
]
=
useState
(
false
);
const
[
confirmLoading
,
setConfirmLoading
]
=
useState
(
false
);
const
[
form
]
=
Form
.
useForm
();
const
[
form
]
=
Form
.
useForm
();
useEffect
(()
=>
{
if
(
visible
)
{
let
_action
=
''
;
if
(
type
===
'add'
)
{
_action
=
item
?
'sub'
:
'root'
;
}
if
(
type
===
'add'
)
{
form
.
setFieldsValue
({
action
:
_action
,
name
:
''
,
remark
:
''
});
}
else
{
form
.
setFieldsValue
({
action
:
''
,
name
:
item
?
item
.
name
:
''
,
remark
:
item
?
item
.
remark
:
''
});
}
}
//eslint-disable-next-line react-hooks/exhaustive-deps
},
[
visible
])
const
handleOk
=
async
()
=>
{
const
handleOk
=
async
()
=>
{
setConfirmLoading
(
true
);
setConfirmLoading
(
true
);
try
{
try
{
const
values
=
await
form
.
validateFields
();
const
values
=
await
form
.
validateFields
();
// console.log('value action', values.action);
let
payload
=
null
;
let
payload
=
null
;
if
(
type
===
'add'
)
{
if
(
type
===
'add'
&&
values
.
action
===
'root'
)
{
payload
=
{
name
:
values
.
name
||
''
,
remark
:
values
.
remark
||
''
,
parentId
:
rootId
};
}
else
if
(
type
===
'add'
)
{
payload
=
{
payload
=
{
...
values
,
name
:
values
.
name
||
''
,
remark
:
values
.
remark
||
''
,
parentId
:
item
.
id
parentId
:
item
.
id
};
};
}
else
{
}
else
{
payload
=
{
payload
=
{
...
item
,
...
item
,
...
values
,
name
:
values
.
name
||
''
,
remark
:
values
.
remark
||
''
,
}
}
}
}
...
@@ -103,11 +148,15 @@ const UpdateTreeItemModal = (props) => {
...
@@ -103,11 +148,15 @@ const UpdateTreeItemModal = (props) => {
return
(
return
(
<
Modal
<
Modal
forceRender
confirmLoading=
{
confirmLoading
}
confirmLoading=
{
confirmLoading
}
visible=
{
visible
}
visible=
{
visible
}
title=
{
type
===
'add'
?
"新增目录"
:
"更新目录"
}
title=
{
type
===
'add'
?
"新增目录"
:
"更新目录"
}
onOk=
{
handleOk
}
onOk=
{
handleOk
}
onCancel=
{
onCancel
}
onCancel=
{
()
=>
{
setConfirmLoading
(
false
);
onCancel
&&
onCancel
();
}
}
>
>
<
UpdateTreeItemForm
form=
{
form
}
item=
{
item
}
type=
{
type
}
/>
<
UpdateTreeItemForm
form=
{
form
}
item=
{
item
}
type=
{
type
}
/>
</
Modal
>
</
Modal
>
...
...
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