Commit 7278b225 by zhaochengxiang

岗位关联

parent 165b9d19
...@@ -386,3 +386,23 @@ export function* addSubscribe(payload) { ...@@ -386,3 +386,23 @@ export function* addSubscribe(payload) {
export function* startProcess(payload) { export function* startProcess(payload) {
return yield call(service.startProcess, payload); return yield call(service.startProcess, payload);
} }
export function* getRelatedAssets(payload) {
return yield call(service.getRelatedAssets, payload);
}
export function* getRelatedServices(payload) {
return yield call(service.getRelatedServices, payload);
}
export function* fillRelatedAssetsInfo(payload) {
return yield call(service.fillRelatedAssetsInfo, payload);
}
export function* getDraftRelatedAssets(payload) {
return yield call(service.getDraftRelatedAssets, payload);
}
export function* getDraftRelatedServices(payload) {
return yield call(service.getDraftRelatedServices, payload);
}
\ No newline at end of file
...@@ -368,3 +368,23 @@ export function addSubscribe(payload) { ...@@ -368,3 +368,23 @@ export function addSubscribe(payload) {
export function startProcess(payload) { export function startProcess(payload) {
return PostJSON("/dataassetmanager/flowApi/startProcess", payload) return PostJSON("/dataassetmanager/flowApi/startProcess", payload)
} }
export function getRelatedAssets(payload) {
return PostJSON("/dataassetmanager/postApi/getRelatedAssets", payload)
}
export function getRelatedServices(payload) {
return PostJSON("/dataassetmanager/postApi/getRelatedServices", payload)
}
export function fillRelatedAssetsInfo(payload) {
return PostJSON("/dataassetmanager/postApi/fillRelatedAssetsInfo", payload)
}
export function getDraftRelatedAssets(payload) {
return PostJSON("/dataassetmanager/postDraftApi/getRelatedAssets", payload)
}
export function getDraftRelatedServices(payload) {
return PostJSON("/dataassetmanager/postDraftApi/getRelatedServices", payload)
}
...@@ -44,10 +44,11 @@ const AddAssetModel = (props) => { ...@@ -44,10 +44,11 @@ const AddAssetModel = (props) => {
showMessage('warn', '已存在相同的资产目录编号,请重新输入'); showMessage('warn', '已存在相同的资产目录编号,请重新输入');
} else { } else {
dispatch({ dispatch({
type: 'assetmanage.addOrUpdateDataAsset', type: 'assetmanage.saveAsDraft',
payload: { payload: {
params: { params: {
dirId: nodeId, dirId: nodeId,
operation: 'change',
}, },
data: { elements: newElements } data: { elements: newElements }
}, },
......
...@@ -1359,7 +1359,7 @@ const AssetAction = (props) => { ...@@ -1359,7 +1359,7 @@ const AssetAction = (props) => {
{ {
action!=='add' && <React.Fragment> action!=='add' && <React.Fragment>
{ {
isPostAsset(assets?.templateType) ? <div className='mt-2'><PostRelation /></div> : <React.Fragment> isPostAsset(assets?.templateType) ? <div className='mt-2'><PostRelation reference={reference} action={currentAction} item={assets} /></div> : <React.Fragment>
<div> <div>
<Divider orientation='left'>字段级资产目录信息</Divider> <Divider orientation='left'>字段级资产目录信息</Divider>
</div> </div>
......
...@@ -4,17 +4,21 @@ import { Tabs, Space, Button, Input, Pagination, Tooltip, Modal } from 'antd' ...@@ -4,17 +4,21 @@ import { Tabs, Space, Button, Input, Pagination, Tooltip, Modal } from 'antd'
import { paginate } from '../../../../util' import { paginate } from '../../../../util'
import Table from '../../ResizeableTable' import Table from '../../ResizeableTable'
import SelectResource from './select-resource' import SelectResource from './select-resource'
import { dispatch } from '../../../../model';
import { AssetDraftReference } from '../../../../util/constant'
const FC = (props) => { const FC = (props) => {
const { item, } = props const { item, reference, action } = props
const [activeKey, setActiveKey] = React.useState('asset') const [activeKey, setActiveKey] = React.useState('asset')
const [keyword, setKeyword] = React.useState() const [keyword, setKeyword] = React.useState()
const [pagination, setPagination] = React.useState({ const [pagination, setPagination] = React.useState({
pageNum: 1, pageNum: 1,
pageSize: 20, pageSize: 20,
}) })
const [loading, setLoading] = React.useState(false) const [loadingAssets, setLoadingAssets] = React.useState(false)
const [data, setData] = React.useState() const [assets, setAssets] = React.useState()
const [loadingServices, setLoadingServices] = React.useState(false)
const [services, setServices] = React.useState()
const [selectedRows, setSelectedRows] = React.useState() const [selectedRows, setSelectedRows] = React.useState()
const [selectResourceParams, setSelectResourceParams] = React.useState({ const [selectResourceParams, setSelectResourceParams] = React.useState({
visible: false, visible: false,
...@@ -25,17 +29,18 @@ const FC = (props) => { ...@@ -25,17 +29,18 @@ const FC = (props) => {
const [modal, contextHolder] = Modal.useModal() const [modal, contextHolder] = Modal.useModal()
React.useEffect(() => { React.useEffect(() => {
getRelations() getRelatedAssets()
getRelatedServices()
}, []) }, [])
const [tableData, total] = React.useMemo(() => { const [tableData, total] = React.useMemo(() => {
let newTableData = [...data??[]] let newTableData = (activeKey==='asset')?[...assets??[]]:[...services??[]]
if (keyword) { if (keyword) {
newTableData = (newTableData??[]).filter(item => (item.name??'').indexOf(keyword) !== -1) newTableData = (newTableData??[]).filter(item => (item.name??'').indexOf(keyword) !== -1)
} }
return [paginate(newTableData, pagination.pageNum, pagination.pageSize), (newTableData??[]).length] return [paginate(newTableData, pagination.pageNum, pagination.pageSize), (newTableData??[]).length]
}, [data, keyword, pagination]) }, [activeKey, assets, services, keyword, pagination])
const cols = [ const cols = [
{ {
...@@ -58,15 +63,42 @@ const FC = (props) => { ...@@ -58,15 +63,42 @@ const FC = (props) => {
}, },
] ]
const getRelations = () => { const getRelatedAssets = () => {
setLoading(true) setLoadingAssets(true)
setTimeout(() => { dispatch({
setLoading(false) type: (reference===AssetDraftReference)?'assetmanage.getDraftRelatedAssets':'assetmanage.getRelatedAssets',
setData(Array.from({ length: 90 }, (_, key) => ({ payload: {
id: `${key}`, params: {
name: `test${key}` dataAssetId: item?.id
}))) }
}, 3000) },
callback: (data) => {
setLoadingAssets(false)
setAssets(data)
},
error: () => {
setLoadingAssets(false)
}
})
}
const getRelatedServices = () => {
setLoadingServices(true)
dispatch({
type: (reference===AssetDraftReference)?'assetmanage.getDraftRelatedServices':'assetmanage.getRelatedServices',
payload: {
params: {
dataAssetId: item?.id
}
},
callback: (data) => {
setLoadingServices(false)
setServices(data)
},
error: () => {
setLoadingServices(false)
}
})
} }
const onEditClick = () => { const onEditClick = () => {
...@@ -89,6 +121,26 @@ const FC = (props) => { ...@@ -89,6 +121,26 @@ const FC = (props) => {
}) })
} }
const onSelectResourceCancel = (data) => {
setSelectResourceParams({
visible: false,
item: undefined,
type: undefined
})
if (data) {
if (activeKey === 'asset') {
setAssets(prevAssets => {
return [...prevAssets??[], ...data]
})
} else if (activeKey === 'service') {
setServices(prevServices => {
return [...prevServices??[], ...data]
})
}
}
}
return ( return (
<div> <div>
<Tabs activeKey={activeKey} onChange={(val) => { setActiveKey(val) }}> <Tabs activeKey={activeKey} onChange={(val) => { setActiveKey(val) }}>
...@@ -96,12 +148,14 @@ const FC = (props) => { ...@@ -96,12 +148,14 @@ const FC = (props) => {
<Tabs.TabPane tab='关联服务' key='service' /> <Tabs.TabPane tab='关联服务' key='service' />
</Tabs> </Tabs>
<div style={{ display: 'flex', justifyContent: 'space-between' }}> <div style={{ display: 'flex', justifyContent: 'space-between' }}>
<Space> {
action === 'edit' && <Space>
<Button onClick={onEditClick}>编辑</Button> <Button onClick={onEditClick}>编辑</Button>
<Tooltip title={(selectedRows??[]).length===0?(activeKey==='asset'?'请先选择资产':'请先选择服务'):''}> <Tooltip title={(selectedRows??[]).length===0?(activeKey==='asset'?'请先选择资产':'请先选择服务'):''}>
<Button disabled={(selectedRows??[]).length===0} onClick={onDeleteClick}>删除</Button> <Button disabled={(selectedRows??[]).length===0} onClick={onDeleteClick}>删除</Button>
</Tooltip> </Tooltip>
</Space> </Space>
}
<Input size="middle" <Input size="middle"
placeholder={activeKey==='service'?'搜索服务名称':''} placeholder={activeKey==='service'?'搜索服务名称':''}
value={keyword} value={keyword}
...@@ -115,7 +169,7 @@ const FC = (props) => { ...@@ -115,7 +169,7 @@ const FC = (props) => {
<div className='mt-3'> <div className='mt-3'>
<Table <Table
rowKey='id' rowKey='id'
loading={loading} loading={loadingAssets||loadingServices}
columns={cols} columns={cols}
dataSource={tableData??[]} dataSource={tableData??[]}
pagination={false} pagination={false}
...@@ -143,15 +197,7 @@ const FC = (props) => { ...@@ -143,15 +197,7 @@ const FC = (props) => {
</div> </div>
<SelectResource <SelectResource
{...selectResourceParams} {...selectResourceParams}
onCancel={(refresh) => { onCancel={onSelectResourceCancel}
setSelectResourceParams({
visible: false,
item: undefined,
type: undefined
})
refresh && getRelations()
}}
/> />
{contextHolder} {contextHolder}
</div> </div>
......
...@@ -14,6 +14,7 @@ import './select-asset.less' ...@@ -14,6 +14,7 @@ import './select-asset.less'
// const specialCol = ['数据关键用户', '业务数据owner', 'it责任人', '创建人', '更新人'] // const specialCol = ['数据关键用户', '业务数据owner', 'it责任人', '创建人', '更新人']
const FC = (props) => { const FC = (props) => {
const { onChange } = props
const [args, setArgs] = React.useState(() => ({ const [args, setArgs] = React.useState(() => ({
page: 1, page: 1,
size: 20, size: 20,
...@@ -59,6 +60,10 @@ const FC = (props) => { ...@@ -59,6 +60,10 @@ const FC = (props) => {
} }
}, [currentTemplate, node]) }, [currentTemplate, node])
React.useEffect(() => {
onChange?.(selectedRows)
}, [selectedRows])
useDebounceEffect(() => { useDebounceEffect(() => {
if (currentTemplate) { if (currentTemplate) {
getAssets() getAssets()
......
...@@ -63,7 +63,7 @@ const FC = (props) => { ...@@ -63,7 +63,7 @@ const FC = (props) => {
}, [rootNode, args], { wait: 300 }) }, [rootNode, args], { wait: 300 })
React.useEffect(() => { React.useEffect(() => {
onChange?.((selectedRows??[]).map(item => item.id)) onChange?.(selectedRows)
}, [selectedRows]) }, [selectedRows])
const treeData1 = React.useMemo(() => { const treeData1 = React.useMemo(() => {
......
...@@ -3,6 +3,7 @@ import { Modal, Button, Spin, message, } from 'antd' ...@@ -3,6 +3,7 @@ import { Modal, Button, Spin, message, } from 'antd'
import SelectAsset from './select-asset' import SelectAsset from './select-asset'
import SelectDataService from './select-data-service' import SelectDataService from './select-data-service'
import { dispatch } from '../../../../model';
const FC = ({ visible, item, type, onCancel }) => { const FC = ({ visible, item, type, onCancel }) => {
const [animated, setAnimated] = React.useState(true) const [animated, setAnimated] = React.useState(true)
...@@ -17,20 +18,46 @@ const FC = ({ visible, item, type, onCancel }) => { ...@@ -17,20 +18,46 @@ const FC = ({ visible, item, type, onCancel }) => {
} }
}, [visible]) }, [visible])
const close = (refresh = false) => { const close = (data = null) => {
setWaiting(false) setWaiting(false)
setAnimated(true) setAnimated(true)
onCancel?.(refresh) onCancel?.(data)
} }
const save = async () => { const save = async () => {
const selectedRowKeys = basicRef.current?.selectedRowKeys const selectedRows = basicRef.current?.selectedRows
if ((selectedRowKeys??[]).length === 0) { if ((selectedRows??[]).length === 0) {
message.warn(type==='asset'?'请先选择资产':'请先选择服务') message.warn(type==='asset'?'请先选择资产':'请先选择服务')
return return
} }
if (type === 'asset') {
setWaiting(true) setWaiting(true)
dispatch({
type: 'assetmanage.fillRelatedAssetsInfo',
payload: {
params: {
dataAssetIds: (selectedRows??[]).map(item => item.id).toString()
}
},
callback: (data) => {
setWaiting(false)
close(data)
},
error: () => {
setWaiting(false)
}
})
} else {
close((selectedRows??[]).map(item => ({
cnName: item.basicInfo?.cnName,
name: item.basicInfo?.name,
path: item.path,
relatedServiceCode: item.basicInfo?.code,
relatedServiceId: item.id,
remark: item.remark,
})))
}
} }
const footer = React.useMemo(() => { const footer = React.useMemo(() => {
...@@ -67,14 +94,14 @@ const FC = ({ visible, item, type, onCancel }) => { ...@@ -67,14 +94,14 @@ const FC = ({ visible, item, type, onCancel }) => {
export default FC export default FC
const Basic = React.forwardRef(function ({ type }, ref) { const Basic = React.forwardRef(function ({ type }, ref) {
const [selectedRowKeys, setSelectedRowKeys] = React.useState() const [selectedRows, setSelectedRows] = React.useState()
React.useImperativeHandle(ref, () => ({ React.useImperativeHandle(ref, () => ({
selectedRowKeys selectedRows
}), [selectedRowKeys]) }), [selectedRows])
const onChange = (val) => { const onChange = (val) => {
setSelectedRowKeys(val) setSelectedRows(val)
} }
return ( return (
......
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