调整资源上传

dev_ysm
杨树明 5 years ago
parent 7173fa94b2
commit 2bd0bb5850

@ -32,7 +32,7 @@ module.exports = {
// See the discussion in https://github.com/facebookincubator/create-react-app/issues/343.s // See the discussion in https://github.com/facebookincubator/create-react-app/issues/343.s
// devtool: "cheap-module-eval-source-map", // devtool: "cheap-module-eval-source-map",
// 开启调试 // 开启调试
devtool: "source-map", // 开启调试 //devtool: "source-map", // 开启调试
// These are the "entry points" to our application. // These are the "entry points" to our application.
// This means they will be the "root" imports that are included in JS bundle. // This means they will be the "root" imports that are included in JS bundle.
// The first two entry points enable "hot" CSS and auto-refreshes for JS. // The first two entry points enable "hot" CSS and auto-refreshes for JS.

@ -734,7 +734,7 @@ class Fileslists extends Component{
let category_id= this.props.match.params.category_id; let category_id= this.props.match.params.category_id;
console.log(this.state.course_groups) // console.log(this.state.course_groups)
return( return(
<React.Fragment > <React.Fragment >

@ -42,7 +42,13 @@ class Selectresource extends Component{
getallfiles:false, getallfiles:false,
searchtype:'getallfiles', searchtype:'getallfiles',
Radiovalue:0, Radiovalue:0,
datatime:undefined datatime:undefined,
course_group_publish_times:[
{
group_id : undefined,
publish_time :undefined,
course_group_name:undefined
}],
} }
} }
componentDidMount() { componentDidMount() {
@ -212,7 +218,7 @@ class Selectresource extends Component{
savecouseShixunModal=()=>{ savecouseShixunModal=()=>{
let {patheditarry,datatime,Radiovalue}=this.state; let {patheditarry,datatime,Radiovalue,course_group_publish_times}=this.state;
let {coursesId,attachmentId}=this.props; let {coursesId,attachmentId}=this.props;
let url="/files/import.json"; let url="/files/import.json";
@ -227,7 +233,7 @@ class Selectresource extends Component{
}) })
} }
if(this.state.Radiovalue===1){ if(this.state.Radiovalue===1&&this.props.course_groups.length===0){
if(datatime===undefined||datatime===null||datatime=== ""){ if(datatime===undefined||datatime===null||datatime=== ""){
this.setState({ this.setState({
Radiovaluetype:true Radiovaluetype:true
@ -245,7 +251,8 @@ class Selectresource extends Component{
attachment_ids:patheditarry, attachment_ids:patheditarry,
course_second_category_id:this.props.coursesidtype===undefined||this.props.coursesidtype==="node"?0:attachmentId, course_second_category_id:this.props.coursesidtype===undefined||this.props.coursesidtype==="node"?0:attachmentId,
delay_publish:Radiovalue, delay_publish:Radiovalue,
publish_time:Radiovalue===1?datatime:undefined 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
} }
).then((response) => { ).then((response) => {
if(response.data.status===0){ if(response.data.status===0){
@ -271,15 +278,59 @@ class Selectresource extends Component{
}); });
} }
onChangeTimepublish= (date, dateString) => { 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<newgroup_publish.length; i++){
if(i===parseInt(key)){
newgroup_publish[i].publish_time=handleDateString(dateString);
}
}
this.setState({
course_group_publish_times:newgroup_publish,
})
}
}
addgrouppublish=()=>{
let newlist=this.state.course_group_publish_times;
newlist.push( {
group_id : undefined,
publish_time :undefined,
course_group_name:undefined
})
this.setState({ this.setState({
datatime:handleDateString(dateString), 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<newgroup_publish.length; i++){
if(i===parseInt(key)){
newgroup_publish[i].course_group_name=index.props.value;
newgroup_publish[i].group_id=index.props.id;
}
}
this.setState({
course_group_publish_times:newgroup_publish,
})
}
render(){ render(){
let {Searchvalue,type,Resourcelist,hometypepvisible,patheditarry,datatime}=this.state; let {Searchvalue,type,Resourcelist,hometypepvisible,patheditarry,datatime,course_group_publish_times}=this.state;
let {visible}=this.props; let {visible}=this.props;
const antIcon = <Icon type="loading" style={{ fontSize: 24 }} spin />; const antIcon = <Icon type="loading" style={{ fontSize: 24 }} spin />;
const radioStyle = { const radioStyle = {
@ -287,6 +338,8 @@ class Selectresource extends Component{
height: '30px', height: '30px',
lineHeight: '30px', lineHeight: '30px',
}; };
console.log(course_group_publish_times)
return( return(
<div> <div>
{/*提示*/} {/*提示*/}
@ -325,12 +378,12 @@ class Selectresource extends Component{
} }
#shixun_tab_div{ #shixun_tab_div{
padding: 0 30px; padding: 0 30px;
padding-top:30px; padding-top:15px;
} }
.search-news{ .search-news{
width: 237px!important; width: 237px!important;
height: 30px; height: 30px;
margin-bottom: 30px; margin-bottom: 15px;
} }
`}</style> `}</style>
@ -373,7 +426,7 @@ class Selectresource extends Component{
height: 37px; height: 37px;
} }
.scrollbox{ .scrollbox{
height:250px !important; height:145px !important;
} }
.selectfilsbox{ .selectfilsbox{
height: 50px; height: 50px;
@ -424,7 +477,7 @@ class Selectresource extends Component{
<Tooltip placement="bottom" title={this.props.isStudent()===true?"不支持学生延迟发布":""} > <Tooltip placement="bottom" title={this.props.isStudent()===true?"不支持学生延迟发布":""} >
<Radio style={radioStyle} value={1} className={"fl"} disabled={this.props.isStudent()}> <Radio style={radioStyle} value={1} className={"fl"} disabled={this.props.isStudent()}>
<span className={"mr5"}>延期发布</span> <span className={"mr5"}>延期发布</span>
<DatePicker {this.props.course_groups.length>0?"":<DatePicker
dropdownClassName="hideDisable" dropdownClassName="hideDisable"
showTime={{ format: 'HH:mm' }} showTime={{ format: 'HH:mm' }}
locale={locale} locale={locale}
@ -438,11 +491,92 @@ class Selectresource extends Component{
disabledTime={disabledDateTime} disabledTime={disabledDateTime}
disabledDate={disabledDate} disabledDate={disabledDate}
disabled={this.state.Radiovalue===1?false:true} disabled={this.state.Radiovalue===1?false:true}
/> />}
</Radio> </Radio>
</Tooltip> </Tooltip>
<span className={"fl mt5 color-grey-c"}>(按照设置的时间定时发布)</span> <span className={"fl mt5 color-grey-c"}>(按照设置的时间定时发布)</span>
</Radio.Group> </Radio.Group>
<style>{`
.Selectleft20{
margin-left: 20px !important;
width: 176px;
height: 40px;
}
#startimes .ant-calendar-picker-icon{
margin-top:-11px;
}
.resourcebox{
max-height:106px;
overflow: auto;
}
.ml70{
margin-left:70px;
}
`}</style>
{this.props.course_groups.length>0?this.props.isStudent()===true?"":<div className={"resourcebox"}>
{this.state.Radiovalue===1?<style>
{
`
.ant-input, .ant-input .ant-input-suffix {
background-color: #fff!important;
}
`
}
</style>:""}
{
course_group_publish_times.map((item,key)=>{
return(
<div className={"mt10"} key={key}>
<Select
className={"ml70"}
disabled={this.state.Radiovalue===1?false:true}
placeholder="请选择分班名称"
value={item.course_group_name}
style={{ width: 200 }}
onChange={(e,index)=>this.selectassigngroups(e,index,key)}
>
{this.props.course_groups.map((items,keys)=>{
let type=0
{course_group_publish_times.map((itsem,kesy)=>{
if(itsem.group_id===items.id){
type=1
return
}
})}
if(type===0){
return(
<Option value={items.name} key={keys} id={items.id}>{items.name}</Option>
)
}
})}
</Select>
<DatePicker
disabled={this.state.Radiovalue===1?false:true}
dropdownClassName="hideDisable"
showTime={{ format: 'HH:mm' }}
locale={locale}
showToday={false}
format={dateFormat}
placeholder="请选择发布时间"
id={"startimes"}
className={"Selectleft20 "}
width={"200px"}
value={item.publish_time===undefined||item.publish_time===""?undefined:moment(item.publish_time, dateFormat)}
onChange={(e,index)=>this.onChangeTimepublish(e,index,key,2)}
// onChange={ this.onChangeTimepublish }
disabledTime={disabledDateTime}
disabledDate={disabledDate}
/>
{key!=0?<i className="iconfont icon-shanchu color-grey-c font-14 font-n ml20" onClick={()=>this.deletegrouppublish(key)}></i>:""}
{key+1===this.props.course_groups.length?"":<i className="iconfont icon-tianjiafangda color-green ml15" onClick={this.addgrouppublish}></i>}
</div>
)
})
}
</div>:""}
</div> </div>
{this.state.patheditarrytype===true?<p className={"color-red ml20"}>请选择资源</p>:""} {this.state.patheditarrytype===true?<p className={"color-red ml20"}>请选择资源</p>:""}

@ -14,12 +14,12 @@ function range(start, end) {
} }
return result; return result;
} }
function disabledDateTime() { function disabledDateTime() {
return { return {
// disabledHours: () => range(0, 24).splice(4, 20),
disabledMinutes: () => range(1, 30).concat(range(31, 60)), disabledMinutes: () => range(1, 30).concat(range(31, 60)),
// disabledSeconds: () => [0, 60], // disabledSeconds: () => range(0,60)
}; }
} }
function disabledDate(current) { function disabledDate(current) {
@ -45,8 +45,9 @@ class Sendresource extends Component{
// moment(new Date()).format('YYYY-MM-DD HH:mm:ss'), // moment(new Date()).format('YYYY-MM-DD HH:mm:ss'),
course_group_publish_times:[ course_group_publish_times:[
{ {
course_group_id : undefined, group_id : undefined,
publish_time :"" publish_time :undefined,
course_group_name:undefined
}], }],
course_groups:undefined, course_groups:undefined,
course_groups_count:undefined, course_groups_count:undefined,
@ -127,7 +128,7 @@ class Sendresource extends Component{
} }
Saves=()=>{ Saves=()=>{
let {fileList,description,is_public,datatime,Radiovalue} =this.state; let {fileList,description,is_public,datatime,Radiovalue,course_group_publish_times} =this.state;
let newfileList=[]; let newfileList=[];
for(var list of fileList){ for(var list of fileList){
@ -141,7 +142,7 @@ class Sendresource extends Component{
return return
} }
if(this.state.Radiovalue===1){ if(this.state.Radiovalue===1&&this.props.course_groups.length===0){
if(datatime===undefined||datatime===null||datatime=== ""){ if(datatime===undefined||datatime===null||datatime=== ""){
this.setState({ this.setState({
Radiovaluetype:true Radiovaluetype:true
@ -156,6 +157,7 @@ class Sendresource extends Component{
if(description===undefined){ if(description===undefined){
}else if(description.length>100){ }else if(description.length>100){
@ -176,9 +178,10 @@ class Sendresource extends Component{
course_second_category_id:this.props.coursesidtype===undefined||this.props.coursesidtype==="node"?0:attachmentId, course_second_category_id:this.props.coursesidtype===undefined||this.props.coursesidtype==="node"?0:attachmentId,
attachment_ids:newfileList, attachment_ids:newfileList,
is_public:is_public, is_public:is_public,
publish_time:Radiovalue===1?datatime===undefined? undefined:datatime:undefined, publish_time:this.props.course_groups.length===0?Radiovalue===1?datatime===undefined? undefined:datatime:undefined:"",
description:description, description:description,
delay_publish:Radiovalue, delay_publish:Radiovalue,
group_settings:this.props.course_groups.length===0?"":course_group_publish_times
}).then((result)=>{ }).then((result)=>{
if(result.data.status===0){ if(result.data.status===0){
@ -237,10 +240,44 @@ class Sendresource extends Component{
Radiovalue: e.target.value, Radiovalue: e.target.value,
}); });
} }
addgrouppublish=()=>{
let newlist=this.state.course_group_publish_times;
newlist.push( {
group_id : undefined,
publish_time :undefined,
course_group_name: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<newgroup_publish.length; i++){
if(i===parseInt(key)){
newgroup_publish[i].course_group_name=index.props.value;
newgroup_publish[i].group_id=index.props.id;
}
}
this.setState({
course_group_publish_times:newgroup_publish,
})
}
render(){ render(){
let { newfileListtype,descriptiontype, let { newfileListtype,descriptiontype,
is_public, is_public,
datatime, datatime,
course_group_publish_times
}=this.state; }=this.state;
const uploadProps = { const uploadProps = {
@ -265,7 +302,7 @@ class Sendresource extends Component{
}; };
console.log(this.props.course_groups) //console.log(this.state.course_group_publish_times)
return( return(
<div> <div>
{/*提示*/} {/*提示*/}
@ -421,10 +458,88 @@ class Sendresource extends Component{
</Radio> </Radio>
</Tooltip> </Tooltip>
<span className={"fl mt5 color-grey-c"}>(按照设置的时间定时发布)</span> <span className={"fl mt5 color-grey-c"}>(按照设置的时间定时发布)</span>
</Radio.Group>
<style>{`
.Selectleft20{
margin-left: 20px !important;
width: 176px;
height: 40px;
}
#startimes .ant-calendar-picker-icon{
margin-top:-11px;
}
.resourcebox{
max-height:150px;
overflow: auto;
}
.ml70{
margin-left:70px;
}
`}</style>
{this.props.course_groups.length>0?this.props.isStudent()===true?"":<div className={"resourcebox"}>
{this.state.Radiovalue===1?<style>
{
`
.ant-input, .ant-input .ant-input-suffix {
background-color: #fff!important;
}
`
}
</style>:""}
{
course_group_publish_times.map((item,key)=>{
return(
<div className={"mt10"} key={key}>
<Select
disabled={this.state.Radiovalue===1?false:true}
placeholder="请选择分班名称"
value={item.course_group_name}
style={{ width: 200 }}
onChange={(e,index)=>this.selectassigngroups(e,index,key)}
>
{this.props.course_groups.map((items,keys)=>{
let type=0
{course_group_publish_times.map((itsem,kesy)=>{
if(itsem.group_id===items.id){
type=1
return
}
})}
if(type===0){
return(
<Option value={items.name} key={keys} id={items.id}>{items.name}</Option>
)
}
})}
</Select>
<DatePicker
disabled={this.state.Radiovalue===1?false:true}
dropdownClassName="hideDisable"
showTime={{ format: 'HH:mm' }}
locale={locale}
showToday={false}
format={dateFormat}
placeholder="请选择发布时间"
id={"startimes"}
className={"Selectleft20 "}
width={"200px"}
value={item.publish_time===undefined||item.publish_time===""?undefined:moment(item.publish_time, dateFormat)}
onChange={(e,index)=>this.onChangeTimepublish(e,index,key,2)}
// onChange={ this.onChangeTimepublish }
disabledTime={disabledDateTime}
disabledDate={disabledDate}
/>
{key!=0?<i className="iconfont icon-shanchu color-grey-c font-14 font-n ml20" onClick={()=>this.deletegrouppublish(key)}></i>:""}
{key+1===this.props.course_groups.length?"":<i className="iconfont icon-tianjiafangda color-green ml15" onClick={this.addgrouppublish}></i>}
</div>
)
})
</Radio.Group> }
</div>:""}
</div> </div>

Loading…
Cancel
Save