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 (
{/*提示*/}
- {this.state.Modalstype&&this.state.Modalstype===true?
:""}
+ /> : ""}
- window.$(`.sourceitem${index} input`).click() }>
-
this.eventStop(event)}>
+ window.$(`.sourceitem${index} input`).click()}>
+
-
-
资源描述 :{discussMessage.description===null?"暂无描述":discussMessage.description}
+
资源描述 :{discussMessage.description === null ? "暂无描述" : discussMessage.description}
{/*
*/}
{/*/!**!/*/}
{/**/}
@@ -365,4 +464,5 @@ class Fileslistitem extends Component{
)
}
}
+
export default Fileslistitem;
diff --git a/public/react/src/modules/courses/Resource/index.js b/public/react/src/modules/courses/Resource/index.js
index 250d643dc..ee6dc5750 100644
--- a/public/react/src/modules/courses/Resource/index.js
+++ b/public/react/src/modules/courses/Resource/index.js
@@ -597,14 +597,22 @@ class Fileslists extends Component{
this.setState({
Addanexternallink:false,
})
+ if(ints===1){
+ this.Updateresourcepage();
+ }
+
}
}
+ Updateresourcepage=()=>{
+ let{pagesize,tagname,searchValue,page,sort,sorttype,coursesecondcategoryid}=this.state;
+ this.getfileslist(pagesize,page,tagname,searchValue,sort,sorttype,coursesecondcategoryid);
+ }
- Cancelvisible=()=>{
+ Cancelvisible=()=>{
this.setState({
Accessoryvisible:false,
@@ -620,6 +628,14 @@ class Fileslists extends Component{
})
}
+ Settingtypess=(id)=>{
+ this.setState({
+ Addanexternallink:true,
+ Exterchainname:"资源设置",
+ discussMessageid:id,
+ })
+ }
+
moveTos=(id)=>{
let {checkBoxValues} = this.state;
@@ -863,9 +879,10 @@ class Fileslists extends Component{
{...this.state}
modalname={Exterchainname}
visible={Addanexternallink}
+ discussMessageid={discussMessageid}
Cancelname={"取消"}
Savesname={"确认"}
- Cancel={()=>this.sendResourcessls(1,false)}
+ Cancel={()=>this.sendResourcessls(2,false)}
categoryid={category_id}
setupdate={(ints,bool)=>this.sendResourcessls(ints,bool)}
has_course_groups={this.state.has_course_groups}
@@ -1049,11 +1066,13 @@ class Fileslists extends Component{
{...this.props}
{...this.state}
discussMessage={item}
+ Updateresourcepage={()=>this.Updateresourcepage()}
isAdmin={this.props.isAdmin()}
isStudent={this.props.isStudent()}
isNotMember={this.props.isNotMember()}
checkBox={this.props.isAdmin()?:""}
Settingtypes={(id)=>this.Settingtypes(id)}
+ Settingtypess={(id)=>this.Settingtypess(id)}
coursesId={this.props.match.params.coursesId}
updatafiledfun={()=>this.updatafiled()}
index={index}
diff --git a/public/react/src/modules/courses/coursesPublic/sendResources.js b/public/react/src/modules/courses/coursesPublic/sendResources.js
index 2927fc1b0..6bbe308f9 100644
--- a/public/react/src/modules/courses/coursesPublic/sendResources.js
+++ b/public/react/src/modules/courses/coursesPublic/sendResources.js
@@ -133,7 +133,7 @@ class sendResources extends Component{
this.props.Cancel()
}
Saves=()=>{
- debugger
+
let {resourcesname,resourceurl,description,is_public,datatime,Radiovalue} =this.state;
const reg = /^[\s\S]*.*[^\s][\s\S]*$/;
@@ -178,30 +178,61 @@ class sendResources extends Component{
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,
- is_public:is_public,
- publish_time:Radiovalue===1?datatime===undefined? undefined:datatime:undefined,
- description:description,
- delay_publish:Radiovalue,
- }).then((result)=>{
+ if(this.props.Exterchainname==="资源设置"){
+ //设置
+ let coursesId=this.props.match.params.coursesId;
+ let attachmentId=this.props.attachmentId;
+ let url="/files/"+this.props.discussMessageid+".json";
+
+ axios.put(url,{
+ name:resourcesname,
+ link:resourceurl,
+ course_id:coursesId,
+ course_second_category_id:this.props.coursesidtype===undefined||this.props.coursesidtype==="node"?0:attachmentId,
+ is_public:is_public,
+ publish_time:Radiovalue===1?datatime===undefined? undefined:datatime:undefined,
+ description:description,
+ delay_publish:Radiovalue,
+ }).then((result)=>{
+ if(result.data.status===0){
+ this.ModalCancelModalCancel();
+ this.props.updataleftNavfun();
+ this.props.showNotification("设置资源成功");
+ this.props.setupdate(1,false)
+ }else{
+ this.props.showNotification(result.data.message);
+ }
+ })
+ }else{
+ let coursesId=this.props.match.params.coursesId;
+ let attachmentId=this.props.attachmentId;
+ let url="/files/upload.json";
+
+
+ axios.post(url,{
+ name:resourcesname,
+ link:resourceurl,
+ course_id:coursesId,
+ course_second_category_id:this.props.coursesidtype===undefined||this.props.coursesidtype==="node"?0:attachmentId,
+ is_public:is_public,
+ publish_time:Radiovalue===1?datatime===undefined? undefined:datatime:undefined,
+ description:description,
+ delay_publish:Radiovalue,
+ }).then((result)=>{
+
+
+ if(result.data.status===0){
+ this.ModalCancelModalCancel();
+ this.props.updataleftNavfun();
+ this.props.showNotification("上传资源成功");
+ this.props.setupdate(1,false)
+ }else{
+ this.props.showNotification(result.data.message);
+ }
+ })
- if(result.data.status===0){
- this.ModalCancelModalCancel();
- this.props.updataleftNavfun();
- this.props.showNotification("上传资源成功");
- this.props.setupdate(this.props.attachmentId)
- }else{
- this.props.showNotification(result.data.message);
- }
- })
+ }