Commit 11105d8e by zhaochengxiang

岗位

parent 7278b225
...@@ -3,6 +3,7 @@ import { Modal, Form, Space, Button, Spin } from 'antd'; ...@@ -3,6 +3,7 @@ import { Modal, Form, Space, Button, Spin } from 'antd';
import { showMessage } from '../../../../util'; import { showMessage } from '../../../../util';
import { dispatch } from '../../../../model'; import { dispatch } from '../../../../model';
import AssetAction from './AssetAction'; import AssetAction from './AssetAction';
import { getTemplateType } from '../../../../util/axios';
const AddAssetModel = (props) => { const AddAssetModel = (props) => {
const { onCancel, visible, nodeId } = props; const { onCancel, visible, nodeId } = props;
...@@ -48,9 +49,9 @@ const AddAssetModel = (props) => { ...@@ -48,9 +49,9 @@ const AddAssetModel = (props) => {
payload: { payload: {
params: { params: {
dirId: nodeId, dirId: nodeId,
operation: 'change', operation: 'release',
}, },
data: { elements: newElements } data: { elements: newElements, templateType: getTemplateType() }
}, },
callback: () => { callback: () => {
showMessage("success","新增成功"); showMessage("success","新增成功");
......
...@@ -7,8 +7,7 @@ import SelectResource from './select-resource' ...@@ -7,8 +7,7 @@ import SelectResource from './select-resource'
import { dispatch } from '../../../../model'; import { dispatch } from '../../../../model';
import { AssetDraftReference } from '../../../../util/constant' import { AssetDraftReference } from '../../../../util/constant'
const FC = (props) => { const FC = React.forwardRef(function ({ item, reference, action }, ref) {
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({
...@@ -28,11 +27,22 @@ const FC = (props) => { ...@@ -28,11 +27,22 @@ const FC = (props) => {
const [modal, contextHolder] = Modal.useModal() const [modal, contextHolder] = Modal.useModal()
// React.useImperativeHandle(ref, () => ({
// selectedRows
// }), [selectedRows])
React.useEffect(() => { React.useEffect(() => {
getRelatedAssets() getRelatedAssets()
getRelatedServices() getRelatedServices()
}, []) }, [])
React.useEffect(() => {
if (item) {
setAssets(item?.postAssets)
setServices(item?.postServices)
}
}, [item])
const [tableData, total] = React.useMemo(() => { const [tableData, total] = React.useMemo(() => {
let newTableData = (activeKey==='asset')?[...assets??[]]:[...services??[]] let newTableData = (activeKey==='asset')?[...assets??[]]:[...services??[]]
if (keyword) { if (keyword) {
...@@ -42,7 +52,28 @@ const FC = (props) => { ...@@ -42,7 +52,28 @@ const FC = (props) => {
return [paginate(newTableData, pagination.pageNum, pagination.pageSize), (newTableData??[]).length] return [paginate(newTableData, pagination.pageNum, pagination.pageSize), (newTableData??[]).length]
}, [activeKey, assets, services, keyword, pagination]) }, [activeKey, assets, services, keyword, pagination])
const cols = [ const assetCols = [
{
title: '序号',
dataIndex: 'index',
width:60,
render:(_, __, index)=> ((pagination.pageNum-1)*pagination.pageSize+index+1)
},
{
title: '路径',
dataIndex: 'path',
},
{
title: '资产编码',
dataIndex: 'relatedAssetCode',
},
{
title: '名称',
dataIndex: 'name',
},
]
const seriveCols = [
{ {
title: '序号', title: '序号',
dataIndex: 'index', dataIndex: 'index',
...@@ -55,7 +86,7 @@ const FC = (props) => { ...@@ -55,7 +86,7 @@ const FC = (props) => {
}, },
{ {
title: '数据服务资产编号', title: '数据服务资产编号',
dataIndex: 'code', dataIndex: 'relatedServiceCode',
}, },
{ {
title: '数据服务名称', title: '数据服务名称',
...@@ -131,11 +162,15 @@ const FC = (props) => { ...@@ -131,11 +162,15 @@ const FC = (props) => {
if (data) { if (data) {
if (activeKey === 'asset') { if (activeKey === 'asset') {
setAssets(prevAssets => { setAssets(prevAssets => {
return [...prevAssets??[], ...data] const filterData = (data??[]).filter(item => (prevAssets??[]).map(_item => _item.relatedAssetId).indexOf(item.relatedAssetId)===-1)
return [...prevAssets??[], ...filterData]
}) })
} else if (activeKey === 'service') { } else if (activeKey === 'service') {
setServices(prevServices => { setServices(prevServices => {
return [...prevServices??[], ...data] const filterData = (data??[]).filter(item => (prevServices??[]).map(_item => _item.relatedServiceId).indexOf(item.relatedServiceId)===-1)
return [...prevServices??[], ...filterData]
}) })
} }
} }
...@@ -149,15 +184,15 @@ const FC = (props) => { ...@@ -149,15 +184,15 @@ const FC = (props) => {
</Tabs> </Tabs>
<div style={{ display: 'flex', justifyContent: 'space-between' }}> <div style={{ display: 'flex', justifyContent: 'space-between' }}>
{ {
action === 'edit' && <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> : <div />
} }
<Input size="middle" <Input size="middle"
placeholder={activeKey==='service'?'搜索服务名称':''} placeholder={activeKey==='asset'?'搜索资产名称':'搜索服务名称'}
value={keyword} value={keyword}
bordered={true} allowClear bordered={true} allowClear
style={{ width: 200 }} style={{ width: 200 }}
...@@ -170,7 +205,7 @@ const FC = (props) => { ...@@ -170,7 +205,7 @@ const FC = (props) => {
<Table <Table
rowKey='id' rowKey='id'
loading={loadingAssets||loadingServices} loading={loadingAssets||loadingServices}
columns={cols} columns={activeKey==='asset'?assetCols:seriveCols}
dataSource={tableData??[]} dataSource={tableData??[]}
pagination={false} pagination={false}
rowSelection={{ rowSelection={{
...@@ -202,6 +237,6 @@ const FC = (props) => { ...@@ -202,6 +237,6 @@ const FC = (props) => {
{contextHolder} {contextHolder}
</div> </div>
) )
} })
export default FC export default FC
\ No newline at end of file
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