Commit 266982e7 by zhaochengxiang

匹配推荐

parent f52df316
import React from 'react' import React from 'react'
import { Modal, Button, Spin, Tooltip, Typography, Space, Input } from "antd" import { Modal, Button, Spin, Tooltip, Typography, Space, Input } from "antd"
import { ArrowsAltOutlined, ShrinkOutlined } from '@ant-design/icons';
import { dispatch } from '../../../../model' import { dispatch } from '../../../../model'
import Table from '../../../../util/Component/Table' import Table from '../../../../util/Component/Table'
...@@ -21,51 +22,9 @@ const FC = (props) => { ...@@ -21,51 +22,9 @@ const FC = (props) => {
cnName: undefined, cnName: undefined,
triggerType: undefined, triggerType: undefined,
}) })
const [isCompact, setCompact] = React.useState(true)
React.useEffect(() => { const cols = [
if (visible) {
setAnimating(true)
setArgs({
name,
cnName,
triggerType
})
setTimeout(() => {
setAnimating(false)
}, 300)
}
}, [visible])
useDebounceEffect(()=>{
if (args.name || args.cnName) {
getSuggests()
}
}, [args], { wait:300 })
const onSourceClick = (id, name) => {
const timestamp = new Date().getTime();
const tempArray = (id??'').split('=');
if (tempArray.length>=3) {
dispatch({
type: 'datamodel.getParent',
payload: {
id
},
callback: data => {
window.open(`/center-home/metadetail?mid=${encodeURIComponent(data?._id)}&action=metadetail&type=detail&manager=false&activekey=1&name=${encodeURIComponent(name||'')}`);
}
})
} else {
if (checkMenuAdmit('datastandard')) {
window.open(`/center-home/menu/datastandard?id=${id}&timestamp=${timestamp}`);
}
}
}
const cols = React.useMemo(() => {
return [
{ {
title: '中文名称', title: '中文名称',
dataIndex: 'cnName', dataIndex: 'cnName',
...@@ -154,7 +113,51 @@ const FC = (props) => { ...@@ -154,7 +113,51 @@ const FC = (props) => {
} }
}, },
] ]
}, [onSourceClick])
React.useEffect(() => {
if (visible) {
setAnimating(true)
setArgs({
name,
cnName,
triggerType
})
setTimeout(() => {
setAnimating(false)
}, 300)
}
}, [visible])
useDebounceEffect(()=>{
if (args.name || args.cnName) {
getSuggests()
}
}, [args], { wait:300 })
const columns = React.useMemo(() => {
return isCompact ? [...cols].slice(0, 4) : [...cols]
}, [cols, isCompact])
const onSourceClick = (id, name) => {
const timestamp = new Date().getTime();
const tempArray = (id??'').split('=');
if (tempArray.length>=3) {
dispatch({
type: 'datamodel.getParent',
payload: {
id
},
callback: data => {
window.open(`/center-home/metadetail?mid=${encodeURIComponent(data?._id)}&action=metadetail&type=detail&manager=false&activekey=1&name=${encodeURIComponent(name||'')}`);
}
})
} else {
if (checkMenuAdmit('datastandard')) {
window.open(`/center-home/menu/datastandard?id=${id}&timestamp=${timestamp}`);
}
}
}
const getSuggests = () => { const getSuggests = () => {
setLoading(true) setLoading(true)
...@@ -214,28 +217,30 @@ const FC = (props) => { ...@@ -214,28 +217,30 @@ const FC = (props) => {
close() close()
} }
const footer = React.useMemo(() => { // const footer = React.useMemo(() => {
return [ // return [
<Button key='cancel' // <Button key='cancel'
onClick={() => close()} // onClick={() => close()}
>取消</Button>, // >取消</Button>,
<Button key='save' type='primary' // <Button key='save' type='primary'
onClick={() => save()} // onClick={() => save()}
>确定</Button> // >确定</Button>
] // ]
}, [close, save]) // }, [close, save])
return ( return (
<Modal <Modal
visible={visible} visible={visible}
footer={footer} footer={null}
width='80%' width={isCompact?'50%':'80%'}
bodyStyle={{ padding: '15px', overflowX: 'auto', maxHeight: '80vh' }} bodyStyle={{ padding: '15px' }}
title='匹配推荐' title='匹配推荐'
centered destroyOnClose centered destroyOnClose
onCancel={() => { close() }} onCancel={() => { close() }}
> >
<div className='mb-3'> {
!animating && <div>
<div className='flex mb-3' style={{ justifyContent: 'space-between' }}>
<Space> <Space>
<span>中文名称:</span> <span>中文名称:</span>
<Input size="middle" <Input size="middle"
...@@ -260,27 +265,39 @@ const FC = (props) => { ...@@ -260,27 +265,39 @@ const FC = (props) => {
style={{ width: inputWidth }} style={{ width: inputWidth }}
/> />
</Space> </Space>
<Button
icon={isCompact ? <ArrowsAltOutlined /> : <ShrinkOutlined />}
onClick={() => {
setCompact(prev => !prev)
}}
/>
</div> </div>
{ <Spin spinning={loading}>
!animating && <Spin spinning={loading}> <div style={{ height: isCompact?'50vh':'80vh', overflow: 'auto' }}>
<Table <Table
extraColWidth={32} extraColWidth={32}
size='small' size='small'
rowKey='iid' rowKey='iid'
dataSource={suggests||[]} dataSource={suggests||[]}
columns={cols} columns={columns}
pagination={false} pagination={false}
rowClassName={(record, index) => { rowClassName={(record, index) => {
return 'pointer'; return 'pointer';
}} }}
onRowClick={(event, record) => { onRowClick={(event, record) => {
setSelectedRows([record]) setSelectedRows([record])
onOk?.(record)
close()
}} }}
rowSelection={{ rowSelection={{
type: 'radio', type: 'radio',
selectedRowKeys: (selectedRows??[]).map(item => item.iid), selectedRowKeys: (selectedRows??[]).map(item => item.iid),
onChange: (selectedRowKeys, selectedRows) => { onChange: (selectedRowKeys, selectedRows) => {
setSelectedRows(selectedRows) setSelectedRows(selectedRows)
if ((selectedRows??[]).length > 0) {
onOk?.(selectedRows[0])
close()
}
}, },
}} }}
/> />
...@@ -289,7 +306,9 @@ const FC = (props) => { ...@@ -289,7 +306,9 @@ const FC = (props) => {
<Button onClick={getSuggests} disabled={!havaMore} >加载更多</Button> <Button onClick={getSuggests} disabled={!havaMore} >加载更多</Button>
</Tooltip> </Tooltip>
</div> </div>
</div>
</Spin> </Spin>
</div>
} }
</Modal> </Modal>
) )
......
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