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
82e3d32c
Commit
82e3d32c
authored
Aug 13, 2021
by
zhaochengxiang
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
字段自动翻译
parent
0b033b6b
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
91 additions
and
5 deletions
+91
-5
ImportActionTable.jsx
src/view/Manage/Model/Component/ImportActionTable.jsx
+87
-4
ImportActionTable.less
src/view/Manage/Model/Component/ImportActionTable.less
+4
-1
No files found.
src/view/Manage/Model/Component/ImportActionTable.jsx
View file @
82e3d32c
...
@@ -115,6 +115,7 @@ const EditableCell = ({
...
@@ -115,6 +115,7 @@ const EditableCell = ({
record
,
record
,
index
,
index
,
datatypes
,
datatypes
,
require
,
children
,
children
,
...
restProps
...
restProps
})
=>
{
})
=>
{
...
@@ -134,7 +135,7 @@ const EditableCell = ({
...
@@ -134,7 +135,7 @@ const EditableCell = ({
valuePropName=
{
(
inputType
===
'check'
)?
'checked'
:
'value'
}
valuePropName=
{
(
inputType
===
'check'
)?
'checked'
:
'value'
}
rules=
{
[
rules=
{
[
{
{
required
:
(
inputType
===
'text'
)
,
required
:
(
require
===
null
)?
false
:
require
,
message
:
`请输入${colTitle}!`
,
message
:
`请输入${colTitle}!`
,
},
},
]
}
]
}
...
@@ -153,7 +154,7 @@ const EditableCell = ({
...
@@ -153,7 +154,7 @@ const EditableCell = ({
valuePropName=
{
'value'
}
valuePropName=
{
'value'
}
rules=
{
[
rules=
{
[
{
{
required
:
tru
e
,
required
:
(
require
===
null
)?
false
:
requir
e
,
message
:
`请输入${colTitle}!`
,
message
:
`请输入${colTitle}!`
,
},
},
]
}
]
}
...
@@ -241,6 +242,7 @@ const ImportActionTable = (props) => {
...
@@ -241,6 +242,7 @@ const ImportActionTable = (props) => {
const
[
currentChangedValues
,
setCurrentChangedValues
]
=
useState
({});
const
[
currentChangedValues
,
setCurrentChangedValues
]
=
useState
({});
const
[
englishSuggests
,
setEnglishSuggests
]
=
useState
([]);
const
[
englishSuggests
,
setEnglishSuggests
]
=
useState
([]);
const
[
keyword
,
setKeyword
]
=
useState
(
''
);
const
[
keyword
,
setKeyword
]
=
useState
(
''
);
const
[
autoTranslate
,
setAutoTranslate
]
=
useState
(
false
);
const
[
filterData
,
setFilterData
]
=
useState
([]);
const
[
filterData
,
setFilterData
]
=
useState
([]);
...
@@ -278,10 +280,14 @@ const ImportActionTable = (props) => {
...
@@ -278,10 +280,14 @@ const ImportActionTable = (props) => {
cnName
:
''
,
cnName
:
''
,
datatype
:
{},
datatype
:
{},
remark
:
''
,
remark
:
''
,
defaultValue
:
''
,
definition
:
''
,
valueRange
:
''
,
...
record
,
...
record
,
});
});
setEditingKey
(
record
.
iid
);
setEditingKey
(
record
.
iid
);
setAutoTranslate
((
record
.
name
||
''
)
===
''
);
if
((
record
.
cnName
||
''
)
!==
''
)
{
if
((
record
.
cnName
||
''
)
!==
''
)
{
onValuesChange
({
cnName
:
record
.
cnName
},
record
,
1
,
record
.
iid
);
onValuesChange
({
cnName
:
record
.
cnName
},
record
,
1
,
record
.
iid
);
...
@@ -372,10 +378,10 @@ const ImportActionTable = (props) => {
...
@@ -372,10 +378,10 @@ const ImportActionTable = (props) => {
// console.log('changed values', changedValues);
// console.log('changed values', changedValues);
// console.log('all values', allValues);
// console.log('all values', allValues);
setSuggests
([]);
if
(
changedValues
.
hasOwnProperty
(
'cnName'
)
||
changedValues
.
hasOwnProperty
(
'name'
))
{
if
(
changedValues
.
hasOwnProperty
(
'cnName'
)
||
changedValues
.
hasOwnProperty
(
'name'
))
{
setSuggests
([]);
const
newData
=
[...
data
];
const
newData
=
[...
data
];
const
index
=
newData
.
findIndex
((
item
)
=>
iid
===
item
.
iid
);
const
index
=
newData
.
findIndex
((
item
)
=>
iid
===
item
.
iid
);
...
@@ -389,6 +395,7 @@ const ImportActionTable = (props) => {
...
@@ -389,6 +395,7 @@ const ImportActionTable = (props) => {
setSuggestHaveMore
(
false
);
setSuggestHaveMore
(
false
);
setCurrentChangedValues
(
changedValues
);
setCurrentChangedValues
(
changedValues
);
function
getSuggest
()
{
dispatchLatest
({
dispatchLatest
({
type
:
'datamodel.suggest'
,
type
:
'datamodel.suggest'
,
payload
:
{
payload
:
{
...
@@ -425,6 +432,30 @@ const ImportActionTable = (props) => {
...
@@ -425,6 +432,30 @@ const ImportActionTable = (props) => {
}
}
}
}
})
})
}
if
(
changedValues
.
hasOwnProperty
(
'cnName'
))
{
if
(
autoTranslate
)
{
dispatchLatest
({
type
:
'datamodel.translatePhase'
,
payload
:
{
params
:
{
phaseInChinese
:
changedValues
.
cnName
,
}
},
callback
:
data
=>
{
form
.
setFieldsValue
({
name
:
data
?.
translated
||
''
});
getSuggest
();
}
})
}
else
{
getSuggest
();
}
}
else
if
(
changedValues
.
hasOwnProperty
(
'name'
))
{
setAutoTranslate
(
changedValues
.
name
===
''
);
getSuggest
();
}
}
else
if
(
changedValues
.
hasOwnProperty
(
'nullable'
)
)
{
}
else
if
(
changedValues
.
hasOwnProperty
(
'nullable'
)
)
{
if
(
changedValues
.
nullable
&&
allValues
.
partOfPrimaryKey
)
{
if
(
changedValues
.
nullable
&&
allValues
.
partOfPrimaryKey
)
{
showMessage
(
'info'
,
'主键不允许为空'
);
showMessage
(
'info'
,
'主键不允许为空'
);
...
@@ -454,6 +485,7 @@ const ImportActionTable = (props) => {
...
@@ -454,6 +485,7 @@ const ImportActionTable = (props) => {
dataIndex
:
'key'
,
dataIndex
:
'key'
,
editable
:
false
,
editable
:
false
,
width
:
50
,
width
:
50
,
fixed
:
'left'
,
render
:
(
text
,
record
,
index
)
=>
{
render
:
(
text
,
record
,
index
)
=>
{
return
(
index
+
1
).
toString
();
return
(
index
+
1
).
toString
();
}
}
...
@@ -464,6 +496,8 @@ const ImportActionTable = (props) => {
...
@@ -464,6 +496,8 @@ const ImportActionTable = (props) => {
dataIndex
:
'cnName'
,
dataIndex
:
'cnName'
,
editable
:
true
,
editable
:
true
,
ellipsis
:
true
,
ellipsis
:
true
,
require
:
true
,
fixed
:
'left'
,
render
:
(
text
,
_
,
__
)
=>
{
render
:
(
text
,
_
,
__
)
=>
{
return
(
return
(
<
span
>
<
span
>
...
@@ -478,6 +512,7 @@ const ImportActionTable = (props) => {
...
@@ -478,6 +512,7 @@ const ImportActionTable = (props) => {
dataIndex
:
'name'
,
dataIndex
:
'name'
,
editable
:
true
,
editable
:
true
,
ellipsis
:
true
,
ellipsis
:
true
,
require
:
true
,
render
:
(
text
,
record
,
index
)
=>
{
render
:
(
text
,
record
,
index
)
=>
{
return
(
return
(
<
span
style=
{
{
fontWeight
:
'bold'
}
}
>
{
highlightSearchContentByTerms
(
text
,
terms
)
}
</
span
>
<
span
style=
{
{
fontWeight
:
'bold'
}
}
>
{
highlightSearchContentByTerms
(
text
,
terms
)
}
</
span
>
...
@@ -490,6 +525,7 @@ const ImportActionTable = (props) => {
...
@@ -490,6 +525,7 @@ const ImportActionTable = (props) => {
dataIndex
:
'datatype'
,
dataIndex
:
'datatype'
,
editable
:
true
,
editable
:
true
,
ellipsis
:
true
,
ellipsis
:
true
,
require
:
true
,
render
:
(
_
,
record
,
__
)
=>
{
render
:
(
_
,
record
,
__
)
=>
{
if
(
record
?.
datatype
)
{
if
(
record
?.
datatype
)
{
...
@@ -564,10 +600,53 @@ const ImportActionTable = (props) => {
...
@@ -564,10 +600,53 @@ const ImportActionTable = (props) => {
}
}
},
},
{
{
title
:
'默认值'
,
dataIndex
:
'defaultValue'
,
editable
:
true
,
ellipsis
:
true
,
width
:
100
,
render
:
(
text
,
_
,
__
)
=>
{
return
(
<
span
>
{
highlightSearchContentByTerms
(
text
,
terms
)
}
</
span
>
)
}
},
{
title
:
'业务定义'
,
dataIndex
:
'definition'
,
editable
:
true
,
ellipsis
:
true
,
width
:
200
,
render
:
(
text
,
_
,
__
)
=>
{
return
(
<
span
>
{
highlightSearchContentByTerms
(
text
,
terms
)
}
</
span
>
)
}
},
{
title
:
'值域'
,
dataIndex
:
'valueRange'
,
editable
:
true
,
ellipsis
:
true
,
width
:
100
,
render
:
(
text
,
_
,
__
)
=>
{
return
(
<
span
>
{
highlightSearchContentByTerms
(
text
,
terms
)
}
</
span
>
)
}
},
{
title
:
'描述'
,
title
:
'描述'
,
dataIndex
:
'remark'
,
dataIndex
:
'remark'
,
editable
:
true
,
editable
:
true
,
ellipsis
:
true
,
ellipsis
:
true
,
width
:
200
,
render
:
(
text
,
_
,
__
)
=>
{
render
:
(
text
,
_
,
__
)
=>
{
return
(
return
(
<
span
>
<
span
>
...
@@ -584,6 +663,7 @@ const ImportActionTable = (props) => {
...
@@ -584,6 +663,7 @@ const ImportActionTable = (props) => {
title
:
'操作'
,
title
:
'操作'
,
dataIndex
:
'action'
,
dataIndex
:
'action'
,
width
:
100
,
width
:
100
,
fixed
:
'right'
,
render
:
(
_
,
record
)
=>
{
render
:
(
_
,
record
)
=>
{
if
(
!
editable
)
return
null
;
if
(
!
editable
)
return
null
;
...
@@ -614,6 +694,7 @@ const ImportActionTable = (props) => {
...
@@ -614,6 +694,7 @@ const ImportActionTable = (props) => {
title
:
'规范'
,
title
:
'规范'
,
dataIndex
:
'validate'
,
dataIndex
:
'validate'
,
width
:
180
,
width
:
180
,
fixed
:
'right'
,
render
:
(
text
,
record
,
index
)
=>
{
render
:
(
text
,
record
,
index
)
=>
{
let
shortCauses
=
[];
let
shortCauses
=
[];
let
causes
=
[];
let
causes
=
[];
...
@@ -698,6 +779,7 @@ const ImportActionTable = (props) => {
...
@@ -698,6 +779,7 @@ const ImportActionTable = (props) => {
colTitle
:
col
.
title
,
colTitle
:
col
.
title
,
editing
:
isEditing
(
record
),
editing
:
isEditing
(
record
),
datatypes
:
supportedDatatypes
,
datatypes
:
supportedDatatypes
,
require
:
col
.
require
}),
}),
};
};
});
});
...
@@ -802,6 +884,7 @@ const ImportActionTable = (props) => {
...
@@ -802,6 +884,7 @@ const ImportActionTable = (props) => {
rowKey=
'iid'
rowKey=
'iid'
pagination=
{
false
}
pagination=
{
false
}
search=
{
false
}
search=
{
false
}
scroll=
{
{
x
:
1500
}
}
options=
{
{
options=
{
{
density
:
false
,
density
:
false
,
setting
:
false
,
setting
:
false
,
...
...
src/view/Manage/Model/Component/ImportActionTable.less
View file @
82e3d32c
...
@@ -12,6 +12,8 @@
...
@@ -12,6 +12,8 @@
}
}
.template-highlight-row {
.template-highlight-row {
background-color: #e7f7ff;
.yy-table-cell {
background-color: #e7f7ff !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