Commit df0a053e authored by 前端-钟卫鹏's avatar 前端-钟卫鹏

fix: 自定义niceform文件上传样式

parent a2afbca9
......@@ -7,7 +7,9 @@ import {
LoadingOutlined,
PlusOutlined,
UploadOutlined,
InboxOutlined
InboxOutlined,
FileFilled,
DeleteOutlined
} from '@ant-design/icons'
import { getAuth } from '@/utils/auth'
......@@ -191,6 +193,14 @@ export const Upload = connect({
this.props.onChange(fileList)
}
public removeItem = (item) => {
const { onChange } = this.props
this.setState({
value: this.state.value.filter(ele => ele.uid !== item.uid)
})
onChange(this.state.value.filter(ele => ele.uid !== item.uid))
}
public onChangeHandler = ({ fileList }) => {
const { onChange } = this.props
fileList = toArr(fileList)
......@@ -243,8 +253,7 @@ export const Upload = connect({
public render() {
// eslint-disable-next-line @typescript-eslint/no-unused-vars
const { listType, locale, onChange, value, ...others } = this.props
const { listType, locale, onChange, value = [], ...others } = this.props
if (listType.indexOf('card') > -1) {
return (
<AntdUpload
......@@ -279,7 +288,13 @@ export const Upload = connect({
</UploadDragger>
)
}
return (
return (<div>
{
value.map(item => (<p key={item.uid} style={{width: 424, display: 'flex', justifyContent: 'space-between'}}>
<a href={item.url}><FileFilled /> {item.name}</a>
<span style={{cursor: 'pointer'}} onClick={() => this.removeItem(item)}><DeleteOutlined /></span>
</p>))
}
<AntdUpload
{...others}
fileList={this.state.value}
......@@ -287,6 +302,7 @@ export const Upload = connect({
onRemove={this.onRemoveHandler}
listType={listType}
headers={{token}}
itemRender={() => null}
>
{!others.readOnly ? (
<Button style={{ margin: '0 0 10px' }}>
......@@ -295,7 +311,7 @@ export const Upload = connect({
</Button>
) : null}
</AntdUpload>
)
</div>)
}
}
)
......
......@@ -217,7 +217,7 @@ const ReadyQualifityCheckedDetail: React.FC = () => {
<Col span={2}><p className={style['card-list_title']}>资格证明文件:</p></Col>
<Col>
{
fileList.map(item => (<p className={style.fileItem}><a href={item.url}><FileFilled /> {item.name}</a> <span onClick={() => removeItem(item)}><DeleteOutlined /></span></p>))
fileList.map((item, index) => (<p key={index} className={style.fileItem}><a href={item.url}><FileFilled /> {item.name}</a> <span onClick={() => removeItem(item)}><DeleteOutlined /></span></p>))
}
<Upload
{...uploadProps}
......
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