Commit 5d8a8b0a by zhaochengxiang

增加收起推荐

parent f2e8e9c7
......@@ -463,8 +463,8 @@ const ImportActionHeader = (props) => {
})
}
if (modelerData?.partition?.partitionType?.name) {
partitionsDescription += '/' + modelerData?.partition?.partitionType?.name||'';
if (modelerData?.partition?.partitionType?.cnName) {
partitionsDescription += '/' + modelerData?.partition?.partitionType?.cnName||'';
}
//类主键
......
......@@ -247,6 +247,7 @@ const ImportActionTable = (props) => {
const [ form ] = Form.useForm();
const [ editingKey, setEditingKey ] = useState('');
const [ loadingSuggest, setLoadingSuggest ] = useState(false);
const [ suggests, setSuggests ] = useState([]);
const [ suggestHaveMore, setSuggestHaveMore ] = useState(false);
const [ suggestOffset, setSuggestOffset ] = useState(1);
......@@ -369,7 +370,7 @@ const ImportActionTable = (props) => {
setInsertIndex(0);
edit(newData[0], false);
} else {
newData.splice(index, 0, {iid});
newData.splice(index, 0, {iid, needAttention: true});
setInsertIndex(index);
edit(newData[index], false);
}
......@@ -565,17 +566,20 @@ const ImportActionTable = (props) => {
setCurrentChangedValues(changedValues);
function getSuggest() {
setLoadingSuggest(true);
dispatchLatest({
type: 'datamodel.suggest',
payload: {
data: { ...modelerData, easyDataModelerDataModelAttributes: newData },
params: {
easyDataModelerDataModelAttributeIid: iid,
name: allValues.name||'',
cnName: allValues.cnName||'',
topN: (offset+perSuggestCount-1),
offset
}
},
callback: data => {
setLoadingSuggest(false);
if (changedValues.hasOwnProperty('cnName')) {
const moreSuggests = (data||[]).length>0?(data[0].suggestions||[]):[];
......@@ -599,6 +603,9 @@ const ImportActionTable = (props) => {
setSuggestOffset(newSuggests.length+1);
setSuggests(newSuggests);
}
},
error: () => {
setLoadingSuggest(false);
}
})
}
......@@ -1104,6 +1111,14 @@ const ImportActionTable = (props) => {
onValuesChange(currentChangedValues, form.getFieldsValue(), suggestOffset);
}
const closeSuggests = (event) => {
event.stopPropagation();
setSuggestHaveMore(false);
setSuggests([]);
setSuggestOffset(1);
}
const displayMenu = (e) => {
show(e);
}
......@@ -1219,11 +1234,13 @@ const ImportActionTable = (props) => {
}
</React.Fragment>
}
{
suggestHaveMore && <div className='flex pt-3' style={{ justifyContent: 'center' }}>
<Button onClick={loadMoreSuggests}>加载更多</Button>
<div className='flex pt-3' style={{ justifyContent: 'center' }}>
<Tooltip title={!suggestHaveMore?'没有更多推荐字段': ''}>
<Button onClick={loadMoreSuggests} disabled={!suggestHaveMore} loading={loadingSuggest}>加载更多</Button>
</Tooltip>
<Button className='ml-3' onClick={closeSuggests}>收起推荐</Button>
</div>
}
</React.Fragment>
),
expandIcon: ({ expanded, onExpand, record }) => {
......
......@@ -202,6 +202,7 @@ const SuggestTable = (props) => {
dataSource={suggests||[]}
pagination={false}
loading={false}
rowKey='iid'
rowClassName={(record, index) => {
return 'pointer';
}}
......@@ -214,7 +215,7 @@ const SuggestTable = (props) => {
columns.map((column, index) => {
return {
...column,
onHeaderCell: (column: { width: any; }) => ({
onHeaderCell: column => ({
width: column.width,
onResize: handleResize(index),
}),
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment