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
fefd1060
Commit
fefd1060
authored
Oct 19, 2021
by
zhaochengxiang
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
模型主页面导入调整
parent
3ca37456
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
66 additions
and
58 deletions
+66
-58
ImportExcel.jsx
src/view/Manage/Model/Component/ImportExcel.jsx
+10
-5
ImportModal.jsx
src/view/Manage/Model/Component/ImportModal.jsx
+40
-40
ImportWord.jsx
src/view/Manage/Model/Component/ImportWord.jsx
+12
-0
index.jsx
src/view/Manage/Model/index.jsx
+4
-13
No files found.
src/view/Manage/Model/Component/ImportExcel.jsx
View file @
fefd1060
...
@@ -22,6 +22,11 @@ class ImportExcel extends React.Component {
...
@@ -22,6 +22,11 @@ class ImportExcel extends React.Component {
window
.
open
(
"/data-govern/docs/DataModel.xlsx"
);
window
.
open
(
"/data-govern/docs/DataModel.xlsx"
);
}
}
normFile
=
(
e
)
=>
{
const
{
fileList
}
=
this
.
state
;
return
fileList
;
};
render
()
{
render
()
{
const
{
onChange
}
=
this
.
props
;
const
{
onChange
}
=
this
.
props
;
...
@@ -33,8 +38,6 @@ class ImportExcel extends React.Component {
...
@@ -33,8 +38,6 @@ class ImportExcel extends React.Component {
const
newFileList
=
fileList
.
slice
();
const
newFileList
=
fileList
.
slice
();
newFileList
.
splice
(
index
,
1
);
newFileList
.
splice
(
index
,
1
);
onChange
&&
onChange
(
newFileList
);
this
.
setState
({
fileList
:
newFileList
});
this
.
setState
({
fileList
:
newFileList
});
},
},
beforeUpload
:
file
=>
{
beforeUpload
:
file
=>
{
...
@@ -42,7 +45,6 @@ class ImportExcel extends React.Component {
...
@@ -42,7 +45,6 @@ class ImportExcel extends React.Component {
onChange
&&
onChange
([
file
]);
onChange
&&
onChange
([
file
]);
this
.
setState
({
fileList
:
[
file
]
});
this
.
setState
({
fileList
:
[
file
]
});
console
.
log
(
'file'
,
file
);
return
false
;
return
false
;
},
},
accept
:
".xlsx"
,
accept
:
".xlsx"
,
...
@@ -51,12 +53,15 @@ class ImportExcel extends React.Component {
...
@@ -51,12 +53,15 @@ class ImportExcel extends React.Component {
return
(
return
(
<
Form
.
Item
<
Form
.
Item
name=
'upload
'
label=
'文件上传
'
label=
'文件上传'
required=
{
true
}
>
>
<
Row
>
<
Row
>
<
Col
span=
{
9
}
>
<
Col
span=
{
9
}
>
<
Form
.
Item
<
Form
.
Item
name=
'upload'
valuePropName=
"fileList"
getValueFromEvent=
{
this
.
normFile
}
noStyle
noStyle
rules=
{
[
rules=
{
[
{
{
...
...
src/view/Manage/Model/Component/ImportModal.jsx
View file @
fefd1060
...
@@ -15,7 +15,7 @@ const importModes = [
...
@@ -15,7 +15,7 @@ const importModes = [
]
]
const
ImportModal
=
(
props
)
=>
{
const
ImportModal
=
(
props
)
=>
{
const
{
catalogId
,
visible
,
onCancel
}
=
props
;
const
{
view
,
catalogId
,
visible
,
onCancel
}
=
props
;
const
[
modeKey
,
setModeKey
]
=
useState
(
''
);
const
[
modeKey
,
setModeKey
]
=
useState
(
''
);
const
[
files
,
setFiles
]
=
useState
([]);
const
[
files
,
setFiles
]
=
useState
([]);
...
@@ -29,17 +29,12 @@ const ImportModal = (props) => {
...
@@ -29,17 +29,12 @@ const ImportModal = (props) => {
}
}
const
onOk
=
async
()
=>
{
const
onOk
=
async
()
=>
{
try
{
if
(
modeKey
===
''
)
{
const
row
=
await
form
.
validateFields
();
form
.
setFields
([{
name
:
'mode'
,
errors
:
[
'请选择导入方式'
]
}]);
return
;
if
(
modeKey
===
'word'
)
{
}
if
(
modeKey
===
'word'
)
{
if
((
files
||
[]).
length
===
0
)
{
form
.
setFields
([{
name
:
'upload'
,
errors
:
[
'请选择文件上传'
]
}]);
}
else
{
setConfirmLoading
(
true
);
setConfirmLoading
(
true
);
dispatchLatest
({
dispatchLatest
({
type
:
'datamodel.importWordGenerateModelDraft'
,
type
:
'datamodel.importWordGenerateModelDraft'
,
...
@@ -47,7 +42,7 @@ const ImportModal = (props) => {
...
@@ -47,7 +42,7 @@ const ImportModal = (props) => {
params
:
{
params
:
{
catalogId
,
catalogId
,
},
},
file
s
file
List
:
row
.
upload
},
},
callback
:
data
=>
{
callback
:
data
=>
{
setConfirmLoading
(
false
);
setConfirmLoading
(
false
);
...
@@ -58,36 +53,38 @@ const ImportModal = (props) => {
...
@@ -58,36 +53,38 @@ const ImportModal = (props) => {
setConfirmLoading
(
false
);
setConfirmLoading
(
false
);
}
}
});
});
}
}
else
if
(
modeKey
===
'excel'
)
{
}
else
if
(
modeKey
===
'excel'
)
{
if
((
files
||
[]).
length
===
0
)
{
form
.
setFields
([{
name
:
'upload'
,
errors
:
[
'请选择文件上传'
]
}]);
}
else
{
setConfirmLoading
(
true
);
setConfirmLoading
(
true
);
dispatchLatest
({
dispatchLatest
({
type
:
'datamodel.extractExcelContent'
,
type
:
'datamodel.extractExcelContent'
,
payload
:
{
fileList
:
files
},
payload
:
{
fileList
:
row
.
upload
},
callback
:
data
=>
{
callback
:
data
=>
{
setConfirmLoading
(
false
);
setConfirmLoading
(
false
);
reset
();
onCancel
&&
onCancel
(
false
,
data
||
[]);
onCancel
&&
onCancel
(
false
,
data
||
[]);
},
},
error
:
()
=>
{
error
:
()
=>
{
setConfirmLoading
(
false
);
setConfirmLoading
(
false
);
}
}
})
})
}
else
if
(
modeKey
===
'excel-copy'
)
{
if
((
hints
||
[]).
length
===
0
)
{
showMessage
(
'warn'
,
'请先从Excel文件中复制内容'
);
}
else
{
reset
();
onCancel
&&
onCancel
(
false
,
hints
||
[]);
}
}
}
}
else
if
(
modeKey
===
'excel-copy'
)
{
}
catch
(
errInfo
)
{
console
.
log
(
'Validate Failed:'
,
errInfo
);
if
((
hints
||
[]).
length
===
0
)
{
}
showMessage
(
'warn'
,
'请先从Excel文件中复制内容'
);
}
else
{
onCancel
&&
onCancel
(
false
,
hints
||
[]);
}
}
}
}
const
cancel
=
()
=>
{
const
cancel
=
()
=>
{
...
@@ -96,20 +93,13 @@ const ImportModal = (props) => {
...
@@ -96,20 +93,13 @@ const ImportModal = (props) => {
}
}
const
reset
=
()
=>
{
const
reset
=
()
=>
{
form
.
resetFields
();
setModeKey
(
''
);
setModeKey
(
''
);
setFiles
([]);
setFiles
([]);
setHints
([]);
setHints
([]);
setConfirmLoading
(
false
);
setConfirmLoading
(
false
);
}
}
const
onImportWordChange
=
(
files
)
=>
{
setFiles
(
files
||
[]);
}
const
onImportExcelChange
=
(
files
)
=>
{
setFiles
(
files
||
[]);
}
const
onImportExcelCopyChange
=
(
data
)
=>
{
const
onImportExcelCopyChange
=
(
data
)
=>
{
setHints
(
data
||
[]);
setHints
(
data
||
[]);
}
}
...
@@ -117,7 +107,6 @@ const ImportModal = (props) => {
...
@@ -117,7 +107,6 @@ const ImportModal = (props) => {
const
footer
=
[
const
footer
=
[
<
Button
<
Button
key=
"0"
key=
"0"
type=
"primary"
onClick=
{
cancel
}
onClick=
{
cancel
}
>
>
取消
取消
...
@@ -145,23 +134,34 @@ const ImportModal = (props) => {
...
@@ -145,23 +134,34 @@ const ImportModal = (props) => {
<
Form
.
Item
<
Form
.
Item
name=
'mode'
name=
'mode'
label=
'导入方式'
label=
'导入方式'
rules=
{
[
{
required
:
true
,
message
:
'请选择导入方式'
,
},
]
}
>
>
<
Radio
.
Group
onChange=
{
onModeChange
}
value=
{
modeKey
}
>
<
Radio
.
Group
onChange=
{
onModeChange
}
value=
{
modeKey
}
>
{
{
importModes
.
map
((
item
,
index
)
=>
{
importModes
.
map
((
item
,
index
)
=>
{
return
<
Radio
value=
{
item
.
key
}
key=
{
index
}
>
{
item
.
name
}
</
Radio
>;
return
<
Radio
value=
{
item
.
key
}
key=
{
index
}
disabled=
{
item
.
key
===
'word'
&&
(
view
!==
'dir'
||
(
catalogId
||
''
)
===
''
)
}
>
{
item
.
name
}
</
Radio
>;
})
})
}
}
</
Radio
.
Group
>
</
Radio
.
Group
>
</
Form
.
Item
>
</
Form
.
Item
>
{
{
modeKey
===
'word'
&&
(
modeKey
===
'word'
&&
(
<
ImportWord
onChange=
{
onImportWordChange
}
{
...
props
}
/>
<
ImportWord
{
...
props
}
/>
)
)
}
}
{
{
modeKey
===
'excel'
&&
(
modeKey
===
'excel'
&&
(
<
ImportExcel
onChange=
{
onImportExcelChange
}
{
...
props
}
/>
<
ImportExcel
{
...
props
}
/>
)
)
}
}
{
{
...
...
src/view/Manage/Model/Component/ImportWord.jsx
View file @
fefd1060
...
@@ -10,6 +10,10 @@ const ImportWord = (props) => {
...
@@ -10,6 +10,10 @@ const ImportWord = (props) => {
setFileList
([]);
setFileList
([]);
},
[
visible
])
},
[
visible
])
const
normFile
=
()
=>
{
return
fileList
;
}
const
uploadProps
=
{
const
uploadProps
=
{
onRemove
:
file
=>
{
onRemove
:
file
=>
{
...
@@ -34,6 +38,14 @@ const ImportWord = (props) => {
...
@@ -34,6 +38,14 @@ const ImportWord = (props) => {
<
Form
.
Item
<
Form
.
Item
name=
'upload'
name=
'upload'
label=
'文件上传'
label=
'文件上传'
valuePropName=
"fileList"
getValueFromEvent=
{
normFile
}
rules=
{
[
{
required
:
true
,
message
:
'请选择文件上传'
,
},
]
}
>
>
<
Upload
{
...
uploadProps
}
>
<
Upload
{
...
uploadProps
}
>
<
Button
icon=
{
<
UploadOutlined
/>
}
>
<
Button
icon=
{
<
UploadOutlined
/>
}
>
...
...
src/view/Manage/Model/index.jsx
View file @
fefd1060
...
@@ -202,17 +202,6 @@ class Model extends React.Component {
...
@@ -202,17 +202,6 @@ class Model extends React.Component {
window.open(`
/
data
-
govern
/
data
-
model
-
action
?
$
{
Action
}
=
add
&
$
{
CatalogId
}
=
$
{(
currentView
===
'dir'
)?(
catalogId
||
''
):
''
}
`);
window.open(`
/
data
-
govern
/
data
-
model
-
action
?
$
{
Action
}
=
add
&
$
{
CatalogId
}
=
$
{(
currentView
===
'dir'
)?(
catalogId
||
''
):
''
}
`);
}
}
// onImportWordBtnClick = () => {
// const { catalogId, currentView } = this.state;
// if (currentView!=='dir' || (catalogId||'') === '') {
// showMessage('info', '请先选择模型目录');
// return;
// }
// this.setState({ importWordModalVisible: true });
// }
onImportModelBtnClick = () => {
onImportModelBtnClick = () => {
const { catalogId, selectModelerIds, currentView } = this.state;
const { catalogId, selectModelerIds, currentView } = this.state;
...
@@ -341,14 +330,14 @@ class Model extends React.Component {
...
@@ -341,14 +330,14 @@ class Model extends React.Component {
}
}
onImportModalCancel = (refresh = false, hints = [], wordData = {}) => {
onImportModalCancel = (refresh = false, hints = [], wordData = {}) => {
const { catalogId,
importModalAction,
currentView } = this.state;
const { catalogId, currentView } = this.state;
this.setState({ importModalVisible: false }, () => {
this.setState({ importModalVisible: false }, () => {
refresh && this.onTableChange();
refresh && this.onTableChange();
if ((hints||[]).length > 0) {
if ((hints||[]).length > 0) {
setTimeout(() => {
setTimeout(() => {
window.open(`
/
data
-
govern
/
data
-
model
-
action
?
$
{
Action
}
=
$
{
importModalAction
}
&
$
{
CatalogId
}
=
$
{(
currentView
===
'dir'
)?(
catalogId
||
''
):
''
}
&
$
{
Hints
}
=
$
{
encodeURIComponent
((
hints
||
[]).
join
(
','
))}
`);
window.open(`
/
data
-
govern
/
data
-
model
-
action
?
$
{
Action
}
=
add
&
$
{
CatalogId
}
=
$
{(
currentView
===
'dir'
)?(
catalogId
||
''
):
''
}
&
$
{
Hints
}
=
$
{
encodeURIComponent
((
hints
||
[]).
join
(
','
))}
`);
}, 1000);
}, 1000);
}
}
...
@@ -560,6 +549,8 @@ class Model extends React.Component {
...
@@ -560,6 +549,8 @@ class Model extends React.Component {
/>
/>
<ImportModal
<ImportModal
view={currentView}
catalogId={catalogId}
visible={importModalVisible}
visible={importModalVisible}
onCancel={this.onImportModalCancel}
onCancel={this.onImportModalCancel}
/>
/>
...
...
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