-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge remote-tracking branch 'origin/dev'
- Loading branch information
Showing
33 changed files
with
375 additions
and
221,880 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
141 changes: 141 additions & 0 deletions
141
src/components/Common/selectorModal/ResourceSelectModal.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,141 @@ | ||
import { ResourceVo } from '@/types/entity'; | ||
import { ModelType } from '@/types/model'; | ||
import { TableResponse } from '@/types/response/table'; | ||
import { | ||
Button, | ||
Col, | ||
Input, | ||
Modal, | ||
Row, | ||
Table, | ||
TableColumnType, | ||
TablePaginationConfig, | ||
} from 'antd'; | ||
import React, { useEffect, useState } from 'react'; | ||
import { connect, useDispatch } from 'umi'; | ||
import './style.less'; | ||
|
||
interface PropsType { | ||
onSelect: (data: ResourceVo) => void; | ||
onCancel: () => void; | ||
response?: TableResponse<ResourceVo>; | ||
visible: boolean; | ||
albumId?: string; | ||
} | ||
|
||
const ResourceSelectModal: React.FC<PropsType> = (props) => { | ||
const { onCancel, onSelect, response, visible, albumId } = props; | ||
const [current, setCurrent] = useState(1); | ||
const [name, setName] = useState(''); | ||
const [dir, setDir] = useState(''); | ||
|
||
const dispatch = useDispatch(); | ||
|
||
useEffect(() => { | ||
dispatch({ | ||
type: 'selectModal/resource/queryList', | ||
payload: { | ||
params: { | ||
current, | ||
pageSize: 10, | ||
filename: name, | ||
dir, | ||
albumId, | ||
}, | ||
}, | ||
}); | ||
}, [dispatch]); | ||
|
||
const columns: TableColumnType<ResourceVo>[] = [ | ||
{ | ||
title: '文件名', | ||
ellipsis: true, | ||
dataIndex: 'filename', | ||
}, | ||
{ | ||
title: '路径', | ||
ellipsis: true, | ||
dataIndex: 'dir', | ||
}, | ||
]; | ||
|
||
const pagination: TablePaginationConfig = { | ||
showTotal: (total) => `总计:${total}`, | ||
onChange: (page) => { | ||
setCurrent(page); | ||
dispatch({ | ||
type: 'selectModal/resource/queryList', | ||
payload: { | ||
params: { | ||
current: page, | ||
pageSize: 10, | ||
filename: name, | ||
dir, | ||
albumId, | ||
}, | ||
}, | ||
}); | ||
}, | ||
total: response?.total, | ||
current: current, | ||
}; | ||
|
||
const onRow = (data: ResourceVo) => ({ | ||
onClick: () => { | ||
onSelect(data); | ||
}, | ||
}); | ||
|
||
const onSearch = () => { | ||
dispatch({ | ||
type: 'selectModal/resource/queryList', | ||
payload: { | ||
params: { | ||
current, | ||
pageSize: 10, | ||
filename: name, | ||
dir, | ||
albumId, | ||
}, | ||
}, | ||
}); | ||
}; | ||
|
||
const rowClassName = (record: ResourceVo) => { | ||
if (record.albumId) { | ||
return 'selectRow'; | ||
} | ||
return ''; | ||
}; | ||
|
||
return ( | ||
<Modal visible={visible} title="选择资源" onCancel={onCancel} onOk={onCancel}> | ||
<Row gutter={[5, 5]}> | ||
<Col> | ||
<Input placeholder="文件名" value={name} onChange={(e) => setName(e.target.value)} /> | ||
</Col> | ||
<Col> | ||
<Input placeholder="目录" value={dir} onChange={(e) => setDir(e.target.value)} /> | ||
</Col> | ||
<Col> | ||
<Button type="primary" onClick={onSearch}> | ||
搜索 | ||
</Button> | ||
</Col> | ||
</Row> | ||
|
||
<Table | ||
rowClassName={rowClassName} | ||
size="small" | ||
columns={columns} | ||
pagination={pagination} | ||
dataSource={response?.data} | ||
onRow={onRow} | ||
/> | ||
</Modal> | ||
); | ||
}; | ||
|
||
export default connect(({ 'selectModal/resource': { response } }: ModelType) => ({ | ||
response, | ||
}))(ResourceSelectModal); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
.selectRow { | ||
background-color: green; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.