|
|
@ -5,7 +5,7 @@ import moment from 'moment'; |
|
|
|
import FileSaver from 'file-saver'; |
|
|
|
import BusinessDatabaseModal from '../components/businessDatabaseModal'; |
|
|
|
const BusinessDatabaseTable = (props) => { |
|
|
|
const { user, dispatch, actions, clientHeight, resourceCatalogId, resourceCatalogKey, |
|
|
|
const { user, dispatch, actions, clientHeight, resourceCatalogId, |
|
|
|
resourceCatalogPath, isRequesting, metadataModels } = props; |
|
|
|
const { metadataManagement } = actions; |
|
|
|
const SortValues = { 'ascend': 'asc', 'descend': 'desc' }; |
|
|
@ -22,11 +22,11 @@ const BusinessDatabaseTable = (props) => { |
|
|
|
|
|
|
|
useEffect(() => { |
|
|
|
setUpdateAtSort('descend'); |
|
|
|
initData({ limit, offset: currentPage - 1, orderDirection: SortValues[updateAtSort] }); |
|
|
|
onSearch('descend'); |
|
|
|
}, [resourceCatalogId]); |
|
|
|
|
|
|
|
const initData = (query = {}) => { |
|
|
|
dispatch(metadataManagement.getBusinessMetadata({ catalog: resourceCatalogId, keywords, orderBy: 'updateAt', ...query })).then(res => { |
|
|
|
dispatch(metadataManagement.getBusinessMetadataDatabases({ catalog: resourceCatalogId, keywords, orderBy: 'updateAt', ...query })).then(res => { |
|
|
|
if (res.success) { |
|
|
|
setTableData(res.payload.data.rows); |
|
|
|
setTableDataCount(res.payload.data.count); |
|
|
@ -39,13 +39,13 @@ const BusinessDatabaseTable = (props) => { |
|
|
|
if (!add) |
|
|
|
setEditData({ title: '查看业务元数据', record: { path: '/' + resourceCatalogPath.join('/'), ...record, ...record.attributesParam } }); |
|
|
|
else |
|
|
|
setEditData({ add: true, title: '新建业务元数据', record: { path: '/' + resourceCatalogPath.join('/'), ...record, ...record.attributesParam } }); |
|
|
|
setEditData({ add: true, title: '新建业务元数据', record: { ...record } }); |
|
|
|
setModalVisible(true); |
|
|
|
} |
|
|
|
}) |
|
|
|
} |
|
|
|
const confirmDelete = (id) => { |
|
|
|
dispatch(metadataManagement.delBusinessMetadata(id)).then(res => { |
|
|
|
dispatch(metadataManagement.delBusinessMetadataDatabases(id)).then(res => { |
|
|
|
if (res.success) { |
|
|
|
onSearch(); setModalVisible(false); |
|
|
|
} |
|
|
@ -211,18 +211,18 @@ const BusinessDatabaseTable = (props) => { |
|
|
|
} |
|
|
|
}]; |
|
|
|
|
|
|
|
const onSearch = () => { |
|
|
|
const onSearch = (sort) => { |
|
|
|
setSelectedRowKeys([]); |
|
|
|
setSelectedRows([]); |
|
|
|
setCurrentPage(1); |
|
|
|
initData({ limit, offset: 0, orderDirection: SortValues[updateAtSort] }); |
|
|
|
initData({ limit, offset: 0, orderDirection: SortValues[sort || updateAtSort] }); |
|
|
|
} |
|
|
|
const handleExport = (isAll = false) => { |
|
|
|
let tableHeader = `<tr>`; |
|
|
|
columns.filter(c => c.dataIndex != 'action').map(c => { tableHeader += `<th><div>${c.title}</div></th>`; }); |
|
|
|
tableHeader += '</tr>'; |
|
|
|
if (isAll) { |
|
|
|
dispatch(metadataManagement.getBusinessMetadata({ catalog: resourceCatalogId })).then(res => { |
|
|
|
dispatch(metadataManagement.getBusinessMetadataDatabases({ catalog: resourceCatalogId })).then(res => { |
|
|
|
if (res.success) { |
|
|
|
handleExportTable(tableHeader, res.payload.data.rows); |
|
|
|
} |
|
|
@ -270,12 +270,14 @@ const BusinessDatabaseTable = (props) => { |
|
|
|
let obj = {} |
|
|
|
if (editData.add) { |
|
|
|
obj = { createBy: user.id, metadataDatabaseId: editData.record.id, ...values } |
|
|
|
dispatch(metadataManagement.postBusinessMetadata(obj)).then(() => { |
|
|
|
onSearch(); setModalVisible(false); |
|
|
|
dispatch(metadataManagement.postBusinessMetadataDatabases(obj)).then(res => { |
|
|
|
if (res.success) { |
|
|
|
onSearch(); setModalVisible(false); |
|
|
|
} |
|
|
|
}); |
|
|
|
} else { |
|
|
|
obj = { ...values } |
|
|
|
dispatch(metadataManagement.putBusinessMetadata(editData.record.businessMetadataDatabases[0].id, obj)).then(res => { |
|
|
|
dispatch(metadataManagement.putBusinessMetadataDatabases(editData.record.businessMetadataDatabases[0].id, obj)).then(res => { |
|
|
|
if (res.success) { |
|
|
|
onSearch(); setModalVisible(false); |
|
|
|
} |
|
|
@ -332,12 +334,12 @@ const BusinessDatabaseTable = (props) => { |
|
|
|
</Spin > |
|
|
|
} |
|
|
|
function mapStateToProps(state) { |
|
|
|
const { global, auth, metadataDatabases, metadataModels } = state; |
|
|
|
const { global, auth, businessMetadataDatabases, metadataModels } = state; |
|
|
|
return { |
|
|
|
user: auth.user, |
|
|
|
actions: global.actions, |
|
|
|
clientHeight: global.clientHeight, |
|
|
|
isRequesting: metadataDatabases.isRequesting || metadataModels.isRequesting, |
|
|
|
isRequesting: businessMetadataDatabases.isRequesting || metadataModels.isRequesting, |
|
|
|
metadataModels: metadataModels.data |
|
|
|
}; |
|
|
|
} |
|
|
|