只能一个附件

dev_aliyun_beta
hjm 5 years ago
parent 467dc3a9c9
commit 308e582d8d

@ -15,7 +15,7 @@ import axios from 'axios';
import './css/TPMsettings.css';
import { getImageUrl, toPath, getUrl ,appendFileSizeToUploadFileAll} from 'educoder';
import { getImageUrl, toPath, getUrl ,appendFileSizeToUploadFileAll, getUploadActionUrl} from 'educoder';
let origin = getUrl();
@ -1372,15 +1372,18 @@ export default class TPMsettings extends Component {
})
}
handleChange = (info) => {
let {fileList}=this.state;
if (info.file.status === 'uploading' || info.file.status === 'done' || info.file.status === 'removed') {
console.log("handleChange1");
let {fileList}=this.state;
if(fileList.length===0){
// if(fileList.length===0){
let fileLists = info.fileList;
this.setState({ fileList:fileLists,
deleteisnot:false});
}
// }
}
}
@ -1497,10 +1500,13 @@ export default class TPMsettings extends Component {
// https://github.com/ant-design/ant-design/issues/15505
// showUploadList={false},然后外部拿到 fileList 数组自行渲染列表。
// showUploadList: false,
action: `${getUrl()}/api/attachments.json`,
action: `${getUploadActionUrl()}`,
onChange: this.handleChange,
onRemove: this.onAttachmentRemove,
beforeUpload: (file) => {
beforeUpload: (file, fileList) => {
if (this.state.fileList.length >= 1) {
return false
}
// console.log('beforeUpload', file.name);
const isLt150M = file.size / 1024 / 1024 < 50;
if (!isLt150M) {

@ -2,7 +2,7 @@ import React, {Component} from 'react';
import {TPMIndexHOC} from '../TPMIndexHOC';
import {SnackbarHOC,appendFileSizeToUploadFileAll} from 'educoder';
import {SnackbarHOC,appendFileSizeToUploadFileAll, getUploadActionUrl} from 'educoder';
import {Input, Select, Radio, Checkbox, Modal, Icon, DatePicker,Upload,Button,message,Form,notification,Tooltip} from 'antd';
@ -757,19 +757,19 @@ class Newshixuns extends Component {
})
}
// 附件相关 START
handleChange = (info) => {
if (info.file.status === 'uploading' || info.file.status === 'done' || info.file.status === 'removed') {
let {fileList}=this.state;
if (info.file.status === 'uploading' || info.file.status === 'done' || info.file.status === 'removed') {
console.log("handleChange1");
if(fileList.length===0){
// if(fileList.length===0){
let fileLists = info.fileList;
this.setState({
// fileList:appendFileSizeToUploadFileAll(fileList),
fileList:fileLists,
deleteisnot:false});
}
// }
}
}
@ -872,10 +872,14 @@ class Newshixuns extends Component {
// https://github.com/ant-design/ant-design/issues/15505
// showUploadList={false},然后外部拿到 fileList 数组自行渲染列表。
// showUploadList: false,
action: `${getUrl()}/api/attachments.json`,
action: `${getUploadActionUrl()}`,
onChange: this.handleChange,
onRemove: this.onAttachmentRemove,
beforeUpload: (file) => {
beforeUpload: (file, fileList) => {
if (this.state.fileList.length >= 1) {
return false
}
// console.log('beforeUpload', file.name);
const isLt150M = file.size / 1024 / 1024 < 50;
if (!isLt150M) {

Loading…
Cancel
Save