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] =?UTF-8?q?=E8=B5=84=E6=BA=90=E6=8F=8F=E8=BF=B0=E6=96=B9?= =?UTF-8?q?=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?