Commit c071c3c8 by zhaochengxiang

批量删除资产

parent b6e2c236
...@@ -277,7 +277,7 @@ const AssetTable = (props) =>{ ...@@ -277,7 +277,7 @@ const AssetTable = (props) =>{
<Space className='ml-5'> <Space className='ml-5'>
<span>资产:</span> <span>资产:</span>
<Button type="primary" onClick={ addAsset }>新增</Button> <Button type="primary" onClick={ addAsset }>新增</Button>
<Button type="primary" danger onClick={ deleteAssets } >删除</Button> <Button type="danger" onClick={ deleteAssets } >删除</Button>
<Button type="primary" onClick={importAsset} >导入</Button> <Button type="primary" onClick={importAsset} >导入</Button>
<Button type="primary" onClick={exportAsset} >导出</Button> <Button type="primary" onClick={exportAsset} >导出</Button>
</Space> </Space>
......
...@@ -18,6 +18,7 @@ const AssetRecycle = (props) => { ...@@ -18,6 +18,7 @@ const AssetRecycle = (props) => {
const [ currentAssetId, setCurrentAssetId ] = useState(''); const [ currentAssetId, setCurrentAssetId ] = useState('');
const [ assetDetailVisible, setAssetDetailVisible ] = useState(false); const [ assetDetailVisible, setAssetDetailVisible ] = useState(false);
const [ assetMountVisible, setAssetMountVisible ] = useState(false); const [ assetMountVisible, setAssetMountVisible ] = useState(false);
const [ selectedRowKeys, setSelectedRowKeys ] = useState([]);
const { pageNum, pageSize } = pagination; const { pageNum, pageSize } = pagination;
...@@ -41,10 +42,12 @@ const AssetRecycle = (props) => { ...@@ -41,10 +42,12 @@ const AssetRecycle = (props) => {
{ {
title: '中文名称', title: '中文名称',
dataIndex: 'cnName', dataIndex: 'cnName',
ellipsis: true,
}, },
{ {
title: '英文名称', title: '英文名称',
dataIndex: 'name', dataIndex: 'name',
ellipsis: true,
}, },
{ {
title: '操作', title: '操作',
...@@ -112,6 +115,31 @@ const AssetRecycle = (props) => { ...@@ -112,6 +115,31 @@ const AssetRecycle = (props) => {
setAssetMountVisible(true); setAssetMountVisible(true);
} }
const deleteItems = () => {
if ((selectedRowKeys||[]).length === 0) {
showMessage('warn', '请先选择资产');
return;
}
modal.confirm({
title: '提示!',
content: '您确定要永久删除选中的资产吗?',
onOk: () => {
dispatchLatest({
type: 'assetmanage.deleteDataAssets',
payload: {
data: selectedRowKeys
},
callback: () => {
showMessage('success', '资产删除成功');
setSelectedRowKeys([]);
getAssets();
}
})
}
});
}
const deleteItem = (record) => { const deleteItem = (record) => {
modal.confirm({ modal.confirm({
title: '提示!', title: '提示!',
...@@ -140,10 +168,29 @@ const AssetRecycle = (props) => { ...@@ -140,10 +168,29 @@ const AssetRecycle = (props) => {
refresh && getAssets(); refresh && getAssets();
} }
const onSelectChange = keys => {
setSelectedRowKeys(keys);
};
const rowSelection = {
selectedRowKeys,
onChange: onSelectChange,
};
return ( return (
<div className='asset-recycle p-3' style={{ backgroundColor: '#fff' }}> <div className='asset-recycle' style={{ backgroundColor: '#fff' }}>
<div
className='d-flex p-3'
style={{
borderBottom: '1px solid #EFEFEF',
}}
>
<Button type="danger" onClick={deleteItems} style={{ marginLeft: 'auto' }} >删除</Button>
</div>
<div className='list p-3'>
<Table <Table
loading={loading} loading={loading}
rowSelection={rowSelection}
columns={columns} columns={columns}
rowKey={'id'} rowKey={'id'}
dataSource={assets||[]} dataSource={assets||[]}
...@@ -166,6 +213,7 @@ const AssetRecycle = (props) => { ...@@ -166,6 +213,7 @@ const AssetRecycle = (props) => {
total={total} total={total}
showTotal={total => `共 ${total} 条`} showTotal={total => `共 ${total} 条`}
/> />
</div>
<AssetDetail <AssetDetail
visible={ assetDetailVisible } visible={ assetDetailVisible }
id={ currentAssetId } id={ currentAssetId }
......
.asset-recycle { .asset-recycle {
height: calc(100vh - 64px - 30px) !important; .list {
height: calc(100vh - 64px - 30px - 53px) !important;
overflow: auto !important; overflow: auto !important;
}
} }
\ 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