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
ac54c3ff
Commit
ac54c3ff
authored
Apr 17, 2023
by
zhaochengxiang
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
调整
parent
641a5c77
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
517 additions
and
517 deletions
+517
-517
ImportActionHeader.jsx
src/view/Manage/Model/Component/ImportActionHeader.jsx
+517
-517
No files found.
src/view/Manage/Model/Component/ImportActionHeader.jsx
View file @
ac54c3ff
...
...
@@ -45,566 +45,268 @@ const updateOptions = [
const
dataTypeRemark
=
'描述ETL框架中目标表的数据类型'
;
const
bindingLoadRemark
=
'描述ETL框架绑定加载列表,如chain、daily、current等'
;
const
ConstraintSelect
=
({
value
=
{},
constraints
=
[],
onChange
,
...
restProps
})
=>
{
const
ImportActionHeader
=
(
props
)
=>
{
const
{
editable
,
form
,
modelerData
,
constraints
,
templates
,
onConstraintChange
,
onTemplateChange
,
validateReports
,
onChange
,
terms
,
supportedPartitionTypes
}
=
props
;
return
(
<
Select
onChange=
{
onChange
}
value=
{
value
?.
name
||
''
}
placeholder=
'请选择规范'
{
...
restProps
}
>
{
(
constraints
||
[])
&&
constraints
.
map
((
constraint
,
index
)
=>
{
return
(
<
Option
key=
{
index
}
value=
{
constraint
.
name
||
''
}
>
{
constraint
.
cnName
||
''
}
</
Option
>
);
})
}
</
Select
>
)
}
const
[
causes
,
setCauses
]
=
useState
([]);
const
[
options
,
setOptions
]
=
useState
([]);
const
TemplateSelect
=
({
value
=
''
,
modelerData
=
undefined
,
templates
=
[],
onChange
,
...
restProps
})
=>
{
const
mountRef
=
useRef
(
true
);
const
[
isCustom
,
setIsCustom
]
=
useState
(
false
);
const
[
autoTranslate
,
setAutoTranslate
]
=
useState
(
false
);
const
[
onlyShowRequireChange
,
setOnlyShowRequireChange
]
=
useState
(
true
);
const
[
maintenanceRecords
,
setMaintenanceRecords
]
=
useState
(
null
);
const
[
dataTypeList
,
setDataTypeList
]
=
useState
(
null
);
const
[
bindingLoadRangeList
,
setBindingLoadRangeList
]
=
useState
(
null
);
const
[
dataCircumstances
,
setDataCircumstances
]
=
useState
(
null
);
useEffect
(()
=>
{
if
(
mountRef
.
current
&&
modelerData
&&
Object
.
keys
(
modelerData
).
length
>
0
)
{
if
(
modelerData
?.
tableType
&&
!
modelerData
?.
easyDataModelerModelingTemplate
?.
name
)
{
setIsCustom
(
true
);
}
else
{
setIsCustom
(
false
);
}
getDataTypeList
();
},
[])
mountRef
.
current
=
false
;
}
},
[
modelerData
])
useEffect
(()
=>
{
if
(
modelerData
?.
dataType
)
{
getBindingLoadRangeList
(
modelerData
?.
dataType
);
}
else
{
setBindingLoadRangeList
([]);
}
},
[
modelerData
?.
dataType
])
return
(
<
span
style=
{
{
display
:
'flex'
,
alignItems
:
'center'
,
justifyContent
:
'space-between'
}
}
>
{
isCustom
?
<
InputDebounce
placeholder=
'请输入数据表类型'
allowClear
value=
{
modelerData
?.
tableType
}
onChange=
{
(
val
)
=>
{
onChange
?.(
val
,
true
);
}
}
style=
{
{
flex
:
1
}
}
/>
:
<
Select
onChange=
{
(
val
)
=>
{
onChange
?.(
val
);
}
}
value=
{
value
||
undefined
}
placeholder=
'请选择数据表类型'
allowClear
style=
{
{
flex
:
1
}
}
{
...
restProps
}
>
{
(
templates
||
[])
&&
templates
.
map
((
template
,
index
)
=>
{
return
(
<
Option
key=
{
index
}
value=
{
template
.
cnName
||
''
}
>
<
Tooltip
title=
{
template
.
remark
}
>
{
template
.
cnName
}
</
Tooltip
>
</
Option
>
);
})
}
</
Select
>
}
<
Checkbox
className=
'ml-3'
checked=
{
isCustom
}
onChange=
{
(
e
)
=>
{
setIsCustom
(
e
.
target
.
checked
);
onChange
?.(
''
);
}
}
>
自定义
</
Checkbox
>
</
span
>
)
}
useEffect
(()
=>
{
const
AttributesSelect
=
({
value
=
[],
modelerData
,
onChange
,
mode
=
'multiple'
,
...
restProps
})
=>
{
const
causes
=
[];
(
validateReports
||
[]).
forEach
(
report
=>
{
if
(
report
.
type
===
'DataModel'
)
{
(
report
.
reportItems
||
[]).
forEach
((
item
)
=>
{
causes
.
push
(
item
.
cause
||
''
);
})
}
});
const
onAttributeChange
=
(
value
)
=>
{
let
currentAttributes
=
[];
if
(
mode
===
'multiple'
)
{
currentAttributes
=
(
modelerData
?.
easyDataModelerDataModelAttributes
||
[]).
filter
(
attribute
=>
(
value
||
[]).
indexOf
(
attribute
.
iid
)
!==-
1
);
if
(
editable
)
{
form
?.
setFields
([{
name
:
'name'
,
errors
:
causes
}]);
}
else
{
(
value
||
[]).
forEach
(
item
=>
{
setCauses
(
causes
);
}
const
filterAttributes
=
(
newAttributes
||
[]).
filter
(
attribute
=>
item
===
attribute
.
iid
);
//eslint-disable-next-line react-hooks/exhaustive-deps
},
[
validateReports
])
if
(
filterAttributes
.
length
!==
0
)
{
currentAttributes
=
[...
currentAttributes
,
...
filterAttributes
];
}
else
{
currentAttributes
=
[...
currentAttributes
,
{
name
:
item
,
iid
:
generateUUID
()
}];
}
})
}
useEffect
(()
=>
{
triggerChange
(
currentAttributes
);
}
setAutoTranslate
((
modelerData
.
name
||
''
)
===
''
);
if
(
modelerData
)
{
form
?.
setFieldsValue
(
modelerData
);
setDataCircumstances
(
modelerData
.
dataCircumstances
);
const
triggerChange
=
(
changedValue
)
=>
{
onChange
?.(
changedValue
);
};
if
((
modelerData
.
id
||
''
)
!==
''
&&
maintenanceRecords
===
null
)
{
getMaintenanceRecords
();
}
}
//eslint-disable-next-line react-hooks/exhaustive-deps
},
[
modelerData
])
//value有可能为空
value
=
value
?
value
:
[];
let
attributeIds
=
[];
let
newAttributes
=
[...(
modelerData
?.
easyDataModelerDataModelAttributes
||
[])];
value
.
forEach
(
attribute
=>
{
attributeIds
.
push
(
attribute
.
iid
);
useEffect
(()
=>
{
if
((
maintenanceRecords
||
[]).
length
>
0
)
{
let
maintenanceDescription
=
''
;
maintenanceRecords
.
forEach
((
record
,
index
)
=>
{
if
(
index
!==
0
)
{
maintenanceDescription
+=
'/'
;
}
maintenanceDescription
+=
record
;
})
if
(
mode
===
'tags'
)
{
const
filterAttributes
=
(
modelerData
?.
easyDataModelerDataModelAttributes
||
[]).
filter
(
_attribute
=>
attribute
.
iid
===
_attribute
.
iid
);
form
?.
setFieldsValue
({
maintenanceRecords
:
maintenanceDescription
});
}
//eslint-disable-next-line react-hooks/exhaustive-deps
},
[
maintenanceRecords
,
editable
])
//分布
const
distributionDescription
=
useMemo
(()
=>
{
let
newDistributionDescription
=
''
if
(
!
editable
&&
modelerData
)
{
if
(
modelerData
?.
easyDataModelerDistributionKey
)
{
(
modelerData
?.
easyDataModelerDistributionKey
||
[]).
forEach
((
item
,
index
)
=>
{
if
(
index
>
0
)
{
newDistributionDescription
+=
','
;
}
if
(
filterAttributes
.
length
===
0
)
{
newAttributes
=
[...
newAttributes
,
attribute
];
}
newDistributionDescription
+=
item
.
name
||
''
;
});
}
})
return
(
<
Select
onChange=
{
(
value
)
=>
{
onAttributeChange
&&
onAttributeChange
(
value
)
}
}
value=
{
attributeIds
}
placeholder=
'请选择字段名称'
mode=
{
mode
}
allowClear=
{
true
}
>
{
(
newAttributes
||
[]).
map
((
attribute
,
index
)
=>
{
return
(
<
Option
key=
{
index
}
value=
{
attribute
.
iid
?
attribute
.
iid
:(
attribute
.
name
||
''
)
}
>
{
attribute
.
name
||
''
}
</
Option
>
);
})
}
</
Select
>
);
}
return
newDistributionDescription
;
},
[
editable
,
modelerData
])
const
PartitionSelect
=
({
value
=
{},
modelerData
,
partitionTypes
=
[],
onChange
,
...
restProps
})
=>
{
//主键
const
primaryDescription
=
useMemo
(()
=>
{
let
newPrimaryDescription
=
''
if
(
modelerData
?.
easyDataModelerPrimaryKey
)
{
(
modelerData
?.
easyDataModelerPrimaryKey
||
[]).
forEach
((
item
,
index
)
=>
{
if
(
index
>
0
)
{
newPrimaryDescription
+=
','
;
}
const
onPartitionTypeChange
=
(
value
)
=>
{
newPrimaryDescription
+=
item
.
name
||
''
;
})
}
return
newPrimaryDescription
;
//eslint-disable-next-line react-hooks/exhaustive-deps
},
[
editable
,
modelerData
])
let
currentPartitionType
=
{};
(
partitionTypes
||
[]).
forEach
((
partitionType
,
index
)
=>
{
if
(
value
===
partitionType
.
name
)
{
currentPartitionType
=
partitionType
;
}
})
//分区
const
partitionsDescription
=
useMemo
(()
=>
{
let
newPartitionsDescription
=
''
if
(
modelerData
?.
partition
?.
keys
)
{
(
modelerData
?.
partition
?.
keys
||
[]).
forEach
((
item
,
index
)
=>
{
if
(
index
>
0
)
{
newPartitionsDescription
+=
','
;
}
triggerChange
({
partitionType
:
currentPartitionType
});
}
newPartitionsDescription
+=
item
.
name
||
''
;
})
}
if
(
modelerData
?.
partition
?.
partitionType
?.
cnName
)
{
newPartitionsDescription
+=
'/'
+
modelerData
?.
partition
?.
partitionType
?.
cnName
||
''
;
}
return
newPartitionsDescription
;
//eslint-disable-next-line react-hooks/exhaustive-deps
},
[
editable
,
modelerData
])
const
onAttributeChange
=
(
value
)
=>
{
const
currentAttributes
=
(
modelerData
?.
easyDataModelerDataModelAttributes
||
[]).
filter
(
attribute
=>
(
value
||
[]).
indexOf
(
attribute
.
iid
)
!==-
1
);
//类主键
const
semiPrimaryDescription
=
useMemo
(()
=>
{
let
newSemiPrimaryDescription
=
''
if
(
modelerData
?.
easyDataModelerSemiPrimaryKey
)
{
(
modelerData
?.
easyDataModelerSemiPrimaryKey
||
[]).
forEach
((
item
,
index
)
=>
{
if
(
index
>
0
)
{
newSemiPrimaryDescription
+=
','
;
}
triggerChange
({
keys
:
currentAttributes
});
}
newSemiPrimaryDescription
+=
item
.
name
||
''
;
})
}
return
newSemiPrimaryDescription
;
//eslint-disable-next-line react-hooks/exhaustive-deps
},
[
editable
,
modelerData
])
const
triggerChange
=
(
changedValue
)
=>
{
onChange
?.({
...
value
,
...
changedValue
,
});
const
formItemLayout
=
{
labelCol
:
{
xs
:
{
span
:
24
},
sm
:
{
span
:
6
},
},
wrapperCol
:
{
xs
:
{
span
:
24
},
sm
:
{
span
:
18
},
},
};
//value有可能为空
value
=
value
?
value
:
{};
let
attributeIds
=
[];
(
value
?.
keys
||
[]).
forEach
(
attribute
=>
{
attributeIds
.
push
(
attribute
.
iid
);
})
return
(
<
Row
gutter=
{
10
}
>
<
Col
span=
{
10
}
>
<
Select
onChange=
{
onPartitionTypeChange
}
value=
{
value
?.
partitionType
?.
name
}
placeholder=
'请选择分区类型'
allowClear=
{
true
}
>
{
(
partitionTypes
||
[]).
map
((
partitionType
,
index
)
=>
{
return
(
<
Option
key=
{
partitionType
.
name
||
''
}
>
{
partitionType
.
cnName
||
''
}
</
Option
>
);
})
}
</
Select
>
</
Col
>
<
Col
span=
{
14
}
>
<
Select
onChange=
{
(
value
)
=>
{
onAttributeChange
&&
onAttributeChange
(
value
)
}
}
value=
{
attributeIds
}
placeholder=
'请选择字段名称'
mode=
'multiple'
allowClear=
{
true
}
>
{
(
modelerData
?.
easyDataModelerDataModelAttributes
||
[]).
map
((
attribute
,
index
)
=>
{
return
(
<
Option
key=
{
index
}
value=
{
attribute
.
iid
||
''
}
>
{
attribute
.
name
||
''
}
</
Option
>
);
})
const
getMaintenanceRecords
=
()
=>
{
dispatch
({
type
:
'datamodel.getMaintenanceRecords'
,
payload
:
{
params
:
{
id
:
modelerData
.
id
}
</
Select
>
</
Col
>
</
Row
>
);
}
const
LoadSelect
=
({
value
=
''
,
onChange
,
...
restProps
})
=>
{
const
onLoadChange
=
(
value
)
=>
{
triggerChange
(
value
.
join
(
'/'
));
}
const
triggerChange
=
(
changedValue
)
=>
{
onChange
?.(
changedValue
);
};
//value有可能为空
value
=
value
?
value
:
''
;
let
loadNames
=
[];
if
(
value
!==
''
)
{
value
.
split
(
'/'
).
forEach
(
item
=>
{
loadNames
.
push
(
item
);
},
callback
:
data
=>
{
setMaintenanceRecords
(
data
);
}
})
}
return
(
<
Select
mode=
"tags"
tokenSeparators=
{
[
'/'
,
' '
]
}
onChange=
{
(
value
)
=>
{
onLoadChange
&&
onLoadChange
(
value
)
}
}
value=
{
loadNames
}
placeholder=
'请选择或者手动输入加载方式'
allowClear=
{
true
}
>
{
loadOptions
.
map
((
item
,
index
)
=>
{
return
(
<
Option
key=
{
index
}
value=
{
item
}
>
{
item
}
</
Option
>
);
})
}
</
Select
>
);
}
const
UpdateSelect
=
({
value
=
''
,
onChange
,
...
restProps
})
=>
{
const
onUpdateChange
=
(
value
)
=>
{
triggerChange
(
value
.
join
(
'/'
));
const
getDataTypeList
=
()
=>
{
dispatch
({
type
:
'datamodel.dataTypeList'
,
callback
:
data
=>
{
setDataTypeList
(
data
);
}
})
}
const
triggerChange
=
(
changedValue
)
=>
{
onChange
?.(
changedValue
);
};
//value有可能为空
value
=
value
?
value
:
''
;
let
updateNames
=
[];
if
(
value
!==
''
)
{
value
.
split
(
'/'
).
forEach
(
item
=>
{
updateNames
.
push
(
item
);
const
getBindingLoadRangeList
=
(
dataTypeName
)
=>
{
dispatch
({
type
:
'datamodel.bindingLoadRangeList'
,
payload
:
{
dataTypeName
},
callback
:
data
=>
{
setBindingLoadRangeList
(
data
);
}
})
}
return
(
<
Select
mode=
"tags"
tokenSeparators=
{
[
'/'
,
' '
]
}
onChange=
{
(
value
)
=>
{
onUpdateChange
&&
onUpdateChange
(
value
)
}
}
value=
{
updateNames
}
allowClear=
{
true
}
{
...
restProps
}
>
{
updateOptions
.
map
((
item
,
index
)
=>
{
return
(
<
Option
key=
{
index
}
value=
{
item
}
>
{
item
}
</
Option
>
);
})
}
</
Select
>
);
}
const
ImportActionHeader
=
(
props
)
=>
{
const
{
editable
,
form
,
modelerData
,
constraints
,
templates
,
onConstraintChange
,
onTemplateChange
,
validateReports
,
onChange
,
terms
,
supportedPartitionTypes
}
=
props
;
const
[
causes
,
setCauses
]
=
useState
([]);
const
[
options
,
setOptions
]
=
useState
([]);
const
[
autoTranslate
,
setAutoTranslate
]
=
useState
(
false
);
const
[
onlyShowRequireChange
,
setOnlyShowRequireChange
]
=
useState
(
true
);
const
[
maintenanceRecords
,
setMaintenanceRecords
]
=
useState
(
null
);
const
[
dataTypeList
,
setDataTypeList
]
=
useState
(
null
);
const
[
bindingLoadRangeList
,
setBindingLoadRangeList
]
=
useState
(
null
);
const
[
dataCircumstances
,
setDataCircumstances
]
=
useState
(
null
);
const
onSearch
=
(
searchText
)
=>
{
useEffect
(()
=>
{
getDataTypeList
();
},
[])
const
_searchText
=
searchText
.
replace
(
/ /g
,
''
);
if
(
_searchText
!==
''
)
{
dispatchLatest
({
type
:
'datamodel.autocomplete'
,
payload
:
{
params
:
{
word
:
_searchText
,
isEasyDataModelerDataModelAttribute
:
false
,
}
},
callback
:
data
=>
{
const
_options
=
[];
(
data
||
[]).
forEach
(
item
=>
{
_options
.
push
({
value
:
item
});
})
useEffect
(()
=>
{
if
(
modelerData
?.
dataType
)
{
getBindingLoadRangeList
(
modelerData
?.
dataType
);
setOptions
(
_options
);
}
})
}
else
{
setBindingLoadRangeList
([]);
dispatchLatest
({
type
:
'datamodel.recommandEnglishWords'
,
payload
:
{
params
:
{
chineseWord
:
modelerData
.
cnName
,
}
},
callback
:
data
=>
{
const
_options
=
[];
(
data
||
[]).
forEach
(
item
=>
{
_options
.
push
({
value
:
item
});
})
setOptions
(
_options
);
}
})
}
}
,
[
modelerData
?.
dataType
])
}
useEffect
(()
=>
{
const
onValuesChange
=
(
changedValues
,
allValues
)
=>
{
onChange
&&
onChange
(
changedValues
,
allValues
);
const
causes
=
[];
(
validateReports
||
[]).
forEach
(
report
=>
{
if
(
report
.
type
===
'DataModel'
)
{
(
report
.
reportItems
||
[]).
forEach
((
item
)
=>
{
causes
.
push
(
item
.
cause
||
''
);
//有手动编辑过英文名称并且有内容的情况下, 不能通过编辑中文名称自动翻译
if
(
changedValues
.
hasOwnProperty
(
'name'
))
{
setAutoTranslate
(
changedValues
.
name
===
''
);
}
else
if
(
changedValues
.
hasOwnProperty
(
'cnName'
))
{
if
(
autoTranslate
)
{
dispatchLatest
({
type
:
'datamodel.translatePhase'
,
payload
:
{
params
:
{
phaseInChinese
:
changedValues
.
cnName
,
}
},
callback
:
data
=>
{
if
((
data
?.
translated
||
''
)
!==
''
)
{
form
?.
setFieldsValue
({
name
:
data
?.
translated
||
''
});
onChange
&&
onChange
({...
changedValues
,
...{
name
:
data
?.
translated
||
''
}},
{...
allValues
,
...{
name
:
data
?.
translated
||
''
}});
}
}
})
}
}
);
if
(
editable
)
{
form
?.
setFields
([{
name
:
'name'
,
errors
:
causes
}]);
}
else
{
setCauses
(
causes
);
}
else
if
(
changedValues
.
hasOwnProperty
(
'dataType'
))
{
if
(
changedValues
.
dataType
)
{
onChange
?.({...
changedValues
,
bindingLoadRange
:
''
},
{...
allValues
,
bindingLoadRange
:
''
});
}
else
{
onChange
?.({...
changedValues
,
bindingLoadRange
:
''
},
{...
allValues
,
bindingLoadRange
:
''
});
}
}
//eslint-disable-next-line react-hooks/exhaustive-deps
},
[
validateReports
])
useEffect
(()
=>
{
setAutoTranslate
((
modelerData
.
name
||
''
)
===
''
);
if
(
modelerData
)
{
form
?.
setFieldsValue
(
modelerData
);
setDataCircumstances
(
modelerData
.
dataCircumstances
);
if
((
modelerData
.
id
||
''
)
!==
''
&&
maintenanceRecords
===
null
)
{
getMaintenanceRecords
();
}
}
//eslint-disable-next-line react-hooks/exhaustive-deps
},
[
modelerData
])
useEffect
(()
=>
{
if
((
maintenanceRecords
||
[]).
length
>
0
)
{
let
maintenanceDescription
=
''
;
maintenanceRecords
.
forEach
((
record
,
index
)
=>
{
if
(
index
!==
0
)
{
maintenanceDescription
+=
'/'
;
}
maintenanceDescription
+=
record
;
})
form
?.
setFieldsValue
({
maintenanceRecords
:
maintenanceDescription
});
}
//eslint-disable-next-line react-hooks/exhaustive-deps
},
[
maintenanceRecords
,
editable
])
//分布
const
distributionDescription
=
useMemo
(()
=>
{
let
newDistributionDescription
=
''
if
(
!
editable
&&
modelerData
)
{
if
(
modelerData
?.
easyDataModelerDistributionKey
)
{
(
modelerData
?.
easyDataModelerDistributionKey
||
[]).
forEach
((
item
,
index
)
=>
{
if
(
index
>
0
)
{
newDistributionDescription
+=
','
;
}
newDistributionDescription
+=
item
.
name
||
''
;
});
}
}
return
newDistributionDescription
;
},
[
editable
,
modelerData
])
//主键
const
primaryDescription
=
useMemo
(()
=>
{
let
newPrimaryDescription
=
''
if
(
modelerData
?.
easyDataModelerPrimaryKey
)
{
(
modelerData
?.
easyDataModelerPrimaryKey
||
[]).
forEach
((
item
,
index
)
=>
{
if
(
index
>
0
)
{
newPrimaryDescription
+=
','
;
}
newPrimaryDescription
+=
item
.
name
||
''
;
})
}
return
newPrimaryDescription
;
//eslint-disable-next-line react-hooks/exhaustive-deps
},
[
editable
,
modelerData
])
//分区
const
partitionsDescription
=
useMemo
(()
=>
{
let
newPartitionsDescription
=
''
if
(
modelerData
?.
partition
?.
keys
)
{
(
modelerData
?.
partition
?.
keys
||
[]).
forEach
((
item
,
index
)
=>
{
if
(
index
>
0
)
{
newPartitionsDescription
+=
','
;
}
newPartitionsDescription
+=
item
.
name
||
''
;
})
}
if
(
modelerData
?.
partition
?.
partitionType
?.
cnName
)
{
newPartitionsDescription
+=
'/'
+
modelerData
?.
partition
?.
partitionType
?.
cnName
||
''
;
}
return
newPartitionsDescription
;
//eslint-disable-next-line react-hooks/exhaustive-deps
},
[
editable
,
modelerData
])
//类主键
const
semiPrimaryDescription
=
useMemo
(()
=>
{
let
newSemiPrimaryDescription
=
''
if
(
modelerData
?.
easyDataModelerSemiPrimaryKey
)
{
(
modelerData
?.
easyDataModelerSemiPrimaryKey
||
[]).
forEach
((
item
,
index
)
=>
{
if
(
index
>
0
)
{
newSemiPrimaryDescription
+=
','
;
}
newSemiPrimaryDescription
+=
item
.
name
||
''
;
})
}
return
newSemiPrimaryDescription
;
//eslint-disable-next-line react-hooks/exhaustive-deps
},
[
editable
,
modelerData
])
const
formItemLayout
=
{
labelCol
:
{
xs
:
{
span
:
24
},
sm
:
{
span
:
6
},
},
wrapperCol
:
{
xs
:
{
span
:
24
},
sm
:
{
span
:
18
},
},
};
const
getMaintenanceRecords
=
()
=>
{
dispatch
({
type
:
'datamodel.getMaintenanceRecords'
,
payload
:
{
params
:
{
id
:
modelerData
.
id
}
},
callback
:
data
=>
{
setMaintenanceRecords
(
data
);
}
})
}
const
getDataTypeList
=
()
=>
{
dispatch
({
type
:
'datamodel.dataTypeList'
,
callback
:
data
=>
{
setDataTypeList
(
data
);
}
})
}
const
getBindingLoadRangeList
=
(
dataTypeName
)
=>
{
dispatch
({
type
:
'datamodel.bindingLoadRangeList'
,
payload
:
{
dataTypeName
},
callback
:
data
=>
{
setBindingLoadRangeList
(
data
);
}
})
}
const
onSearch
=
(
searchText
)
=>
{
const
_searchText
=
searchText
.
replace
(
/ /g
,
''
);
if
(
_searchText
!==
''
)
{
dispatchLatest
({
type
:
'datamodel.autocomplete'
,
payload
:
{
params
:
{
word
:
_searchText
,
isEasyDataModelerDataModelAttribute
:
false
,
}
},
callback
:
data
=>
{
const
_options
=
[];
(
data
||
[]).
forEach
(
item
=>
{
_options
.
push
({
value
:
item
});
})
setOptions
(
_options
);
}
})
}
else
{
dispatchLatest
({
type
:
'datamodel.recommandEnglishWords'
,
payload
:
{
params
:
{
chineseWord
:
modelerData
.
cnName
,
}
},
callback
:
data
=>
{
const
_options
=
[];
(
data
||
[]).
forEach
(
item
=>
{
_options
.
push
({
value
:
item
});
})
setOptions
(
_options
);
}
})
}
}
const
onValuesChange
=
(
changedValues
,
allValues
)
=>
{
onChange
&&
onChange
(
changedValues
,
allValues
);
//有手动编辑过英文名称并且有内容的情况下, 不能通过编辑中文名称自动翻译
if
(
changedValues
.
hasOwnProperty
(
'name'
))
{
setAutoTranslate
(
changedValues
.
name
===
''
);
}
else
if
(
changedValues
.
hasOwnProperty
(
'cnName'
))
{
if
(
autoTranslate
)
{
dispatchLatest
({
type
:
'datamodel.translatePhase'
,
payload
:
{
params
:
{
phaseInChinese
:
changedValues
.
cnName
,
}
},
callback
:
data
=>
{
if
((
data
?.
translated
||
''
)
!==
''
)
{
form
?.
setFieldsValue
({
name
:
data
?.
translated
||
''
});
onChange
&&
onChange
({...
changedValues
,
...{
name
:
data
?.
translated
||
''
}},
{...
allValues
,
...{
name
:
data
?.
translated
||
''
}});
}
}
})
}
}
else
if
(
changedValues
.
hasOwnProperty
(
'dataType'
))
{
if
(
changedValues
.
dataType
)
{
onChange
?.({...
changedValues
,
bindingLoadRange
:
''
},
{...
allValues
,
bindingLoadRange
:
''
});
}
else
{
onChange
?.({...
changedValues
,
bindingLoadRange
:
''
},
{...
allValues
,
bindingLoadRange
:
''
});
}
}
}
}
const
onOnlyShowRequireChange
=
()
=>
{
setOnlyShowRequireChange
(
!
onlyShowRequireChange
);
...
...
@@ -855,4 +557,302 @@ const ImportActionHeader = (props) => {
)
}
export
default
ImportActionHeader
;
\ No newline at end of file
export
default
ImportActionHeader
;
const
ConstraintSelect
=
({
value
=
{},
constraints
=
[],
onChange
,
...
restProps
})
=>
{
return
(
<
Select
onChange=
{
onChange
}
value=
{
value
?.
name
||
''
}
placeholder=
'请选择规范'
{
...
restProps
}
>
{
(
constraints
||
[])
&&
constraints
.
map
((
constraint
,
index
)
=>
{
return
(
<
Option
key=
{
index
}
value=
{
constraint
.
name
||
''
}
>
{
constraint
.
cnName
||
''
}
</
Option
>
);
})
}
</
Select
>
)
}
const
TemplateSelect
=
({
value
=
''
,
modelerData
=
undefined
,
templates
=
[],
onChange
,
...
restProps
})
=>
{
const
mountRef
=
useRef
(
true
);
const
[
isCustom
,
setIsCustom
]
=
useState
(
false
);
useEffect
(()
=>
{
if
(
mountRef
.
current
&&
modelerData
&&
Object
.
keys
(
modelerData
).
length
>
0
)
{
if
(
modelerData
?.
tableType
&&
!
modelerData
?.
easyDataModelerModelingTemplate
?.
name
)
{
setIsCustom
(
true
);
}
else
{
setIsCustom
(
false
);
}
mountRef
.
current
=
false
;
}
},
[
modelerData
])
return
(
<
span
style=
{
{
display
:
'flex'
,
alignItems
:
'center'
,
justifyContent
:
'space-between'
}
}
>
{
isCustom
?
<
InputDebounce
placeholder=
'请输入数据表类型'
allowClear
value=
{
modelerData
?.
tableType
}
onChange=
{
(
val
)
=>
{
onChange
?.(
val
,
true
);
}
}
style=
{
{
flex
:
1
}
}
/>
:
<
Select
onChange=
{
(
val
)
=>
{
onChange
?.(
val
);
}
}
value=
{
value
||
undefined
}
placeholder=
'请选择数据表类型'
allowClear
style=
{
{
flex
:
1
}
}
{
...
restProps
}
>
{
(
templates
||
[])
&&
templates
.
map
((
template
,
index
)
=>
{
return
(
<
Option
key=
{
index
}
value=
{
template
.
cnName
||
''
}
>
<
Tooltip
title=
{
template
.
remark
}
>
{
template
.
cnName
}
</
Tooltip
>
</
Option
>
);
})
}
</
Select
>
}
<
Checkbox
className=
'ml-3'
checked=
{
isCustom
}
onChange=
{
(
e
)
=>
{
setIsCustom
(
e
.
target
.
checked
);
onChange
?.(
''
);
}
}
>
自定义
</
Checkbox
>
</
span
>
)
}
const
AttributesSelect
=
({
value
=
[],
modelerData
,
onChange
,
mode
=
'multiple'
,
...
restProps
})
=>
{
const
onAttributeChange
=
(
value
)
=>
{
let
currentAttributes
=
[];
if
(
mode
===
'multiple'
)
{
currentAttributes
=
(
modelerData
?.
easyDataModelerDataModelAttributes
||
[]).
filter
(
attribute
=>
(
value
||
[]).
indexOf
(
attribute
.
iid
)
!==-
1
);
}
else
{
(
value
||
[]).
forEach
(
item
=>
{
const
filterAttributes
=
(
newAttributes
||
[]).
filter
(
attribute
=>
item
===
attribute
.
iid
);
if
(
filterAttributes
.
length
!==
0
)
{
currentAttributes
=
[...
currentAttributes
,
...
filterAttributes
];
}
else
{
currentAttributes
=
[...
currentAttributes
,
{
name
:
item
,
iid
:
generateUUID
()
}];
}
})
}
triggerChange
(
currentAttributes
);
}
const
triggerChange
=
(
changedValue
)
=>
{
onChange
?.(
changedValue
);
};
//value有可能为空
value
=
value
?
value
:
[];
let
attributeIds
=
[];
let
newAttributes
=
[...(
modelerData
?.
easyDataModelerDataModelAttributes
||
[])];
value
.
forEach
(
attribute
=>
{
attributeIds
.
push
(
attribute
.
iid
);
if
(
mode
===
'tags'
)
{
const
filterAttributes
=
(
modelerData
?.
easyDataModelerDataModelAttributes
||
[]).
filter
(
_attribute
=>
attribute
.
iid
===
_attribute
.
iid
);
if
(
filterAttributes
.
length
===
0
)
{
newAttributes
=
[...
newAttributes
,
attribute
];
}
}
})
return
(
<
Select
onChange=
{
(
value
)
=>
{
onAttributeChange
&&
onAttributeChange
(
value
)
}
}
value=
{
attributeIds
}
placeholder=
'请选择字段名称'
mode=
{
mode
}
allowClear=
{
true
}
>
{
(
newAttributes
||
[]).
map
((
attribute
,
index
)
=>
{
return
(
<
Option
key=
{
index
}
value=
{
attribute
.
iid
?
attribute
.
iid
:(
attribute
.
name
||
''
)
}
>
{
attribute
.
name
||
''
}
</
Option
>
);
})
}
</
Select
>
);
}
const
PartitionSelect
=
({
value
=
{},
modelerData
,
partitionTypes
=
[],
onChange
,
...
restProps
})
=>
{
const
onPartitionTypeChange
=
(
value
)
=>
{
let
currentPartitionType
=
{};
(
partitionTypes
||
[]).
forEach
((
partitionType
,
index
)
=>
{
if
(
value
===
partitionType
.
name
)
{
currentPartitionType
=
partitionType
;
}
})
triggerChange
({
partitionType
:
currentPartitionType
});
}
const
onAttributeChange
=
(
value
)
=>
{
const
currentAttributes
=
(
modelerData
?.
easyDataModelerDataModelAttributes
||
[]).
filter
(
attribute
=>
(
value
||
[]).
indexOf
(
attribute
.
iid
)
!==-
1
);
triggerChange
({
keys
:
currentAttributes
});
}
const
triggerChange
=
(
changedValue
)
=>
{
onChange
?.({
...
value
,
...
changedValue
,
});
};
//value有可能为空
value
=
value
?
value
:
{};
let
attributeIds
=
[];
(
value
?.
keys
||
[]).
forEach
(
attribute
=>
{
attributeIds
.
push
(
attribute
.
iid
);
})
return
(
<
Row
gutter=
{
10
}
>
<
Col
span=
{
10
}
>
<
Select
onChange=
{
onPartitionTypeChange
}
value=
{
value
?.
partitionType
?.
name
}
placeholder=
'请选择分区类型'
allowClear=
{
true
}
>
{
(
partitionTypes
||
[]).
map
((
partitionType
,
index
)
=>
{
return
(
<
Option
key=
{
partitionType
.
name
||
''
}
>
{
partitionType
.
cnName
||
''
}
</
Option
>
);
})
}
</
Select
>
</
Col
>
<
Col
span=
{
14
}
>
<
Select
onChange=
{
(
value
)
=>
{
onAttributeChange
&&
onAttributeChange
(
value
)
}
}
value=
{
attributeIds
}
placeholder=
'请选择字段名称'
mode=
'multiple'
allowClear=
{
true
}
>
{
(
modelerData
?.
easyDataModelerDataModelAttributes
||
[]).
map
((
attribute
,
index
)
=>
{
return
(
<
Option
key=
{
index
}
value=
{
attribute
.
iid
||
''
}
>
{
attribute
.
name
||
''
}
</
Option
>
);
})
}
</
Select
>
</
Col
>
</
Row
>
);
}
const
LoadSelect
=
({
value
=
''
,
onChange
,
...
restProps
})
=>
{
const
onLoadChange
=
(
value
)
=>
{
triggerChange
(
value
.
join
(
'/'
));
}
const
triggerChange
=
(
changedValue
)
=>
{
onChange
?.(
changedValue
);
};
//value有可能为空
value
=
value
?
value
:
''
;
let
loadNames
=
[];
if
(
value
!==
''
)
{
value
.
split
(
'/'
).
forEach
(
item
=>
{
loadNames
.
push
(
item
);
})
}
return
(
<
Select
mode=
"tags"
tokenSeparators=
{
[
'/'
,
' '
]
}
onChange=
{
(
value
)
=>
{
onLoadChange
&&
onLoadChange
(
value
)
}
}
value=
{
loadNames
}
placeholder=
'请选择或者手动输入加载方式'
allowClear=
{
true
}
>
{
loadOptions
.
map
((
item
,
index
)
=>
{
return
(
<
Option
key=
{
index
}
value=
{
item
}
>
{
item
}
</
Option
>
);
})
}
</
Select
>
);
}
const
UpdateSelect
=
({
value
=
''
,
onChange
,
...
restProps
})
=>
{
const
onUpdateChange
=
(
value
)
=>
{
triggerChange
(
value
.
join
(
'/'
));
}
const
triggerChange
=
(
changedValue
)
=>
{
onChange
?.(
changedValue
);
};
//value有可能为空
value
=
value
?
value
:
''
;
let
updateNames
=
[];
if
(
value
!==
''
)
{
value
.
split
(
'/'
).
forEach
(
item
=>
{
updateNames
.
push
(
item
);
})
}
return
(
<
Select
mode=
"tags"
tokenSeparators=
{
[
'/'
,
' '
]
}
onChange=
{
(
value
)
=>
{
onUpdateChange
&&
onUpdateChange
(
value
)
}
}
value=
{
updateNames
}
allowClear=
{
true
}
{
...
restProps
}
>
{
updateOptions
.
map
((
item
,
index
)
=>
{
return
(
<
Option
key=
{
index
}
value=
{
item
}
>
{
item
}
</
Option
>
);
})
}
</
Select
>
);
}
\ 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