hjm 5 years ago
commit c006bc7b79

@ -341,7 +341,7 @@ class Selectresource extends Component{
> >
{ {
Resourcelist === undefined ?Resourcelist.files.length===0?<NoneData/>: Resourcelist === undefined ?"":Resourcelist.files.length===0?<NoneData/>:
<Checkbox.Group style={{ width: '100%' }} value={patheditarry} onChange={this.shixunhomeworkedit}> <Checkbox.Group style={{ width: '100%' }} value={patheditarry} onChange={this.shixunhomeworkedit}>
{ {
@ -365,7 +365,7 @@ class Selectresource extends Component{
) )
}) })
} }
</Checkbox.Group>:"" </Checkbox.Group>
} }
</div> </div>

@ -1,7 +1,7 @@
import React,{ Component } from "react"; import React,{ Component } from "react";
import { Modal,Checkbox,Select,Input,Upload,Button,Icon,message,DatePicker,Tooltip} from "antd"; import { Modal,Checkbox,Select,Input,Upload,Button,Icon,message,DatePicker,Tooltip} from "antd";
import axios from'axios'; import axios from'axios';
import {getUrl,handleDateString} from 'educoder'; import {getUrl,handleDateString,appendFileSizeToUploadFileAll} from 'educoder';
import locale from 'antd/lib/date-picker/locale/zh_CN'; import locale from 'antd/lib/date-picker/locale/zh_CN';
import moment from 'moment'; import moment from 'moment';
import Modals from '../../modals/Modals'; import Modals from '../../modals/Modals';
@ -252,12 +252,12 @@ class Selectsetting extends Component{
let fileList = info.fileList; let fileList = info.fileList;
if(info.file.status!="removed"){ if(info.file.status!="removed"){
this.setState({ this.setState({
fileList, fileList: appendFileSizeToUploadFileAll(fileList),
fileListtype:true fileListtype:true
}); });
}else{ }else{
this.setState({ this.setState({
fileList, fileList: appendFileSizeToUploadFileAll(fileList),
}); });
} }
@ -290,10 +290,10 @@ class Selectsetting extends Component{
// } // }
onAttachmentRemove = (id) => { 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/${id}.json` const url = `/attachments/${file.response ? file.response.id : file.uid}.json`
axios.delete(url, { axios.delete(url, {
}) })
.then((response) => { .then((response) => {
@ -319,6 +319,9 @@ class Selectsetting extends Component{
.catch(function (error) { .catch(function (error) {
console.log(error); console.log(error);
}); });
this.setState({
fileListtype:false,
})
} }
onChangeTimepublishs= (date, dateString,key) => { onChangeTimepublishs= (date, dateString,key) => {
@ -373,7 +376,7 @@ class Selectsetting extends Component{
width: 600, width: 600,
// https://github.com/ant-design/ant-design/issues/15505 // https://github.com/ant-design/ant-design/issues/15505
// showUploadList={false},然后外部拿到 fileList 数组自行渲染列表。 // showUploadList={false},然后外部拿到 fileList 数组自行渲染列表。
showUploadList: false, // showUploadList: false,
action: `${getUrl()}/api/attachments.json`, action: `${getUrl()}/api/attachments.json`,
onChange: this.handleChange, onChange: this.handleChange,
onRemove: this.onAttachmentRemove, onRemove: this.onAttachmentRemove,
@ -591,36 +594,36 @@ class Selectsetting extends Component{
</Upload> </Upload>
</p> </p>
<style> {/*<style>*/}
{ {/*{*/}
` {/*`*/}
.maxwidth400{ {/*.maxwidth400{*/}
max-width: 400px; {/*max-width: 400px;*/}
overflow: hidden; {/*overflow: hidden;*/}
text-overflow: ellipsis; {/*text-overflow: ellipsis;*/}
white-space: nowrap; {/*white-space: nowrap;*/}
} {/*}*/}
` {/*`*/}
} {/*}*/}
</style> {/*</style>*/}
{this.state.fileList.length===0?"":this.state.fileList.map((item,key)=>{ {/*{this.state.fileList.length===0?"":this.state.fileList.map((item,key)=>{*/}
return( {/*return(*/}
<p className="color-grey mt10" key={key} > {/*<p className="color-grey mt10" key={key} >*/}
<a className="color-grey fl"> {/*<a className="color-grey fl">*/}
<i className="font-14 color-green iconfont icon-fujian mr8" aria-hidden="true"></i> {/*<i className="font-14 color-green iconfont icon-fujian mr8" aria-hidden="true"></i>*/}
</a> {/*</a>*/}
<span className="mr12 color9B9B maxwidth400 fl" length="58"> {/*<span className="mr12 color9B9B maxwidth400 fl" length="58">*/}
{item.name} {/*{item.name}*/}
</span> {/*</span>*/}
<span className="color656565 mt2 color-grey-6 font-12 mr8"> {/*<span className="color656565 mt2 color-grey-6 font-12 mr8">*/}
{item.response===undefined?"":isNaN(this.props.bytesToSize(item.response.filesize))?"123":this.props.bytesToSize(item.response.filesize)} {/*{item.response===undefined?"":isNaN(bytesToSize(item.filesize))?"123":bytesToSize(item.filesize)}*/}
</span> {/*</span>*/}
<i className="font-14 iconfont icon-guanbi " {/*<i className="font-14 iconfont icon-guanbi "*/}
id={item.response===undefined?"":item.response.id} {/*id={item.response===undefined?"":item.response.id}*/}
aria-hidden="true" onClick={()=>this.onAttachmentRemove(item.response===undefined?"":item.response.id&&item.response.id)}></i> {/*aria-hidden="true" onClick={()=>this.onAttachmentRemove(item.response===undefined?"":item.response.id&&item.response.id)}></i>*/}
</p> {/*</p>*/}
) {/*)*/}
})} {/*})}*/}
{this.state.newfileListtypes===true?<p className={"color-red"}>请先上传资源</p>:""} {this.state.newfileListtypes===true?<p className={"color-red"}>请先上传资源</p>:""}
@ -632,12 +635,13 @@ class Selectsetting extends Component{
} }
`}</style> `}</style>
<Checkbox <div className={this.state.fileListtype===true?"mt30":""}>
checked={is_public} <Checkbox
onChange={this.onChangepublics}> checked={is_public}
<span className={"font-14"}>勾选后所有用户可见否则仅课堂成员可见</span> onChange={this.onChangepublics}>
</Checkbox> <span className={"font-14"}>勾选后所有用户可见否则仅课堂成员可见</span>
</Checkbox>
</div>
{/*{this.props.has_course_groups&&this.props.has_course_groups===true?:""}*/} {/*{this.props.has_course_groups&&this.props.has_course_groups===true?:""}*/}
{/*{this.state.course_groupss&&this.state.course_groupss.length>0?<Checkbox*/} {/*{this.state.course_groupss&&this.state.course_groupss.length>0?<Checkbox*/}
{/*checked={unified_setting}*/} {/*checked={unified_setting}*/}

