Commit 5201b9ac by zhaochengxiang

新增岗位

parent 99fe986f
import React, { useState } from 'react'; import React, { useState, useRef } from 'react';
import { Modal, Form, Space, Button, Spin } from 'antd'; import { Modal, Form, Space, Button, Spin } from 'antd';
import { showMessage } from '../../../../util'; import { showMessage } from '../../../../util';
import { dispatch } from '../../../../model'; import { dispatch } from '../../../../model';
...@@ -9,6 +9,7 @@ const AddAssetModel = (props) => { ...@@ -9,6 +9,7 @@ const AddAssetModel = (props) => {
const { onCancel, visible, nodeId } = props; const { onCancel, visible, nodeId } = props;
const [ waiting, setWaiting ] = useState(false); const [ waiting, setWaiting ] = useState(false);
const [ elements, setElements ] = useState([]); const [ elements, setElements ] = useState([]);
const [postRelations, setPostRelations] = useState();
const [ form ] = Form.useForm(); const [ form ] = Form.useForm();
...@@ -16,6 +17,10 @@ const AddAssetModel = (props) => { ...@@ -16,6 +17,10 @@ const AddAssetModel = (props) => {
setElements(value); setElements(value);
} }
const onPostRelationsChange = (value) => {
setPostRelations(value);
}
const close = (refresh = false) => { const close = (refresh = false) => {
setWaiting(false) setWaiting(false)
form?.resetFields() form?.resetFields()
...@@ -45,13 +50,18 @@ const AddAssetModel = (props) => { ...@@ -45,13 +50,18 @@ const AddAssetModel = (props) => {
showMessage('warn', '已存在相同的资产目录编号,请重新输入'); showMessage('warn', '已存在相同的资产目录编号,请重新输入');
} else { } else {
dispatch({ dispatch({
type: 'assetmanage.saveAsDraft', type: 'assetmanage.checkAdmin',
callback: (data) => {
const isAdmin = (data==='true')?true:false
dispatch({
type: isAdmin?'assetmanage.addOrUpdateDataAsset':'assetmanage.saveAsDraft',
payload: { payload: {
params: { params: {
dirId: nodeId, dirId: nodeId,
operation: 'release', operation: 'release',
}, },
data: { elements: newElements, templateType: getTemplateType() } data: { elements: newElements, templateType: getTemplateType(), ...postRelations }
}, },
callback: () => { callback: () => {
showMessage("success","新增成功"); showMessage("success","新增成功");
...@@ -61,6 +71,11 @@ const AddAssetModel = (props) => { ...@@ -61,6 +71,11 @@ const AddAssetModel = (props) => {
setWaiting(false); setWaiting(false);
} }
}) })
},
error: () => {
setWaiting(false);
}
})
} }
}, },
error: () => { error: () => {
...@@ -81,7 +96,7 @@ const AddAssetModel = (props) => { ...@@ -81,7 +96,7 @@ const AddAssetModel = (props) => {
title='新增资产目录信息' title='新增资产目录信息'
visible={ visible } visible={ visible }
centered centered
width={ 800 } width='80%'
onCancel={() => { close() } } onCancel={() => { close() } }
footer={ footer={
<Space> <Space>
...@@ -97,6 +112,7 @@ const AddAssetModel = (props) => { ...@@ -97,6 +112,7 @@ const AddAssetModel = (props) => {
dirId={nodeId} dirId={nodeId}
action='add' action='add'
onElementsChange={onElementsChange} onElementsChange={onElementsChange}
onPostRelationsChange={onPostRelationsChange}
/> />
</Spin> </Spin>
</Modal> </Modal>
......
...@@ -28,7 +28,7 @@ import PostRelation from './post-relation'; ...@@ -28,7 +28,7 @@ import PostRelation from './post-relation';
import './AssetAction.less'; import './AssetAction.less';
const AssetAction = (props) => { const AssetAction = (props) => {
const { id, dirId, action, terms, onChange, reference, form, onMetadataChange, onElementsChange, readonly = false, permissionId, catalog } = props; const { id, dirId, action, terms, onChange, reference, form, onMetadataChange, onElementsChange, readonly = false, permissionId, catalog, onPostRelationsChange } = props;
const [ currentAction, setCurrentAction ] = useState(action); const [ currentAction, setCurrentAction ] = useState(action);
const [ assetParams, setAssetParams ] = useState({ assets: {}, attributes: [] }); const [ assetParams, setAssetParams ] = useState({ assets: {}, attributes: [] });
...@@ -1370,9 +1370,9 @@ const AssetAction = (props) => { ...@@ -1370,9 +1370,9 @@ const AssetAction = (props) => {
</Spin> </Spin>
{ {
action!=='add' && <React.Fragment> action!=='add' ? <React.Fragment>
{ {
isPostAsset(assets?.templateType) ? <div className='mt-2'><PostRelation ref={postRealtionRef} 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} onChange={onPostRelationsChange} /></div> : <React.Fragment>
<div> <div>
<Divider orientation='left'>字段级资产目录信息</Divider> <Divider orientation='left'>字段级资产目录信息</Divider>
</div> </div>
...@@ -1463,7 +1463,7 @@ const AssetAction = (props) => { ...@@ -1463,7 +1463,7 @@ const AssetAction = (props) => {
/> />
</React.Fragment> </React.Fragment>
} }
</React.Fragment> </React.Fragment> : <div className='mt-2'><PostRelation ref={postRealtionRef} reference={reference} action={currentAction} item={assets} onChange={onPostRelationsChange} /></div>
} }
<SelectStandard <SelectStandard
......
...@@ -9,7 +9,7 @@ import { AssetDraftReference } from '../../../../util/constant' ...@@ -9,7 +9,7 @@ import { AssetDraftReference } from '../../../../util/constant'
import AssetDetailDrawer from "./AssetDetailDrawer"; import AssetDetailDrawer from "./AssetDetailDrawer";
import { AppContext } from '../../../../App' import { AppContext } from '../../../../App'
const FC = React.forwardRef(function ({ item, reference, action }, ref) { const FC = React.forwardRef(function ({ item, reference, action, onChange }, ref) {
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({
...@@ -43,8 +43,17 @@ const FC = React.forwardRef(function ({ item, reference, action }, ref) { ...@@ -43,8 +43,17 @@ const FC = React.forwardRef(function ({ item, reference, action }, ref) {
}), [assets, services]) }), [assets, services])
React.useEffect(() => { React.useEffect(() => {
onChange?.({
postAssets: assets??[],
postServices: services??[]
})
}, [assets, services])
React.useEffect(() => {
if (item) {
getRelatedAssets() getRelatedAssets()
getRelatedServices() getRelatedServices()
}
}, [item]) }, [item])
const [tableData, total] = React.useMemo(() => { const [tableData, total] = React.useMemo(() => {
...@@ -255,7 +264,7 @@ const FC = React.forwardRef(function ({ item, reference, action }, ref) { ...@@ -255,7 +264,7 @@ const FC = React.forwardRef(function ({ item, reference, action }, ref) {
</Tabs> </Tabs>
<div style={{ display: 'flex', justifyContent: 'space-between' }}> <div style={{ display: 'flex', justifyContent: 'space-between' }}>
{ {
action === 'edit' ? <Space> action !== 'detail' ? <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>
......
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