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
42d01639
Commit
42d01639
authored
Jan 17, 2022
by
zhaochengxiang
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
快速创建
parent
67d63047
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
62 additions
and
18 deletions
+62
-18
ImportExcelCopy.jsx
src/view/Manage/Model/Component/ImportExcelCopy.jsx
+44
-12
ImportModal.jsx
src/view/Manage/Model/Component/ImportModal.jsx
+11
-6
ModelTable.less
src/view/Manage/Model/Component/ModelTable.less
+7
-0
No files found.
src/view/Manage/Model/Component/ImportExcelCopy.jsx
View file @
42d01639
import
React
from
'react'
;
import
{
Input
}
from
'antd'
;
import
{
Input
,
Row
,
Col
,
Descriptions
}
from
'antd'
;
class
ImportExcelCopy
extends
React
.
Component
{
constructor
()
{
super
();
this
.
state
=
{
inputValue
:
''
inputValue
:
''
,
translateValues
:
[]
};
}
componentDidUpdate
(
preProps
,
preState
)
{
const
{
visible
}
=
this
.
props
;
if
(
!
visible
&&
visible
!==
preProps
.
visible
)
{
this
.
setState
({
inputValue
:
''
});
this
.
setState
({
inputValue
:
''
,
translateValues
:
[]
});
}
}
onInputChange
=
(
e
)
=>
{
const
{
onChange
}
=
this
.
props
;
this
.
setState
({
inputValue
:
e
.
target
.
value
},
()
=>
{
onChange
&&
onChange
(
e
.
target
.
value
.
replace
(
/
[
,,,_
]
/g
,
'
\
n'
).
split
(
'
\
n'
).
filter
(
value
=>
value
!==
''
&&
value
!==
' '
));
const
_translateValues
=
e
.
target
.
value
.
replace
(
/
[
,,,_
]
/g
,
'
\
n'
).
split
(
'
\
n'
).
filter
(
value
=>
value
!==
''
&&
value
!==
' '
);
onChange
&&
onChange
(
_translateValues
);
this
.
setState
({
translateValues
:
_translateValues
});
});
}
render
()
{
const
{
inputValue
}
=
this
.
state
;
const
{
inputValue
,
translateValues
}
=
this
.
state
;
const
_placeholder
=
'支持两种方式创建
\
n方式一: Excel内容复制粘贴(模型名称和中文字段名)
\
n方式二: 手动输入模型名称和中文字段'
;
let
_attrsStr
=
''
;
translateValues
.
forEach
((
item
,
index
)
=>
{
if
(
index
===
0
)
{
_attrsStr
=
''
;
}
else
if
(
index
===
1
)
{
_attrsStr
=
item
;
}
else
{
_attrsStr
+=
`,
${
item
}
`
;
}
})
return
(
<
Input
.
TextArea
value=
{
inputValue
||
''
}
onChange=
{
this
.
onInputChange
}
autoSize=
{
{
minRows
:
4
,
maxRows
:
20
}
}
placeholder=
{
_placeholder
}
>
</
Input
.
TextArea
>
<
Row
gutter=
{
(
translateValues
.
length
>
0
)?
10
:
0
}
>
<
Col
span=
{
(
translateValues
.
length
>
0
)?
14
:
24
}
>
<
Input
.
TextArea
value=
{
inputValue
||
''
}
onChange=
{
this
.
onInputChange
}
autoSize=
{
{
minRows
:
4
,
maxRows
:
20
}
}
placeholder=
{
_placeholder
}
>
</
Input
.
TextArea
>
</
Col
>
{
(
translateValues
.
length
>
0
)
&&
<
Col
span=
{
10
}
>
<
Descriptions
className=
'excel-copy-descritpion'
column=
{
1
}
size=
'small'
>
<
Descriptions
.
Item
label=
'模型名称'
>
{
translateValues
[
0
]
}
</
Descriptions
.
Item
>
{
_attrsStr
.
length
>
0
&&
<
Descriptions
.
Item
label=
'字段名称'
>
{
_attrsStr
}
</
Descriptions
.
Item
>
}
</
Descriptions
>
</
Col
>
}
</
Row
>
)
}
}
...
...
src/view/Manage/Model/Component/ImportModal.jsx
View file @
42d01639
...
...
@@ -8,15 +8,16 @@ import ImportExcelCopy from './ImportExcelCopy';
import
{
dispatchLatest
}
from
'../../../../model'
;
const
importModes
=
[
{
name
:
'快速创建'
,
key
:
'excel-copy'
},
{
name
:
'空白创建'
,
key
:
'no-condition'
},
{
name
:
'Word导入'
,
key
:
'word'
},
{
name
:
'Excel导入'
,
key
:
'excel'
},
{
name
:
'Excel复制粘贴'
,
key
:
'excel-copy'
},
]
const
ImportModal
=
(
props
)
=>
{
const
{
view
,
catalogId
,
visible
,
onCancel
,
onCancelByWord
}
=
props
;
const
[
modeKey
,
setModeKey
]
=
useState
(
''
);
const
[
modeKey
,
setModeKey
]
=
useState
(
'
excel-copy
'
);
const
[
hints
,
setHints
]
=
useState
([]);
const
[
confirmLoading
,
setConfirmLoading
]
=
useState
(
false
);
...
...
@@ -73,7 +74,10 @@ const ImportModal = (props) => {
reset
();
onCancel
&&
onCancel
(
false
,
true
,
hints
||
[]);
}
}
else
if
(
modeKey
===
'no-condition'
)
{
reset
();
onCancel
&&
onCancel
(
false
,
true
,
[]);
}
}
catch
(
errInfo
)
{
console
.
log
(
'Validate Failed:'
,
errInfo
);
...
...
@@ -87,8 +91,8 @@ const ImportModal = (props) => {
}
const
reset
=
()
=>
{
form
.
resetFields
(
);
setModeKey
(
''
);
form
.
setFieldsValue
({
mode
:
'excel-copy'
}
);
setModeKey
(
'
excel-copy
'
);
setHints
([]);
setConfirmLoading
(
false
);
}
...
...
@@ -119,7 +123,7 @@ const ImportModal = (props) => {
forceRender
visible=
{
visible
}
title=
'新建模型'
width=
{
5
2
0
}
width=
{
5
4
0
}
onCancel=
{
cancel
}
footer=
{
footer
}
>
...
...
@@ -133,6 +137,7 @@ const ImportModal = (props) => {
message
:
'请选择新建方式'
,
},
]
}
initialValue=
{
modeKey
}
>
<
Radio
.
Group
onChange=
{
onModeChange
}
value=
{
modeKey
}
>
{
...
...
src/view/Manage/Model/Component/ModelTable.less
View file @
42d01639
...
...
@@ -38,4 +38,10 @@
.yy-descriptions-item-label, .yy-descriptions-item-content {
color: #fff !important;
}
}
.excel-copy-descritpion {
.yy-descriptions-row > td {
padding-bottom: 0px !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