|
|
@ -1,9 +1,9 @@ |
|
|
|
import React, { useEffect, useState } from 'react' |
|
|
|
import { Input, Tooltip, Empty, Pagination, Modal, Form } from 'antd' |
|
|
|
import { Input, Tooltip, Empty, Pagination, Popover, message } from 'antd' |
|
|
|
import { InsertRowBelowOutlined, DatabaseOutlined, FileOutlined, PullRequestOutlined, KeyOutlined } from '@ant-design/icons'; |
|
|
|
import { useFsRequest, ApiTable } from '$utils'; |
|
|
|
import { connect } from 'react-redux'; |
|
|
|
import { downloadImg } from '../utils/index' |
|
|
|
import { downloadImg, markRedKeywords } from '../utils/index' |
|
|
|
import KeyModal from '../components/keyModal'; |
|
|
|
const METADTA_TYPE = { |
|
|
|
'库': 'databases', |
|
|
@ -11,12 +11,21 @@ const METADTA_TYPE = { |
|
|
|
'文件': 'files', |
|
|
|
'接口': 'restapis', |
|
|
|
} |
|
|
|
|
|
|
|
const METADTA_TYPE_NAMES = { |
|
|
|
'库': '库表/库(Schema)', |
|
|
|
'表': '库表/表(Table)', |
|
|
|
'文件': '文件(File)', |
|
|
|
'接口': '接口(Api)', |
|
|
|
} |
|
|
|
|
|
|
|
import './style.less'; |
|
|
|
function Retrieval(props) { |
|
|
|
const { user, catalogs, dispatch, actions } = props; |
|
|
|
const [keywords, setKeywords] = useState() |
|
|
|
const [firstInput, setFirstInput] = useState() |
|
|
|
const [page, setPage] = useState(1) |
|
|
|
const [currentData, setCurrentData] = useState(null) |
|
|
|
const formRef = React.createRef(); |
|
|
|
// const { data: catalogs = [] } = useFsRequest({
|
|
|
|
// url: ApiTable.getResourceCatalog,
|
|
|
@ -77,6 +86,17 @@ function Retrieval(props) { |
|
|
|
</Tooltip> : text |
|
|
|
} |
|
|
|
|
|
|
|
const renderName = (text) => { |
|
|
|
function createMarkup(textFilter) { |
|
|
|
return { __html: textFilter.length == text.length ? markRedKeywords(textFilter, keywords) : markRedKeywords(textFilter, keywords) + '...' }; |
|
|
|
} |
|
|
|
return text?.length > 16 ? |
|
|
|
<Popover placement="topRight" title={null} content={<span dangerouslySetInnerHTML={createMarkup(text)} />}> |
|
|
|
<span dangerouslySetInnerHTML={createMarkup(text.substring(0, 16))} /> |
|
|
|
</Popover> |
|
|
|
: <span dangerouslySetInnerHTML={createMarkup(text)} /> |
|
|
|
} |
|
|
|
|
|
|
|
const downloadData = (s) => { |
|
|
|
if (s?.type == '文件') { |
|
|
|
const suffix = s?.fileName?.substring(s?.fileName?.length - 3, s?.fileName?.length) |
|
|
@ -109,21 +129,23 @@ function Retrieval(props) { |
|
|
|
<div className='column1'> |
|
|
|
{renderIcon(s?.type)} |
|
|
|
{s?.code && <span> 代码:{renderText(s?.code)}</span>} |
|
|
|
<span> 名称:{renderText(s?.name)}</span> |
|
|
|
<span> 类型:{s?.type}</span> |
|
|
|
<span> 名称:{renderName(s?.name)}</span> |
|
|
|
<span> 类型:{METADTA_TYPE_NAMES[s?.type]}</span> |
|
|
|
<span> 路径:{renderText(catalogText)}</span> |
|
|
|
<span> 标签:{renderText(tagText)}</span> |
|
|
|
</div> |
|
|
|
<div className='column2'>相关操作:<a onClick={() => { window.open(`/metadataManagement/latestMetadata?type=${METADTA_TYPE[s.type]}&treeId=${s?.catalog}&resourceId=${s.id}&catalogKey=${s.catalogKey}`) }}>定位</a> |
|
|
|
{s?.type == '表' || s?.type == '文件' ? |
|
|
|
user?.role == '数据消费者' ? |
|
|
|
<KeyModal |
|
|
|
resourceId={s.id} |
|
|
|
approveList={approveList} |
|
|
|
onFinish={() => { |
|
|
|
downloadData(s) |
|
|
|
}} |
|
|
|
/> : |
|
|
|
<a onClick={() => { |
|
|
|
const token = approveList?.rows?.find(x => x.resourceId == s.id)?.token |
|
|
|
if (!token) { |
|
|
|
message.warning('您暂未申请该数据资源,请先申请该数据资源') |
|
|
|
} else { |
|
|
|
setCurrentData(s) |
|
|
|
} |
|
|
|
|
|
|
|
}}>下载</a> : |
|
|
|
<a onClick={() => { downloadData(s) }}>下载</a> : ''} |
|
|
|
</div> |
|
|
|
</div> |
|
|
@ -137,6 +159,16 @@ function Retrieval(props) { |
|
|
|
}} |
|
|
|
/>} |
|
|
|
{!result?.rows?.length > 0 && <Empty />} |
|
|
|
|
|
|
|
{currentData && <KeyModal |
|
|
|
resourceId={currentData?.id} |
|
|
|
approveList={approveList} |
|
|
|
onFinish={() => { |
|
|
|
downloadData(currentData) |
|
|
|
setCurrentData(null) |
|
|
|
}} |
|
|
|
onCancel={() => { setCurrentData(null) }} |
|
|
|
/>} |
|
|
|
</> |
|
|
|
} |
|
|
|
|
|
|
|