Commit c071c3c8 by zhaochengxiang

批量删除资产

parent b6e2c236
......@@ -277,7 +277,7 @@ const AssetTable = (props) =>{
<Space className='ml-5'>
<span>资产:</span>
<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={exportAsset} >导出</Button>
</Space>
......
import React, { useEffect, useState } from 'react';
import { Table, Pagination, Space, Tooltip, Button, Modal } from 'antd';
import { ReconciliationOutlined, DeleteOutlined, UndoOutlined } from '@ant-design/icons';
import { ReconciliationOutlined, DeleteOutlined, UndoOutlined } from '@ant-design/icons';
import { dispatchLatest } from '../../../model';
import AssetDetail from '../AssetManage/components/AssetDetail';
......@@ -18,6 +18,7 @@ const AssetRecycle = (props) => {
const [ currentAssetId, setCurrentAssetId ] = useState('');
const [ assetDetailVisible, setAssetDetailVisible ] = useState(false);
const [ assetMountVisible, setAssetMountVisible ] = useState(false);
const [ selectedRowKeys, setSelectedRowKeys ] = useState([]);
const { pageNum, pageSize } = pagination;
......@@ -41,10 +42,12 @@ const AssetRecycle = (props) => {
{
title: '中文名称',
dataIndex: 'cnName',
ellipsis: true,
},
{
title: '英文名称',
dataIndex: 'name',
ellipsis: true,
},
{
title: '操作',
......@@ -112,6 +115,31 @@ const AssetRecycle = (props) => {
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) => {
modal.confirm({
title: '提示!',
......@@ -140,32 +168,52 @@ const AssetRecycle = (props) => {
refresh && getAssets();
}
const onSelectChange = keys => {
setSelectedRowKeys(keys);
};
const rowSelection = {
selectedRowKeys,
onChange: onSelectChange,
};
return (
<div className='asset-recycle p-3' style={{ backgroundColor: '#fff' }}>
<Table
loading={loading}
columns={columns}
rowKey={'id'}
dataSource={assets||[]}
pagination={false}
/>
<Pagination
size="small"
className="text-center mt-3"
showSizeChanger
showQuickJumper
onChange={(_pageNum, _pageSize) => {
setPagination({ pageNum: _pageNum, pageSize: _pageSize || 10 });
<div className='asset-recycle' style={{ backgroundColor: '#fff' }}>
<div
className='d-flex p-3'
style={{
borderBottom: '1px solid #EFEFEF',
}}
onShowSizeChange={(_pageNum, _pageSize) => {
setPagination({ pageNum: _pageNum || 1, pageSize: _pageSize });
}}
current={pageNum}
pageSize={pageSize}
defaultCurrent={1}
total={total}
showTotal={total => `共 ${total} 条`}
/>
>
<Button type="danger" onClick={deleteItems} style={{ marginLeft: 'auto' }} >删除</Button>
</div>
<div className='list p-3'>
<Table
loading={loading}
rowSelection={rowSelection}
columns={columns}
rowKey={'id'}
dataSource={assets||[]}
pagination={false}
/>
<Pagination
size="small"
className="text-center mt-3"
showSizeChanger
showQuickJumper
onChange={(_pageNum, _pageSize) => {
setPagination({ pageNum: _pageNum, pageSize: _pageSize || 10 });
}}
onShowSizeChange={(_pageNum, _pageSize) => {
setPagination({ pageNum: _pageNum || 1, pageSize: _pageSize });
}}
current={pageNum}
pageSize={pageSize}
defaultCurrent={1}
total={total}
showTotal={total => `共 ${total} 条`}
/>
</div>
<AssetDetail
visible={ assetDetailVisible }
id={ currentAssetId }
......
.asset-recycle {
height: calc(100vh - 64px - 30px) !important;
overflow: auto !important;
.list {
height: calc(100vh - 64px - 30px - 53px) !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