From 251f2a0bfab2794adc28aec06e54fbd7f579e3a7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=A8=E6=A0=91=E6=98=8E?= <775174143@qq.com> Date: Tue, 20 Aug 2019 18:09:19 +0800 Subject: [PATCH 1/2] =?UTF-8?q?=E8=B0=83=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../courses/coursesPublic/SelectSetting.js | 344 +++---- .../courses/coursesPublic/sendResource.js | 922 +++++++++--------- 2 files changed, 633 insertions(+), 633 deletions(-) diff --git a/public/react/src/modules/courses/coursesPublic/SelectSetting.js b/public/react/src/modules/courses/coursesPublic/SelectSetting.js index 557cec972..b453d0075 100644 --- a/public/react/src/modules/courses/coursesPublic/SelectSetting.js +++ b/public/react/src/modules/courses/coursesPublic/SelectSetting.js @@ -7,7 +7,7 @@ import moment from 'moment'; import Modals from '../../modals/Modals'; const Option = Select.Option; - + const dateFormat ="YYYY-MM-DD HH:mm" function range(start, end) { const result = []; @@ -131,7 +131,7 @@ class Selectsetting extends Component{ - getalldata=()=>{ + getalldata=()=>{ } componentDidUpdate = (prevProps) => { @@ -139,9 +139,9 @@ class Selectsetting extends Component{ if ( prevProps.visible != this.props.visible ) { console.log(prevProps) console.log(this.props) - this.setState({ - visible:this.props.visible - }) + this.setState({ + visible:this.props.visible + }) this.getalldata() } @@ -205,23 +205,23 @@ class Selectsetting extends Component{ // } // }) - // if(unified_setting===false){ - // - // course_groups.forEach((item,key)=>{ - // if(item.course_group_id===undefined){ - // this.setState({ - // course_group_idtypes:true - // }) - // return - // } - // }) - // - // } + // if(unified_setting===false){ + // + // course_groups.forEach((item,key)=>{ + // if(item.course_group_id===undefined){ + // this.setState({ + // course_group_idtypes:true + // }) + // return + // } + // }) + // + // } let coursesId=this.props.match.params.coursesId; let attachmentId=this.props.attachmentId; - let url="/files/"+this.props.discussMessageid+".json"; + let url="/files/"+this.props.discussMessageid+".json"; // axios.put(url,{ course_id:coursesId, @@ -298,7 +298,7 @@ class Selectsetting extends Component{ onAttachmentRemove = (file) => { // 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.response ? file.response.id : file.uid}.json` axios.delete(url, { }) .then((response) => { @@ -368,7 +368,7 @@ class Selectsetting extends Component{ newlist.push( { course_group_id : undefined, publish_time :"" - // moment(new Date()).format('YYYY-MM-DD HH:mm') + // moment(new Date()).format('YYYY-MM-DD HH:mm') }) this.setState({ course_groups:newlist @@ -381,7 +381,7 @@ class Selectsetting 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, @@ -463,7 +463,7 @@ class Selectsetting extends Component{
*/} - {/**/} - {/**/} - {/**/} - {/**/} - {/*{item.name}*/} - {/**/} - {/**/} - {/*{item.response===undefined?"":isNaN(bytesToSize(item.filesize))?"123":bytesToSize(item.filesize)}*/} - {/**/} - {/*this.onAttachmentRemove(item.response===undefined?"":item.response.id&&item.response.id)}>*/} - {/*
*/} - {/*)*/} + {/*return(*/} + {/**/} + {/**/} + {/**/} + {/**/} + {/**/} + {/*{item.name}*/} + {/**/} + {/**/} + {/*{item.response===undefined?"":isNaN(bytesToSize(item.filesize))?"123":bytesToSize(item.filesize)}*/} + {/**/} + {/*this.onAttachmentRemove(item.response===undefined?"":item.response.id&&item.response.id)}>*/} + {/*
*/} + {/*)*/} {/*})}*/} {this.state.newfileListtypes===true?请先上传资源
:""} - {/**/} - {/**/} - - {/*
+ - {/*
*/} ++
请选择分班
:""}*/} diff --git a/public/react/src/modules/courses/coursesPublic/sendResource.js b/public/react/src/modules/courses/coursesPublic/sendResource.js index 20f22b119..576c9b514 100644 --- a/public/react/src/modules/courses/coursesPublic/sendResource.js +++ b/public/react/src/modules/courses/coursesPublic/sendResource.js @@ -8,18 +8,18 @@ import moment from 'moment'; const CheckboxGroup = Checkbox.Group; const Option = Select.Option; function range(start, end) { - const result = []; - for (let i = start; i < end; i++) { - result.push(i); - } - return result; + const result = []; + for (let i = start; i < end; i++) { + result.push(i); + } + return result; } function disabledDateTime() { - return { - // disabledHours: () => range(0, 24).splice(4, 20), - disabledMinutes: () => range(1, 30).concat(range(31, 60)), - // disabledSeconds: () => [0, 60], - }; + return { + // disabledHours: () => range(0, 24).splice(4, 20), + disabledMinutes: () => range(1, 30).concat(range(31, 60)), + // disabledSeconds: () => [0, 60], + }; } function disabledDate(current) { @@ -29,63 +29,63 @@ function disabledDate(current) { const dateFormat="YYYY-MM-DD HH:mm"; class Sendresource extends Component{ - constructor(props){ - super(props); - this.state={ - group_ids:[], - fileList:[], - Modalstype:false, - Modalstopval:"", - ModalCancel:"", - ModalSave:"", + constructor(props){ + super(props); + this.state={ + group_ids:[], + fileList:[], + Modalstype:false, + Modalstopval:"", + ModalCancel:"", + ModalSave:"", fileListtype:false, - loadtype:false, - is_unified_setting:true, - is_public:false, - datatime:undefined, - // moment(new Date()).format('YYYY-MM-DD HH:mm:ss'), - course_group_publish_times:[ - { - course_group_id : undefined, - publish_time :"" - }], - course_groups:undefined, - course_groups_count:undefined - } - } - - - componentDidMount() { - - let coursesId=this.props.match.params.coursesId; - if(this.props.isAdmin()){ - let url = `/courses/${coursesId}/all_course_groups.json` - - axios.get(url, { - }) - .then((response) => { - this.setState({ - course_groups: response.data.course_groups, - course_groups_count:response.data.course_groups_count - }) - }) - .catch(function (error) { - console.log(error); - }); - } - - } - - //勾选实训 - shixunhomeworkedit=(list)=>{ - - this.setState({ - group_ids:list - }) - - } - // 附件相关 START - handleChange = (info) => { + loadtype:false, + is_unified_setting:true, + is_public:false, + datatime:undefined, + // moment(new Date()).format('YYYY-MM-DD HH:mm:ss'), + course_group_publish_times:[ + { + course_group_id : undefined, + publish_time :"" + }], + course_groups:undefined, + course_groups_count:undefined + } + } + + + componentDidMount() { + + let coursesId=this.props.match.params.coursesId; + if(this.props.isAdmin()){ + let url = `/courses/${coursesId}/all_course_groups.json` + + axios.get(url, { + }) + .then((response) => { + this.setState({ + course_groups: response.data.course_groups, + course_groups_count:response.data.course_groups_count + }) + }) + .catch(function (error) { + console.log(error); + }); + } + + } + + //勾选实训 + shixunhomeworkedit=(list)=>{ + + this.setState({ + group_ids:list + }) + + } + // 附件相关 START + handleChange = (info) => { let fileList = info.fileList; if(info.file.status!="removed"){ @@ -98,280 +98,280 @@ class Sendresource extends Component{ fileList: appendFileSizeToUploadFileAll(fileList), }); } - } + } - // onAttachmentRemove = (file) => { - // + // onAttachmentRemove = (file) => { + // // this.setState({ // fileListtype:false, // }) - // // confirm({ - // // title: '确定要删除这个附件吗?', - // // okText: '确定', - // // cancelText: '取消', - // // // content: 'Some descriptions', - // // onOk: () => { - // // this.deleteAttachment(file) - // // }, - // // onCancel() { - // // console.log('Cancel'); - // // }, - // // }); - // // return false; + // // 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; // - // this.deleteAttachment(file); - // } + // this.deleteAttachment(file); + // } onAttachmentRemove = (file) => { - const url = `/attachments/${file.response ? file.response.id : file.uid}.json` - axios.delete(url, { - }) - .then((response) => { - if (response.data) { - const { status } = response.data; - if (status == 0) { + const url = `/attachments/${file.response ? file.response.id : file.uid}.json` + axios.delete(url, { + }) + .then((response) => { + if (response.data) { + const { status } = response.data; + if (status == 0) { this.setState({ fileListtype:false, fileList:[] }) - } + } - } - }) - .catch(function (error) { - console.log(error); - }); + } + }) + .catch(function (error) { + console.log(error); + }); + this.setState({ + fileListtype:false, + }) + } + + ModalCancelModalCancel=()=>{ + this.setState({ + Modalstype:false, + Modalstopval:"", + ModalSave:this.ModalCancelModalCancel, + loadtype:false + }) + this.props.Cancel() + } + Saves=()=>{ + + let id=this.props.categoryid; + let {fileList,description,is_public,is_unified_setting,datatime,course_group_publish_times} =this.state; + + let newfileList=[]; + for(var list of fileList){ + newfileList.push(list.response.id) + } + + if(newfileList.length===0){ this.setState({ - fileListtype:false, + newfileListtype:true }) - } - - ModalCancelModalCancel=()=>{ - this.setState({ - Modalstype:false, - Modalstopval:"", - ModalSave:this.ModalCancelModalCancel, - loadtype:false - }) - this.props.Cancel() - } - Saves=()=>{ - - let id=this.props.categoryid; - let {fileList,description,is_public,is_unified_setting,datatime,course_group_publish_times} =this.state; - - let newfileList=[]; - for(var list of fileList){ - newfileList.push(list.response.id) - } - - if(newfileList.length===0){ - this.setState({ - newfileListtype:true - }) - return - } - // if(is_unified_setting===false){ - // course_group_publish_times.forEach((item,key)=>{ - // if(item.course_group_id===undefined||item.publish_time===undefined){ - // this.setState({ - // course_group_publish_timestype:true - // }) - // return - // } - // }) - // - // } - - - - if(description===undefined){ - - }else if(description.length>100){ - - this.setState({ - descriptiontype:true - }) - return - } - - let coursesId=this.props.match.params.coursesId; - let attachmentId=this.props.attachmentId; - let url="/files/upload.json"; - - - axios.post(url,{ - course_id:coursesId, - course_second_category_id:this.props.coursesidtype===undefined||this.props.coursesidtype==="node"?0:attachmentId, - attachment_ids:newfileList, - is_public:is_public, - is_unified_setting:is_unified_setting, - publish_time:is_unified_setting===true?datatime===undefined? moment(new Date()).format('YYYY-MM-DD HH:mm'):datatime:undefined, - description:description, - course_group_publish_times:is_unified_setting===false?course_group_publish_times:undefined - }).then((result)=>{ - - if(result.data.status===0){ - // this.setState({ - // Modalstype:true, - // Modalstopval:result.data.message, - // ModalSave:this.ModalCancelModalCancel, - // loadtype:true - // }) - this.ModalCancelModalCancel(); - this.props.updataleftNavfun(); - // this.props.showNotification(result.data.message); - this.props.showNotification("上传资源成功"); - this.props.setupdate(this.props.attachmentId) - } - }) - - - - } - - settextarea=(e)=>{ - this.setState({ - description:e.target.value - }) - } - - onChangesetting=(e)=>{ - - this.setState({ - is_unified_setting:e.target.checked - }) - - } - - onChangepublic=(e)=>{ - - this.setState({ - is_public:e.target.checked - }) - - } - - onChangeTimepublish= (date, dateString,key,type) => { - if(type===1){ - this.setState({ - datatime:handleDateString(dateString), - }) - }else if(type===2){ - let {course_group_publish_times}=this.state; - let newgroup_publish=course_group_publish_times; - for(var i=0; i- - -
- - } -+
{ @@ -433,152 +433,152 @@ class Sendresource extends Component{ (单个文件最大150M) :""} -
+ {/**/} {/*{this.state.fileList.length===0?"":this.state.fileList.map((item,key)=>{*/} - {/*debugger*/} - {/*return(*/} - {/**/} - {/**/} - {/**/} - {/**/} - {/**/} - {/*{item.name}*/} - {/**/} - {/**/} - {/*{item.response===undefined?"":isNaN(bytesToSize(item.filesize))?"":bytesToSize(item.filesize)}*/} - {/**/} - {/*this.onAttachmentRemove(item.response===undefined?"":item.response.id&&item.response.id)}>*/} - {/*
*/} - {/*)*/} + {/*debugger*/} + {/*return(*/} + {/**/} + {/**/} + {/**/} + {/**/} + {/**/} + {/*{item.name}*/} + {/**/} + {/**/} + {/*{item.response===undefined?"":isNaN(bytesToSize(item.filesize))?"":bytesToSize(item.filesize)}*/} + {/**/} + {/*this.onAttachmentRemove(item.response===undefined?"":item.response.id&&item.response.id)}>*/} + {/*
*/} + {/*)*/} {/*})}*/} - {newfileListtype===true&&this.state.fileListtype===false?请先上传资源
:""} - - {/**/} - {/**/} - - {/*
+ {newfileListtype===true&&this.state.fileListtype===false?
请先上传资源
:""} + ++ + +
请填写完整
:""}*/} - - {descriptiontype===true?请输入资源描述,最大限制100个字符
:""} - - -请填写完整
:""}*/} + + {descriptiontype===true?请输入资源描述,最大限制100个字符
:""} + + +