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

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

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