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>
......
import React, { useEffect, useState } from 'react'; import React, { useEffect, useState } from 'react';
import { Table, Pagination, Space, Tooltip, Button, Modal } from 'antd'; 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 { dispatchLatest } from '../../../model';
import AssetDetail from '../AssetManage/components/AssetDetail'; import AssetDetail from '../AssetManage/components/AssetDetail';
...@@ -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,32 +168,52 @@ const AssetRecycle = (props) => { ...@@ -140,32 +168,52 @@ 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' }}>
<Table <div
loading={loading} className='d-flex p-3'
columns={columns} style={{
rowKey={'id'} borderBottom: '1px solid #EFEFEF',
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 }); <Button type="danger" onClick={deleteItems} style={{ marginLeft: 'auto' }} >删除</Button>
}} </div>
current={pageNum} <div className='list p-3'>
pageSize={pageSize} <Table
defaultCurrent={1} loading={loading}
total={total} rowSelection={rowSelection}
showTotal={total => `共 ${total} 条`} 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 <AssetDetail
visible={ assetDetailVisible } visible={ assetDetailVisible }
id={ currentAssetId } id={ currentAssetId }
......
.asset-recycle { .asset-recycle {
height: calc(100vh - 64px - 30px) !important; .list {
overflow: auto !important; 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