From 39c32919657bbd526a31db0fac1851810f238ad1 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, 2 Jul 2019 16:03:40 +0800 Subject: [PATCH] =?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/SelectResource.js | 4 +- .../courses/coursesPublic/SelectSetting.js | 88 ++++++++++--------- .../courses/coursesPublic/sendResource.js | 78 ++++++++-------- 3 files changed, 89 insertions(+), 81 deletions(-) diff --git a/public/react/src/modules/courses/coursesPublic/SelectResource.js b/public/react/src/modules/courses/coursesPublic/SelectResource.js index ef36a2ab4..84afa9e2c 100644 --- a/public/react/src/modules/courses/coursesPublic/SelectResource.js +++ b/public/react/src/modules/courses/coursesPublic/SelectResource.js @@ -341,7 +341,7 @@ class Selectresource extends Component{ > { - Resourcelist === undefined ?Resourcelist.files.length===0?: + Resourcelist === undefined ?"":Resourcelist.files.length===0?: { @@ -365,7 +365,7 @@ class Selectresource extends Component{ ) }) } - :"" + } diff --git a/public/react/src/modules/courses/coursesPublic/SelectSetting.js b/public/react/src/modules/courses/coursesPublic/SelectSetting.js index 61cbecf11..4e84bae8c 100644 --- a/public/react/src/modules/courses/coursesPublic/SelectSetting.js +++ b/public/react/src/modules/courses/coursesPublic/SelectSetting.js @@ -1,7 +1,7 @@ import React,{ Component } from "react"; import { Modal,Checkbox,Select,Input,Upload,Button,Icon,message,DatePicker,Tooltip} from "antd"; 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 moment from 'moment'; import Modals from '../../modals/Modals'; @@ -252,12 +252,12 @@ class Selectsetting extends Component{ let fileList = info.fileList; if(info.file.status!="removed"){ this.setState({ - fileList, + fileList: appendFileSizeToUploadFileAll(fileList), fileListtype:true }); }else{ 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/${id}.json` + const url = `/attachments/${file.response ? file.response.id : file.uid}.json` axios.delete(url, { }) .then((response) => { @@ -319,6 +319,9 @@ class Selectsetting extends Component{ .catch(function (error) { console.log(error); }); + this.setState({ + fileListtype:false, + }) } onChangeTimepublishs= (date, dateString,key) => { @@ -373,7 +376,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, @@ -591,36 +594,36 @@ class Selectsetting extends Component{

- - {this.state.fileList.length===0?"":this.state.fileList.map((item,key)=>{ - return( -

- - - - - {item.name} - - - {item.response===undefined?"":isNaN(this.props.bytesToSize(item.response.filesize))?"123":this.props.bytesToSize(item.response.filesize)} - - -

- ) - })} + {/**/} + {/*{this.state.fileList.length===0?"":this.state.fileList.map((item,key)=>{*/} + {/*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?

请先上传资源

:""} @@ -632,12 +635,13 @@ class Selectsetting extends Component{ } `} - - 勾选后所有用户可见,否则仅课堂成员可见 - - +
+ + 勾选后所有用户可见,否则仅课堂成员可见 + +
{/*{this.props.has_course_groups&&this.props.has_course_groups===true?:""}*/} {/*{this.state.course_groupss&&this.state.course_groupss.length>0? { + onAttachmentRemove = (file) => { - const url = `/attachments/${id}.json` + const url = `/attachments/${file.response ? file.response.id : file.uid}.json` axios.delete(url, { }) .then((response) => { @@ -146,6 +146,9 @@ class Sendresource extends Component{ .catch(function (error) { console.log(error); }); + this.setState({ + fileListtype:false, + }) } ModalCancelModalCancel=()=>{ @@ -322,7 +325,7 @@ class Sendresource extends Component{ const uploadProps = { width: 600, - showUploadList:false, + // showUploadList:false, action: `${getUrl()}/api/attachments.json`, onChange: this.handleChange, onRemove: this.onAttachmentRemove, @@ -427,36 +430,37 @@ class Sendresource extends Component{

- - {this.state.fileList.length===0?"":this.state.fileList.map((item,key)=>{ - return( -

- - - - - {item.name} - - - {item.response===undefined?"":isNaN(this.props.bytesToSize(item.response.filesize))?"":this.props.bytesToSize(item.response.filesize)} - - -

- ) - })} + {/**/} + {/*{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)}>*/} + {/*

*/} + {/*)*/} + {/*})}*/} {newfileListtype===true?

请先上传资源

:""} @@ -468,7 +472,7 @@ class Sendresource extends Component{ } `} - +
勾选后所有用户可见,否则仅课堂成员可见