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,getUploadActionUrl ,bytesToSize,getImageUrl,appendFileSizeToUploadFileAll,appendFileSizeToUploadFile} from 'educoder'; import axios from 'axios'; import Modals from '../../../modals/Modals'; const Search = Input.Search; const CheckboxGroup = Checkbox.Group; let GraduationTasksnewtype=true; class GraduationTasksSubmitedit extends Component{ constructor(props){ super(props) this.state={ coursename:"", coursesearch:"", title_num:20, title_value:"", fileList: [], contents: [{val:"",id:1}], type:true, workslist:undefined, search:"", memberslist:undefined, task_status:[], selectmemberslist:[], minvalue:"", setvalue:"", minmaxtype:false, selectobjct:undefined, Loadtype:false, description:undefined, attachments:undefined, spinnings:false, shixunsreplace:false, limit:20 } } componentDidMount(){ this.props.form.validateFields(); let workId=this.props.match.params.work_Id; let url = "/graduation_works/"+workId+"/edit.json"; axios.get(url).then((result)=>{ 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){ }else{ this.searchList("",1,20,result.data.task_id) } this.props.form.setFieldsValue({ description:result.data.description, }); } }).catch((error)=>{ console.log(error) }) } handleSelectChange = (value) => { console.log(value); this.props.form.setFieldsValue({ note: `Hi, ${value === 'male' ? 'man' : 'lady'}!`, }); } goback=()=>{ // let courseId=this.props.match.params.coursesId; // if(courseId===undefined){ // this.props.history.push("/courses"); // }else{ // this.props.history.push(this.props.current_user.first_category_url); // } this.props.history.replace(`/courses/${this.state.workslist.course_id}/graduation_tasks/${this.state.workslist.graduation_id}`); } // 输入title changeTitle=(e)=>{ this.setState({ title_num:20-parseInt(e.target.value.length), title_value:e.target.value }) } // 附件相关 START handleChange = (info) => { if (info.file.status === 'uploading') { let fileList = info.fileList; this.setState({ fileList:appendFileSizeToUploadFileAll(fileList) }); } if (info.file.status === 'done' || info.file.status === 'removed') { let fileList = info.fileList; this.setState({ fileList:appendFileSizeToUploadFileAll(fileList) }); } } onAttachmentRemove = (file) => { if(!file.percent || file.percent == 100){ this.setState({ Modalstype:true, Modalstopval:'确定要删除这个附件吗?', ModalSave: ()=>this.deleteAttachment(file), ModalCancel:this.cancelAttachment }) return false; } } cancelAttachment=()=>{ this.setState({ Modalstype:false, Modalstopval:'', ModalSave:"", ModalCancel:"" }) } deleteAttachment = (file) => { if(!file.percent || file.percent == 100){ let {attachments,fileList}=this.state; let id=file.response ==undefined ? file.id : file.response.id; 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; if(file.uid===undefined){ for(var i=0; i { const index = state.fileList.indexOf(file); const newFileList = state.fileList.slice(); newFileList.splice(index, 1); return { fileList: newFileList, }; }); } } }) .catch(function (error) { console.log(error); }); } } inputSearchValue=(e)=>{ if(e.target.value===""){ this.setState({ search:null }) }else{ this.setState({ search:e.target.value }) } } searchValue=()=>{ let {search,workslist} = this.state; this.searchList(search,1,20,workslist.task_id) } searchList=(search,page,limit,id,types)=>{ let {memberslist}=this.state; let newmemberslist=memberslist this.setState({ }) let newid=id if(newid===undefined){ newid=this.props.match.params.work_Id; } let url="/graduation_tasks/"+newid+"/graduation_works/search_member_list.json"; axios.post(url,{ search:search, page:page, limit:limit }).then((result)=>{ if(result){ if(types===1){ if(result.data.members.length>0) { result.data.members.map((item, key) => { newmemberslist.push(item) }) } this.setState({ memberslist:newmemberslist, search:search, page:page, limit:limit }) }else{ this.setState({ memberslist:result.data.members, search:search, page:page, limit:limit }) } } }).catch((error)=>{ console.log(error) }) } contentViewScroll=(e)=>{ //滑动到底判断 let newscrollTop=parseInt(e.currentTarget.scrollTop); let allclientHeight=e.currentTarget.clientHeight+newscrollTop; if(e.currentTarget.scrollHeight-allclientHeight===0||e.currentTarget.scrollHeight-allclientHeight===1||e.currentTarget.scrollHeight-allclientHeight===-1){ // console.log("到达底部"); let{ search,page,limit,workslist}=this.state; let newpage=page+1 this.searchList(search,newpage,limit,workslist.task_id,1) } } funtaskstatus=(checkedValues)=>{ let{memberslist,selectobjct,workslist}=this.state; if(selectobjct.length>workslist.max_num){ this.setState({ minvalue:workslist.max_num, setvalue:"大于", minmaxtype:true }) return }else{ this.setState({ minmaxtype:false }) } let newlist =memberslist; let newcheckedValues=checkedValues; let selects=[]; for(var list of selectobjct){ selects.push(list) } for(var i=0; i{ let{selectmemberslist,task_status}=this.state; let newlist=task_status; let selects=selectmemberslist; for(var i=0; i{ this.props.history.goBack() } handleSubmit=(e) => { let {fileList,selectmemberslist,workslist}=this.state; this.Commoninterface(fileList,selectmemberslist,workslist); // setTimeout(function () { // GraduationTasksnewtype=true // },10000) } Commoninterface =(fileList,selectmemberslist,workslist)=>{ let coursesIds=this.props.match.params.coursesId let workId=this.props.match.params.work_Id; let userids=[]; // for(var list of selectmemberslist){ // if(list.user_id!=undefined&&list.user_id!=null){ // userids.push(list.user_id) // } // } if(selectmemberslist!=undefined&&selectmemberslist.length>0){ selectmemberslist.map((list,key)=>{ if(list.user_id!=undefined&&list.user_id!=null){ userids.push(list.user_id) } }) } let listid=[]; // for(var list of fileList){ // listid.push(list.response == undefined ? list.id : list.response.id) // } if(fileList!=undefined&&fileList.length>0){ fileList.map((list,key)=>{ listid.push(list.response == undefined ? list.id : list.response.id) }) } this.props.form.validateFields((err, values) => { // console.log(fileList); if(values.description===undefined||values.description===""){ this.scrollToAnchor("valuestypes"); return } if(workslist.task_type===2){ if(userids.lengthworkslist.max_num){ this.setState({ minvalue:workslist.max_num, setvalue:"大于", minmaxtype:true }) return } } this.setState({ spinnings:true }) // if(fileList.length===0){ // this.setState({ // shixunsreplace:true, // }) // return // } let url="/graduation_works/"+workId+".json"; axios.put(url, { description:values.description, attachment_ids:listid, user_ids:userids } ).then((response) => { this.setState({ spinnings:false }) if(response!== undefined){ // this.goback() window.location.href=`/courses/${coursesIds}/graduation_tasks/${workId}/appraise` } // if(response.status===200) { // GraduationTasksnewtype=false; // if(response.data.status===0){ // // this.setState({ // // Modalstype:true, // // Modalstopval:response.data.message, // // ModalSave:this.setedit, // // Loadtype:true // // }) // }else{ // GraduationTasksnewtype=true; // } // } }).catch((error) => { console.log(error) this.setState({ spinnings:false }) }) }); } hidestartshixunsreplace = ()=>{ let {fileList,selectmemberslist,workslist}=this.state; this.Commoninterface(fileList,selectmemberslist,workslist); } hidestartshixunsreplacetwo= ()=>{ this.setState({ shixunsreplace:false, spinnings:false }) } scrollToAnchor = (anchorName) => { if (anchorName) { // 找到锚点 let anchorElement = document.getElementById(anchorName); // 如果对应id的锚点存在,就跳转到锚点 if(anchorElement) { anchorElement.scrollIntoView({block: 'start', behavior: 'smooth'}); } } } render(){ const { getFieldDecorator } = this.props.form; let {search,fileList, workslist,setvalue,minvalue,minmaxtype,Loadtype,description,attachments, Modalstype,Modalstopval,ModalCancel,ModalSave,memberslist,task_status,selectmemberslist,shixunsreplace} =this.state; let courseId=this.props.match.params.coursesId; let task_Id=this.props.match.params.coursesId; // let category_id=this.props.match.params.category_id; let work_Id=this.props.match.params.work_Id const uploadProps = { width: 600, fileList, multiple: true, // https://github.com/ant-design/ant-design/issues/15505 // showUploadList={false},然后外部拿到 fileList 数组自行渲染列表。 // showUploadList: false, action: `${getUploadActionUrl()}`, onChange: this.handleChange, onRemove: this.onAttachmentRemove, beforeUpload: (file) => { // TODO 文件存在则提示并退出 let gotSameFile = false; this.state.fileList && this.state.fileList.some((item) => { if (item.name && item.name.startsWith(file.name)) { gotSameFile = true; return true } }) if (gotSameFile) { this.props.showNotification("该附件已被上传!") return false } console.log('beforeUpload', file.name); const isLt150M = file.size / 1024 / 1024 < 150; if (!isLt150M) { this.props.showNotification('文件大小必须小于150MB!'); } return isLt150M; }, }; document.title=workslist&&workslist.course_name; return(
{/*提示*/}

还未上传附件

是否确认提交作品?

{/* {workslist&&workslist.course_name}*/} {/*>*/} 毕设任务 > 任务详情 > {/**/} {/*{workslist&&workslist.task_name}*/} {/*>*/} {/**/} {this.props.current_user&&this.props.current_user.real_name} 修改作品

{ workslist && workslist.task_name }

返回
{description&&description?
{getFieldDecorator('description', { rules: [{ required: true, message: '请在此输入作品内容或附件的简要描述', }, { max: 5000, message: '最大限制为5000个字符', }], })( )} (单个文件150M以内) {/*{attachments&&attachments.map((item,key)=>{*/} {/*return(*/} {/*
*/} {/**/} {/**/} {/**/} {/**/} {/*{item.title}*/} {/**/} {/**/} {/*{item.filesize}*/} {/**/} {/*{item.delete===true?*/} {/*this.onAttachmentRemoves(item.id)}*/} {/*aria-hidden="true">*/} {/*:""}*/} {/*
*/} {/*)*/} {/*})}*/} {/**/} {/*{this.state.fileList.length===0?"":this.state.fileList.map((item,key)=>{*/} {/*return(*/} {/*

*/} {/**/} {/**/} {/**/} {/**/} {/*{item.name}*/} {/**/} {/**/} {/*{item.response===undefined?"":bytesToSize(item.size)}*/} {/**/} {/*this.onAttachmentRemove(item.response===undefined?"":item.response.id&&item.response.id)}>*/} {/*

*/} {/*)*/} {/*})}*/}
{workslist&&workslist.task_type===1?"":
成员要求:{workslist&&workslist.min_num}~{workslist&&workslist.max_num}人
{memberslist===undefined?"":memberslist.length===0?

未找到包含{search}的学生

:memberslist&&memberslist.map((item,key)=>{ return(
{ return parseInt(task_status[key])===item.user_id?true:false }) } disabled={item.commit_status===true?true:false} className="fl ">
{item.user_name}
{item.group_name}
{item.student_id}
{item.commit_status===true?已提交 :""}
) })}
{selectmemberslist&&selectmemberslist.map((item,key)=>{ console.log(item) if(item.group_name!=undefined) { return (
{item.user_name}
{item.group_name}
{item.student_id}
{key > 0 ?
this.delecttask_status(item.user_id)}>
: ""}
) } })}
{minmaxtype===true? 人数不能{setvalue+minvalue}个人 :""}
} {/**/}
取消
:""}
) } } const GraduationTasksSubmiteditApp = Form.create({ name: 'coursesNew' })(GraduationTasksSubmitedit); export default GraduationTasksSubmiteditApp;