Commit 295f309b authored by 王苓芝's avatar 王苓芝

文件格式控制

parent e2da9548
import { Upload, Icon, Modal, notification } from 'antd';
import { Upload, Icon, Modal, message } from 'antd';
import React from 'react';
import config from '../../../config/env.config';
import { qiniuToken } from '@/services/qiniu';
......@@ -22,6 +22,7 @@ class PicturesWall extends React.Component {
previewVisible: false,
previewImage: '',
fileList: [],
isValid: false,
};
async componentDidMount() {
......@@ -45,14 +46,19 @@ class PicturesWall extends React.Component {
beforeUpload = file => {
const types = ['application/pdf', 'image/png', 'image/jpeg'];
if (types.indexOf(file.type) === -1) {
notification.error('输入格式有问题');
return false;
this.setState({ isValid: false });
message.error('输入格式有问题');
}
return true;
return types.indexOf(file.type) !== -1;
};
handleChange = ({ fileList }) => {
this.setState({ fileList });
handleChange = info => {
console.log('info', info.file);
if (!this.state.isValid) {
this.setState({ fileList: [] });
return;
}
this.setState({ fileList: info.fileList });
};
customRequest = ({ file, onError, onSuccess }) => {
......@@ -89,6 +95,7 @@ class PicturesWall extends React.Component {
render() {
const { previewVisible, previewImage, fileList } = this.state;
console.log('fileList---render', fileList);
const uploadButton = (
<div>
<Icon type="plus" />
......
......@@ -76,7 +76,7 @@ export default props => {
<Modal title="上传发票" visible={visible} footer={null} onCancel={props.onCancel} width="700px">
<Tabs defaultActiveKey="1" className={styles.tab} onChange={changeTab} activeKey={tabValue}>
<TabPane tab="上传凭证" key="1">
<UploadC ref={picUpload} accept=".png,.jpg,.jpeg,.pdf" />
<UploadC ref={picUpload} />
</TabPane>
<TabPane tab="上传附件" key="2">
<a
......
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