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
21c03651
Commit
21c03651
authored
Apr 06, 2021
by
zhaochengxiang
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
模型增加模版
parent
7ba19260
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
61 additions
and
30 deletions
+61
-30
datamodel.js
src/model/datamodel.js
+5
-2
datamodeler.js
src/service/datamodeler.js
+5
-0
ImportAction.jsx
src/view/Manage/Model/Component/ImportAction.jsx
+40
-7
ImportActionTable.jsx
src/view/Manage/Model/Component/ImportActionTable.jsx
+2
-20
ModelTable.jsx
src/view/Manage/Model/Component/ModelTable.jsx
+9
-1
No files found.
src/model/datamodel.js
View file @
21c03651
...
...
@@ -70,8 +70,11 @@ export function* extractExcelContent(payload) {
return
yield
call
(
datamodelerService
.
extractExcelContent
,
payload
);
}
export
function
*
getAllConstraints
()
{
return
yield
call
(
datamodelerService
.
constraints
);
export
function
*
getAllConstraintsAndTemplates
()
{
const
constraints
=
yield
call
(
datamodelerService
.
constraints
);
const
templates
=
yield
call
(
datamodelerService
.
templates
);
return
{
constraints
,
templates
};
}
//获取初稿
...
...
src/service/datamodeler.js
View file @
21c03651
...
...
@@ -31,6 +31,11 @@ export function constraints() {
return
GetJSON
(
"/datamodeler/easyDataModelerConstraint/constraints"
);
}
//模版
export
function
templates
()
{
return
GetJSON
(
"/datamodeler/easyDataModelerConstraint/templates"
);
}
//创建初稿
export
function
draft
(
payload
)
{
return
PostJSON
(
"/datamodeler/easyDataModelerDesign/draft"
,
payload
);
...
...
src/view/Manage/Model/Component/ImportAction.jsx
View file @
21c03651
...
...
@@ -14,6 +14,8 @@ const ImportAction = (props) => {
const
[
constraints
,
setConstraints
]
=
useState
([]);
const
[
constraint
,
setConstraint
]
=
useState
({});
const
[
templates
,
setTemplates
]
=
useState
([]);
const
[
template
,
setTemplate
]
=
useState
({});
const
[
modelerData
,
setModelerData
]
=
useState
(
null
);
const
[
supportedDatatypes
,
setSupportedDatatypes
]
=
useState
([]);
...
...
@@ -37,12 +39,14 @@ const ImportAction = (props) => {
getCurrentDataModel
();
}
else
{
dispatchLatest
({
type
:
'datamodel.getAllConstraints'
,
type
:
'datamodel.getAllConstraints
AndTemplates
'
,
callback
:
data
=>
{
setConstraints
(
data
||
[]);
setConstraints
(
data
.
constraints
||
[]);
setTemplates
(
data
.
templates
||
[]);
if
(
action
===
'add'
)
{
setConstraint
((
data
||
[]).
length
>
0
?
data
[
0
]:{});
getDraft
((
data
||
[]).
length
>
0
?
data
[
0
]:{},
hints
);
setConstraint
((
data
.
constraints
||
[]).
length
>
0
?
data
.
constraints
[
0
]:{});
setTemplate
((
data
.
templates
||
[]).
length
>
0
?
data
.
templates
[
0
]:{});
getDraft
((
data
.
constraints
||
[]).
length
>
0
?
data
.
constraints
[
0
]:{},
(
data
.
templates
||
[]).
length
>
0
?
data
.
templates
[
0
]:{}
,
hints
);
}
else
if
(
action
===
'edit'
)
{
getCurrentDataModel
();
}
...
...
@@ -52,13 +56,14 @@ const ImportAction = (props) => {
//eslint-disable-next-line react-hooks/exhaustive-deps
},
[
action
,
hints
,
modelerId
]);
const
getDraft
=
(
_constraint
,
_hints
)
=>
{
const
getDraft
=
(
_constraint
,
_
template
,
_
hints
)
=>
{
dispatchLatest
({
type
:
'datamodel.getDraft'
,
payload
:
{
data
:
{
hints
:
_hints
,
modelerModelingConstraint
:
_constraint
modelerModelingConstraint
:
_constraint
,
easyDataModelerModelingTemplate
:
_template
}
},
callback
:
data
=>
{
...
...
@@ -112,7 +117,26 @@ const ImportAction = (props) => {
});
setConstraint
(
currentConstraint
);
getDraft
(
currentConstraint
,
_hints
);
getDraft
(
currentConstraint
,
template
,
_hints
);
}
const
onTemplateChange
=
(
value
)
=>
{
let
currentTemplate
=
null
,
_hints
=
[];
(
templates
||
[]).
forEach
((
_template
,
index
)
=>
{
if
(
_template
.
id
===
value
)
{
currentTemplate
=
_template
;
}
});
(
modelerData
.
easyDataModelerDataModelAttributes
||
[]).
forEach
((
_attribute
,
index
)
=>
{
if
(
_attribute
.
name
&&
_attribute
.
name
!==
''
)
{
_hints
.
push
(
_attribute
.
cnName
);
}
});
setTemplate
(
currentTemplate
);
getDraft
(
constraint
,
currentTemplate
,
_hints
);
}
const
getSupportedDatatypes
=
()
=>
{
...
...
@@ -145,6 +169,15 @@ const ImportAction = (props) => {
})
}
</
Select
>
<
Select
className=
'ml-3'
value=
{
template
.
id
?
template
.
id
:
null
}
placeholder=
'请选择模版'
style=
{
{
minWidth
:
100
}
}
onChange=
{
onTemplateChange
}
>
{
(
templates
||
[]).
map
((
template
,
index
)
=>
{
return
(
<
Option
key=
{
index
}
value=
{
template
.
id
}
>
{
template
.
cnName
||
''
}
</
Option
>
)
})
}
</
Select
>
</
div
>
}
<
ImportActionHeader
...
...
src/view/Manage/Model/Component/ImportActionTable.jsx
View file @
21c03651
import
React
,
{
useState
,
useCallback
,
useRef
,
useEffect
}
from
'react'
;
import
{
Table
,
Input
,
InputNumber
,
Form
,
Typography
,
Radio
,
Divider
,
Button
,
Popconfirm
,
Select
,
Row
,
Col
}
from
'antd'
;
import
{
Table
,
Input
,
InputNumber
,
Form
,
Typography
,
Radio
,
Divider
,
Button
,
Popconfirm
,
Select
,
Row
,
Col
,
Descriptions
}
from
'antd'
;
import
{
DndProvider
,
useDrag
,
useDrop
}
from
'react-dnd'
;
import
{
HTML5Backend
}
from
'react-dnd-html5-backend'
;
import
update
from
'immutability-helper'
;
...
...
@@ -424,24 +424,6 @@ const ImportActionTable = (props) => {
return
columns
;
}
// const mergedColumns = columns.map((col) => {
// if (!col.editable) {
// return col;
// }
// return {
// ...col,
// onCell: (record) => ({
// record,
// inputType: 'text',
// dataIndex: col.dataIndex,
// title: col.title,
// editing: isEditing(record),
// datatypes: supportedDatatypes,
// }),
// };
// });
const
moveRow
=
useCallback
(
(
dragIndex
,
hoverIndex
)
=>
{
...
...
@@ -505,7 +487,7 @@ const ImportActionTable = (props) => {
suggests
&&
suggests
.
map
((
suggest
,
index
)
=>
{
return
(
<
Radio
key=
{
index
}
value=
{
index
}
className=
'mt-3'
style=
{
{
display
:
'block'
}
}
>
{
`
${suggest.name
||''}`
}
{
`
中文名称: ${suggest.cnName||''} 英文名称: ${suggest.name||''} 描述: ${suggest.remark
||''}`
}
</
Radio
>
)
})
...
...
src/view/Manage/Model/Component/ModelTable.jsx
View file @
21c03651
...
...
@@ -17,7 +17,7 @@ const ModelTable = (props) => {
setSelectedRowKeys
([]);
onSelect
&&
onSelect
([]);
//eslint-disable-next-line react-hooks/exhaustive-deps
},
[
catalogId
]);
...
...
@@ -82,6 +82,14 @@ const ModelTable = (props) => {
callback
:
()
=>
{
showMessage
(
'success'
,
'模型删除成功'
);
onChange
&&
onChange
();
const
index
=
selectedRowKeys
.
findIndex
((
rowKey
)
=>
rowKey
===
record
.
id
);
if
(
index
!==
-
1
)
{
const
newSelectedRowKeys
=
[...
selectedRowKeys
];
newSelectedRowKeys
.
splice
(
index
,
1
);
setSelectedRowKeys
(
newSelectedRowKeys
);
onSelect
&&
onSelect
(
newSelectedRowKeys
);
}
}
})
}
...
...
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