@ -2,7 +2,7 @@ import React,{ Component } from "react";
import { Modal,Checkbox,Upload,Button,Icon,message,DatePicker,Select,Tooltip} from "antd"; import { Modal,Checkbox,Upload,Button,Icon,message,DatePicker,Select,Tooltip} from "antd";
import axios from 'axios'; import axios from 'axios';
import Modals from '../../modals/Modals'; import Modals from '../../modals/Modals';
import {getUrl,handleDateString} from 'educoder'; import {getUrl,handleDateString,bytesToSize,appendFileSizeToUploadFileAll} from 'educoder';
import locale from 'antd/lib/date-picker/locale/zh_CN'; import locale from 'antd/lib/date-picker/locale/zh_CN';
import moment from 'moment'; import moment from 'moment';
const CheckboxGroup = Checkbox.Group; const CheckboxGroup = Checkbox.Group;
@ -85,12 +85,12 @@ class Sendresource extends Component{
let fileList = info.fileList; let fileList = info.fileList;
if(info.file.status!="removed"){ if(info.file.status!="removed"){
this.setState({ this.setState({
fileList, fileList: appendFileSizeToUploadFileAll(fileList),
fileListtype:true fileListtype:true
}); });
}else{ }else{
this.setState({ this.setState({
fileList, fileList: appendFileSizeToUploadFileAll(fileList),
}); });
} }
} }
@ -126,9 +126,9 @@ class Sendresource extends Component{
// } // }
onAttachmentRemove = (id) => { onAttachmentRemove = (file) => {
const url = `/attachments/${id}.json` const url = `/attachments/${file.response ? file.response.id : file.uid}.json`
axios.delete(url, { axios.delete(url, {
}) })
.then((response) => { .then((response) => {
@ -146,6 +146,9 @@ class Sendresource extends Component{
.catch(function (error) { .catch(function (error) {
console.log(error); console.log(error);
}); });
this.setState({
fileListtype:false,
})
} }
ModalCancelModalCancel=()=>{ ModalCancelModalCancel=()=>{
@ -322,7 +325,7 @@ class Sendresource extends Component{
const uploadProps = { const uploadProps = {
width: 600, width: 600,
showUploadList:false, // showUploadList:false,
action: `${getUrl()}/api/attachments.json`, action: `${getUrl()}/api/attachments.json`,
onChange: this.handleChange, onChange: this.handleChange,
onRemove: this.onAttachmentRemove, onRemove: this.onAttachmentRemove,
@ -427,36 +430,37 @@ class Sendresource extends Component{
</Upload> </Upload>
</p> </p>
<style> {/*<style>*/}
{ {/*{*/}
` {/*`*/}
.maxwidth400{ {/*.maxwidth400{*/}
max-width: 400px; {/*max-width: 400px;*/}
overflow: hidden; {/*overflow: hidden;*/}
text-overflow: ellipsis; {/*text-overflow: ellipsis;*/}
white-space: nowrap; {/*white-space: nowrap;*/}
} {/*}*/}
` {/*`*/}
} {/*}*/}
</style> {/*</style>*/}
{this.state.fileList.length===0?"":this.state.fileList.map((item,key)=>{ {/*{this.state.fileList.length===0?"":this.state.fileList.map((item,key)=>{*/}
return( {/*debugger*/}
<p className="color-grey mt10" key={key} > {/*return(*/}
<a className="color-grey fl"> {/*<p className="color-grey mt10" key={key} >*/}
<i className="font-14 color-green iconfont icon-fujian mr8" aria-hidden="true"></i> {/*<a className="color-grey fl">*/}
</a> {/*<i className="font-14 color-green iconfont icon-fujian mr8" aria-hidden="true"></i>*/}
<span className="mr12 color9B9B maxwidth400 fl" length="58"> {/*</a>*/}
{item.name} {/*<span className="mr12 color9B9B maxwidth400 fl" length="58">*/}
</span> {/*{item.name}*/}
<span className="color656565 mt2 color-grey-6 font-12 mr8"> {/*</span>*/}
{item.response===undefined?"":isNaN(this.props.bytesToSize(item.response.filesize))?"":this.props.bytesToSize(item.response.filesize)} {/*<span className="color656565 mt2 color-grey-6 font-12 mr8">*/}
</span> {/*{item.response===undefined?"":isNaN(bytesToSize(item.filesize))?"":bytesToSize(item.filesize)}*/}
<i className="font-14 iconfont icon-guanbi " {/*</span>*/}
id={item.response===undefined?"":item.response.id} {/*<i className="font-14 iconfont icon-guanbi "*/}
aria-hidden="true" onClick={()=>this.onAttachmentRemove(item.response===undefined?"":item.response.id&&item.response.id)}></i> {/*id={item.response===undefined?"":item.response.id}*/}
</p> {/*aria-hidden="true" onClick={()=>this.onAttachmentRemove(item.response===undefined?"":item.response.id&&item.response.id)}></i>*/}
) {/*</p>*/}
})} {/*)*/}
{/*})}*/}
{newfileListtype===true?<p className={"color-red"}>请先上传资源</p>:""} {newfileListtype===true?<p className={"color-red"}>请先上传资源</p>:""}
@ -468,7 +472,7 @@ class Sendresource extends Component{
} }
`}</style> `}</style>
<Checkbox checked={is_public} onChange={this.onChangepublic}> <div className={this.state.fileListtype===true?"mt30":""}></div><Checkbox checked={is_public} onChange={this.onChangepublic}>
<span className={"font-14"}>勾选后所有用户可见否则仅课堂成员可见</span> <span className={"font-14"}>勾选后所有用户可见否则仅课堂成员可见</span>
</Checkbox> </Checkbox>

Loading…
Cancel
Save