diff --git a/public/react/src/modules/courses/coursesPublic/SelectResource.js b/public/react/src/modules/courses/coursesPublic/SelectResource.js index 31c6d2f52..e2454652b 100644 --- a/public/react/src/modules/courses/coursesPublic/SelectResource.js +++ b/public/react/src/modules/courses/coursesPublic/SelectResource.js @@ -42,12 +42,7 @@ class Selectresource extends Component{ getallfiles:false, searchtype:'getallfiles', Radiovalue:0, - datatime:undefined, - course_group_publish_times:[ - { - group_id : [], - publish_time :undefined, - }], + datatime:undefined } } componentDidMount() { @@ -79,7 +74,7 @@ class Selectresource extends Component{ } SenttotheSearch=(value)=>{ - let {searchtype}=this.state; + let {searchtype}=this.state; if(searchtype==="getallfiles"){ this.getallfiles(value,1) }else if(searchtype==="getmyfiles"){ @@ -91,32 +86,32 @@ class Selectresource extends Component{ setupdatalist=(url,newpage)=>{ let {Resourcelist,Searchvalue}=this.state; if(Resourcelist!=undefined){ - let newResourcelist=Resourcelist.files; - axios.get(url,{ - params:{ - page:newpage, - page_size:15, - search:Searchvalue, - } - }).then((result)=>{ + let newResourcelist=Resourcelist.files; + axios.get(url,{ + params:{ + page:newpage, + page_size:15, + search:Searchvalue, + } + }).then((result)=>{ - var list=result.data.data.files; + var list=result.data.data.files; for(var i=0;i{ - console.log(error) - }) + }).catch((error)=>{ + console.log(error) + }) } } contentViewScroll=(e)=>{ @@ -152,7 +147,7 @@ class Selectresource extends Component{ // this.props.funshixunmodallist(Searchvalue,types,true,1) // this.props.funpatheditarry([]) if(types==="all"){ - this.getallfiles(undefined,1) + this.getallfiles(undefined,1) }else if(types==="my"){ this.getmyfiles(undefined,1) } @@ -168,12 +163,12 @@ class Selectresource extends Component{ search:value, } }).then((result)=>{ - this.setState({ - Resourcelist:result.data.data, - hometypepvisible:false, - getallfiles:true, - searchtype:'getallfiles' - }) + this.setState({ + Resourcelist:result.data.data, + hometypepvisible:false, + getallfiles:true, + searchtype:'getallfiles' + }) }).catch((error)=>{ console.log(error) }) @@ -189,11 +184,11 @@ class Selectresource extends Component{ search:value, } }).then((result)=>{ - this.setState({ - Resourcelist: result.data.data, - hometypepvisible:false, - searchtype:'getmyfiles' - }) + this.setState({ + Resourcelist: result.data.data, + hometypepvisible:false, + searchtype:'getmyfiles' + }) }).catch((error)=>{ console.log(error) }) @@ -201,7 +196,7 @@ class Selectresource extends Component{ hidecouseShixunModal=()=>{ - this.props.hidecouseShixunModal() + this.props.hidecouseShixunModal() } ModalCancelModalCancel=()=>{ @@ -217,22 +212,22 @@ class Selectresource extends Component{ savecouseShixunModal=()=>{ - let {patheditarry,datatime,Radiovalue,course_group_publish_times}=this.state; + let {patheditarry,datatime,Radiovalue}=this.state; let {coursesId,attachmentId}=this.props; - let url="/files/import.json"; - - if(patheditarry===undefined||patheditarry.length===0){ - this.setState({ - patheditarrytype:true - }) - return - }else{ - this.setState({ - patheditarrytype:false - }) - } - - if(this.state.Radiovalue===1&&this.props.course_groups.length===0){ + let url="/files/import.json"; + + if(patheditarry===undefined||patheditarry.length===0){ + this.setState({ + patheditarrytype:true + }) + return + }else{ + this.setState({ + patheditarrytype:false + }) + } + + if(this.state.Radiovalue===1){ if(datatime===undefined||datatime===null||datatime=== ""){ this.setState({ Radiovaluetype:true @@ -249,17 +244,16 @@ class Selectresource extends Component{ course_id:coursesId, attachment_ids:patheditarry, course_second_category_id:this.props.coursesidtype===undefined||this.props.coursesidtype==="node"?0:attachmentId, - delay_publish:Radiovalue, - publish_time:this.props.course_groups.length===0?Radiovalue===1?datatime===undefined? undefined:datatime:undefined:undefined, - group_settings:this.props.course_groups.length===0?undefined:course_group_publish_times + delay_publish:Radiovalue, + publish_time:Radiovalue===1?datatime:undefined } ).then((response) => { - if(response.data.status===0){ - this.ModalCancelModalCancel(); - this.props.updataleftNavfun(); - this.props.showNotification("选用资源成功"); - this.props.setupdate(attachmentId) - } + if(response.data.status===0){ + this.ModalCancelModalCancel(); + this.props.updataleftNavfun(); + this.props.showNotification("选用资源成功"); + this.props.setupdate(attachmentId) + } }).catch((error) => { console.log(error) }) @@ -277,58 +271,15 @@ class Selectresource extends Component{ }); } - 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 { - addgrouppublish=()=>{ - let newlist=this.state.course_group_publish_times; - newlist.push( { - group_id : undefined, - publish_time :undefined, - }) - this.setState({ - course_group_publish_times:newlist - }) - } - deletegrouppublish=(key)=>{ - let newlist=this.state.course_group_publish_times; - newlist.splice(key,1); this.setState({ - course_group_publish_times:newlist + datatime:handleDateString(dateString), }) - } - selectassigngroups=(e,index,key)=>{ - debugger - let {course_group_publish_times}=this.state; - let newgroup_publish=course_group_publish_times; - for(var i=0; i; const radioStyle = { @@ -336,8 +287,6 @@ class Selectresource extends Component{ height: '30px', lineHeight: '30px', }; - - console.log(course_group_publish_times) return(
{/*提示*/} @@ -350,73 +299,73 @@ class Selectresource extends Component{ /> {visible===true? - - + } + - -
-
- -
  • this.changeTag("all")} className={ type==="all" ? "active edu-filter-cir-grey font-12":"edu-filter-cir-grey font-12"}>全部
  • -
  • this.changeTag("my")} className={ type==="my" ? " active edu-filter-cir-grey font-12":"edu-filter-cir-grey font-12"}>我的资源
  • -
    - this.SenttotheSearch(value)} - style={{width: '100%'}} - /> + - -
      -
    • 资源名称
    • -
    • 大小
    • -
    • 发布人
    • -
    • 时间
    • -
    +
      +
    • 资源名称
    • +
    • 大小
    • +
    • 发布人
    • +
    • 时间
    • +
    - -
    - - { - Resourcelist === undefined ?"":Resourcelist.files.length===0?: - - - { - Resourcelist.files.map((item,key)=>{ - return( -
    -
  • - - - -
  • -
  • {item.filesize}
  • -
  • {item.author.name}
  • -
  • {formatDate(item.created_on)}
  • -
    - ) - }) - } -
    - - } -
    +
    -
    - 发布设置: - - - 立即发布 - - - - 延期发布 - {this.props.course_groups.length>0?"":this.onChangeTimepublish(e,index,undefined,1)} - disabledTime={disabledDateTime} - disabledDate={disabledDate} - disabled={this.state.Radiovalue===1?false:true} - />} - - - (按照设置的时间定时发布) - - - - {this.props.course_groups.length>0?this.props.isStudent()===true?"":
    - {this.state.Radiovalue===1?:""} { - course_group_publish_times.map((item,key)=>{ - return( -
    - - - this.onChangeTimepublish(e,index,key,2)} - // onChange={ this.onChangeTimepublish } - disabledTime={disabledDateTime} - disabledDate={disabledDate} - /> - {key!=0?this.deletegrouppublish(key)}>:""} - {key+1===this.props.course_groups.length?"":} -
    - ) - }) + Resourcelist === undefined ?"":Resourcelist.files.length===0?: + + + { + Resourcelist.files.map((item,key)=>{ + return( +
    +
  • + + + +
  • +
  • {item.filesize}
  • +
  • {item.author.name}
  • +
  • {formatDate(item.created_on)}
  • +
    + ) + }) + } +
    } -
    :""} -
    +
    + +
    + 发布设置: + + + 立即发布 + + + + 延期发布 + this.onChangeTimepublish(e,index,undefined,1)} + disabledTime={disabledDateTime} + disabledDate={disabledDate} + disabled={this.state.Radiovalue===1?false:true} + /> + + + (按照设置的时间定时发布) + +
    - {this.state.patheditarrytype===true?

    请选择资源

    :""} - {this.state.Radiovaluetype===true?

    发布时间不能为空

    :""} -
    + {this.state.patheditarrytype===true?

    请选择资源

    :""} + {this.state.Radiovaluetype===true?

    发布时间不能为空

    :""} +
    -
    - - :""} + + :""}
    ) } diff --git a/public/react/src/modules/courses/coursesPublic/sendResource.js b/public/react/src/modules/courses/coursesPublic/sendResource.js index b0f4b1b69..7915e6674 100644 --- a/public/react/src/modules/courses/coursesPublic/sendResource.js +++ b/public/react/src/modules/courses/coursesPublic/sendResource.js @@ -14,12 +14,12 @@ function range(start, end) { } return result; } - function disabledDateTime() { return { + // disabledHours: () => range(0, 24).splice(4, 20), disabledMinutes: () => range(1, 30).concat(range(31, 60)), - // disabledSeconds: () => range(0,60) - } + // disabledSeconds: () => [0, 60], + }; } function disabledDate(current) { @@ -45,8 +45,8 @@ class Sendresource extends Component{ // moment(new Date()).format('YYYY-MM-DD HH:mm:ss'), course_group_publish_times:[ { - group_id : undefined, - publish_time :undefined, + course_group_id : undefined, + publish_time :"" }], course_groups:undefined, course_groups_count:undefined, @@ -86,34 +86,34 @@ class Sendresource extends Component{ } onAttachmentRemove = (file) => { - if(!file.percent || file.percent == 100){ - 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); - }); - this.setState({ - fileListtype:false, - }) - }else{ - this.setState({ - fileListtype:false, - fileList:[] - }) - } + if(!file.percent || file.percent == 100){ + 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); + }); + this.setState({ + fileListtype:false, + }) + }else{ + this.setState({ + fileListtype:false, + fileList:[] + }) + } } ModalCancelModalCancel=()=>{ @@ -127,7 +127,7 @@ class Sendresource extends Component{ } Saves=()=>{ - let {fileList,description,is_public,datatime,Radiovalue,course_group_publish_times} =this.state; + let {fileList,description,is_public,datatime,Radiovalue} =this.state; let newfileList=[]; for(var list of fileList){ @@ -141,7 +141,7 @@ class Sendresource extends Component{ return } - if(this.state.Radiovalue===1&&this.props.course_groups.length===0){ + if(this.state.Radiovalue===1){ if(datatime===undefined||datatime===null||datatime=== ""){ this.setState({ Radiovaluetype:true @@ -156,7 +156,6 @@ class Sendresource extends Component{ - if(description===undefined){ }else if(description.length>100){ @@ -177,10 +176,9 @@ class Sendresource extends Component{ course_second_category_id:this.props.coursesidtype===undefined||this.props.coursesidtype==="node"?0:attachmentId, attachment_ids:newfileList, is_public:is_public, - publish_time:this.props.course_groups.length===0?Radiovalue===1?datatime===undefined? undefined:datatime:undefined:"", + publish_time:Radiovalue===1?datatime===undefined? undefined:datatime:undefined, description:description, delay_publish:Radiovalue, - group_settings:this.props.course_groups.length===0?"":course_group_publish_times }).then((result)=>{ if(result.data.status===0){ @@ -239,42 +237,10 @@ class Sendresource extends Component{ Radiovalue: e.target.value, }); } - - addgrouppublish=()=>{ - let newlist=this.state.course_group_publish_times; - newlist.push( { - group_id : undefined, - publish_time :undefined, - }) - this.setState({ - course_group_publish_times:newlist - }) - } - deletegrouppublish=(key)=>{ - let newlist=this.state.course_group_publish_times; - newlist.splice(key,1); - this.setState({ - course_group_publish_times:newlist - }) - } - selectassigngroups=(e,index,key)=>{ - let {course_group_publish_times}=this.state; - let newgroup_publish=course_group_publish_times; - for(var i=0; i {/*提示*/} @@ -406,8 +372,8 @@ class Sendresource extends Component{ {this.props.course_is_public===true?
    公开: - 选中,所有用户可见,否则课堂成员可见 - + 选中,所有用户可见,否则课堂成员可见 +
    :""} - {this.props.course_groups.length>0?this.props.isStudent()===true?"":
    - {this.state.Radiovalue===1?:""} - { - course_group_publish_times.map((item,key)=>{ - return( -
    - - - this.onChangeTimepublish(e,index,key,2)} - // onChange={ this.onChangeTimepublish } - disabledTime={disabledDateTime} - disabledDate={disabledDate} - /> - {key!=0?this.deletegrouppublish(key)}>:""} - {key+1===this.props.course_groups.length?"":} -
    - ) - }) - } -
    :""} +