Merge branch 'dev_aliyun' of https://bdgit.educoder.net/Hjqreturn/educoder into dev_aliyun

dev_oauth
hjm 6 years ago
commit 12e7e78253

@ -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{
<div className="pl20 pr20"
style={{"Height":"204px"}}>
style={{"Height":"204px"}}>
<style>{`
.color-grey-9a{color: #9A9A9A !important;}
@ -487,7 +487,7 @@ class Selectsetting extends Component{
{datalist&&datalist.attachment_histories.length===0?"":<span className={"newcolor-orange fl"}>当前版本</span>}
</li>
<li className="fl edu-txt-left task-hide paddingl5 "
style={{width: '76px'}}> {datalist&&datalist.downloads_count} </li>
style={{width: '76px'}}> {datalist&&datalist.downloads_count} </li>
<li className="fl paddingl10 " style={{width: '100px'}}> {datalist&&datalist.quotes} </li>
<li className="fl paddingl10 datastyle">
{moment(datalist&&datalist.created_on).format('YYYY-MM-DD HH:mm')==="Invalid date"?"":moment(datalist&&datalist.created_on).format('YYYY-MM-DD HH:mm')}
@ -495,21 +495,21 @@ class Selectsetting extends Component{
</div>
{datalist&&datalist.attachment_histories.map((item,key)=>{
return(
<div className="clearfix edu-txt-center lineh-40 bor-bottom-greyE" key={key}>
<li className="fl" style={{width: '241px'}}>
<span className={"isabox"} title={item.title}> {item.title} </span>
{/*<span className={"newcolor-orange fl"}>当前版本</span>*/}
</li>
<li className="fl edu-txt-left task-hide paddingl5 "
style={{width: '76px'}}> {item.downloads_count} </li>
<li className="fl paddingl10 " style={{width: '100px'}}> {item.quotes} </li>
<li className="fl paddingl10 datastyle">
{moment(item.created_on).format('YYYY-MM-DD HH:mm')==="Invalid date"?"":moment(item.created_on).format('YYYY-MM-DD HH:mm')}
</li>
</div>
)
})}
return(
<div className="clearfix edu-txt-center lineh-40 bor-bottom-greyE" key={key}>
<li className="fl" style={{width: '241px'}}>
<span className={"isabox"} title={item.title}> {item.title} </span>
{/*<span className={"newcolor-orange fl"}>当前版本</span>*/}
</li>
<li className="fl edu-txt-left task-hide paddingl5 "
style={{width: '76px'}}> {item.downloads_count} </li>
<li className="fl paddingl10 " style={{width: '100px'}}> {item.quotes} </li>
<li className="fl paddingl10 datastyle">
{moment(item.created_on).format('YYYY-MM-DD HH:mm')==="Invalid date"?"":moment(item.created_on).format('YYYY-MM-DD HH:mm')}
</li>
</div>
)
})}
</div>
<style>{`
.popups{
@ -571,21 +571,21 @@ class Selectsetting extends Component{
<p className={"winth540"}>
{
this.state.fileListtype===true?
<div>
<Tooltip placement="bottom" title={
<pre>
this.state.fileListtype===true?
<div>
<Tooltip placement="bottom" title={
<pre>
每次只能上传一个资源<br/>删除下面资源可重新上传
</pre>
}>
<Button className="uploadBtns">
更新版本
</Button>
</Tooltip>
<span>(单个文件最大150M)</span>
</div>
:""
}>
<Button className="uploadBtns">
更新版本
</Button>
</Tooltip>
<span>(单个文件最大150M)</span>
</div>
:""
}
<Upload {...uploadProps} fileList={this.state.fileList} className="upload_1">
@ -600,121 +600,121 @@ class Selectsetting extends Component{
</p>
{/*<style>*/}
{/*{*/}
{/*`*/}
{/*.maxwidth400{*/}
{/*max-width: 400px;*/}
{/*overflow: hidden;*/}
{/*text-overflow: ellipsis;*/}
{/*white-space: nowrap;*/}
{/*}*/}
{/*`*/}
{/*}*/}
{/*{*/}
{/*`*/}
{/*.maxwidth400{*/}
{/*max-width: 400px;*/}
{/*overflow: hidden;*/}
{/*text-overflow: ellipsis;*/}
{/*white-space: nowrap;*/}
{/*}*/}
{/*`*/}
{/*}*/}
{/*</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 maxwidth400 fl" length="58">*/}
{/*{item.name}*/}
{/*</span>*/}
{/*<span className="color656565 mt2 color-grey-6 font-12 mr8">*/}
{/*{item.response===undefined?"":isNaN(bytesToSize(item.filesize))?"123":bytesToSize(item.filesize)}*/}
{/*</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>*/}
{/*)*/}
{/*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 maxwidth400 fl" length="58">*/}
{/*{item.name}*/}
{/*</span>*/}
{/*<span className="color656565 mt2 color-grey-6 font-12 mr8">*/}
{/*{item.response===undefined?"":isNaN(bytesToSize(item.filesize))?"123":bytesToSize(item.filesize)}*/}
{/*</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>*/}
{/*)*/}
{/*})}*/}
{this.state.newfileListtypes===true?<p className={"color-red"}>请先上传资源</p>:""}
{/*<p className={"winth540"}>*/}
{/*<style>{`*/}
{/*.ant-checkbox-wrapper{*/}
{/*margin-left:0px !important;*/}
{/*margin-top:10px;*/}
{/*}*/}
{/*`}</style>*/}
{/*<div className={this.state.fileListtype===true?"mt30":""}>*/}
{/*<Checkbox*/}
{/*checked={is_public}*/}
{/*onChange={this.onChangepublics}>*/}
{/*<span className={"font-14"}>勾选后所有用户可见,否则仅课堂成员可见</span>*/}
{/*</Checkbox>*/}
{/*</div>*/}
{/*/!*{this.props.has_course_groups&&this.props.has_course_groups===true?:""}*!/*/}
{/*/!*{this.state.course_groupss&&this.state.course_groupss.length>0?<Checkbox*!/*/}
{/*/!*checked={unified_setting}*!/*/}
{/*/!*onChange={this.onChangesettings}>*!/*/}
{/*/!*<span>统一设置</span><span className={"font-14 color-grey-9"}>(选中则所有分班使用相同的发布设置,否则各个单独设置)</span>*!/*/}
{/*/!*</Checkbox>:""}*!/*/}
{/*<style>*/}
{/*{`*/}
{/*.Selectleft20{*/}
{/*margin-left: 20px !important;*/}
{/*width: 176px;*/}
{/*height: 40px; */}
{/*}*/}
{/*.resourcebox{*/}
{/*max-height:150px;*/}
{/*overflow: auto;*/}
{/*}*/}
{/*`}*/}
{/*</style>*/}
{/*/!*this.props.has_course_groups&&this.props.has_course_groups===true?:""*!/*/}
{/*<div className={"resourcebox"}>*/}
{/*{unified_setting===false?*/}
{/*this.state.course_groups&&this.state.course_groups.map((item,key)=>{*/}
{/*return(*/}
{/*<div className={"mt10 "} key={key}>*/}
{/*<Select placeholder="请选择分班名称"*/}
{/*value={item.course_group_id}*/}
{/*style={{ width: 200 }}*/}
{/*onChange={(e,index)=>this.selectassigngroups(e,index,key)}*/}
{/*>*/}
{/*{ this.state.course_groupss&&this.state.course_groupss.map((item,key)=>{*/}
{/*return(*/}
{/*<Option value={item.id} key={key}>{item.name}</Option>*/}
{/*)*/}
{/*})}*/}
{/*</Select>*/}
{/*<DatePicker*/}
{/*showToday={false}*/}
{/*dropdownClassName="hideDisable"*/}
{/*showTime={{ format: 'HH:mm' }}*/}
{/*format="YYYY-MM-DD HH:mm"*/}
{/*locale={locale}*/}
{/*placeholder="请选择发布时间"*/}
{/*id={"startimes"}*/}
{/*className={"Selectleft20"}*/}
{/*width={"200px"}*/}
{/*value={item.publish_time===undefined||item.publish_time===""?"":item.publish_time===null?"":moment(item.publish_time, dateFormat)}*/}
{/*onChange={(e,index)=>this.onChangeTimepublishs(e,index,key)}*/}
{/*// 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===course_groups.length-1?<i className="iconfont icon-tianjiafangda color-green ml15" onClick={this.addgrouppublish}></i>:""}*/}
{/*</div>*/}
{/*)*/}
{/*}):""}*/}
{/*</div>*/}
<p className={"winth540"}>
<style>{`
.ant-checkbox-wrapper{
margin-left:0px !important;
margin-top:10px;
}
`}</style>
{/*</p>*/}
<div className={this.state.fileListtype===true?"mt30":""}>
<Checkbox
checked={is_public}
onChange={this.onChangepublics}>
<span className={"font-14"}>勾选后所有用户可见否则仅课堂成员可见</span>
</Checkbox>
</div>
{/*{this.props.has_course_groups&&this.props.has_course_groups===true?:""}*/}
{/*{this.state.course_groupss&&this.state.course_groupss.length>0?<Checkbox*/}
{/*checked={unified_setting}*/}
{/*onChange={this.onChangesettings}>*/}
{/*<span>统一设置</span><span className={"font-14 color-grey-9"}>(选中则所有分班使用相同的发布设置,否则各个单独设置)</span>*/}
{/*</Checkbox>:""}*/}
<style>
{`
.Selectleft20{
margin-left: 20px !important;
width: 176px;
height: 40px;
}
.resourcebox{
max-height:150px;
overflow: auto;
}
`}
</style>
{/*this.props.has_course_groups&&this.props.has_course_groups===true?:""*/}
<div className={"resourcebox"}>
{unified_setting===false?
this.state.course_groups&&this.state.course_groups.map((item,key)=>{
return(
<div className={"mt10 "} key={key}>
<Select placeholder="请选择分班名称"
value={item.course_group_id}
style={{ width: 200 }}
onChange={(e,index)=>this.selectassigngroups(e,index,key)}
>
{ this.state.course_groupss&&this.state.course_groupss.map((item,key)=>{
return(
<Option value={item.id} key={key}>{item.name}</Option>
)
})}
</Select>
<DatePicker
showToday={false}
dropdownClassName="hideDisable"
showTime={{ format: 'HH:mm' }}
format="YYYY-MM-DD HH:mm"
locale={locale}
placeholder="请选择发布时间"
id={"startimes"}
className={"Selectleft20"}
width={"200px"}
value={item.publish_time===undefined||item.publish_time===""?"":item.publish_time===null?"":moment(item.publish_time, dateFormat)}
onChange={(e,index)=>this.onChangeTimepublishs(e,index,key)}
// 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===course_groups.length-1?<i className="iconfont icon-tianjiafangda color-green ml15" onClick={this.addgrouppublish}></i>:""}
</div>
)
}):""}
</div>
</p>
<style>
{`
#startime .ant-calendar-picker-icon{
@ -723,22 +723,22 @@ class Selectsetting extends Component{
`}
</style>
{unified_setting===true?
<p className={this.state.fileListtype===true?"mt30":""}>
<p className={"mt10"}>
<span>
<DatePicker
showToday={false}
dropdownClassName="hideDisable"
showTime={{ format: 'HH:mm' }}
format="YYYY-MM-DD HH:mm"
locale={locale}
placeholder="请选择发布时间"
id={"startime"}
width={"210px"}
value={datatime===undefined||datatime===""?"":moment(datatime, dateFormat)}
onChange={this.onChangeTimepublish}
disabledTime={disabledDateTime}
showToday={false}
dropdownClassName="hideDisable"
showTime={{ format: 'HH:mm' }}
format="YYYY-MM-DD HH:mm"
locale={locale}
placeholder="请选择发布时间"
id={"startime"}
width={"210px"}
value={datatime===undefined||datatime===""?"":moment(datatime, dateFormat)}
onChange={this.onChangeTimepublish}
disabledTime={disabledDateTime}
disabledDate={disabledDate}
/>
/>
</span>
</p>:""}
{/*{this.state.course_group_idtypes===true?<p className={"color-red"}>请选择分班</p>:""}*/}

@ -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<newgroup_publish.length; i++){
if(i===parseInt(key)){
newgroup_publish[i].publish_time=handleDateString(dateString);
}
}
this.setState({
course_group_publish_times:newgroup_publish,
})
}
}
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_id=index.props.value;
}
}
this.setState({
course_group_publish_times:newgroup_publish,
})
}
deletegrouppublish=(key)=>{
let newlist=this.state.course_group_publish_times;
newlist.splice(key,1);
this.setState({
course_group_publish_times:newlist
})
}
addgrouppublish=()=>{
let newlist=this.state.course_group_publish_times;
newlist.push( {
course_group_id : undefined,
publish_time :undefined
})
this.setState({
course_group_publish_times:newlist
})
}
render(){
let {settextarea,newfileListtype,descriptiontype,
course_group_publish_timestype,
Modalstopval,
ModalCancel,
ModalSave,
loadtype,
is_unified_setting,
is_public,
datatime,
course_group_publish_times,
course_groups
}=this.state;
const uploadProps = {
width: 600,
// showUploadList:false,
action: `${getUrl()}/api/attachments.json`,
onChange: this.handleChange,
onRemove: this.onAttachmentRemove,
beforeUpload: (file) => {
// console.log('beforeUpload', file.name);
const isLt150M = file.size / 1024 / 1024 < 150;
if (!isLt150M) {
message.error('文件大小必须小于150MB!');
}
return isLt150M;
},
};
return(
<div>
{/*提示*/}
<Modals
modalsType={this.state.Modalstype}
modalsTopval={this.state.Modalstopval}
modalCancel={this.state.ModalCancel}
modalSave={this.state.ModalSave}
loadtype= {this.state.loadtype}
/>
<Modal
keyboard={false}
className={"HomeworkModal"}
title={this.props.modalname}
visible={this.props.visible}
closable={false}
footer={null}
destroyOnClose={true}
>
<div className="task-popup-content">
<p className="task-popup-text-center font-16">
<span className={"color-blue underline"}> </span>
</p>
<style>{`
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<newgroup_publish.length; i++){
if(i===parseInt(key)){
newgroup_publish[i].publish_time=handleDateString(dateString);
}
}
this.setState({
course_group_publish_times:newgroup_publish,
})
}
}
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_id=index.props.value;
}
}
this.setState({
course_group_publish_times:newgroup_publish,
})
}
deletegrouppublish=(key)=>{
let newlist=this.state.course_group_publish_times;
newlist.splice(key,1);
this.setState({
course_group_publish_times:newlist
})
}
addgrouppublish=()=>{
let newlist=this.state.course_group_publish_times;
newlist.push( {
course_group_id : undefined,
publish_time :undefined
})
this.setState({
course_group_publish_times:newlist
})
}
render(){
let {settextarea,newfileListtype,descriptiontype,
course_group_publish_timestype,
Modalstopval,
ModalCancel,
ModalSave,
loadtype,
is_unified_setting,
is_public,
datatime,
course_group_publish_times,
course_groups
}=this.state;
const uploadProps = {
width: 600,
// showUploadList:false,
action: `${getUrl()}/api/attachments.json`,
onChange: this.handleChange,
onRemove: this.onAttachmentRemove,
beforeUpload: (file) => {
// console.log('beforeUpload', file.name);
const isLt150M = file.size / 1024 / 1024 < 150;
if (!isLt150M) {
message.error('文件大小必须小于150MB!');
}
return isLt150M;
},
};
return(
<div>
{/*提示*/}
<Modals
modalsType={this.state.Modalstype}
modalsTopval={this.state.Modalstopval}
modalCancel={this.state.ModalCancel}
modalSave={this.state.ModalSave}
loadtype= {this.state.loadtype}
/>
<Modal
keyboard={false}
className={"HomeworkModal"}
title={this.props.modalname}
visible={this.props.visible}
closable={false}
footer={null}
destroyOnClose={true}
>
<div className="task-popup-content">
<p className="task-popup-text-center font-16">
<span className={"color-blue underline"}> </span>
</p>
<style>{`
.uploadBtn.ant-btn {
border: none;
color: #4CACFF;
@ -404,7 +404,7 @@ class Sendresource extends Component{
margin-top:31px;
}
`}</style>}
<p className={"winth540"}>
<p className={"winth540"}>
{
@ -433,152 +433,152 @@ class Sendresource extends Component{
<span className={"ml10"}>(单个文件最大150M)</span>
</span>:""}
</Upload>
</p>
</p>
{/*<style>*/}
{/*{*/}
{/*`*/}
{/*.maxwidth400{*/}
{/*max-width: 400px;*/}
{/*overflow: hidden;*/}
{/*text-overflow: ellipsis;*/}
{/*white-space: nowrap;*/}
{/*}*/}
{/*`*/}
{/*}*/}
{/*{*/}
{/*`*/}
{/*.maxwidth400{*/}
{/*max-width: 400px;*/}
{/*overflow: hidden;*/}
{/*text-overflow: ellipsis;*/}
{/*white-space: nowrap;*/}
{/*}*/}
{/*`*/}
{/*}*/}
{/*</style>*/}
{/*{this.state.fileList.length===0?"":this.state.fileList.map((item,key)=>{*/}
{/*debugger*/}
{/*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 maxwidth400 fl" length="58">*/}
{/*{item.name}*/}
{/*</span>*/}
{/*<span className="color656565 mt2 color-grey-6 font-12 mr8">*/}
{/*{item.response===undefined?"":isNaN(bytesToSize(item.filesize))?"":bytesToSize(item.filesize)}*/}
{/*</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>*/}
{/*)*/}
{/*debugger*/}
{/*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 maxwidth400 fl" length="58">*/}
{/*{item.name}*/}
{/*</span>*/}
{/*<span className="color656565 mt2 color-grey-6 font-12 mr8">*/}
{/*{item.response===undefined?"":isNaN(bytesToSize(item.filesize))?"":bytesToSize(item.filesize)}*/}
{/*</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>*/}
{/*)*/}
{/*})}*/}
{newfileListtype===true&&this.state.fileListtype===false?<p className={"color-red"}>请先上传资源</p>:""}
{/*<p className={"winth540"}>*/}
{/*<style>{`*/}
{/*.ant-checkbox-wrapper{*/}
{/*margin-left:0px !important;*/}
{/*margin-top:10px;*/}
{/*}*/}
{/*`}</style>*/}
{/*<div className={this.state.fileListtype===true?"mt30":""}></div><Checkbox checked={is_public} onChange={this.onChangepublic}>*/}
{/*<span className={"font-14"}>勾选后所有用户可见,否则仅课堂成员可见</span>*/}
{/*</Checkbox>*/}
{/*/!*{this.state.course_groups_count&&this.state.course_groups_count>0?<Checkbox checked={is_unified_setting} onChange={this.onChangesetting}>*!/*/}
{/*/!*<span>统一设置</span><span className={"font-14 color-grey-9"}>(选中则所有分班使用相同的发布设置,否则各个单独设置)</span>*!/*/}
{/*/!*</Checkbox>:""}*!/*/}
{/*<style>{`*/}
{/*.Selectleft20{*/}
{/*margin-left: 20px !important;*/}
{/*width: 176px;*/}
{/*height: 40px; */}
{/*}*/}
{/*#startimes .ant-calendar-picker-icon{*/}
{/*margin-top:-11px;*/}
{/*}*/}
{/*.resourcebox{*/}
{/*max-height:150px;*/}
{/*overflow: auto;*/}
{/*}*/}
{/*`}</style>*/}
{/*<div className={"resourcebox"}>*/}
{/*{is_unified_setting===false?*/}
{/*course_group_publish_times.map((item,key)=>{*/}
{/*return(*/}
{/*<div className={"mt10"} key={key}>*/}
{/*<Select placeholder="请选择分班名称"*/}
{/*value={item.course_group_id}*/}
{/*style={{ width: 200 }}*/}
{/*onChange={(e,index)=>this.selectassigngroups(e,index,key)}*/}
{/*>*/}
{/*{course_groups&&course_groups.map((item,key)=>{*/}
{/*return(*/}
{/*<Option value={item.id} key={key}>{item.name}</Option>*/}
{/*)*/}
{/*})}*/}
{/*</Select>*/}
{/*<DatePicker*/}
{/*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===course_group_publish_times.length-1&&key<this.state.course_groups_count-1?<i className="iconfont icon-tianjiafangda color-green ml15" onClick={this.addgrouppublish}></i>:""}*/}
{/*</div>*/}
{/*)*/}
{/*})*/}
{/*:""}*/}
{/*</div>*/}
{/*</p>*/}
{is_unified_setting===true?<p className={this.state.fileListtype===true?"mt30":"mt10"}>
{newfileListtype===true&&this.state.fileListtype===false?<p className={"color-red"}>请先上传资源</p>:""}
<p className={"winth540"}>
<style>{`
.ant-checkbox-wrapper{
margin-left:0px !important;
margin-top:10px;
}
`}</style>
<div className={this.state.fileListtype===true?"mt30":""}></div><Checkbox checked={is_public} onChange={this.onChangepublic}>
<span className={"font-14"}>勾选后所有用户可见否则仅课堂成员可见</span>
</Checkbox>
{/*{this.state.course_groups_count&&this.state.course_groups_count>0?<Checkbox checked={is_unified_setting} onChange={this.onChangesetting}>*/}
{/*<span>统一设置</span><span className={"font-14 color-grey-9"}>(选中则所有分班使用相同的发布设置,否则各个单独设置)</span>*/}
{/*</Checkbox>:""}*/}
<style>{`
.Selectleft20{
margin-left: 20px !important;
width: 176px;
height: 40px;
}
#startimes .ant-calendar-picker-icon{
margin-top:-11px;
}
.resourcebox{
max-height:150px;
overflow: auto;
}
`}</style>
<div className={"resourcebox"}>
{is_unified_setting===false?
course_group_publish_times.map((item,key)=>{
return(
<div className={"mt10"} key={key}>
<Select placeholder="请选择分班名称"
value={item.course_group_id}
style={{ width: 200 }}
onChange={(e,index)=>this.selectassigngroups(e,index,key)}
>
{course_groups&&course_groups.map((item,key)=>{
return(
<Option value={item.id} key={key}>{item.name}</Option>
)
})}
</Select>
<DatePicker
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===course_group_publish_times.length-1&&key<this.state.course_groups_count-1?<i className="iconfont icon-tianjiafangda color-green ml15" onClick={this.addgrouppublish}></i>:""}
</div>
)
})
:""}
</div>
</p>
{is_unified_setting===true?<p className={"mt10"}>
<span>
<DatePicker
dropdownClassName="hideDisable"
showTime={{ format: 'HH:mm' }}
locale={locale}
format={dateFormat}
placeholder="请选择发布时间"
id={"startime"}
showToday={false}
width={"210px"}
value={datatime===undefined||datatime===""?undefined:moment(datatime, dateFormat)}
onChange={(e,index)=>this.onChangeTimepublish(e,index,undefined,1)}
disabledTime={disabledDateTime}
dropdownClassName="hideDisable"
showTime={{ format: 'HH:mm' }}
locale={locale}
format={dateFormat}
placeholder="请选择发布时间"
id={"startime"}
showToday={false}
width={"210px"}
value={datatime===undefined||datatime===""?undefined:moment(datatime, dateFormat)}
onChange={(e,index)=>this.onChangeTimepublish(e,index,undefined,1)}
disabledTime={disabledDateTime}
disabledDate={disabledDate}
/>
/>
</span>
</p>:""}
{/*{course_group_publish_timestype===true?<p className={"color-red mt10"}>请填写完整</p>:""}*/}
<textarea placeholder="请在此输入资源描述最大限制100个字符" className={"mt10"} value={this.state.description} onInput={this.settextarea} style={{
width: '100%',
height:'120px',
border:'1px solid rgba(234,234,234,1)',
padding: '10px'
}}></textarea>
{descriptiontype===true?<p className={"color-red"}>请输入资源描述最大限制100个字符</p>:""}
<div className="clearfix mt30 edu-txt-center mb10">
<a className="task-btn color-white mr70" onClick={this.props.Cancel}>{this.props.Cancelname}</a>
<a className="task-btn task-btn-orange" onClick={()=>this.Saves()}>{this.props.Savesname}</a>
</div>
</div>
</Modal>
</div>
)
}
</p>:""}
{/*{course_group_publish_timestype===true?<p className={"color-red mt10"}>请填写完整</p>:""}*/}
<textarea placeholder="请在此输入资源描述最大限制100个字符" className={"mt10"} value={this.state.description} onInput={this.settextarea} style={{
width: '100%',
height:'120px',
border:'1px solid rgba(234,234,234,1)',
padding: '10px'
}}></textarea>
{descriptiontype===true?<p className={"color-red"}>请输入资源描述最大限制100个字符</p>:""}
<div className="clearfix mt30 edu-txt-center mb10">
<a className="task-btn color-white mr70" onClick={this.props.Cancel}>{this.props.Cancelname}</a>
<a className="task-btn task-btn-orange" onClick={()=>this.Saves()}>{this.props.Savesname}</a>
</div>
</div>
</Modal>
</div>
)
}
}
export default Sendresource;

@ -35,14 +35,14 @@ if (!window['indexHOCLoaded']) {
// $('head').append($('<link rel="stylesheet" type="text/css" />')
// .attr('href', `${_url_origin}/stylesheets/educoder/antd.min.css?1525440977`));
$('head').append($('<link rel="stylesheet" type="text/css" />')
.attr('href', `${_url_origin}/stylesheets/css/edu-common.css?8`));
.attr('href', `${_url_origin}/stylesheets/css/edu-common.css?9`));
$('head').append($('<link rel="stylesheet" type="text/css" />')
.attr('href', `${_url_origin}/stylesheets/educoder/edu-main.css?8`));
.attr('href', `${_url_origin}/stylesheets/educoder/edu-main.css?9`));
// index.html有加载
$('head').append($('<link rel="stylesheet" type="text/css" />')
.attr('href', `${_url_origin}/stylesheets/educoder/edu-all.css?8`));
.attr('href', `${_url_origin}/stylesheets/educoder/edu-all.css?9`));
// $('head').append($('<link rel="stylesheet" type="text/css" />')

Loading…
Cancel
Save