|
|
|
@ -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 } from 'educoder';
|
|
|
|
|
import { WordsBtn,getUrl ,bytesToSize} from 'educoder';
|
|
|
|
|
import axios from 'axios';
|
|
|
|
|
import Modals from '../../../modals/Modals';
|
|
|
|
|
import '../../css/Courses.css';
|
|
|
|
@ -40,27 +40,28 @@ class GraduationTasksedit extends Component{
|
|
|
|
|
axios.get(url).then((result)=>{
|
|
|
|
|
// console.log(result)
|
|
|
|
|
|
|
|
|
|
let newfilelist=[];
|
|
|
|
|
if(result.data.attachments.length!=0){
|
|
|
|
|
for(var list of result.data.attachments){
|
|
|
|
|
newfilelist.push({
|
|
|
|
|
uid:list.id,
|
|
|
|
|
name:list.title,
|
|
|
|
|
status: 'done',
|
|
|
|
|
url:list.url,
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
// let newfilelist=[];
|
|
|
|
|
// if(result.data.attachments.length!=0){
|
|
|
|
|
// for(var list of result.data.attachments){
|
|
|
|
|
// newfilelist.push({
|
|
|
|
|
// uid:list.id,
|
|
|
|
|
// name:list.title,
|
|
|
|
|
// status: 'done',
|
|
|
|
|
// url:list.url,
|
|
|
|
|
// })
|
|
|
|
|
// }
|
|
|
|
|
//
|
|
|
|
|
// }
|
|
|
|
|
let namelength=result.data.task_name.length;
|
|
|
|
|
let sixlength=title_num-namelength
|
|
|
|
|
this.setState({
|
|
|
|
|
fileList:newfilelist,
|
|
|
|
|
// fileList:newfilelist,
|
|
|
|
|
description:result.data.description,
|
|
|
|
|
tasktype:result.data.task_type,
|
|
|
|
|
name:result.data.task_name,
|
|
|
|
|
data:result.data,
|
|
|
|
|
title_num:sixlength
|
|
|
|
|
title_num:sixlength,
|
|
|
|
|
attachments:result.data.attachments,
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@ -100,36 +101,36 @@ class GraduationTasksedit extends Component{
|
|
|
|
|
// 附件相关 START
|
|
|
|
|
handleChange = (info) => {
|
|
|
|
|
let fileList = info.fileList;
|
|
|
|
|
console.log(fileList)
|
|
|
|
|
// console.log(fileList)
|
|
|
|
|
// for(var list of fileList ){
|
|
|
|
|
// console.log(fileList)
|
|
|
|
|
// }
|
|
|
|
|
this.setState({ fileList });
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
onAttachmentRemove = (file) => {
|
|
|
|
|
// confirm({
|
|
|
|
|
// title: '确定要删除这个附件吗?',
|
|
|
|
|
// okText: '确定',
|
|
|
|
|
// cancelText: '取消',
|
|
|
|
|
// // content: 'Some descriptions',
|
|
|
|
|
// onOk: () => {
|
|
|
|
|
// this.deleteAttachment(file)
|
|
|
|
|
// },
|
|
|
|
|
// onCancel() {
|
|
|
|
|
// console.log('Cancel');
|
|
|
|
|
// },
|
|
|
|
|
// });
|
|
|
|
|
// onAttachmentRemove = (file) => {
|
|
|
|
|
// // confirm({
|
|
|
|
|
// // title: '确定要删除这个附件吗?',
|
|
|
|
|
// // okText: '确定',
|
|
|
|
|
// // cancelText: '取消',
|
|
|
|
|
// // // content: 'Some descriptions',
|
|
|
|
|
// // onOk: () => {
|
|
|
|
|
// // this.deleteAttachment(file)
|
|
|
|
|
// // },
|
|
|
|
|
// // onCancel() {
|
|
|
|
|
// // console.log('Cancel');
|
|
|
|
|
// // },
|
|
|
|
|
// // });
|
|
|
|
|
// // return false;
|
|
|
|
|
//
|
|
|
|
|
// this.setState({
|
|
|
|
|
// Modalstype:true,
|
|
|
|
|
// Modalstopval:'确定要删除这个附件吗?',
|
|
|
|
|
// ModalSave: ()=>this.deleteAttachment(file),
|
|
|
|
|
// ModalCancel:this.cancelAttachment
|
|
|
|
|
// })
|
|
|
|
|
// return false;
|
|
|
|
|
|
|
|
|
|
this.setState({
|
|
|
|
|
Modalstype:true,
|
|
|
|
|
Modalstopval:'确定要删除这个附件吗?',
|
|
|
|
|
ModalSave: ()=>this.deleteAttachment(file),
|
|
|
|
|
ModalCancel:this.cancelAttachment
|
|
|
|
|
})
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
|
|
cancelAttachment=()=>{
|
|
|
|
|
this.setState({
|
|
|
|
@ -141,10 +142,11 @@ class GraduationTasksedit extends Component{
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
deleteAttachment = (file) => {
|
|
|
|
|
onAttachmentRemove = (file) => {
|
|
|
|
|
|
|
|
|
|
this.cancelAttachment();
|
|
|
|
|
const url = `/attachments/${file.response ? file.response.id : file.uid}.json`
|
|
|
|
|
// const url = `/attachments/${file.response ? file.response.id : file.uid}.json`
|
|
|
|
|
const url = `/attachments/${file}.json`
|
|
|
|
|
axios.delete(url, {
|
|
|
|
|
})
|
|
|
|
|
.then((response) => {
|
|
|
|
@ -268,7 +270,7 @@ class GraduationTasksedit extends Component{
|
|
|
|
|
}
|
|
|
|
|
render(){
|
|
|
|
|
const { getFieldDecorator } = this.props.form;
|
|
|
|
|
let {title_num,pageType,name,description,Loadtype,
|
|
|
|
|
let {title_num,pageType,name,description,Loadtype,attachments,
|
|
|
|
|
Modalstype,Modalstopval,ModalCancel,ModalSave,shixunsreplace} =this.state;
|
|
|
|
|
|
|
|
|
|
let {coursedata}=this.props;
|
|
|
|
@ -279,7 +281,7 @@ class GraduationTasksedit extends Component{
|
|
|
|
|
width: 600,
|
|
|
|
|
// https://github.com/ant-design/ant-design/issues/15505
|
|
|
|
|
// showUploadList={false},然后外部拿到 fileList 数组自行渲染列表。
|
|
|
|
|
// showUploadList: false,
|
|
|
|
|
showUploadList: false,
|
|
|
|
|
action: `${getUrl()}/api/attachments.json`,
|
|
|
|
|
onChange: this.handleChange,
|
|
|
|
|
onRemove: this.onAttachmentRemove,
|
|
|
|
@ -418,8 +420,65 @@ class GraduationTasksedit extends Component{
|
|
|
|
|
</Button>
|
|
|
|
|
(单个文件150M以内)
|
|
|
|
|
</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.onAttachmentRemove(item.id)}
|
|
|
|
|
aria-hidden="true">
|
|
|
|
|
</i>:""}
|
|
|
|
|
</div>
|
|
|
|
|
)
|
|
|
|
|
})}
|
|
|
|
|
<style>
|
|
|
|
|
{
|
|
|
|
|
`
|
|
|
|
|
.maxwidth500{
|
|
|
|
|
max-width:500px;
|
|
|
|
|
overflow: hidden;
|
|
|
|
|
text-overflow: ellipsis;
|
|
|
|
|
white-space: nowrap;
|
|
|
|
|
color: #05101a;
|
|
|
|
|
}
|
|
|
|
|
`
|
|
|
|
|
}
|
|
|
|
|
</style>
|
|
|
|
|
{this.state.fileList.length===0?"":this.state.fileList.map((item,key)=>{
|
|
|
|
|
return(
|
|
|
|
|
<p className="color-grey mt10" key={key} >
|
|
|
|
|
<a className="color-grey fl">
|
|
|
|
|
<i className="font-14 color-green iconfont icon-fujian mr8" aria-hidden="true"></i>
|
|
|
|
|
</a>
|
|
|
|
|
<span className="mr12 color9B9B maxwidth500 fl" length="58">
|
|
|
|
|
{item.name}
|
|
|
|
|
</span>
|
|
|
|
|
<span className="color656565 mt2 color-grey-6 font-12 mr8">
|
|
|
|
|
{item.response===undefined?"":bytesToSize(item.size)}
|
|
|
|
|
</span>
|
|
|
|
|
<i className="font-14 iconfont icon-guanbi "
|
|
|
|
|
id={item.response===undefined?"":item.response.id}
|
|
|
|
|
aria-hidden="true" onClick={()=>this.onAttachmentRemove(item.response===undefined?"":item.response.id&&item.response.id)}></i>
|
|
|
|
|
</p>
|
|
|
|
|
)
|
|
|
|
|
})}
|
|
|
|
|
{/*{attachments&&attachments.map((item,key)=>{*/}
|
|
|
|
|
|
|
|
|
|
{/*return(*/}
|
|
|
|
|