Commit 158511dc by zhaochengxiang

属性值过滤

parent c489f5b7
...@@ -276,4 +276,8 @@ export function* getResourceSortingStatus() { ...@@ -276,4 +276,8 @@ export function* getResourceSortingStatus() {
export function* getResourceRelatedMetadataStatus() { export function* getResourceRelatedMetadataStatus() {
return yield call(service.getResourceRelatedMetadataStatus) return yield call(service.getResourceRelatedMetadataStatus)
}
export function* getElementValues(payload) {
return yield call(service.getElementValues, payload)
} }
\ No newline at end of file
...@@ -266,4 +266,9 @@ export function getPreviewRangeByDirId(payload) { ...@@ -266,4 +266,9 @@ export function getPreviewRangeByDirId(payload) {
export function getResourceRelatedMetadataStatus() { export function getResourceRelatedMetadataStatus() {
return GetJSON("/dataassetmanager/resourceApi/listRelatedMetadataStatus"); return GetJSON("/dataassetmanager/resourceApi/listRelatedMetadataStatus");
}
export function getElementValues(payload) {
return GetJSON("/dataassetmanager/parameterApi/conf/getPropertiesByDataAssetType", payload);
} }
\ No newline at end of file
import React from 'react'
import { Modal, Button, Form, Checkbox, Spin, Row, Col } from 'antd'
import { getAssetType } from '../../../util'
import { dispatch } from '../../../model'
const FC = (props) => {
const { visible, type, defaultValue, onCancel } = props
const [loading, setLoading] = React.useState(false)
const [data, setData] = React.useState()
const basicRef = React.useRef()
React.useEffect(() => {
if (visible) {
getElementValues()
}
}, [visible])
const getElementValues = () => {
setLoading(true)
dispatch({
type: 'assetmanage.getElementValues',
payload: {
dataAssetType: getAssetType(type)
},
callback: data => {
setLoading(false)
setData(data)
},
error: () => {
setLoading(false)
}
})
}
const close = (refresh = false, val = undefined) => {
setLoading(false)
setData()
onCancel?.(refresh, val)
}
const save = async () => {
try {
const rows = await basicRef.current?.validate()
close(true, rows)
}
catch (e) {
}
}
const footer = React.useMemo(() => {
return [
<Button key={'cancel'}
onClick={() => close()}
>取消</Button>,
<Button key={'save'} type='primary'
onClick={() => save()}
>确定</Button>
]
}, [close, save])
return (
<Modal
visible={visible}
footer={footer}
bodyStyle={{ padding: '15px 15px 0px', overflowX: 'auto', maxHeight: '80vh' }}
title='属性值过滤'
centered destroyOnClose
onCancel={() => { close() }}
>
<Spin spinning={loading}>
<Basic ref={basicRef} data={data} defaultValue={defaultValue} />
</Spin>
</Modal>
)
}
export default FC
export const Basic = React.forwardRef(function ({ data, defaultValue }, ref) {
const [form] = Form.useForm()
React.useImperativeHandle(ref, () => ({
validate: async () => {
const rows = await form.validateFields()
const newRows = []
for (const id in rows) {
newRows.push({
elementId: id,
elementValues: rows[`${id}`]
})
}
return newRows
},
}), [form])
React.useEffect(() => {
const newFiledsValue = {}
for (const item of defaultValue) {
newFiledsValue[item.elementId] = item.elementValues
}
form?.setFieldsValue(newFiledsValue)
}, [defaultValue])
return (
<Form
form={form}
labelCol={{ span: 5 }}
wrapperCol={{ span: 19 }}
autoComplete="off"
>
{
(data??[]).map((item, index) => {
return (
<Form.Item
name={item.id}
label={item.name}
>
<Checkbox.Group style={{ width: '100%' }}>
<Row>
{
(item.value?.content??[]).map((item, index) => {
return (
<Col span={6} key={index}>
<Checkbox
value={item}
style={{
lineHeight: '32px',
}}
>
{item}
</Checkbox>
</Col>
)
})
}
</Row>
</Checkbox.Group>
</Form.Item>
)
})
}
</Form>
)
})
\ No newline at end of file
...@@ -19,6 +19,7 @@ import ImportAsset from '../AssetManage/Component/ImportAssetDrawer' ...@@ -19,6 +19,7 @@ import ImportAsset from '../AssetManage/Component/ImportAssetDrawer'
import ChangeCatalog from './change-catalog' import ChangeCatalog from './change-catalog'
import AssetDelete from '../AssetManage/Component/AssetDeleteModal' import AssetDelete from '../AssetManage/Component/AssetDeleteModal'
import FilterElement from '../AssetManage/Component/FilterElementModal' import FilterElement from '../AssetManage/Component/FilterElementModal'
import FilterElementValue from './filter-element-value'
import '../AssetManage/Component/AssetTable.less' import '../AssetManage/Component/AssetTable.less'
import { AssetDirectorySubject } from '../AssetManage/Component/AssetDirectory' import { AssetDirectorySubject } from '../AssetManage/Component/AssetDirectory'
...@@ -35,6 +36,7 @@ const FC = (props) => { ...@@ -35,6 +36,7 @@ const FC = (props) => {
keyword: undefined, keyword: undefined,
sortingStatus: undefined, sortingStatus: undefined,
resourceStatus: undefined, resourceStatus: undefined,
elementValueFilters: []
}, },
})) }))
const [fullScreen, setFullScreen] = React.useState(false) const [fullScreen, setFullScreen] = React.useState(false)
...@@ -78,6 +80,11 @@ const FC = (props) => { ...@@ -78,6 +80,11 @@ const FC = (props) => {
type: undefined, type: undefined,
reference: undefined reference: undefined
}) })
const [FilterElementValueParams, setFilterElementValueParams] = React.useState({
visible: false,
type: undefined,
defaultValue: undefined,
})
const [page, setPage] = usePage() const [page, setPage] = usePage()
const [ modal, contextHolder ] = Modal.useModal() const [ modal, contextHolder ] = Modal.useModal()
...@@ -334,7 +341,7 @@ const FC = (props) => { ...@@ -334,7 +341,7 @@ const FC = (props) => {
dispatch({ dispatch({
type: 'assetmanage.listDataResourcesByPage', type: 'assetmanage.listDataResourcesByPage',
payload: { payload: {
data: [], data: args.params.elementValueFilters??[],
params: { params: {
dirId, dirId,
pageNum: args.params.page, pageNum: args.params.page,
...@@ -344,7 +351,7 @@ const FC = (props) => { ...@@ -344,7 +351,7 @@ const FC = (props) => {
resourceStatus: args.params.resourceStatus, resourceStatus: args.params.resourceStatus,
sortingStatus: args.params.sortingStatus, sortingStatus: args.params.sortingStatus,
recursive, recursive,
filterTodo: args.params.onlyPending,
} }
}, },
callback: data => { callback: data => {
...@@ -705,6 +712,13 @@ const FC = (props) => { ...@@ -705,6 +712,13 @@ const FC = (props) => {
value={searchType} value={searchType}
onChange={(value) => { onChange={(value) => {
setSearchType(value) setSearchType(value)
if (value === 'attribute') {
setFilterElementValueParams({
visible: true,
type: ResourceManageReference,
defaultValue: args.params.elementValueFilters
})
}
}} }}
style={{ width: 120 }} style={{ width: 120 }}
> >
...@@ -837,6 +851,21 @@ const FC = (props) => { ...@@ -837,6 +851,21 @@ const FC = (props) => {
refresh && getElements() refresh && getElements()
}} }}
/> />
<FilterElementValue
{...FilterElementValueParams}
onCancel={(refresh, val) => {
setFilterElementValueParams({
visible: false,
type: undefined,
defaultValue: undefined,
})
setSearchType('keyword')
if (refresh) {
setArgsAndPage({ elementValueFilters: val })
}
}}
/>
{contextHolder} {contextHolder}
</div> </div>
) )
......
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