Commit 98c063dc by zhaochengxiang

岗位

parent 11105d8e
...@@ -76,6 +76,7 @@ const AssetAction = (props) => { ...@@ -76,6 +76,7 @@ const AssetAction = (props) => {
const app = useContext(AppContext); const app = useContext(AppContext);
const uploadRef = useRef(undefined); const uploadRef = useRef(undefined);
const postRealtionRef = useRef();
const actionCol = { const actionCol = {
title: '操作', title: '操作',
...@@ -893,11 +894,17 @@ const AssetAction = (props) => { ...@@ -893,11 +894,17 @@ const AssetAction = (props) => {
operation: 'change', operation: 'change',
} }
let data = action==='add' ? { elements: newElements } : { ...assets, elements: newElements }
if (isPostAsset(assets?.templateType)) {
data = {...data, ...postRealtionRef.current?.relations}
}
dispatch({ dispatch({
type: isAdmin?'assetmanage.addOrUpdateDataAsset':'assetmanage.saveAsDraft', type: isAdmin?'assetmanage.addOrUpdateDataAsset':'assetmanage.saveAsDraft',
payload: { payload: {
params, params,
data: action==='add' ? { elements: newElements } : { ...assets, elements: newElements } data,
}, },
callback: () => { callback: () => {
setConfirmLoading(false); setConfirmLoading(false);
...@@ -1359,7 +1366,7 @@ const AssetAction = (props) => { ...@@ -1359,7 +1366,7 @@ const AssetAction = (props) => {
{ {
action!=='add' && <React.Fragment> action!=='add' && <React.Fragment>
{ {
isPostAsset(assets?.templateType) ? <div className='mt-2'><PostRelation reference={reference} action={currentAction} item={assets} /></div> : <React.Fragment> isPostAsset(assets?.templateType) ? <div className='mt-2'><PostRelation ref={postRealtionRef} reference={reference} action={currentAction} item={assets} /></div> : <React.Fragment>
<div> <div>
<Divider orientation='left'>字段级资产目录信息</Divider> <Divider orientation='left'>字段级资产目录信息</Divider>
</div> </div>
......
...@@ -6,6 +6,8 @@ import Table from '../../ResizeableTable' ...@@ -6,6 +6,8 @@ import Table from '../../ResizeableTable'
import SelectResource from './select-resource' import SelectResource from './select-resource'
import { dispatch } from '../../../../model'; import { dispatch } from '../../../../model';
import { AssetDraftReference } from '../../../../util/constant' import { AssetDraftReference } from '../../../../util/constant'
import AssetDetailDrawer from "./AssetDetailDrawer";
import { AppContext } from '../../../../App'
const FC = React.forwardRef(function ({ item, reference, action }, ref) { const FC = React.forwardRef(function ({ item, reference, action }, ref) {
const [activeKey, setActiveKey] = React.useState('asset') const [activeKey, setActiveKey] = React.useState('asset')
...@@ -24,23 +26,25 @@ const FC = React.forwardRef(function ({ item, reference, action }, ref) { ...@@ -24,23 +26,25 @@ const FC = React.forwardRef(function ({ item, reference, action }, ref) {
item: undefined, item: undefined,
type: undefined, type: undefined,
}) })
const [detailParams, setDetailParams] = React.useState({
visible: false,
id: undefined,
dirId: undefined,
})
const app = React.useContext(AppContext)
const [modal, contextHolder] = Modal.useModal() const [modal, contextHolder] = Modal.useModal()
// React.useImperativeHandle(ref, () => ({ React.useImperativeHandle(ref, () => ({
// selectedRows relations: {
// }), [selectedRows]) postAssets: assets??[],
postServices: services??[]
}
}), [assets, services])
React.useEffect(() => { React.useEffect(() => {
getRelatedAssets() getRelatedAssets()
getRelatedServices() getRelatedServices()
}, [])
React.useEffect(() => {
if (item) {
setAssets(item?.postAssets)
setServices(item?.postServices)
}
}, [item]) }, [item])
const [tableData, total] = React.useMemo(() => { const [tableData, total] = React.useMemo(() => {
...@@ -71,6 +75,27 @@ const FC = React.forwardRef(function ({ item, reference, action }, ref) { ...@@ -71,6 +75,27 @@ const FC = React.forwardRef(function ({ item, reference, action }, ref) {
title: '名称', title: '名称',
dataIndex: 'name', dataIndex: 'name',
}, },
{
title: '操作',
dataIndex: 'action',
width: 80,
fixed: 'right',
render: (_, record) => {
return (
<Space>
<a onClick={(e) => {
e.stopPropagation();
setDetailParams({
visible: true,
id: record?.relatedAssetId,
})
}}>
详情
</a>
</Space>
)
}
}
] ]
const seriveCols = [ const seriveCols = [
...@@ -92,6 +117,24 @@ const FC = React.forwardRef(function ({ item, reference, action }, ref) { ...@@ -92,6 +117,24 @@ const FC = React.forwardRef(function ({ item, reference, action }, ref) {
title: '数据服务名称', title: '数据服务名称',
dataIndex: 'name', dataIndex: 'name',
}, },
{
title: '操作',
dataIndex: 'action',
width: 80,
fixed: 'right',
render: (_, record) => {
return (
<Space>
<a onClick={(e) => {
e.stopPropagation();
app?.openDetail?.({ service: { id: record.relatedServiceId }, isOnlyEnding: true })
}}>
详情
</a>
</Space>
)
}
}
] ]
const getRelatedAssets = () => { const getRelatedAssets = () => {
...@@ -141,14 +184,22 @@ const FC = React.forwardRef(function ({ item, reference, action }, ref) { ...@@ -141,14 +184,22 @@ const FC = React.forwardRef(function ({ item, reference, action }, ref) {
} }
const onDeleteClick = () => { const onDeleteClick = () => {
modal.confirm({ if (activeKey === 'asset') {
title:'提示', setAssets(prevAssets => {
content: '是否确认删除选中内容?', const filterData = (prevAssets??[]).filter(item => (selectedRows??[]).map(_item => _item.relatedAssetId).indexOf(item.relatedAssetId)===-1)
okText: '确认',
cancelText: '取消',
onOk: () => {
return filterData
})
} else if (activeKey === 'service') {
setServices(prevServices => {
const filterData = (prevServices??[]).filter(item => (selectedRows??[]).map(_item => _item.relatedServiceId).indexOf(item.relatedServiceId)===-1)
return filterData
})
} }
setSelectedRows(prevSelectedRows => {
return []
}) })
} }
...@@ -178,7 +229,11 @@ const FC = React.forwardRef(function ({ item, reference, action }, ref) { ...@@ -178,7 +229,11 @@ const FC = React.forwardRef(function ({ item, reference, action }, ref) {
return ( return (
<div> <div>
<Tabs activeKey={activeKey} onChange={(val) => { setActiveKey(val) }}> <Tabs activeKey={activeKey} onChange={(val) => {
setActiveKey(val)
setPagination({ ...pagination, pageNum: 1 })
setSelectedRows()
}}>
<Tabs.TabPane tab='关联资产' key='asset' /> <Tabs.TabPane tab='关联资产' key='asset' />
<Tabs.TabPane tab='关联服务' key='service' /> <Tabs.TabPane tab='关联服务' key='service' />
</Tabs> </Tabs>
...@@ -203,13 +258,13 @@ const FC = React.forwardRef(function ({ item, reference, action }, ref) { ...@@ -203,13 +258,13 @@ const FC = React.forwardRef(function ({ item, reference, action }, ref) {
</div> </div>
<div className='mt-3'> <div className='mt-3'>
<Table <Table
rowKey='id' rowKey={activeKey==='asset'?'relatedAssetId':'relatedServiceId'}
loading={loadingAssets||loadingServices} loading={loadingAssets||loadingServices}
columns={activeKey==='asset'?assetCols:seriveCols} columns={activeKey==='asset'?assetCols:seriveCols}
dataSource={tableData??[]} dataSource={tableData??[]}
pagination={false} pagination={false}
rowSelection={{ rowSelection={{
selectedRowKeys: (selectedRows??[]).map(item => item.id), selectedRowKeys: (selectedRows??[]).map(item => (activeKey==='asset')?item.relatedAssetId:item.relatedServiceId),
onChange: (selectedRowKeys, selectedRows) => { onChange: (selectedRowKeys, selectedRows) => {
setSelectedRows(selectedRows) setSelectedRows(selectedRows)
}, },
...@@ -234,6 +289,17 @@ const FC = React.forwardRef(function ({ item, reference, action }, ref) { ...@@ -234,6 +289,17 @@ const FC = React.forwardRef(function ({ item, reference, action }, ref) {
{...selectResourceParams} {...selectResourceParams}
onCancel={onSelectResourceCancel} onCancel={onSelectResourceCancel}
/> />
<AssetDetailDrawer
{...detailParams}
readonly={true}
onCancel={() => {
setDetailParams({
visible: false,
id: undefined,
dirId: undefined,
})
}}
/>
{contextHolder} {contextHolder}
</div> </div>
) )
......
...@@ -96,6 +96,7 @@ const FC = (props) => { ...@@ -96,6 +96,7 @@ const FC = (props) => {
title: '操作', title: '操作',
dataIndex: 'action', dataIndex: 'action',
width: 80, width: 80,
fixed: 'right',
render: (_, record) => { render: (_, record) => {
return ( return (
<Space> <Space>
......
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