From c7dad0d3ef8acb1f0d3a6458a785d92ca43bce77 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=A8=E6=A0=91=E6=9E=97?= <904079904@qq.com> Date: Mon, 9 Mar 2020 20:17:39 +0800 Subject: [PATCH 1/3] =?UTF-8?q?=E8=B0=83=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- public/react/src/modules/courses/Index.js | 4 +- .../src/modules/courses/Resource/index.js | 62 ++- .../courses/coursesPublic/sendResources.js | 508 ++++++++++++++++++ 3 files changed, 567 insertions(+), 7 deletions(-) create mode 100644 public/react/src/modules/courses/coursesPublic/sendResources.js diff --git a/public/react/src/modules/courses/Index.js b/public/react/src/modules/courses/Index.js index fb4afd436..8a21e76da 100644 --- a/public/react/src/modules/courses/Index.js +++ b/public/react/src/modules/courses/Index.js @@ -10,7 +10,7 @@ import { CNotificationHOC } from './common/CNotificationHOC' import {ImageLayerOfCommentHOC} from '../page/layers/ImageLayerOfCommentHOC' import "./css/Courses.css" //引入对应跳转的组件 - +//里面有资源 const ListPageIndex = Loadable({ loader: () => import('./ListPageIndex'), loading:Loading, @@ -964,4 +964,4 @@ class CoursesIndex extends Component{ } } -export default withRouter(ImageLayerOfCommentHOC({imgSelector: '.imageLayerParent img, .imageLayerParent .imageTarget', parentSelector: '.newMain'}) (CNotificationHOC() ( SnackbarHOC() ( TPMIndexHOC(CoursesIndex) )))); \ No newline at end of file +export default withRouter(ImageLayerOfCommentHOC({imgSelector: '.imageLayerParent img, .imageLayerParent .imageTarget', parentSelector: '.newMain'}) (CNotificationHOC() ( SnackbarHOC() ( TPMIndexHOC(CoursesIndex) )))); diff --git a/public/react/src/modules/courses/Resource/index.js b/public/react/src/modules/courses/Resource/index.js index 8187cd5af..250d643dc 100644 --- a/public/react/src/modules/courses/Resource/index.js +++ b/public/react/src/modules/courses/Resource/index.js @@ -6,6 +6,8 @@ import Modals from '../../modals/Modals'; import Sendtofilesmodal from "../coursesPublic/SendToFilesModal"; import Selectresource from "../coursesPublic/SelectResource"; import Sendresource from "../coursesPublic/sendResource"; +import SendResources from "../coursesPublic/sendResources"; + import Selectsetting from "../coursesPublic/SelectSetting"; import HomeworkModal from "../coursesPublic/HomeworkModal"; import Fileslistitem from './Fileslistitem'; @@ -34,7 +36,9 @@ class Fileslists extends Component{ name:"", sendTotype:false, Accessoryvisible:false, - discussMessageid:undefined, + Addanexternallink:false, + Exterchainname:"添加外链", + discussMessageid:undefined, course_modules:undefined, has_course_groups:false, course_is_public:undefined, @@ -570,6 +574,35 @@ class Fileslists extends Component{ }) } + //添加外链资源设置 + sendResourcessls = (ints,bool) => { + if(bool===true){ + + if(ints===1){ + this.setState({ + Addanexternallink:true, + Exterchainname:"添加外链" + }) + + }else{ + this.setState({ + Addanexternallink:true, + Exterchainname:"资源设置" + }) + + } + + + }else{ + this.setState({ + Addanexternallink:false, + }) + } + + } + + + Cancelvisible=()=>{ @@ -729,7 +762,9 @@ class Fileslists extends Component{ course_is_public, filesId, child, - sort + sort, + Addanexternallink, + Exterchainname } = this.state; let category_id= this.props.match.params.category_id; @@ -781,7 +816,7 @@ class Fileslists extends Component{ loadtype={Loadtype} />:""} { - shixunmodal===true||Accessoryvisible===true||Settingtype===true? + +
+ 资源名称: + + + +
+ { + resourcesnamebool? +请输入资源名称
+ : + "" + } ++ 链接地址: + +
+ { + resourceurlbool? +请输入外链url
+ : + "" + } + + ++ + + {this.props.course_is_public===true?
请填写完整
:""}*/} + +请输入资源描述,最大限制100个字符
:""} + {this.state.Radiovaluetype===true?发布时间不能为空
:""} + + + + + + ) + } +} +export default sendResources; From f87becc4967af7a8a2ec427e53cc236d9e50edaf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=A8=E6=A0=91=E6=9E=97?= <904079904@qq.com> Date: Mon, 9 Mar 2020 22:07:52 +0800 Subject: [PATCH 2/3] =?UTF-8?q?=E8=B5=84=E6=BA=90=E6=8F=8F=E8=BF=B0?= =?UTF-8?q?=E6=96=B9=E9=9D=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../modules/courses/Resource/Fileslistitem.js | 298 ++++++++++++------ .../src/modules/courses/Resource/index.js | 23 +- .../courses/coursesPublic/sendResources.js | 77 +++-- 3 files changed, 274 insertions(+), 124 deletions(-) diff --git a/public/react/src/modules/courses/Resource/Fileslistitem.js b/public/react/src/modules/courses/Resource/Fileslistitem.js index 53f607b2e..37dd95298 100644 --- a/public/react/src/modules/courses/Resource/Fileslistitem.js +++ b/public/react/src/modules/courses/Resource/Fileslistitem.js @@ -1,6 +1,6 @@ -import React,{ Component } from "react"; -import { WordsBtn } from 'educoder'; -import {Tooltip,message} from 'antd'; +import React, {Component} from "react"; +import {WordsBtn} from 'educoder'; +import {Tooltip, message} from 'antd'; import {Link} from 'react-router-dom'; import {getImageUrl} from 'educoder'; import axios from 'axios' @@ -10,25 +10,40 @@ import CoursesListType from '../coursesPublic/CoursesListType'; import Showoldfiles from "../coursesPublic/Showoldfiles"; import Modals from '../../modals/Modals'; -class Fileslistitem extends Component{ - constructor(props){ +class Fileslistitem extends Component { + constructor(props) { super(props); - this.state = { - - } + this.state = {} } - settingList=()=>{ - let {discussMessage}=this.props + settingList = (bools) => { + let {discussMessage} = this.props this.setState({ - discussMessageid:discussMessage.id + discussMessageid: discussMessage.id }) - this.props.Settingtypes(discussMessage.id) - } + if (bools === true) { + this.props.Settingtypes(discussMessage.id) + } else { + this.props.Settingtypess(discussMessage.id) + } - showfiles=(list)=>{ - if(this.props.checkIfLogin()===false){ + } + //外链 + showfiless = (url,id) => { + window.open(url) + let urls=`/files/${id}/update_visits.json`; + axios.post(urls,{ + }).then((result)=>{ + if(result.data.status===0){ + this.props.Updateresourcepage() + }else{ + this.props.showNotification(result.data.message); + } + }) + } + showfiles = (list) => { + if (this.props.checkIfLogin() === false) { this.props.showLoginDialog() return } @@ -43,21 +58,21 @@ class Fileslistitem extends Component{ // return // } - if(list.is_history_file===false){ + if (list.is_history_file === false) { // this.props.DownloadFileA(list.title,list.url) //window.location.href=list.url; window.open(list.url, '_blank'); - }else{ - let {discussMessage,coursesId}=this.props - let file_id=discussMessage.id - let url="/files/"+file_id+"/histories.json" - axios.get(url,{ - params:{ - course_id:coursesId + } else { + let {discussMessage, coursesId} = this.props + let file_id = discussMessage.id + let url = "/files/" + file_id + "/histories.json" + axios.get(url, { + params: { + course_id: coursesId }, - }).then((result)=>{ + }).then((result) => { - if(result.data.attachment_histories.length===0){ + if (result.data.attachment_histories.length === 0) { // if(result.data.is_pdf===true){ // this.props.ShowOnlinePdf(result.data.url) // //预览pdf @@ -66,64 +81,66 @@ class Fileslistitem extends Component{ // } // this.props.DownloadFileA(result.data.title,result.data.url) window.open(list.url, '_blank'); - }else{ + } else { this.setState({ - Showoldfiles:true, - allfiles:result.data + Showoldfiles: true, + allfiles: result.data }) } - }).catch((error)=>{ + }).catch((error) => { console.log(error) }) } } - closaoldfilesprops=()=>{ + closaoldfilesprops = () => { this.setState({ - Showoldfiles:false, + Showoldfiles: false, }) } onDelete = (id) => { this.setState({ - Modalstype:true, - Modalstopval:"是否确认删除?", - ModalCancel:this.cancelmodel, - ModalSave:()=>this.savedelete(id), + Modalstype: true, + Modalstopval: "是否确认删除?", + ModalCancel: this.cancelmodel, + ModalSave: () => this.savedelete(id), }) } - cancelmodel=()=>{ + cancelmodel = () => { this.setState({ - Modalstype:false, - Loadtype:false, - Modalstopval:"", - ModalCancel:"", - ModalSave:"", - checkBoxValues:[], + Modalstype: false, + Loadtype: false, + Modalstopval: "", + ModalCancel: "", + ModalSave: "", + checkBoxValues: [], }) } - savedelete=(id)=>{ + savedelete = (id) => { this.setState({ - Modalstype:false, + Modalstype: false, }) const cid = this.props.match.params.coursesId const url = `/files/bulk_delete.json`; - axios.delete(url, { data: { - course_id:cid, + axios.delete(url, { + data: { + course_id: cid, ids: [id], - }}) + } + }) .then((response) => { if (response.data.status == 0) { //Modalstopval:response.data.message, @@ -132,11 +149,11 @@ class Fileslistitem extends Component{ this.setState({ // Modalstype:true, // Modalstopval:"删除成功", - ModalsBottomval:"", + ModalsBottomval: "", // ModalSave:this.cancelmodel, // Loadtype:true, - checkBoxValues:[], - checkAllValue:false + checkBoxValues: [], + checkAllValue: false }) this.props.showNotification("删除成功"); @@ -147,28 +164,30 @@ class Fileslistitem extends Component{ }); } - eventStop = (event) =>{ + eventStop = (event) => { event.stopPropagation() } - render(){ + render() { - const { checkBox, - discussMessage,index + const { + checkBox, + discussMessage, index } = this.props; - return( + let bools = discussMessage.link && discussMessage.link ? false : true; + return (外链
+ : + "" } - {discussMessage.is_publish===false?