Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
S
szse
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
zhaochengxiang
szse
Commits
b61721b7
Commit
b61721b7
authored
Oct 28, 2025
by
放生的三文鱼
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
修改资产保存的业务逻辑和修改送审接口
parent
2a51fce8
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
298 additions
and
27 deletions
+298
-27
assetmanage.js
src/model/assetmanage.js
+5
-0
dataassetmanager.js
src/service/dataassetmanager.js
+8
-3
ImportModal.jsx
src/view/Manage/AssetDraft/component/ImportModal.jsx
+248
-0
assetData.jsx
src/view/Manage/AssetDraft/hooks/assetData.jsx
+4
-2
AssetAction.jsx
src/view/Manage/AssetManage/Component/AssetAction.jsx
+33
-22
No files found.
src/model/assetmanage.js
View file @
b61721b7
...
...
@@ -364,3 +364,8 @@ export function* checkIsNeedSaveAsDraftDataAsset(payload) {
export
function
*
saveAsDraftDataAsset
(
payload
)
{
return
yield
call
(
service
.
saveAsDraftDataAsset
,
payload
)
}
// updateDraftDataAsset
export
function
*
updateDraftDataAsset
(
payload
)
{
return
yield
call
(
service
.
updateDraftDataAsset
,
payload
)
}
src/service/dataassetmanager.js
View file @
b61721b7
...
...
@@ -350,9 +350,9 @@ export function deleteDraftDataAsset(payload) {
return
PostJSON
(
'/dataassetmanager/draftApi/deleteDrafts'
,
payload
);
}
// /
draftApi/publish
Drafts
export
function
publish
DraftDataAsset
(
payload
)
{
return
PostJSON
(
`/dataassetmanager/draftApi/
publish
Drafts?
${
qs
.
stringify
(
payload
,
{
arrayFormat
:
'repeat'
})}
`
);
// /
/draftApi/audit
Drafts
export
function
audit
DraftDataAsset
(
payload
)
{
return
PostJSON
(
`/dataassetmanager/draftApi/
audit
Drafts?
${
qs
.
stringify
(
payload
,
{
arrayFormat
:
'repeat'
})}
`
);
}
// /draftApi/getDraftDetail
...
...
@@ -370,4 +370,9 @@ export function saveAsDraftDataAsset(payload) {
return
PostJSON
(
'/dataassetmanager/draftApi/saveAsDraft'
,
payload
);
}
// /draftApi/updateDraft
export
function
updateDraftDataAsset
(
payload
)
{
return
PostJSON
(
'/dataassetmanager/draftApi/updateDraft'
,
payload
);
}
src/view/Manage/AssetDraft/component/ImportModal.jsx
0 → 100644
View file @
b61721b7
import
React
,
{
useState
,
useEffect
,
useContext
}
from
'react'
;
import
{
Button
,
Upload
,
Drawer
,
Table
,
Pagination
,
Divider
,
Form
,
Typography
}
from
'antd'
;
import
{
UploadOutlined
,
DownloadOutlined
}
from
'@ant-design/icons'
;
import
{
dispatch
}
from
'../../../model'
;
import
{
showMessage
,
formatDate
}
from
'../../../util'
;
import
{
AppContext
}
from
'../../../App'
;
import
{
getTemplateType
}
from
'../../../util/axios'
;
const
FC
=
(
props
)
=>
{
const
{
onCancel
,
onSuccess
,
visible
,
}
=
props
;
const
[
fileList
,
setFileList
]
=
useState
([]);
const
[
confirmLoading
,
setConfirmLoading
]
=
useState
(
false
);
const
[
loading
,
setLoading
]
=
useState
(
false
);
const
[
logs
,
setLogs
]
=
useState
([]);
const
[
pagination
,
setPagination
]
=
useState
(
{
pageNum
:
1
,
pageSize
:
20
}
);
const
{
pageNum
,
pageSize
}
=
pagination
;
const
[
total
,
setTotal
]
=
useState
(
0
);
const
[
users
,
setUsers
]
=
useState
([]);
const
app
=
useContext
(
AppContext
);
const
columns
=
[
{
title
:
'序号'
,
dataIndex
:
'key'
,
render
:
(
text
,
record
,
index
)
=>
{
return
(
index
+
1
).
toString
();
},
width
:
60
,
},
{
title
:
'开始时间'
,
dataIndex
:
'startTime'
,
width
:
200
,
ellipsis
:
true
,
render
:
(
_
,
record
,
__
)
=>
{
return
formatDate
(
record
.
startTime
);
}
},
{
title
:
'结束时间'
,
dataIndex
:
'endTime'
,
width
:
200
,
ellipsis
:
true
,
render
:
(
_
,
record
,
__
)
=>
{
return
formatDate
(
record
.
endTime
);
}
},
{
title
:
'耗时'
,
dataIndex
:
'costTime'
,
width
:
100
,
ellipsis
:
true
,
render
:
(
_
,
record
,
__
)
=>
{
return
record
.
costTime
?
`
${
Number
(
record
.
costTime
/
1000
)}
秒`
:
''
;
}
},
{
title
:
'导入人'
,
dataIndex
:
'operator'
,
width
:
100
,
ellipsis
:
true
,
render
:
(
text
,
record
)
=>
{
const
user
=
users
?.
filter
((
user
)
=>
user
.
pernr
===
text
);
if
(
user
&&
user
.
length
>
0
)
{
return
user
[
0
].
nachn
?
`
${
user
[
0
].
nachn
}
(
${
user
[
0
].
pernr
}
)`
:
user
[
0
].
pernr
;
}
return
text
;
}
},
{
title
:
'导入状态'
,
dataIndex
:
'state'
,
ellipsis
:
true
,
}
]
useEffect
(()
=>
{
if
(
visible
)
{
setPagination
({
pageNum
:
1
,
pageSize
:
20
});
getUsers
();
getLogs
();
}
//eslint-disable-next-line react-hooks/exhaustive-deps
},
[
visible
])
const
getLogs
=
(
p
=
1
,
s
=
20
)
=>
{
setLoading
(
true
);
dispatch
({
type
:
'assetmanage.importDraftLogs'
,
payload
:
{
page
:
p
,
pageSize
:
s
},
callback
:
data
=>
{
setLoading
(
false
);
setTotal
(
data
.
total
);
setLogs
(
data
.
data
||
[]);
},
error
:
()
=>
{
setLoading
(
false
);
}
})
}
const
getUsers
=
()
=>
{
dispatch
({
type
:
'pds.getOwners'
,
callback
:
(
data
)
=>
{
setUsers
(
data
);
}
})
}
const
uploadProps
=
{
onRemove
:
file
=>
{
const
index
=
fileList
.
indexOf
(
file
);
const
newFileList
=
fileList
.
slice
();
newFileList
.
splice
(
index
,
1
);
setFileList
(
newFileList
);
},
beforeUpload
:
file
=>
{
const
isLt2OM
=
file
.
size
/
1024
/
1024
<
20
;
if
(
!
isLt2OM
)
{
showMessage
(
'error'
,
'上传文件必须小于20M'
);
setFileList
([]);
return
false
;
}
setFileList
([
file
]);
return
false
;
},
fileList
:
fileList
||
[],
accept
:
".xlsx"
,
};
const
downloadTemplate
=
()
=>
{
window
.
open
(
`/api/dataassetmanager/dataAssetApi/getImportTemplate?templateType=
${
getTemplateType
()}
`
);
}
const
handleOk
=
()
=>
{
if
((
fileList
||
[]).
length
===
0
)
{
showMessage
(
'info'
,
'请先选择文件上传'
);
return
;
}
setConfirmLoading
(
true
);
dispatch
({
type
:
'assetmanage.draftAssetImport'
,
payload
:
{
fileList
:
fileList
,
params
:
{
env
:
`
${
app
?.
env
?.
domainId
}
`, saveAsDraft: false } },
callback: data => {
setConfirmLoading(false);
setFileList([]);
getLogs(pageNum, pageSize);
showMessage('success', '导入动作完成,详情查看日志');
onSuccess && onSuccess(data||'');
},
error: () => {
setConfirmLoading(false);
}
});
}
const reset = () => {
setConfirmLoading(false);
setFileList([]);
}
return (
<Drawer
forceRender
visible={ visible }
title='资产目录草稿批量修改'
width={900}
placement="right"
closable={ true }
onClose={() => {
reset();
onCancel && onCancel();
}}
>
<div className='mt-3'>
<Form layout='inline'>
<Form.Item label='Excel导入:'>
<Button className='mr-2' icon={<DownloadOutlined />} onClick={ downloadTemplate }>
模板下载
</Button>
<Upload style={{ display: 'inline' }} {...uploadProps }>
<Button icon={
<UploadOutlined />}>
选择文件上传
</Button>
</Upload>
</Form.Item>
<Form.Item>
<Button type='primary' onClick={handleOk} loading={confirmLoading}>确定导入</Button>
</Form.Item>
<Button onClick={() => getLogs()} style={{ marginLeft: 'auto' }}>刷新日志</Button>
</Form>
</div>
<Divider orientation="left">导入日志</Divider>
<Table
className='mt-3'
columns={columns||[]}
rowKey={'id'}
dataSource={logs||[]}
pagination={false}
loading={loading}
expandable={{
expandedRowRender: record => <React.Fragment>
{record.message?.split('<br/>').map((info, index) => {
return <Typography.Paragraph key={index}>{info}</Typography.Paragraph>
})}
</React.Fragment>
}}
sticky
/>
<Pagination
className="text-center mt-3"
showSizeChanger
onChange={(_pageNum, _pageSize) => {
setPagination({ pageNum: _pageNum||1, pageSize: _pageSize || 20 });
getLogs(_pageNum||1, _pageSize||20);
}}
onShowSizeChange={(_pageNum, _pageSize) => {
setPagination({ pageNum: _pageNum || 1, pageSize: _pageSize || 20 });
getLogs(_pageNum||1, _pageSize||20);
}}
current={pageNum}
pageSize={pageSize}
defaultCurrent={1}
total={total}
showTotal={total => `
共
$
{
total
}
条
`}
/>
</Drawer>
)
}
export default FC;
\ No newline at end of file
src/view/Manage/AssetDraft/hooks/assetData.jsx
View file @
b61721b7
...
...
@@ -5,7 +5,7 @@ import {
getDraftDataAsset
,
listFilterElementsGroupByType
,
deleteDraftDataAsset
,
publish
DraftDataAsset
,
audit
DraftDataAsset
,
}
from
"../../../../service/dataassetmanager"
;
import
{
AssetItem
}
from
"../../AssetManage/Component/AssetTable"
;
import
{
showMessage
,
showErrorNotifaction
}
from
"../../../../util"
;
...
...
@@ -38,6 +38,7 @@ export function useGetAssetDraft({ setDraftParams }) {
data
:
id
?
id
:
selectedRowKeys
,
});
showMessage
(
"success"
,
"删除成功"
);
setSelectedRowKeys
([]);
getDraftData
();
}
catch
(
error
)
{
console
.
log
(
"error"
,
error
);
...
...
@@ -48,10 +49,11 @@ export function useGetAssetDraft({ setDraftParams }) {
// 批量送审
const
batchPublish
=
async
(
id
=
""
)
=>
{
try
{
await
publish
DraftDataAsset
({
await
audit
DraftDataAsset
({
draftIds
:
id
?
id
:
selectedRowKeys
,
});
showMessage
(
"success"
,
"送审成功"
);
setSelectedRowKeys
([]);
getDraftData
();
}
catch
(
error
)
{
console
.
log
(
"error"
,
error
);
...
...
src/view/Manage/AssetManage/Component/AssetAction.jsx
View file @
b61721b7
...
...
@@ -54,6 +54,7 @@ const AssetAction = (props) => {
const
[
currentDomainGroup
,
setCurrentDomainGroup
]
=
useState
(
undefined
);
const
[
currentBussinessDomain
,
setCurrentBussinessDomain
]
=
useState
(
undefined
);
const
[
canEdit
,
setEdit
]
=
useState
(
false
);
const
[
saveAsDraft
,
setSaveAsDraft
]
=
useState
(
false
);
const
[
isExist
,
setIsExist
]
=
useState
(
false
);
const
[
metadata
,
setMetadata
]
=
useState
(
undefined
);
const
[
loadingMetadataColumnList
,
setLoadingMetadataColumnList
]
=
useState
(
false
);
...
...
@@ -73,8 +74,6 @@ const AssetAction = (props) => {
const
app
=
useContext
(
AppContext
);
const
uploadRef
=
useRef
(
undefined
);
console
.
log
(
'dirs'
,
dirId
)
const
columns
=
[
{
title
:
'技术ID(英文名称)'
,
...
...
@@ -160,6 +159,7 @@ const AssetAction = (props) => {
];
useEffect
(()
=>
{
console
.
log
(
'props'
,
AssetManageReference
,
props
);
getSystems
();
getUsers
();
getTreeData
();
...
...
@@ -172,7 +172,6 @@ const AssetAction = (props) => {
setPagination
({...
pagination
,
pageNum
:
1
});
getElements
();
getDraftData
()
checkIsNeedSaveAsDraftDataAsset
()
}
else
if
((
id
||
''
)
!==
''
)
{
setPagination
({...
pagination
,
pageNum
:
1
});
...
...
@@ -180,6 +179,7 @@ const AssetAction = (props) => {
getAssetPaths
();
getResourceRelations
();
checkDataAssetEditable
();
checkIsNeedSaveAsDraftDataAsset
()
getAsset
();
}
else
{
...
...
@@ -343,7 +343,6 @@ const AssetAction = (props) => {
}
const
getElements
=
(
cb
=
null
)
=>
{
console
.
log
(
'data'
,
templateType
)
const
tempinfo
=
{}
if
(
templateType
){
tempinfo
.
templateType
=
templateType
...
...
@@ -404,7 +403,7 @@ const AssetAction = (props) => {
}
},
callback
:
value
=>
{
set
Edi
t
(
value
);
set
SaveAsDraf
t
(
value
);
}
})
}
...
...
@@ -657,7 +656,6 @@ const AssetAction = (props) => {
const onOk = async() => {
try {
const row = await form?.validateFields();
const newElements = [...elements];
(newElements||[]).forEach(element => {
if (row.hasOwnProperty(element.name)) {
...
...
@@ -672,11 +670,32 @@ const AssetAction = (props) => {
if ((metadataId||'')!=='') {
params.metadataId = metadataId;
}
setConfirmLoading(true);
console.log('assets',assets);
console.log('newElements',newElements);
if(draftId){
// 请求完成后的操作
const afterRequest = (getData) => {
setConfirmLoading(false);
setCurrentAction('detail');
getData()
showMessage("success",(action==='add')?"新增成功":"修改成功");
onChange && onChange();
}
if(draftId){ //资产草稿内的直接更新
dispatch({
type: 'assetmanage.updateDraftDataAsset',
payload: {
data:{ ...assets, elements: newElements }
},
callback: () => {
afterRequest(getDraftData);
},
error: () => {
setConfirmLoading(false);
}
})
}
else if(saveAsDraft){ //资产管理内的资产要求保存为草稿
dispatch({
type: 'assetmanage.saveAsDraftDataAsset',
payload: {
...
...
@@ -686,17 +705,13 @@ const AssetAction = (props) => {
data:{ ...assets, elements: newElements }
},
callback: () => {
setConfirmLoading(false);
setCurrentAction('detail');
getDraftData();
showMessage("success",(action==='add')?"新增成功":"修改成功");
onChange && onChange();
afterRequest(getAsset);
},
error: () => {
setConfirmLoading(false);
}
})
}else{
}else{
//资产管理内的资产不要求保存为草稿则直接保存
dispatch({
type: 'assetmanage.checkCodeIsExist',
payload: {
...
...
@@ -714,11 +729,7 @@ const AssetAction = (props) => {
data: action==='add' ? { elements: newElements } : { ...assets, elements: newElements }
},
callback: () => {
setConfirmLoading(false);
setCurrentAction('detail');
getAsset();
showMessage("success",(action==='add')?"新增成功":"修改成功");
onChange && onChange();
afterRequest(getAsset);
},
error: () => {
setConfirmLoading(false);
...
...
@@ -999,7 +1010,7 @@ const AssetAction = (props) => {
{
currentAction==='detail' ? <Tooltip title={isExist?'资产存在草稿箱中,不允许编辑':''}><Button type='primary' disabled={isExist} onClick={onActionButtonClick}>编辑</Button></Tooltip> : <React.Fragment>
<Button type='primary' onClick={onCancelButtonClick}>取消</Button>
{
(canEdit&&draftId)
?<Button type='primary' onClick={onActionButtonClick}>保存为草稿</Button>:
{
saveAsDraft
?<Button type='primary' onClick={onActionButtonClick}>保存为草稿</Button>:
<Button type='primary' onClick={onActionButtonClick}>保存</Button>}
</React.Fragment>
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment