|
|
@@ -11,6 +11,7 @@ import ImagesViewer from '../components/imagesVIewer/index'
|
|
|
import PropTypes from 'prop-types';
|
|
|
import 'css/upload.css'
|
|
|
import {_baseURL} from "../configs/api.config";
|
|
|
+import store from './../redux/store/store'
|
|
|
|
|
|
let uploadFail = false;
|
|
|
export default class UploadEnclosure extends Component {
|
|
|
@@ -18,6 +19,7 @@ export default class UploadEnclosure extends Component {
|
|
|
static propTypes = {
|
|
|
action: PropTypes.string.isRequired,//上传地址
|
|
|
data: PropTypes.object,//上传所需参数
|
|
|
+ headers: PropTypes.object,//上传所需头部参数
|
|
|
accept: PropTypes.string,//接受上传的文件类型
|
|
|
listType: PropTypes.string,//附件列表格式,默认picture-card
|
|
|
count: PropTypes.number,//附件限制数量,默认为1
|
|
|
@@ -36,6 +38,9 @@ export default class UploadEnclosure extends Component {
|
|
|
count: 1,
|
|
|
data: {
|
|
|
folderId: 0
|
|
|
+ },
|
|
|
+ headers: {
|
|
|
+
|
|
|
},
|
|
|
multiple: false,
|
|
|
title: '附件',
|
|
|
@@ -70,7 +75,7 @@ export default class UploadEnclosure extends Component {
|
|
|
const {fileList} = this.state
|
|
|
const {
|
|
|
action, listType, count, multiple,
|
|
|
- title, needPoint, limit, accept, data
|
|
|
+ title, needPoint, limit, accept, data, headers
|
|
|
} = this.props
|
|
|
|
|
|
const imgs = []
|
|
|
@@ -84,6 +89,13 @@ export default class UploadEnclosure extends Component {
|
|
|
if (imgs.length > 9) {
|
|
|
pointAble = false
|
|
|
}
|
|
|
+ const userInfo = store.getState().redUserInfo
|
|
|
+
|
|
|
+ const headerParams = {
|
|
|
+ // headers?...headers:{},
|
|
|
+ "Authorization": userInfo.token,
|
|
|
+ ...headers,
|
|
|
+ }
|
|
|
|
|
|
const uploadButton = (
|
|
|
<div>
|
|
|
@@ -106,6 +118,8 @@ export default class UploadEnclosure extends Component {
|
|
|
listType={listType}
|
|
|
fileList={fileList}
|
|
|
multiple={multiple}
|
|
|
+ withCredentials={true}
|
|
|
+ headers={headerParams}
|
|
|
beforeUpload={this.beforeUpload}
|
|
|
onPreview={this.handlePreview}
|
|
|
onChange={this.handleChange}
|