Merge branch 'dev_aliyun' of http://bdgit.educoder.net/Hjqreturn/educoder into dev_aliyun

dev_aliyun_beta
cxt 5 years ago
commit 0ae7984358

File diff suppressed because one or more lines are too long

@ -2,7 +2,7 @@ import React,{Component} from "React";
import { Form, Select, Input, Button,Checkbox,Upload,Icon,message,Modal,Spin,Tooltip} from "antd";
import {Link} from 'react-router-dom';
import TPMMDEditor from '../../../tpm/challengesnew/TPMMDEditor';
import { WordsBtn,getUrl ,bytesToSize,getImageUrl,appendFileSizeToUploadFileAll} from 'educoder';
import { WordsBtn,getUrl ,bytesToSize,getImageUrl,appendFileSizeToUploadFileAll,appendFileSizeToUploadFile} from 'educoder';
import axios from 'axios';
import Modals from '../../../modals/Modals';
const Search = Input.Search;
@ -49,13 +49,23 @@ class GraduationTasksSubmitedit extends Component{
if(result){
console.log(result.data.description);
const fileList = result.data.attachments.map(item => {
return {
id: item.id,
uid: item.id,
name: appendFileSizeToUploadFile(item),
url: item.url,
filesize: item.filesize,
status: 'done'
}
})
this.setState({
workslist:result.data,
attachments:result.data.attachments,
selectmemberslist:result.data.members,
selectobjct:result.data.members,
description:result.data.description,
fileList:fileList
})
if(result.data.task_type===1){
@ -134,18 +144,7 @@ class GraduationTasksSubmitedit extends Component{
}
}
onAttachmentRemoves = (file) => {
if(!file.percent || file.percent == 100){
this.setState({
Modalstype:true,
Modalstopval:'确定要删除这个附件吗?',
ModalSave: ()=>this.deleteAttachments(file),
ModalCancel:this.cancelAttachment
})
return false;
}
}
cancelAttachment=()=>{
this.setState({
Modalstype:false,
@ -155,49 +154,7 @@ class GraduationTasksSubmitedit extends Component{
})
}
deleteAttachments = (id) => {
let {attachments,fileList}=this.state;
const url = `/attachments/${id}.json`
axios.delete(url, {
})
.then((response) => {
if (response.data) {
// const { status } = response.data;
if (response.data.status === 0) {
console.log('--- success')
let newattachments=attachments;
for(var i=0; i<newattachments.length; i++){
if(newattachments[i].id===id){
newattachments.splice(i, 1);
}
}
this.setState({
attachments:newattachments
})
this.cancelAttachment();
this.setState((state) => {
const index = state.fileList.indexOf(id);
const newFileList = state.fileList.slice();
newFileList.splice(index, 1);
return {
fileList: newFileList
};
});
}
}
})
.catch(function (error) {
console.log(error);
});
}
deleteAttachment = (file) => {
if(!file.percent || file.percent == 100){
let {attachments,fileList}=this.state;
@ -672,34 +629,34 @@ class GraduationTasksSubmitedit extends Component{
</Upload>
{attachments&&attachments.map((item,key)=>{
return(
<div className="color-grey mt5"
key={key}
>
<a className="color-grey ml3">
<i className="font-14 color-green iconfont icon-fujian mr8" aria-hidden="true"></i>
</a>
<a
href={item.url}
className="mr12 color9B9B" length="58">
{item.title}
</a>
<span className="color656565 mt2 color-grey-6 font-12 mr8">
{item.filesize}
</span>
{item.delete===true?
<i className="font-14 iconfont icon-guanbi "
id={item.id}
onClick={()=>this.onAttachmentRemoves(item.id)}
aria-hidden="true">
</i>:""}
</div>
)
})}
{/*{attachments&&attachments.map((item,key)=>{*/}
{/*return(*/}
{/*<div className="color-grey mt5"*/}
{/*key={key}*/}
{/*>*/}
{/*<a className="color-grey ml3">*/}
{/*<i className="font-14 color-green iconfont icon-fujian mr8" aria-hidden="true"></i>*/}
{/*</a>*/}
{/*<a*/}
{/*href={item.url}*/}
{/*className="mr12 color9B9B" length="58">*/}
{/*{item.title}*/}
{/*</a>*/}
{/*<span className="color656565 mt2 color-grey-6 font-12 mr8">*/}
{/*{item.filesize}*/}
{/*</span>*/}
{/*{item.delete===true?*/}
{/*<i className="font-14 iconfont icon-guanbi "*/}
{/*id={item.id}*/}
{/*onClick={()=>this.onAttachmentRemoves(item.id)}*/}
{/*aria-hidden="true">*/}
{/*</i>:""}*/}
{/*</div>*/}
{/*)*/}
{/*})}*/}
{/*<style>*/}
{/*{*/}

@ -2,7 +2,7 @@ import React,{Component} from "React";
import { Form, Select, Input, Button,Checkbox,Upload,Icon,message,Modal} from "antd";
import {Link} from 'react-router-dom';
import TPMMDEditor from '../../../tpm/challengesnew/TPMMDEditor';
import { WordsBtn,getUrl ,bytesToSize,appendFileSizeToUploadFileAll,AttachmentList} from 'educoder';
import { WordsBtn,getUrl ,bytesToSize,appendFileSizeToUploadFileAll,AttachmentList,appendFileSizeToUploadFile} from 'educoder';
import axios from 'axios';
import Modals from '../../../modals/Modals';
import '../../css/Courses.css';
@ -54,6 +54,17 @@ class GraduationTasksedit extends Component{
// }
let namelength=result.data.task_name.length;
// let sixlength=title_num-namelength
const fileList = result.data.attachments.map(item => {
return {
id: item.id,
uid: item.id,
name: appendFileSizeToUploadFile(item),
url: item.url,
filesize: item.filesize,
status: 'done'
}
})
this.setState({
// fileList:newfilelist,
description:result.data.description,
@ -62,6 +73,7 @@ class GraduationTasksedit extends Component{
data:result.data,
title_num:namelength,
attachments:result.data.attachments,
fileList:fileList,
})
@ -280,7 +292,7 @@ class GraduationTasksedit extends Component{
}
render(){
const { getFieldDecorator } = this.props.form;
let {title_num,pageType,name,description,Loadtype,attachments,
let {title_num,pageType,name,description,Loadtype,attachments,fileList,
Modalstype,Modalstopval,ModalCancel,ModalSave,shixunsreplace} =this.state;
let {coursedata}=this.props;
@ -289,6 +301,7 @@ class GraduationTasksedit extends Component{
let category_id=this.props.match.params.category_id;
const uploadProps = {
width: 600,
fileList,
// https://github.com/ant-design/ant-design/issues/15505
// showUploadList={false},然后外部拿到 fileList 数组自行渲染列表。
// showUploadList: false,
@ -434,7 +447,7 @@ class GraduationTasksedit extends Component{
)}
</Form.Item>
<input type="hidden" id='descriptiontypes' />
<AttachmentList {...this.props} {...this.state} attachments={attachments&&attachments}></AttachmentList>
{/*<AttachmentList {...this.props} {...this.state} attachments={attachments&&attachments}></AttachmentList>*/}
{/*{attachments&&attachments.map((item,key)=>{*/}
{/*return(*/}

Loading…
Cancel
Save