Commit a9868730 by zhaochengxiang

模型标签过滤

parent 453ee33e
...@@ -134,7 +134,7 @@ const ModelNameColumn = (props) => { ...@@ -134,7 +134,7 @@ const ModelNameColumn = (props) => {
} }
const ModelTable = (props) => { const ModelTable = (props) => {
const { data, onChange, onItemAction, onSelect, onHistory, catalogId, keyword, onAutoCreateTable, offset = null, view, modelState, user, selectModelerIds, visibleColNames } = props; const { data, onChange, onItemAction, onSelect, onHistory, catalogId, keyword, onAutoCreateTable, offset = null, view, modelState, user, selectModelerIds, visibleColNames, tagSelectOptions } = props;
const [ selectedRowKeys, setSelectedRowKeys ] = useState([]); const [ selectedRowKeys, setSelectedRowKeys ] = useState([]);
const [ expandedSelectedRowKeys, setExpandedSelectedRowKeys ] = useState([]); const [ expandedSelectedRowKeys, setExpandedSelectedRowKeys ] = useState([]);
...@@ -360,6 +360,25 @@ const ModelTable = (props) => { ...@@ -360,6 +360,25 @@ const ModelTable = (props) => {
} }
}) })
const tableData = useMemo(() => {
if ((tagSelectOptions??[]).length === 0) {
return data
} else if (resoureTagMap) {
const ids = []
for (const key in resoureTagMap) {
for (const item of resoureTagMap[key]) {
const index = (tagSelectOptions??[]).filter(_item => item.tagId === _item.id)
if (index !== -1) {
ids.push(key)
break
}
}
}
return (data??[]).filter(item => ids.indexOf(item.id) !== -1)
}
}, [data, tagSelectOptions, resoureTagMap])
const getResourceTag = () => { const getResourceTag = () => {
const ids = (data??[]).map(item => item.id); const ids = (data??[]).map(item => item.id);
if (ids.length > 0) { if (ids.length > 0) {
...@@ -585,7 +604,7 @@ const ModelTable = (props) => { ...@@ -585,7 +604,7 @@ const ModelTable = (props) => {
<Paragraph style={{ overflow: 'hidden' }}> <Paragraph style={{ overflow: 'hidden' }}>
<Text className='title-color' ellipsis={true}> <Text className='title-color' ellipsis={true}>
总数: 总数:
<Text className='text-color'>{(data||[]).length}</Text> <Text className='text-color'>{(tableData||[]).length}</Text>
</Text> </Text>
</Paragraph> </Paragraph>
<Paragraph style={{ overflow: 'hidden', marginLeft: 20 }}> <Paragraph style={{ overflow: 'hidden', marginLeft: 20 }}>
...@@ -603,7 +622,7 @@ const ModelTable = (props) => { ...@@ -603,7 +622,7 @@ const ModelTable = (props) => {
// rows={Array.from({ length: 10000 }).map((_, i) => ({ // rows={Array.from({ length: 10000 }).map((_, i) => ({
// name: `test${i}`, // name: `test${i}`,
// }))} // }))}
rows={data||[]} rows={tableData||[]}
rowHeight={51} rowHeight={51}
rowClassName={(row) => { rowClassName={(row) => {
return (row.id === anchorId)?'anchor':'' return (row.id === anchorId)?'anchor':''
......
import React, { useEffect } from 'react' import React, { useEffect } from 'react'
import { Tooltip, Tag, Typography, Space, Button, Modal, Spin } from 'antd' import { Tooltip, Tag, Typography, Space, Button, Modal, Spin, Select, } from 'antd'
import { import {
EllipsisOutlined, EllipsisOutlined,
PlusOutlined, PlusOutlined,
} from '@ant-design/icons' } from '@ant-design/icons'
import produce from 'immer'
import DataQuality, { DataQualityFeighTagSelect } from '../../../QianKun/data-quality' import DataQuality, { DataQualityFeighTagSelect } from '../../../QianKun/data-quality'
import { showMessage } from '../../../../util' import { showMessage } from '../../../../util'
import { dispatch } from '../../../../model' import { dispatch } from '../../../../model'
...@@ -214,7 +216,73 @@ export function TagCell({ value, readonly = false, onChange, onAdd }) { ...@@ -214,7 +216,73 @@ export function TagCell({ value, readonly = false, onChange, onAdd }) {
) )
} }
export function TagSelectPopup({ visible, type, items, onCancel, onChange }) { export function TagSelect({ options, onChange }) {
const [popupParams, setPopupParams] = React.useState({
visible: false,
value: undefined
})
return (
<React.Fragment>
<Select
mode='multiple'
placeholder='请选择标签'
tagRender={(props) => {
const { value } = props
const index = (options??[]).findIndex(item => item.value === value)
if (index !== -1) {
return <TagRender data={options[index]} {...props} />
}
return <React.Fragment></React.Fragment>
}}
onDropdownVisibleChange={(open) => {
if (open) {
setPopupParams({
visible: true,
value: options
})
}
}}
open={false}
style={{ width: 300 }}
value={(options??[]).map(item => item.value)}
options={options}
allowClear
onChange={(newValue) => {
const newOptions = (options??[]).filter(item => newValue.indexOf(item.value) !== -1)
onChange?.(newOptions)
}}
maxTagCount='responsive'
/>
<TagSelectPopup
tagSearchType='tag-search'
value={options}
onCancel={(value) => {
setPopupParams({
visible: false,
value: undefined
})
}}
onChange={(value) => {
const newOptions = produce(value??[], (draft) => {
draft?.forEach(item => {
item.value = item.id
item.label = item.name
})
})
onChange?.(newOptions)
}}
{...popupParams}
/>
</React.Fragment>
)
}
export function TagSelectPopup({ visible, type, tagSearchType, items, onCancel, onChange }) {
const [waiting, setWaiting] = React.useState(false) const [waiting, setWaiting] = React.useState(false)
const [selectedRows, setSelectedRows] = React.useState([]) const [selectedRows, setSelectedRows] = React.useState([])
const [showDataQuality, setShowDataQuality] = React.useState(false) const [showDataQuality, setShowDataQuality] = React.useState(false)
...@@ -241,6 +309,14 @@ export function TagSelectPopup({ visible, type, items, onCancel, onChange }) { ...@@ -241,6 +309,14 @@ export function TagSelectPopup({ visible, type, items, onCancel, onChange }) {
showMessage('warn', '请先选择标签') showMessage('warn', '请先选择标签')
return return
} }
if (tagSearchType === 'tag-search') {
onChange?.(selectedRows)
close()
return
}
setWaiting(true) setWaiting(true)
dispatch({ dispatch({
type: 'tag.addTags', type: 'tag.addTags',
......
...@@ -22,6 +22,7 @@ import DebounceInput from './Component/DebounceInput'; ...@@ -22,6 +22,7 @@ import DebounceInput from './Component/DebounceInput';
import ColSettingModal from './Component/ColSettingModal'; import ColSettingModal from './Component/ColSettingModal';
import PermissionButton from '../../../util/Component/PermissionButton'; import PermissionButton from '../../../util/Component/PermissionButton';
import SelectSearchProperties from './Component/select-search-properties'; import SelectSearchProperties from './Component/select-search-properties';
import { TagSelect } from './Component/tag-help';
import './index.less'; import './index.less';
...@@ -68,6 +69,7 @@ class Model extends React.Component { ...@@ -68,6 +69,7 @@ class Model extends React.Component {
permissions: [], permissions: [],
selectSearchPropertiesVisible: false, selectSearchPropertiesVisible: false,
searchProperties: [], searchProperties: [],
tagSelectOptions: [],
} }
} }
...@@ -656,6 +658,12 @@ class Model extends React.Component { ...@@ -656,6 +658,12 @@ class Model extends React.Component {
</Space> </Space>
<Space> <Space>
<TagSelect
options={this.state.tagSelectOptions}
onChange={(val) => {
this.setState({ tagSelectOptions: val })
}}
/>
<InputDebounce <InputDebounce
placeholder="通过模型名称全文搜索" placeholder="通过模型名称全文搜索"
allowClear allowClear
...@@ -675,6 +683,7 @@ class Model extends React.Component { ...@@ -675,6 +683,7 @@ class Model extends React.Component {
catalogId={catalogId} catalogId={catalogId}
view={currentView} view={currentView}
data={filterTableData} data={filterTableData}
tagSelectOptions={this.state.tagSelectOptions}
modelState={currentModelState} modelState={currentModelState}
offset={offset} offset={offset}
keyword={keyword} keyword={keyword}
......
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