Commit 1be5186c by zhaochengxiang

删除资产

parent 68e00aaf
import { useState } from "react";
import { Modal, Radio, Popover } from "antd";
import { QuestionCircleOutlined } from '@ant-design/icons';
const AssetDeleteModal = (props) => {
const { visible, onCancel, onDelete, onDeleteAll } = props;
const [ value, setValue ] = useState(1);
const onChange = (e) => {
setValue(e.target.value);
};
return (
<Modal
title="删除资产"
visible={visible}
onCancel={
() => {
onCancel && onCancel();
}
}
onOk={
() => {
if (value === 1) {
onDelete && onDelete();
} else {
onDeleteAll && onDeleteAll();
}
}
}
>
<div>
<Radio.Group onChange={onChange} value={value}>
<Radio value={1}>
<span style={{ paddingRight: 3 }}>删除本目录下的资产</span>
<Popover content={
<span>
当要删除的资产,只存在一个目录时,删除该资产并且设置为未分类资产;<br/>
存在多个目录时,只删除该目录下的这项资产,不会设置为未分类资产
</span>
}
style={{ marginLeft: 3 }}
>
<QuestionCircleOutlined className='pointer' />
</Popover>
</Radio>
<Radio value={2}>
<span>删除该资产(所有目录下的资产均删除)</span>
<Popover content='该资产所在的目录内,均删除该项资产,并设置为未分类资产' style={{ marginLeft: 3 }}>
<QuestionCircleOutlined className='pointer' />
</Popover>
</Radio>
</Radio.Group>
</div>
</Modal>
);
}
export default AssetDeleteModal;
\ No newline at end of file
......@@ -288,7 +288,11 @@ const AssetManageTree = (props) => {
const { nodeId, text } = node;
const currentPath = path ? `${path}/${text}` : text;
if (node.level !== 1) {
list.push({ key: nodeId , title: text, value: currentPath, level: node.level });
}
if (node.children) {
generateList(node.children, list, currentPath);
}
......
......@@ -16,6 +16,7 @@ import { dispatch, dispatchLatestHomepage } from '../../../../model';
import { showMessage, showNotifaction, getQueryParam, inputWidth, isSzseEnv } from '../../../../util';
import { AnchorId, AnchorDirId, AnchorTimestamp, AssetBrowseReference, AssetManageReference, AssetRecycleReference, ResourceBrowseReference } from '../../../../util/constant';
import { FullScreenSvg, CancelFullScreenSvg } from './AssetSvg';
import AssetDeleteModal from './AssetDeleteModal';
import "./AssetTable.less";
import 'react-contexify/dist/ReactContexify.css';
......@@ -145,6 +146,7 @@ const AssetTable = (props) => {
const [ recursive, setRecursive ] = useState(true);
const [ fullSearch, setFullSearch ] = useState(false);
const [ compact, setCompact ] = useState(false);
const [ assetDeleteModalVisible, setAssetDeleteModalVisible ] = useState(false);
const [ modal, contextHolder ] = Modal.useModal();
const anchorId = getQueryParam(AnchorId, props?.location?.search);
......@@ -496,31 +498,19 @@ const AssetTable = (props) => {
const deleteAssets = () => {
if ((checkedKeys||[]).length > 0) {
if (reference === AssetManageReference) {
setAssetDeleteModalVisible(true);
} else {
modal.confirm({
title: '提示',
content: (reference!==AssetRecycleReference)?'这些资产在所有目录上唯一存在,移除后,你可以前往“未挂载资产”重新挂载。': '您确定要永久删除这些资产吗?',
content: '您确定要永久删除这些资产吗?',
onOk: () => {
let payload = {
data: checkedKeys
}
if (reference !== AssetRecycleReference) {
const asssetIdsAndDirIds = [];
(assets||[]).forEach(asset => {
if (checkedKeys.indexOf(asset.id) !== -1) {
asssetIdsAndDirIds.push({ dataAssetId: asset.id||'', dirId: asset.dirId||'' });
}
})
payload = {
data: asssetIdsAndDirIds
}
}
dispatch({
type: (reference!==AssetRecycleReference)?'assetmanage.unloadDataAssets':'assetmanage.deleteDataAssets',
type: 'assetmanage.deleteDataAssets',
payload,
callback: () => {
showMessage("success","删除成功");
......@@ -532,8 +522,9 @@ const AssetTable = (props) => {
})
}
})
}
}else{
showMessage("warn","请选择删除项")
showMessage("warn","请先选择资产")
}
}
......@@ -563,6 +554,54 @@ const AssetTable = (props) => {
setAssetMountVisible(true);
}
const onAssetDeleteModalCancel = () => {
setAssetDeleteModalVisible(false);
}
const onAssetDeleteModalDelete = () => {
setAssetDeleteModalVisible(false);
const asssetIdsAndDirIds = [];
(assets||[]).forEach(asset => {
if (checkedKeys.indexOf(asset.id) !== -1) {
asssetIdsAndDirIds.push({ dataAssetId: asset.id||'', dirId: asset.dirId||'' });
}
})
let payload = {
data: asssetIdsAndDirIds
};
dispatch({
type: 'assetmanage.unloadDataAssets',
payload,
callback: () => {
showMessage("success","删除成功");
getDataAssets();
setCheckedKeys([]);
}
})
}
const onAssetDeleteModalDeleteAll = () => {
setAssetDeleteModalVisible(false);
let payload = {
data: checkedKeys
};
dispatch({
type: 'assetmanage.unloadDataAssetsFromAllDirs',
payload,
callback: () => {
showMessage("success","删除成功");
getDataAssets();
setCheckedKeys([]);
}
})
}
const recoveryAssets = () => {
if ((checkedKeys||[]).length > 0) {
modal.confirm({
......@@ -902,6 +941,12 @@ const AssetTable = (props) => {
visible={assetDetailDrawerVisible}
onCancel={onAssetDetailDrawerCancel}
/>
<AssetDeleteModal
visible={assetDeleteModalVisible}
onCancel={onAssetDeleteModalCancel}
onDelete={onAssetDeleteModalDelete}
onDeleteAll={onAssetDeleteModalDeleteAll}
/>
<RcMenu id={MENU_ID}>
{
(contextMenuItem.resourceState==='notRelatedAsset') && <RcItem id="uncombed" onClick={handleItemClick}>
......
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