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
1da09032
Commit
1da09032
authored
Apr 01, 2021
by
zhaochengxiang
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
数据类型编辑
parent
4cda2acf
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
192 additions
and
25 deletions
+192
-25
datamodeler.js
src/service/datamodeler.js
+3
-3
ImportAction.jsx
src/view/Manage/Model/Component/ImportAction.jsx
+24
-4
ImportActionTable.jsx
src/view/Manage/Model/Component/ImportActionTable.jsx
+113
-10
ImportModal.jsx
src/view/Manage/Model/Component/ImportModal.jsx
+37
-4
ModelTree.jsx
src/view/Manage/Model/Component/ModelTree.jsx
+3
-1
UpdateTreeItemModal.jsx
src/view/Manage/Model/Component/UpdateTreeItemModal.jsx
+7
-1
index.jsx
src/view/Manage/Model/index.jsx
+5
-2
No files found.
src/service/datamodeler.js
View file @
1da09032
import
{
filePost
,
GetJSON
,
PostJSON
}
from
"../util/axios"
import
{
filePost
,
GetJSON
,
PostJSON
,
Post
}
from
"../util/axios"
export
function
loadDataModelCatalog
()
{
export
function
loadDataModelCatalog
()
{
return
GetJSON
(
"/datamodeler/easyDataModelerCURD/loadDataModelCatalog"
);
return
GetJSON
(
"/datamodeler/easyDataModelerCURD/loadDataModelCatalog"
);
...
@@ -38,7 +38,7 @@ export function draft(payload) {
...
@@ -38,7 +38,7 @@ export function draft(payload) {
//获取支持的数据类型
//获取支持的数据类型
export
function
getSupportedDatatypes
()
{
export
function
getSupportedDatatypes
()
{
return
GetJSON
(
"/datamodeler/easyDataModeler
Design
/getSupportedDatatypes"
);
return
GetJSON
(
"/datamodeler/easyDataModeler
CURD
/getSupportedDatatypes"
);
}
}
export
function
suggest
(
payload
)
{
export
function
suggest
(
payload
)
{
...
@@ -47,7 +47,7 @@ export function suggest(payload) {
...
@@ -47,7 +47,7 @@ export function suggest(payload) {
//保存模型
//保存模型
export
function
saveDataModel
(
payload
)
{
export
function
saveDataModel
(
payload
)
{
return
Post
JSON
(
"/datamodeler/easyDataModelerDesign
/saveDataModel"
,
payload
);
return
Post
(
"/datamodeler/easyDataModelerCURD
/saveDataModel"
,
payload
);
}
}
export
function
deleteDataModel
(
payload
)
{
export
function
deleteDataModel
(
payload
)
{
...
...
src/view/Manage/Model/Component/ImportAction.jsx
View file @
1da09032
...
@@ -5,13 +5,14 @@ import ImportActionHeader from './ImportActionHeader';
...
@@ -5,13 +5,14 @@ import ImportActionHeader from './ImportActionHeader';
import
ImportActionTable
from
'./ImportActionTable'
;
import
ImportActionTable
from
'./ImportActionTable'
;
// import ImportActionIndex from './ImportActionIndex';
// import ImportActionIndex from './ImportActionIndex';
import
{
dispatchLatest
}
from
'../../../../model'
;
import
{
dispatchLatest
,
dispatch
}
from
'../../../../model'
;
const
ImportAction
=
(
props
)
=>
{
const
ImportAction
=
(
props
)
=>
{
const
{
action
,
hints
}
=
props
;
const
{
action
,
hints
,
onChange
}
=
props
;
const
[
constraints
,
setConstraints
]
=
useState
([]);
const
[
constraints
,
setConstraints
]
=
useState
([]);
const
[
modelerData
,
setModelerData
]
=
useState
({});
const
[
modelerData
,
setModelerData
]
=
useState
({});
const
[
supportedDatatypes
,
setSupportedDatatypes
]
=
useState
([]);
const
mountRef
=
useRef
();
const
mountRef
=
useRef
();
mountRef
.
current
=
true
;
mountRef
.
current
=
true
;
...
@@ -44,12 +45,27 @@ const ImportAction = (props) => {
...
@@ -44,12 +45,27 @@ const ImportAction = (props) => {
},
},
callback
:
data
=>
{
callback
:
data
=>
{
setModelerData
(
data
||
{});
setModelerData
(
data
||
{});
onChange
&&
onChange
(
data
||
{});
getSupportedDatatypes
();
}
}
})
})
}
}
const
getSupportedDatatypes
=
()
=>
{
dispatch
({
type
:
'datamodel.getSupportedDatatypes'
,
callback
:
data
=>
{
setSupportedDatatypes
(
data
||
[]);
}
});
}
const
onTableChange
=
(
data
)
=>
{
const
onTableChange
=
(
data
)
=>
{
setModelerData
({...
modelerData
,
easyDataModelerDataModelAttributes
:
data
});
const
newMedelerData
=
{...
modelerData
,
easyDataModelerDataModelAttributes
:
data
};
setModelerData
(
newMedelerData
);
onChange
&&
onChange
(
newMedelerData
);
}
}
return
(
return
(
...
@@ -63,7 +79,11 @@ const ImportAction = (props) => {
...
@@ -63,7 +79,11 @@ const ImportAction = (props) => {
className=
'mb-3'
className=
'mb-3'
/>
/>
}
}
<
ImportActionTable
modelerData=
{
modelerData
||
{}
}
onChange=
{
onTableChange
}
editable=
{
action
!==
'detail'
}
/>
<
ImportActionTable
modelerData=
{
modelerData
||
{}
}
supportedDatatypes=
{
supportedDatatypes
}
onChange=
{
onTableChange
}
editable=
{
action
!==
'detail'
}
/>
{
/* <ImportActionIndex data={indexData} fileds={fileds} onChange={onIndexChange} editable={action!=='detail'} /> */
}
{
/* <ImportActionIndex data={indexData} fileds={fileds} onChange={onIndexChange} editable={action!=='detail'} /> */
}
</>
</>
);
);
...
...
src/view/Manage/Model/Component/ImportActionTable.jsx
View file @
1da09032
import
React
,
{
useState
,
useCallback
,
useRef
}
from
'react'
;
import
React
,
{
useState
,
useCallback
,
useRef
}
from
'react'
;
import
{
Table
,
Input
,
InputNumber
,
Form
,
Typography
,
Radio
,
Divider
,
Button
,
Checkbox
,
Popconfirm
}
from
'antd'
;
import
{
Table
,
Input
,
InputNumber
,
Form
,
Typography
,
Radio
,
Divider
,
Button
,
Popconfirm
,
Select
}
from
'antd'
;
import
{
DndProvider
,
useDrag
,
useDrop
}
from
'react-dnd'
;
import
{
DndProvider
,
useDrag
,
useDrop
}
from
'react-dnd'
;
import
{
HTML5Backend
}
from
'react-dnd-html5-backend'
;
import
{
HTML5Backend
}
from
'react-dnd-html5-backend'
;
import
update
from
'immutability-helper'
;
import
update
from
'immutability-helper'
;
import
{
generateUUID
}
from
'../../../../util'
;
import
{
generateUUID
}
from
'../../../../util'
;
import
{
dispatchLatest
}
from
'../../../../model'
;
import
{
dispatchLatest
}
from
'../../../../model'
;
const
{
Option
}
=
Select
;
const
type
=
'DragableTableBodyRow'
;
const
type
=
'DragableTableBodyRow'
;
const
DatatypeInput
=
({
value
=
{},
datatypes
,
onChange
})
=>
{
const
[
name
,
setName
]
=
useState
(
value
.
name
||
''
);
const
[
parameterNames
,
setParameterNames
]
=
useState
(
value
.
parameterNames
||
[]);
const
[
parameterValues
,
setParameterValues
]
=
useState
(
value
.
parameterValues
||
[]);
const
onNameChange
=
(
value
)
=>
{
setName
(
value
);
let
currentDatatype
=
{};
(
datatypes
||
[]).
forEach
((
datatype
,
index
)
=>
{
if
(
value
===
datatype
.
name
)
{
currentDatatype
=
datatype
;
}
})
setParameterNames
(
currentDatatype
.
parameterNames
);
setParameterValues
(
currentDatatype
.
parameterValues
);
triggerChange
({
name
:
value
,
parameterNames
:
currentDatatype
.
parameterNames
,
parameterValues
:
currentDatatype
.
parameterValues
});
}
const
onParameterValuesChange
=
(
value
,
index
)
=>
{
const
newParameterValues
=
[...
parameterValues
];
newParameterValues
[
index
]
=
value
;
setParameterValues
(
newParameterValues
);
triggerChange
({
parameterValues
:
newParameterValues
});
}
const
triggerChange
=
(
changedValue
)
=>
{
onChange
&&
onChange
({
...
value
,
...
changedValue
,
});
};
return
(
<>
<
span
>
<
Select
onChange=
{
onNameChange
}
value=
{
name
}
>
{
(
datatypes
||
[])
&&
datatypes
.
map
((
_datatype
,
index
)
=>
{
return
(
<
Option
key=
{
_datatype
.
name
||
''
}
>
{
_datatype
.
name
||
''
}
</
Option
>
);
})
}
</
Select
>
{
(
parameterNames
||
[]).
map
((
parameterName
,
index
)
=>
{
return
(
<
InputNumber
key=
{
index
}
onChange=
{
(
e
)
=>
{
onParameterValuesChange
(
e
.
target
.
value
,
index
);
}
}
value=
{
parameterValues
[
index
]
}
/>
);
})
}
</
span
>
</>
)
}
const
EditableCell
=
({
const
EditableCell
=
({
editing
,
editing
,
dataIndex
,
dataIndex
,
...
@@ -15,29 +88,57 @@ const EditableCell = ({
...
@@ -15,29 +88,57 @@ const EditableCell = ({
inputType
,
inputType
,
record
,
record
,
index
,
index
,
datatypes
,
children
,
children
,
...
restProps
...
restProps
})
=>
{
})
=>
{
const
inputNode
=
inputType
===
'check'
?
<
Checkbox
/>
:
(
inputType
===
'number'
?
<
InputNumber
/>
:
<
Input
/>
)
return
(
let
editingComponent
=
null
;
<
td
{
...
restProps
}
>
if
(
editing
)
{
{
editing
?
(
if
(
dataIndex
!==
'datatype'
)
{
editingComponent
=
(
<
Form
.
Item
<
Form
.
Item
name=
{
dataIndex
}
name=
{
dataIndex
}
style=
{
{
style=
{
{
margin
:
0
,
margin
:
0
,
}
}
}
}
valuePropName=
{
(
inputType
===
'check'
)?
'checked'
:
'value'
}
valuePropName=
{
'value'
}
rules=
{
[
rules=
{
[
{
{
required
:
(
inputType
===
'check'
)?
false
:
true
,
required
:
true
,
message
:
`请输入${title}!`
,
message
:
`请输入${title}!`
,
},
},
]
}
]
}
>
>
{
inputNode
}
<
Input
/>
</
Form
.
Item
>
);
}
else
{
editingComponent
=
(
<
Form
.
Item
name=
{
dataIndex
}
style=
{
{
margin
:
0
,
}
}
valuePropName=
{
'value'
}
rules=
{
[
{
required
:
true
,
message
:
`请输入${title}!`
,
},
]
}
>
<
DatatypeInput
datatypes=
{
datatypes
}
/>
</
Form
.
Item
>
</
Form
.
Item
>
)
}
}
return
(
<
td
{
...
restProps
}
>
{
editing
?
(
editingComponent
)
:
(
)
:
(
children
children
)
}
)
}
...
@@ -93,7 +194,7 @@ const DragableBodyRow = ({ index, moveRow, className, style, ...restProps }) =>
...
@@ -93,7 +194,7 @@ const DragableBodyRow = ({ index, moveRow, className, style, ...restProps }) =>
};
};
const
ImportActionTable
=
(
props
)
=>
{
const
ImportActionTable
=
(
props
)
=>
{
const
{
modelerData
,
onChange
,
editable
}
=
props
;
const
{
modelerData
,
onChange
,
editable
,
supportedDatatypes
}
=
props
;
const
data
=
modelerData
.
easyDataModelerDataModelAttributes
||
[];
const
data
=
modelerData
.
easyDataModelerDataModelAttributes
||
[];
const
[
form
]
=
Form
.
useForm
();
const
[
form
]
=
Form
.
useForm
();
const
[
editingKey
,
setEditingKey
]
=
useState
(
''
);
const
[
editingKey
,
setEditingKey
]
=
useState
(
''
);
...
@@ -145,6 +246,7 @@ const ImportActionTable = (props) => {
...
@@ -145,6 +246,7 @@ 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
);
const
newData
=
[...
data
];
const
newData
=
[...
data
];
const
index
=
newData
.
findIndex
((
item
)
=>
editingKey
===
item
.
iid
);
const
index
=
newData
.
findIndex
((
item
)
=>
editingKey
===
item
.
iid
);
...
@@ -267,6 +369,7 @@ const ImportActionTable = (props) => {
...
@@ -267,6 +369,7 @@ const ImportActionTable = (props) => {
dataIndex
:
col
.
dataIndex
,
dataIndex
:
col
.
dataIndex
,
title
:
col
.
title
,
title
:
col
.
title
,
editing
:
isEditing
(
record
),
editing
:
isEditing
(
record
),
datatypes
:
supportedDatatypes
,
}),
}),
};
};
});
});
...
@@ -293,7 +396,7 @@ const ImportActionTable = (props) => {
...
@@ -293,7 +396,7 @@ const ImportActionTable = (props) => {
<
Divider
>
数据表结构
</
Divider
>
<
Divider
>
数据表结构
</
Divider
>
{
{
editable
&&
<
div
className=
'd-flex mb-3'
>
editable
&&
<
div
className=
'd-flex mb-3'
>
<
Button
type=
"primary"
onClick=
{
onAddClick
}
style=
{
{
marginLeft
:
'auto'
}
}
disabled=
{
editingKey
!==
''
}
>
新增行
</
Button
>
<
Button
type=
"primary"
onClick=
{
onAddClick
}
style=
{
{
marginLeft
:
'auto'
}
}
disabled=
{
editingKey
!==
''
}
>
新增行
</
Button
>
</
div
>
</
div
>
}
}
<
DndProvider
backend=
{
HTML5Backend
}
>
<
DndProvider
backend=
{
HTML5Backend
}
>
...
...
src/view/Manage/Model/Component/ImportModal.jsx
View file @
1da09032
...
@@ -35,6 +35,7 @@ class ImportModal extends React.Component {
...
@@ -35,6 +35,7 @@ class ImportModal extends React.Component {
radioValue
:
''
,
radioValue
:
''
,
excelFiles
:
[],
excelFiles
:
[],
hints
:
[],
hints
:
[],
modelerData
:
{},
confirmLoading
:
false
,
confirmLoading
:
false
,
}
}
}
}
...
@@ -77,6 +78,39 @@ class ImportModal extends React.Component {
...
@@ -77,6 +78,39 @@ class ImportModal extends React.Component {
})
})
}
}
save
=
()
=>
{
const
{
catalogId
,
onCancel
}
=
this
.
props
;
const
{
modelerData
}
=
this
.
state
;
this
.
setState
({
confirmLoading
:
true
},
()
=>
{
dispatchLatest
({
type
:
'datamodel.saveDataModel'
,
payload
:
{
data
:
modelerData
},
callback
:
mid
=>
{
dispatchLatest
({
type
:
'datamodel.bindCatalogDataModel'
,
payload
:
{
params
:
{
easyDataModelCatalogId
:
catalogId
,
easyDataModelerDataModelIds
:
mid
}
},
callback
:
()
=>
{
this
.
setState
({
confirmLoading
:
false
});
onCancel
&&
onCancel
();
}
})
}
})
})
}
onActionChange
=
(
data
)
=>
{
this
.
setState
({
modelerData
:
data
});
}
onImportExcelChange
=
(
files
)
=>
{
onImportExcelChange
=
(
files
)
=>
{
this
.
setState
({
excelFiles
:
files
||
[]
});
this
.
setState
({
excelFiles
:
files
||
[]
});
}
}
...
@@ -94,9 +128,7 @@ class ImportModal extends React.Component {
...
@@ -94,9 +128,7 @@ class ImportModal extends React.Component {
destroyOnClose
destroyOnClose
onCancel=
{
()
=>
{
onCancel=
{
()
=>
{
this
.
setState
({
step
:
0
},
()
=>
{
this
.
setState
({
step
:
0
},
()
=>
{
if
(
onCancel
)
{
onCancel
&&
onCancel
();
onCancel
();
}
})
})
}
}
}
}
footer=
{
[
footer=
{
[
...
@@ -122,6 +154,7 @@ class ImportModal extends React.Component {
...
@@ -122,6 +154,7 @@ class ImportModal extends React.Component {
type=
"primary"
type=
"primary"
loading=
{
confirmLoading
}
loading=
{
confirmLoading
}
style=
{
{
display
:
(
step
===
2
)?
''
:
'none'
}
}
style=
{
{
display
:
(
step
===
2
)?
''
:
'none'
}
}
onClick=
{
this
.
save
}
>
>
保存
保存
</
Button
>
</
Button
>
...
@@ -160,7 +193,7 @@ class ImportModal extends React.Component {
...
@@ -160,7 +193,7 @@ class ImportModal extends React.Component {
step
===
1
&&
radioValue
===
4
&&
<></>
step
===
1
&&
radioValue
===
4
&&
<></>
}
}
{
{
step
===
2
&&
<
ImportAction
hints=
{
hints
}
/>
step
===
2
&&
<
ImportAction
hints=
{
hints
}
onChange=
{
this
.
onActionChange
}
/>
}
}
</>
</>
</
Modal
>
</
Modal
>
...
...
src/view/Manage/Model/Component/ModelTree.jsx
View file @
1da09032
...
@@ -100,7 +100,9 @@ class ModelTree extends React.Component {
...
@@ -100,7 +100,9 @@ class ModelTree extends React.Component {
dispatchLatest
({
dispatchLatest
({
type
:
'datamodel.deleteDataModelCatalog'
,
type
:
'datamodel.deleteDataModelCatalog'
,
payload
:
{
payload
:
{
easyDataModelerCatalogId
:
item
.
id
params
:
{
easyDataModelerCatalogId
:
item
.
id
}
},
},
callback
:
()
=>
{
callback
:
()
=>
{
message
.
success
(
'删除目录成功'
);
message
.
success
(
'删除目录成功'
);
...
...
src/view/Manage/Model/Component/UpdateTreeItemModal.jsx
View file @
1da09032
...
@@ -5,6 +5,13 @@ import { dispatchLatest } from '../../../../model';
...
@@ -5,6 +5,13 @@ import { dispatchLatest } from '../../../../model';
class
UpdateTreeItemForm
extends
React
.
Component
{
class
UpdateTreeItemForm
extends
React
.
Component
{
componentDidUpdate
(
preProps
,
preState
)
{
const
{
form
}
=
this
.
props
;
if
(
form
&&
form
.
resetFields
)
{
form
.
resetFields
([
'name'
,
'remark'
])
}
}
render
()
{
render
()
{
const
{
item
,
type
,
form
}
=
this
.
props
;
const
{
item
,
type
,
form
}
=
this
.
props
;
...
@@ -99,7 +106,6 @@ const UpdateTreeItemModal = (props) => {
...
@@ -99,7 +106,6 @@ const UpdateTreeItemModal = (props) => {
confirmLoading=
{
confirmLoading
}
confirmLoading=
{
confirmLoading
}
visible=
{
visible
}
visible=
{
visible
}
title=
{
type
===
'add'
?
"新增目录"
:
"更新目录"
}
title=
{
type
===
'add'
?
"新增目录"
:
"更新目录"
}
destroyOnClose
onOk=
{
handleOk
}
onOk=
{
handleOk
}
onCancel=
{
onCancel
}
onCancel=
{
onCancel
}
>
>
...
...
src/view/Manage/Model/index.jsx
View file @
1da09032
...
@@ -15,10 +15,12 @@ class Model extends React.Component {
...
@@ -15,10 +15,12 @@ class Model extends React.Component {
this
.
state
=
{
this
.
state
=
{
importModalVisible
:
false
,
importModalVisible
:
false
,
exportModalVisible
:
false
,
exportModalVisible
:
false
,
catalogId
:
''
,
}
}
}
}
onTreeSelect
=
(
key
)
=>
{
onTreeSelect
=
(
key
)
=>
{
this
.
setState
({
catalogId
:
key
});
dispatchLatest
({
dispatchLatest
({
type
:
'datamodel.getCurrentDataModelCatalog'
,
type
:
'datamodel.getCurrentDataModelCatalog'
,
payload
:
{
payload
:
{
...
@@ -47,7 +49,7 @@ class Model extends React.Component {
...
@@ -47,7 +49,7 @@ class Model extends React.Component {
}
}
render
()
{
render
()
{
const
{
importModalVisible
,
exportModalVisible
}
=
this
.
state
;
const
{
importModalVisible
,
exportModalVisible
,
catalogId
}
=
this
.
state
;
return
(
return
(
<
div
style=
{
{
backgroundColor
:
'#fff'
,
height
:
'100%'
}
}
>
<
div
style=
{
{
backgroundColor
:
'#fff'
,
height
:
'100%'
}
}
>
...
@@ -76,7 +78,8 @@ class Model extends React.Component {
...
@@ -76,7 +78,8 @@ class Model extends React.Component {
<
ImportModal
<
ImportModal
visible=
{
importModalVisible
}
visible=
{
importModalVisible
}
onCancel=
{
this
.
onImportModalCancel
}
onCancel=
{
this
.
onImportModalCancel
}
catalogId=
{
catalogId
}
/>
/>
<
ExportModal
<
ExportModal
...
...
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