|
@@ -10,12 +10,14 @@ import {isObjEmpty, isObjNull} from "../utils/common";
|
|
|
import ImagesViewer from '../components/imagesVIewer/index'
|
|
import ImagesViewer from '../components/imagesVIewer/index'
|
|
|
import PropTypes from 'prop-types';
|
|
import PropTypes from 'prop-types';
|
|
|
import 'css/upload.css'
|
|
import 'css/upload.css'
|
|
|
|
|
+import {_baseURL} from "../configs/api.config";
|
|
|
|
|
|
|
|
let uploadFail = false;
|
|
let uploadFail = false;
|
|
|
export default class UploadEnclosure extends Component {
|
|
export default class UploadEnclosure extends Component {
|
|
|
|
|
|
|
|
static propTypes = {
|
|
static propTypes = {
|
|
|
action: PropTypes.string.isRequired,//上传地址
|
|
action: PropTypes.string.isRequired,//上传地址
|
|
|
|
|
+ data: PropTypes.object,//上传所需参数
|
|
|
accept: PropTypes.string,//接受上传的文件类型
|
|
accept: PropTypes.string,//接受上传的文件类型
|
|
|
listType: PropTypes.string,//附件列表格式,默认picture-card
|
|
listType: PropTypes.string,//附件列表格式,默认picture-card
|
|
|
count: PropTypes.number,//附件限制数量,默认为1
|
|
count: PropTypes.number,//附件限制数量,默认为1
|
|
@@ -32,6 +34,9 @@ export default class UploadEnclosure extends Component {
|
|
|
static defaultProps = {
|
|
static defaultProps = {
|
|
|
listType: 'picture-card',
|
|
listType: 'picture-card',
|
|
|
count: 1,
|
|
count: 1,
|
|
|
|
|
+ data: {
|
|
|
|
|
+ folderId: 0
|
|
|
|
|
+ },
|
|
|
multiple: false,
|
|
multiple: false,
|
|
|
title: '附件',
|
|
title: '附件',
|
|
|
needPoint: true,
|
|
needPoint: true,
|
|
@@ -65,7 +70,7 @@ export default class UploadEnclosure extends Component {
|
|
|
const {fileList} = this.state
|
|
const {fileList} = this.state
|
|
|
const {
|
|
const {
|
|
|
action, listType, count, multiple,
|
|
action, listType, count, multiple,
|
|
|
- title, needPoint, limit, accept
|
|
|
|
|
|
|
+ title, needPoint, limit, accept, data
|
|
|
} = this.props
|
|
} = this.props
|
|
|
|
|
|
|
|
const imgs = []
|
|
const imgs = []
|
|
@@ -97,6 +102,7 @@ export default class UploadEnclosure extends Component {
|
|
|
<Upload
|
|
<Upload
|
|
|
action={action}
|
|
action={action}
|
|
|
accept={accept}
|
|
accept={accept}
|
|
|
|
|
+ data={data}
|
|
|
listType={listType}
|
|
listType={listType}
|
|
|
fileList={fileList}
|
|
fileList={fileList}
|
|
|
multiple={multiple}
|
|
multiple={multiple}
|
|
@@ -142,10 +148,19 @@ export default class UploadEnclosure extends Component {
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
handleChange = ({fileList}) => {
|
|
handleChange = ({fileList}) => {
|
|
|
|
|
+ console.log('filelist', fileList)
|
|
|
if (uploadFail) {
|
|
if (uploadFail) {
|
|
|
return
|
|
return
|
|
|
}
|
|
}
|
|
|
if (fileList.length <= this.props.count || !this.props.limit) {
|
|
if (fileList.length <= this.props.count || !this.props.limit) {
|
|
|
|
|
+ if (fileList) {
|
|
|
|
|
+ fileList.forEach((value, index) => {
|
|
|
|
|
+ value.url = (value.response && value.response.data) ? value.response.data.accessPath : value.url
|
|
|
|
|
+ value.picUrl = value.url
|
|
|
|
|
+ value.relativeUrl = (value.response && value.response.data) ? value.response.data.fullPath : value.relativeUrl
|
|
|
|
|
+ })
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
this.setState({fileList})
|
|
this.setState({fileList})
|
|
|
this.props.handleChange(fileList)
|
|
this.props.handleChange(fileList)
|
|
|
}
|
|
}
|