hjm 6 years ago
commit a506a860e5

@ -28,24 +28,6 @@ class Fileslistitem extends Component{
this.props.Settingtypes(discussMessage.id) this.props.Settingtypes(discussMessage.id)
} }
downloadfiles=(url)=>{
axios.get((url),{responseType: 'blob'}).then((response) => {
const blob = new Blob([response.data]);
const downloadElement = document.createElement('a');
const href = window.URL.createObjectURL(blob);
// const string = Base64.decode(response.headers['content-disposition'].split('=')[1]);
const string = response.headers['content-disposition'].split('=')[1];
downloadElement.href = href;
downloadElement.download = string;
document.body.appendChild(downloadElement);
downloadElement.click();
document.body.removeChild(downloadElement) ;// 下载完成移除元素
window.URL.revokeObjectURL(href) // 释放掉blob对象
}).catch((error) => {
console.log(error)
});
}
showfiles=(value)=>{ showfiles=(value)=>{
let {discussMessage,coursesId}=this.props let {discussMessage,coursesId}=this.props
let file_id=discussMessage.id let file_id=discussMessage.id
@ -56,7 +38,15 @@ class Fileslistitem extends Component{
}, },
}).then((result)=>{ }).then((result)=>{
if(result.data.attachment_histories.length===0){ if(result.data.attachment_histories.length===0){
this.downloadfiles(result.data.url) let link = document.createElement('a');
document.body.appendChild(link);
link.href = result.data.url;
link.download = result.data.title;
//兼容火狐浏览器
let evt = document.createEvent("MouseEvents");
evt.initEvent("click", false, false);
link.dispatchEvent(evt);
document.body.removeChild(link);
}else{ }else{
this.setState({ this.setState({
Showoldfiles:true, Showoldfiles:true,

@ -548,7 +548,7 @@ class Exercisesetting extends Component{
}, },
}; };
console.log(flagPageEdit===true?polls&&polls.exercise_status===1?3:2:1) // console.log(flagPageEdit===true?polls&&polls.exercise_status===1?3:2:1)
return( return(
<div> <div>
<Modals <Modals

@ -7,6 +7,7 @@ import '../css/members.css';
import '../css/busyWork.css'; import '../css/busyWork.css';
import axios from 'axios'; import axios from 'axios';
import Modals from '../../modals/Modals'; import Modals from '../../modals/Modals';
import DownloadMessage from '../../modals/DownloadMessage';
import Studentshavecompletedthelist from './Studentshavecompletedthelist'; import Studentshavecompletedthelist from './Studentshavecompletedthelist';
import WrappedExercisesetting from './Exercisesetting'; import WrappedExercisesetting from './Exercisesetting';
import ExerciseDisplay from './ExerciseDisplay' import ExerciseDisplay from './ExerciseDisplay'
@ -112,9 +113,24 @@ class Testpapersettinghomepage extends Component{
experiment=(url)=>{ experiment=(url)=>{
axios.get(url).then((response) => { axios.get(url).then((response) => {
if(response.status === 200){ if(response.data.status&&response.data.status===-1){
window.open(url, '_blank');
}else if(response.data.status&&response.data.status===-2){
if(response.data.messages === "100"){
// 已超出文件导出的上限数量100 ),建议:
this.setState({
DownloadType:false,
DownloadMessageval:100
})
}else {
//因附件资料超过500M
this.setState({
DownloadType:false,
DownloadMessageval:500
})
}
}else {
window.open(url, '_blank');
} }
}).catch((error) => { }).catch((error) => {
console.log(error) console.log(error)
@ -152,6 +168,13 @@ class Testpapersettinghomepage extends Component{
Loadtype:false Loadtype:false
}) })
} }
Downloadcal=()=>{
this.setState({
DownloadType:false,
DownloadMessageval:undefined
})
}
render(){ render(){
let {tab,visible,Commonheadofthetestpaper}=this.state; let {tab,visible,Commonheadofthetestpaper}=this.state;
const isAdmin =this.props.isAdmin(); const isAdmin =this.props.isAdmin();
@ -159,6 +182,12 @@ class Testpapersettinghomepage extends Component{
return( return(
<div className="newMain clearfix "> <div className="newMain clearfix ">
<DownloadMessage
{...this.props}
value={this.state.DownloadMessageval}
modalCancel={this.Downloadcal}
modalsType={this.state.DownloadType}
/>
<div className={"educontent mb20"} style={{width:"1200px"}}> <div className={"educontent mb20"} style={{width:"1200px"}}>
{/* 公用的提示弹框 */} {/* 公用的提示弹框 */}
{this.state.Modalstype===true?<Modals {this.state.Modalstype===true?<Modals
@ -262,7 +291,7 @@ class Testpapersettinghomepage extends Component{
导出<i className="iconfont icon-xiajiantou font-12 ml2"></i> 导出<i className="iconfont icon-xiajiantou font-12 ml2"></i>
<ul className="drop_down_menu" style={{"right":"-34px","left":"unset","height":"auto"}}> <ul className="drop_down_menu" style={{"right":"-34px","left":"unset","height":"auto"}}>
<li><a onClick={()=>this.experiment(`/api/exercises/${this.props.match.params.Id}/exercise_lists.xlsx`)}>学生成绩</a></li> <li><a onClick={()=>this.experiment(`/api/exercises/${this.props.match.params.Id}/exercise_lists.xlsx`)}>学生成绩</a></li>
<li><a href={`/api/exercises/${this.props.match.params.Id}/export_exercise`} >空白试卷</a></li> <li><a onClick={()=>this.experiment(`/api/exercises/${this.props.match.params.Id}/export_exercise`)} >空白试卷</a></li>
<li><a onClick={()=>this.experiment(`/api/zip/export_exercises?exercise_id=${this.props.match.params.Id}${this.state.groupyslsval}`)}>学生答题试卷</a></li> <li><a onClick={()=>this.experiment(`/api/zip/export_exercises?exercise_id=${this.props.match.params.Id}${this.state.groupyslsval}`)}>学生答题试卷</a></li>
</ul> </ul>
</li>:""} </li>:""}

@ -2,7 +2,7 @@ import React,{Component} from "React";
import { Form, Select, Input, Button,Checkbox,Upload,Icon,message,Modal,Spin,Tooltip} from "antd"; import { Form, Select, Input, Button,Checkbox,Upload,Icon,message,Modal,Spin,Tooltip} from "antd";
import {Link} from 'react-router-dom'; import {Link} from 'react-router-dom';
import TPMMDEditor from '../../../tpm/challengesnew/TPMMDEditor'; import TPMMDEditor from '../../../tpm/challengesnew/TPMMDEditor';
import { WordsBtn,getUrl ,bytesToSize,getImageUrl} from 'educoder'; import { WordsBtn,getUrl ,bytesToSize,getImageUrl,appendFileSizeToUploadFileAll} from 'educoder';
import axios from 'axios'; import axios from 'axios';
import Modals from '../../../modals/Modals'; import Modals from '../../../modals/Modals';
const Search = Input.Search; const Search = Input.Search;
@ -116,12 +116,12 @@ class GraduationTasksSubmitedit extends Component{
} }
// 附件相关 START // 附件相关 START
handleChange = (info) => { handleChange = (info) => {
let fileList = info.fileList;
// for(var list of fileList ){ if (info.file.status === 'uploading') {
// console.log(list)
// } let fileList = info.fileList;
this.setState({ fileList }); this.setState({ fileList:appendFileSizeToUploadFileAll(fileList) });
}
} }
//onAttachmentRemove = (file) => { //onAttachmentRemove = (file) => {
@ -479,6 +479,18 @@ class GraduationTasksSubmitedit extends Component{
onChange: this.handleChange, onChange: this.handleChange,
onRemove: this.onAttachmentRemove, onRemove: this.onAttachmentRemove,
beforeUpload: (file) => { beforeUpload: (file) => {
// TODO 文件存在则提示并退出
let gotSameFile = false;
this.state.fileList && this.state.fileList.some((item) => {
if (item.name && item.name.startsWith(file.name)) {
gotSameFile = true;
return true
}
})
if (gotSameFile) {
this.props.showNotification("该附件已被上传!")
return false
}
console.log('beforeUpload', file.name); console.log('beforeUpload', file.name);
const isLt150M = file.size / 1024 / 1024 < 150; const isLt150M = file.size / 1024 / 1024 < 150;
if (!isLt150M) { if (!isLt150M) {

@ -2,7 +2,7 @@ import React,{Component} from "React";
import { Form, Select, Input, Button,Checkbox,Upload,Icon,message,Modal,Tooltip,Spin} from "antd"; import { Form, Select, Input, Button,Checkbox,Upload,Icon,message,Modal,Tooltip,Spin} from "antd";
import {Link} from 'react-router-dom'; import {Link} from 'react-router-dom';
import TPMMDEditor from '../../../tpm/challengesnew/TPMMDEditor'; import TPMMDEditor from '../../../tpm/challengesnew/TPMMDEditor';
import { WordsBtn,getUrl,getImageUrl,bytesToSize} from 'educoder'; import { WordsBtn,getUrl,getImageUrl,bytesToSize,appendFileSizeToUploadFileAll} from 'educoder';
import axios from 'axios'; import axios from 'axios';
import Modals from '../../../modals/Modals'; import Modals from '../../../modals/Modals';
const Search = Input.Search; const Search = Input.Search;
@ -123,12 +123,10 @@ class GraduationTasksSubmitnew extends Component{
} }
// 附件相关 START // 附件相关 START
handleChange = (info) => { handleChange = (info) => {
if (info.file.status === 'uploading') {
let fileList = info.fileList; let fileList = info.fileList;
this.setState({ fileList:appendFileSizeToUploadFileAll(fileList) });
// for(var list of fileList ){ }
// console.log(list)
// }
this.setState({ fileList });
} }
onAttachmentRemove = (file) => { onAttachmentRemove = (file) => {
@ -478,6 +476,18 @@ render(){
onChange: this.handleChange, onChange: this.handleChange,
onRemove: this.onAttachmentRemove, onRemove: this.onAttachmentRemove,
beforeUpload: (file) => { beforeUpload: (file) => {
// TODO 文件存在则提示并退出
let gotSameFile = false;
this.state.fileList && this.state.fileList.some((item) => {
if (item.name && item.name.startsWith(file.name)) {
gotSameFile = true;
return true
}
})
if (gotSameFile) {
this.props.showNotification("该附件已被上传!")
return false
}
console.log('beforeUpload', file.name); console.log('beforeUpload', file.name);
const isLt150M = file.size / 1024 / 1024 < 150; const isLt150M = file.size / 1024 / 1024 < 150;
if (!isLt150M) { if (!isLt150M) {

@ -3,7 +3,8 @@ import axios from 'axios';
// 导出实习报告批量zip 、xlsx 类型 // 导出实习报告批量zip 、xlsx 类型
export function Internshipreportsy (url,struy,types,stingtype,response){ export function Internshipreportsy (url,struy,types,stingtype){
axios.get((url),{responseType: 'blob'}).then((response) => {
const blob = new Blob([response.data], { type: stingtype }); const blob = new Blob([response.data], { type: stingtype });
const downloadElement = document.createElement('a'); const downloadElement = document.createElement('a');
const href = window.URL.createObjectURL(blob); const href = window.URL.createObjectURL(blob);
@ -14,4 +15,7 @@ export function Internshipreportsy (url,struy,types,stingtype,response){
downloadElement.click(); downloadElement.click();
document.body.removeChild(downloadElement) ;// 下载完成移除元素 document.body.removeChild(downloadElement) ;// 下载完成移除元素
window.URL.revokeObjectURL(href) // 释放掉blob对象 window.URL.revokeObjectURL(href) // 释放掉blob对象
}).catch((error) => {
console.log(error)
});
} }

@ -4,6 +4,7 @@ import {WordsBtn, ActionBtn} from 'educoder';
import TraineetraininginformationModal from './TraineetraininginformationModal'; import TraineetraininginformationModal from './TraineetraininginformationModal';
import ModulationModal from "../coursesPublic/ModulationModal"; import ModulationModal from "../coursesPublic/ModulationModal";
import HomeworkModal from "../coursesPublic/HomeworkModal"; import HomeworkModal from "../coursesPublic/HomeworkModal";
import DownloadMessage from '../../modals/DownloadMessage';
import {Base64} from 'js-base64'; import {Base64} from 'js-base64';
import {Internshipreportsy} from './Httpdownloads' import {Internshipreportsy} from './Httpdownloads'
import { import {
@ -1338,80 +1339,39 @@ class Listofworks extends Component {
} }
/// 确认是否下载 /// 确认是否下载
confirmysl(url,type){ confirmysl(url){
var struy="";
try {
struy = moment().format('YYYY-MM-DD')+"-"+moment().format('hh-mm');
struy=struy.replace(/-/g,"");
}catch (e) {
console.log(1347);
console.log(e);
}
axios.get(url).then((response) => { axios.get(url).then((response) => {
if(response !== undefined){
if(response.data.status&&response.data.status===-1){ if(response.data.status&&response.data.status===-1){
}else if(response.data.status&&response.data.status===-2){ }else if(response.data.status&&response.data.status===-2){
if(response.data.messages === "100"){
// 已超出文件导出的上限数量100 ),建议:
this.setState({
DownloadType:false,
DownloadMessageval:100
})
}else { }else {
// if(type === 1){ //因附件资料超过500M
// Internshipreportsy(url,struy,".zip",'application/zip'); this.setState({
// }else{ DownloadType:false,
Internshipreportsy(url,struy,".xlsx",'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet',response); DownloadMessageval:500
// } })
} }
}else {
window.open(url, '_blank');
} }
}).catch((error) => { }).catch((error) => {
console.log(error) console.log(error)
}); });
} }
// 导出实习报告批量
// internshipreport = (url,struy,types,stingtype)=>{
// console.log("internshipreport");
//
// axios.get((url),{responseType: 'blob'}).then((response) => {
// console.log("1350");
// console.log(response);
// const type='application/zip'//ZIP文件
// const blob = new Blob([response.data], { type: stingtype });
// const downloadElement = document.createElement('a');
// const href = window.URL.createObjectURL(blob);
// const string = Base64.decode(response.headers['content-disposition'].split('=')[1]);
// console.log(response.headers['content-disposition'].split('=')[1]);
// downloadElement.href = href;
// downloadElement.download = string+struy+types;
// document.body.appendChild(downloadElement);
// downloadElement.click();
// document.body.removeChild(downloadElement) ;// 下载完成移除元素
// window.URL.revokeObjectURL(href) // 释放掉blob对象
// }).catch((error) => {
// console.log(error)
// });
// }
// // 课堂学生成绩的导出下载
// Classstudentachievement=(url,struy)=>{
// console.log("Classstudentachievement");
// axios.get((url),{responseType: 'blob'}).then((response) => {
// console.log("1374");
// console.log(response);
// const type='application/vnd.openxmlformats-officedocument.spreadsheetml.sheet' //excel文件
// const blob = new Blob([response.data], { type: type });
// const downloadElement = document.createElement('a');
// const href = window.URL.createObjectURL(blob);
// const string = Base64.decode(response.headers['content-disposition'].split('=')[1]);
// console.log(response.headers['content-disposition'].split('=')[1]);
// downloadElement.href = href;
// downloadElement.download =string+struy+".xlsx";
// document.body.appendChild(downloadElement);
// downloadElement.click();
// document.body.removeChild(downloadElement); // 下载完成移除元素
// window.URL.revokeObjectURL(href) // 释放掉blob对象
// }).catch((error) => {
// console.log(error)
// });
// }
Downloadcal=()=>{
this.setState({
DownloadType:false,
DownloadMessageval:undefined
})
}
render() { render() {
// console.log("Listofworks.js000") // console.log("Listofworks.js000")
@ -1437,6 +1397,12 @@ class Listofworks extends Component {
updatas={() => this.isupdatas()} updatas={() => this.isupdatas()}
/> : ""} /> : ""}
<DownloadMessage
{...this.props}
value={this.state.DownloadMessageval}
modalCancel={this.Downloadcal}
modalsType={this.state.DownloadType}
/>
{visibles === true ? {visibles === true ?
<div> <div>
@ -1560,8 +1526,8 @@ class Listofworks extends Component {
{this.props.isAdmin()? <li className="li_line drop_down fr color-blue font-16 mr8 mt20" style={{"padding":"0 20px"}}> {this.props.isAdmin()? <li className="li_line drop_down fr color-blue font-16 mr8 mt20" style={{"padding":"0 20px"}}>
导出<i className="iconfont icon-xiajiantou font-12 ml2"></i> 导出<i className="iconfont icon-xiajiantou font-12 ml2"></i>
<ul className="drop_down_menu" style={{"right":"-0px","left":"unset","height":"auto"}}> <ul className="drop_down_menu" style={{"right":"-0px","left":"unset","height":"auto"}}>
<li><a onClick={()=>this.confirmysl(`/zip/shixun_report?homework_common_id=${this.props.match.params.homeworkid}&work_status=${this.state.course_groupyslstwo}&course_group=${this.state.checkedValuesineinfo}&search=${this.state.searchtext}`,1)}>实训报告</a></li> <li><a onClick={()=>this.confirmysl(`/zip/shixun_report?homework_common_id=${this.props.match.params.homeworkid}&work_status=${this.state.course_groupyslstwo}&course_group=${this.state.checkedValuesineinfo}&search=${this.state.searchtext}`)}>实训报告</a></li>
<li><a onClick={()=>this.confirmysl(`/homework_commons/${this.props.match.params.homeworkid}/works_list.xlsx?group_id=${this.state.checkedValuesineinfo}&search=${this.state.searchtext}`,2)} >学生成绩</a></li> <li><a onClick={()=>this.confirmysl(`/homework_commons/${this.props.match.params.homeworkid}/works_list.xlsx?group_id=${this.state.checkedValuesineinfo}&search=${this.state.searchtext}`)} >学生成绩</a></li>
</ul> </ul>
</li>:""} </li>:""}

@ -3,7 +3,8 @@ import CoursesListType from '../coursesPublic/CoursesListType';
import {WordsBtn,ActionBtn} from 'educoder'; import {WordsBtn,ActionBtn} from 'educoder';
import ShixunWorkModal from './Shixunworkdetails/ShixunWorkModal'; import ShixunWorkModal from './Shixunworkdetails/ShixunWorkModal';
import HomeworkModal from "../coursesPublic/HomeworkModal"; import HomeworkModal from "../coursesPublic/HomeworkModal";
import NoneData from '../coursesPublic/NoneData' import NoneData from '../coursesPublic/NoneData';
import DownloadMessage from '../../modals/DownloadMessage';
import { import {
Form, Form,
Select, Select,
@ -457,87 +458,40 @@ class ShixunStudentWork extends Component {
}) })
} }
// 导出实习报告批量 // 导出实习报告批量
internshipreport = (url) => { /// 确认是否下载
console.log("internshipreport"); confirmysl(url){
console.log("internshipreport");
var struy="";
try {
struy = moment().format('YYYY-MM-DD')+"-"+moment().format('hh-mm');
struy=struy.replace(/-/g,"");
}catch (e) {
console.log(1347);
console.log(e);
}
axios.get(url).then((response) => { axios.get(url).then((response) => {
console.log("326");
console.log(response);
if(response.data.status&&response.data.status===-1){ if(response.data.status&&response.data.status===-1){
}else if(response.data.status&&response.data.status===-2){ }else if(response.data.status&&response.data.status===-2){
if(response.data.messages === "100"){
// 已超出文件导出的上限数量100 ),建议:
}else{ this.setState({
const type='application/zip'//ZIP文件 DownloadType:false,
const blob = new Blob([response.data], { type: type }) DownloadMessageval:100
const downloadElement = document.createElement('a') })
const href = window.URL.createObjectURL(blob) }else {
const string = Base64.decode(response.headers['content-disposition'].split('=')[1]); //因附件资料超过500M
console.log(response.headers['content-disposition'].split('=')[1]); this.setState({
downloadElement.href = href DownloadType:false,
downloadElement.download = string+struy+".zip" DownloadMessageval:500
document.body.appendChild(downloadElement) })
downloadElement.click()
document.body.removeChild(downloadElement) // 下载完成移除元素
window.URL.revokeObjectURL(href) // 释放掉blob对象
}
}).catch((error) => {
console.log(error)
});
}
// 课堂学生成绩的导出下载
Classstudentachievement = (url) => {
console.log("Classstudentachievement");
// console.log();
var struy="";
try {
struy = moment().format('YYYY-MM-DD')+"-"+moment().format('hh-mm');
struy=struy.replace(/-/g,"");
}catch (e) {
console.log(1397);
console.log(e);
} }
}else {
axios.get(url).then((response) => { window.open(url, '_blank');
console.log("1374");
console.log(response);
if(response.data.status&&response.data.status===-1){
}else if(response.data.status&&response.data.status===-2){
}else{
const type='application/vnd.openxmlformats-officedocument.spreadsheetml.sheet' //excel文件
const blob = new Blob([response.data], { type: type })
const downloadElement = document.createElement('a')
const href = window.URL.createObjectURL(blob)
const string = Base64.decode(response.headers['content-disposition'].split('=')[1]);
console.log(response.headers['content-disposition'].split('=')[1]);
downloadElement.href = href
downloadElement.download =string+struy+".xlsx";
document.body.appendChild(downloadElement)
downloadElement.click()
document.body.removeChild(downloadElement) // 下载完成移除元素
window.URL.revokeObjectURL(href) // 释放掉blob对象
} }
}).catch((error) => { }).catch((error) => {
console.log(error) console.log(error)
}); });
} }
Downloadcal=()=>{
this.setState({
DownloadType:false,
DownloadMessageval:undefined
})
}
render() { render() {
let { let {
data, data,
@ -627,6 +581,13 @@ class ShixunStudentWork extends Component {
issCancel={()=>this.hideshowmodel()} issCancel={()=>this.hideshowmodel()}
updatas={()=>this.getupdata()} updatas={()=>this.getupdata()}
/>:""} />:""}
<DownloadMessage
{...this.props}
value={this.state.DownloadMessageval}
modalCancel={this.Downloadcal}
modalsType={this.state.DownloadType}
/>
{/*立即发布*/} {/*立即发布*/}
<HomeworkModal <HomeworkModal
modaltype={this.state.modaltype} modaltype={this.state.modaltype}
@ -722,9 +683,9 @@ class ShixunStudentWork extends Component {
{this.props.isAdmin() ? <li className="li_line drop_down fr color-blue font-16 mr8 mt20" style={{"padding": "0 20px"}}> {this.props.isAdmin() ? <li className="li_line drop_down fr color-blue font-16 mr8 mt20" style={{"padding": "0 20px"}}>
导出<i className="iconfont icon-xiajiantou font-12 ml2"></i> 导出<i className="iconfont icon-xiajiantou font-12 ml2"></i>
<ul className="drop_down_menu" style={{"right": "-0px", "left": "unset", "height": "auto"}}> <ul className="drop_down_menu" style={{"right": "-0px", "left": "unset", "height": "auto"}}>
<li><a onClick={()=>this.internshipreport(`/zip/shixun_report?homework_common_id=${this.props.match.params.homeworkid}`)}>实训报告</a> <li><a onClick={()=>this.confirmysl(`/zip/shixun_report?homework_common_id=${this.props.match.params.homeworkid}`)}>实训报告</a>
</li> </li>
<li><a onClick={()=>this.Classstudentachievement(`/homework_commons/${this.props.match.params.homeworkid}/works_list.xlsx`)}>学生成绩</a> <li><a onClick={()=>this.confirmysl(`/homework_commons/${this.props.match.params.homeworkid}/works_list.xlsx`)}>学生成绩</a>
</li> </li>
</ul> </ul>
</li> : ""} </li> : ""}

@ -8,6 +8,7 @@ import OfficialAcademicTranscript from './shixunreport/OfficialAcademicTranscrip
import Coursesshixundetails from './shixunreport/Coursesshixundetails'; import Coursesshixundetails from './shixunreport/Coursesshixundetails';
import Shixunechart from './shixunreport/Shixunechart'; import Shixunechart from './shixunreport/Shixunechart';
import {UnControlled as CodeMirror} from 'react-codemirror2'; import {UnControlled as CodeMirror} from 'react-codemirror2';
import DownloadMessage from '../../modals/DownloadMessage';
import 'codemirror/mode/cmake/cmake'; import 'codemirror/mode/cmake/cmake';
import 'codemirror/mode/xml/xml'; import 'codemirror/mode/xml/xml';
import 'codemirror/mode/javascript/javascript'; import 'codemirror/mode/javascript/javascript';
@ -30,46 +31,35 @@ class ShixunWorkReport extends Component {
spinning:true spinning:true
} }
} }
// 导出实习报告批量 /// 确认是否下载
internshipreport = (url) => { confirmysl(url){
console.log("internshipreport"); axios.get(url).then((response) => {
var struy=""; if(response.data.status&&response.data.status===-1){
try {
struy = moment().format('YYYY-MM-DD')+"-"+moment().format('hh-mm');
struy=struy.replace(/-/g,"");
}catch (e) {
console.log(1347);
console.log(e);
}
axios.get((url),{responseType: 'blob'}).then((response) => {
console.log("1350");
console.log(response);
if(response.status&&response.status===-1){
}else if(response.data.status&&response.data.status===-2){
if(response.data.messages === "100"){
// 已超出文件导出的上限数量100 ),建议:
}else if(response.status&&response.status===-2){ this.setState({
DownloadType:false,
}else{ DownloadMessageval:100
// window.location.href("/api"+url); })
// console.log("开始下载zip文件") }else {
const type='application/zip'//ZIP文件 //因附件资料超过500M
const blob = new Blob([response.data], { type: type }) this.setState({
const downloadElement = document.createElement('a') DownloadType:false,
const href = window.URL.createObjectURL(blob) DownloadMessageval:500
const string = Base64.decode(response.headers['content-disposition'].split('=')[1]); })
console.log(response.headers['content-disposition'].split('=')[1]); }
downloadElement.href = href }else {
downloadElement.download = string+struy+".zip" window.open(url, '_blank');
document.body.appendChild(downloadElement)
downloadElement.click()
document.body.removeChild(downloadElement) // 下载完成移除元素
window.URL.revokeObjectURL(href) // 释放掉blob对象
} }
}).catch((error) => { }).catch((error) => {
console.log(error) console.log(error)
}); });
} }
componentDidMount() { componentDidMount() {
this.setState({ this.setState({
spinning:true spinning:true
@ -103,6 +93,12 @@ class ShixunWorkReport extends Component {
} }
} }
} }
Downloadcal=()=>{
this.setState({
DownloadType:false,
DownloadMessageval:undefined
})
}
render() { render() {
let{data} =this.state; let{data} =this.state;
let category_id=data===undefined?"":data.category.category_id; let category_id=data===undefined?"":data.category.category_id;
@ -128,13 +124,18 @@ class ShixunWorkReport extends Component {
<WordsBtn className="fl">{data&&data.username}</WordsBtn> <WordsBtn className="fl">{data&&data.username}</WordsBtn>
</p> </p>
</div> </div>
<DownloadMessage
{...this.props}
value={this.state.DownloadMessageval}
modalCancel={this.Downloadcal}
modalsType={this.state.DownloadType}
/>
<div style={{ width:'100%',height:'75px'}} > <div style={{ width:'100%',height:'75px'}} >
<p className=" fl color-black mt25 summaryname">{data&&data.shixun_name}</p> <p className=" fl color-black mt25 summaryname">{data&&data.shixun_name}</p>
{/*{this.props.isAdmin()?<a className=" fr font-14 ml30 mt10 mr20 color-grey-9 ">导出实训报告数据</a>:""}*/} {/*{this.props.isAdmin()?<a className=" fr font-14 ml30 mt10 mr20 color-grey-9 ">导出实训报告数据</a>:""}*/}
{this.props.isAdmin() ? <a {this.props.isAdmin() ? <a
className="fr color-blue font-16" className="fr color-blue font-16"
onClick={()=>this.internshipreport(`/zip/shixun_report?homework_common_id=${homeworkid}`)} onClick={()=>this.confirmysl(`/zip/shixun_report?homework_common_id=${homeworkid}`)}
>导出实训报告数据</a> : ""} >导出实训报告数据</a> : ""}
</div> </div>

@ -27,7 +27,7 @@ import '../poll/pollStyle.css'
import moment from 'moment'; import moment from 'moment';
import 'moment/locale/zh-cn'; import 'moment/locale/zh-cn';
import Modals from "../../modals/Modals"; import Modals from "../../modals/Modals";
import DownloadMessage from '../../modals/DownloadMessage';
const RadioGroup = Radio.Group; const RadioGroup = Radio.Group;
//GraduationTaskssetting.js //GraduationTaskssetting.js
@ -1609,89 +1609,40 @@ class Trainingjobsetting extends Component {
showmodel:false showmodel:false
}) })
} }
// 导出实习报告批量
internshipreport = (url) => {
console.log("internshipreport");
var struy="";
try {
struy = moment().format('YYYY-MM-DD')+"-"+moment().format('hh-mm');
struy=struy.replace(/-/g,"");
}catch (e) {
console.log(1347);
console.log(e);
}
axios.get((url),{responseType: 'blob'}).then((response) => {
console.log("1350");
console.log(response);
if(response.status&&response.status===-1){
/// 确认是否下载
confirmysl(url){
axios.get(url).then((response) => {
if(response.data.status&&response.data.status===-1){
}else if(response.status&&response.status===-2){ }else if(response.data.status&&response.data.status===-2){
if(response.data.messages === "100"){
}else{ // 已超出文件导出的上限数量100 ),建议:
// window.location.href("/api"+url); this.setState({
// console.log("开始下载zip文件") DownloadType:false,
const type='application/zip'//ZIP文件 DownloadMessageval:100
const blob = new Blob([response.data], { type: type }) })
const downloadElement = document.createElement('a') }else {
const href = window.URL.createObjectURL(blob) //因附件资料超过500M
const string = Base64.decode(response.headers['content-disposition'].split('=')[1]); this.setState({
console.log(response.headers['content-disposition'].split('=')[1]); DownloadType:false,
downloadElement.href = href DownloadMessageval:500
downloadElement.download = string+struy+".zip" })
document.body.appendChild(downloadElement)
downloadElement.click()
document.body.removeChild(downloadElement) // 下载完成移除元素
window.URL.revokeObjectURL(href) // 释放掉blob对象
}
}).catch((error) => {
console.log(error)
});
}
// 课堂学生成绩的导出下载
Classstudentachievement = (url) => {
console.log("Classstudentachievement");
// console.log();
var struy="";
try {
struy = moment().format('YYYY-MM-DD')+"-"+moment().format('hh-mm');
struy=struy.replace(/-/g,"");
}catch (e) {
console.log(1397);
console.log(e);
} }
}else {
window.open(url, '_blank');
axios.get((url),{responseType: 'blob'}).then((response) => {
console.log("1374");
console.log(response);
if(response.status&&response.status===-1){
}else if(response.status&&response.status===-2){
}else{
const type='application/vnd.openxmlformats-officedocument.spreadsheetml.sheet' //excel文件
const blob = new Blob([response.data], { type: type })
const downloadElement = document.createElement('a')
const href = window.URL.createObjectURL(blob)
const string = Base64.decode(response.headers['content-disposition'].split('=')[1]);
console.log(response.headers['content-disposition'].split('=')[1]);
downloadElement.href = href
downloadElement.download =string+struy+".xlsx";
document.body.appendChild(downloadElement)
downloadElement.click()
document.body.removeChild(downloadElement) // 下载完成移除元素
window.URL.revokeObjectURL(href) // 释放掉blob对象
} }
}).catch((error) => { }).catch((error) => {
console.log(error) console.log(error)
}); });
} }
Downloadcal=()=>{
this.setState({
DownloadType:false,
DownloadMessageval:undefined
})
}
render() { render() {
@ -1725,6 +1676,14 @@ class Trainingjobsetting extends Component {
data={[]} data={[]}
issCancel={()=>this.hideshowmodel()} issCancel={()=>this.hideshowmodel()}
/>:""} />:""}
<DownloadMessage
{...this.props}
value={this.state.DownloadMessageval}
modalCancel={this.Downloadcal}
modalsType={this.state.DownloadType}
/>
{/*立即发布*/} {/*立即发布*/}
<HomeworkModal <HomeworkModal
modaltype={this.state.modaltype} modaltype={this.state.modaltype}
@ -1831,9 +1790,9 @@ class Trainingjobsetting extends Component {
{this.props.isAdmin() ? <li className="li_line drop_down fr color-blue font-16 mr8 mt20" style={{"padding": "0 20px"}}> {this.props.isAdmin() ? <li className="li_line drop_down fr color-blue font-16 mr8 mt20" style={{"padding": "0 20px"}}>
导出<i className="iconfont icon-xiajiantou font-12 ml2"></i> 导出<i className="iconfont icon-xiajiantou font-12 ml2"></i>
<ul className="drop_down_menu" style={{"right": "-0px", "left": "unset", "height": "auto"}}> <ul className="drop_down_menu" style={{"right": "-0px", "left": "unset", "height": "auto"}}>
<li><a onClick={()=>this.internshipreport(`/zip/shixun_report?homework_common_id=${this.props.match.params.homeworkid}`)}>实训报告</a> <li><a onClick={()=>this.confirmysl(`/zip/shixun_report?homework_common_id=${this.props.match.params.homeworkid}`)}>实训报告</a>
</li> </li>
<li><a onClick={()=>this.Classstudentachievement(`/homework_commons/${this.props.match.params.homeworkid}/works_list.xlsx`)}>学生成绩</a> <li><a onClick={()=>this.confirmysl(`/homework_commons/${this.props.match.params.homeworkid}/works_list.xlsx`)}>学生成绩</a>
</li> </li>
</ul> </ul>
</li>: ""} </li>: ""}

@ -1,8 +1,6 @@
import React, {Component} from "react"; import React, {Component} from "react";
import CoursesListType from '../coursesPublic/CoursesListType'; import CoursesListType from '../coursesPublic/CoursesListType';
import {WordsBtn, ActionBtn, markdownToHTML} from 'educoder'; import {WordsBtn, ActionBtn, markdownToHTML} from 'educoder';
import GraduateTopicReply from '../graduation/topics/GraduateTopicReply'
import MemoDetailMDEditortwo from '../../forums/MemoDetailMDEditortwo'
import { import {
Form, Form,
Select, Select,
@ -37,13 +35,9 @@ import CommonReply from "../common/comments/CommonReply";
import Homeworddescription from "../shixunHomework/Homeworddescription"; import Homeworddescription from "../shixunHomework/Homeworddescription";
import ShixunWorkModal from './Shixunworkdetails/ShixunWorkModal'; import ShixunWorkModal from './Shixunworkdetails/ShixunWorkModal';
import HomeworkModal from "../coursesPublic/HomeworkModal"; import HomeworkModal from "../coursesPublic/HomeworkModal";
// import Homeworddescription from "../shixunHomework/Homeworddescription"; import DownloadMessage from '../../modals/DownloadMessage';
const TextArea = Input.TextArea const TextArea = Input.TextArea
//GraduationTaskssetting.js
//作业问答页面 //作业问答页面
class Workquestionandanswer extends Component { class Workquestionandanswer extends Component {
//unifiedsetting 统一设置 //unifiedsetting 统一设置
@ -319,89 +313,38 @@ class Workquestionandanswer extends Component {
}) })
} }
/// 确认是否下载
confirmysl(url){
axios.get(url).then((response) => {
if(response.data.status&&response.data.status===-1){
// 导出实习报告批量 }else if(response.data.status&&response.data.status===-2){
internshipreport = (url) => { if(response.data.messages === "100"){
console.log("internshipreport"); // 已超出文件导出的上限数量100 ),建议:
var struy=""; this.setState({
try { DownloadType:false,
struy = moment().format('YYYY-MM-DD')+"-"+moment().format('hh-mm'); DownloadMessageval:100
struy=struy.replace(/-/g,""); })
}catch (e) { }else {
console.log(1347); //因附件资料超过500M
console.log(e); this.setState({
DownloadType:false,
DownloadMessageval:500
})
} }
}else {
axios.get((url),{responseType: 'blob'}).then((response) => { window.open(url, '_blank');
console.log("1350");
console.log(response);
if(response.status&&response.status===-1){
}else if(response.status&&response.status===-2){
}else{
// window.location.href("/api"+url);
// console.log("开始下载zip文件")
const type='application/zip'//ZIP文件
const blob = new Blob([response.data], { type: type })
const downloadElement = document.createElement('a')
const href = window.URL.createObjectURL(blob)
const string = Base64.decode(response.headers['content-disposition'].split('=')[1]);
console.log(response.headers['content-disposition'].split('=')[1]);
downloadElement.href = href
downloadElement.download = string+struy+".zip"
document.body.appendChild(downloadElement)
downloadElement.click()
document.body.removeChild(downloadElement) // 下载完成移除元素
window.URL.revokeObjectURL(href) // 释放掉blob对象
} }
}).catch((error) => { }).catch((error) => {
console.log(error) console.log(error)
}); });
} }
Downloadcal=()=>{
// 课堂学生成绩的导出下载 this.setState({
Classstudentachievement = (url) => { DownloadType:false,
console.log("Classstudentachievement"); DownloadMessageval:undefined
// console.log(); })
var struy="";
try {
struy = moment().format('YYYY-MM-DD')+"-"+moment().format('hh-mm');
struy=struy.replace(/-/g,"");
}catch (e) {
console.log(1397);
console.log(e);
}
axios.get((url),{responseType: 'blob'}).then((response) => {
console.log("1374");
console.log(response);
if(response.status&&response.status===-1){
}else if(response.status&&response.status===-2){
}else{
const type='application/vnd.openxmlformats-officedocument.spreadsheetml.sheet' //excel文件
const blob = new Blob([response.data], { type: type })
const downloadElement = document.createElement('a')
const href = window.URL.createObjectURL(blob)
const string = Base64.decode(response.headers['content-disposition'].split('=')[1]);
console.log(response.headers['content-disposition'].split('=')[1]);
downloadElement.href = href
downloadElement.download =string+struy+".xlsx";
document.body.appendChild(downloadElement)
downloadElement.click()
document.body.removeChild(downloadElement) // 下载完成移除元素
window.URL.revokeObjectURL(href) // 释放掉blob对象
}
}).catch((error) => {
console.log(error)
});
} }
render() { render() {
const dateFormat = 'YYYY-MM-DD HH:mm:ss'; const dateFormat = 'YYYY-MM-DD HH:mm:ss';
let { let {
@ -430,6 +373,12 @@ class Workquestionandanswer extends Component {
issCancel={() => this.hideshowmodel()} issCancel={() => this.hideshowmodel()}
updatas={() => this.isupdatas()} updatas={() => this.isupdatas()}
/> : ""} /> : ""}
<DownloadMessage
{...this.props}
value={this.state.DownloadMessageval}
modalCancel={this.Downloadcal}
modalsType={this.state.DownloadType}
/>
{/*立即发布*/} {/*立即发布*/}
<HomeworkModal <HomeworkModal
modaltype={this.state.modaltype} modaltype={this.state.modaltype}
@ -527,9 +476,9 @@ class Workquestionandanswer extends Component {
<li className="li_line drop_down fr color-blue font-16 mr8 mt20" style={{"padding": "0 20px"}}> <li className="li_line drop_down fr color-blue font-16 mr8 mt20" style={{"padding": "0 20px"}}>
导出<i className="iconfont icon-xiajiantou font-12 ml2"></i> 导出<i className="iconfont icon-xiajiantou font-12 ml2"></i>
<ul className="drop_down_menu" style={{"right": "-0px", "left": "unset", "height": "auto"}}> <ul className="drop_down_menu" style={{"right": "-0px", "left": "unset", "height": "auto"}}>
<li><a onClick={()=>this.internshipreport(`/zip/shixun_report?homework_common_id=${this.props.match.params.homeworkid}`)}>实训报告</a> <li><a onClick={()=>this.confirmysl(`/zip/shixun_report?homework_common_id=${this.props.match.params.homeworkid}`)}>实训报告</a>
</li> </li>
<li><a onClick={()=>this.Classstudentachievement(`/homework_commons/${this.props.match.params.homeworkid}/works_list.xlsx`)}>学生成绩</a> <li><a onClick={()=>this.confirmysl(`/homework_commons/${this.props.match.params.homeworkid}/works_list.xlsx`)}>学生成绩</a>
</li> </li>
</ul> </ul>
</li> : ""} </li> : ""}

@ -165,7 +165,7 @@ class EducoderLogin extends Component {
<div style={{"margin-top": "40px","height":"580px"}}> <div style={{"margin-top": "40px","height":"580px"}}>
<LoginRegisterComponent {...this.props} {...this.state} <LoginRegisterComponent {...this.props} {...this.state}
Setshowbool={(e)=>this.Setshowbool(e)} ></LoginRegisterComponent> Setshowbool={(e,name,pass)=>this.Setshowbool(e,name,pass)} ></LoginRegisterComponent>
</div> </div>

@ -0,0 +1,51 @@
import React, { Component } from 'react';
import {getImageUrl} from 'educoder';
import { Modal} from 'antd';
class DownloadMessage extends Component {
constructor(props) {
super(props);
this.state = {
funmodalsType:false,
istype:false
}
}
setDownload=()=>{
this.props.modalCancel();
window.open(`/users/${this.props.user.login}/private_messages`)
}
render() {
return(
<Modal
keyboard={false}
title="提示"
visible={this.props.modalsType===undefined?false:this.props.modalsType}
closable={false}
footer={null}
destroyOnClose={true}
centered={true}
width="530px"
>
<div className="task-popup-content">
{this.props.value===500?<p>
<p className="task-popup-text-center font-16">因附件资料超过500M您可以通过检索分批下载</p>
<p className="task-popup-text-center font-16 mt5">或者通过微信或者QQ联系管理员辅助您打包下载</p>
</p>:this.props.value===100?
<p>
<p className="task-popup-text-center font-16">已超出文件导出的上限数量 <span className={"color-orange-tip"}>100</span> </p>
<p className="task-popup-text-center font-16 mt20">1.通过检索分批次下载</p>
<p className="task-popup-text-center font-16 mt5">2.联系管理员辅助下载</p>
</p>
:""}
<div className="clearfix mt30 edu-txt-center">
<a className="task-btn mr30" onClick={this.props.modalCancel}>取消</a>
<a className="task-btn task-btn-orange" onClick={this.setDownload}>立即联系</a>
</div>
</div>
</Modal>
)
}
}
export default DownloadMessage;

@ -31,6 +31,42 @@ class InterestpageComponent extends Component {
passmm:this.props.passmm, passmm:this.props.passmm,
} }
} }
componentWillReceiveProps(nextProps) {
// console.log("46");
// console.log(nextProps);
// console.log(this.props);
if (nextProps.namezh != this.props.namezh) {
// console.log("50");
// console.log(nextProps.user);
if (nextProps.namezh !== undefined) {
// console.log("53");
// console.log(nextProps.user);
this.setState({
namezh: nextProps.namezh,
})
}
}
if (nextProps.passmm != this.props.passmm) {
// console.log("50");
// console.log(nextProps.user);
if (nextProps.passmm !== undefined) {
// console.log("53");
// console.log(nextProps.user);
this.setState({
passmm: nextProps.passmm,
})
}
}
}
Clickteacher=(e)=>{ Clickteacher=(e)=>{
console.log(e); console.log(e);
if(e === "teacher"){ if(e === "teacher"){
@ -98,6 +134,8 @@ class InterestpageComponent extends Component {
//跳转然后登入 //跳转然后登入
Jumptotheinterestpage=()=>{ Jumptotheinterestpage=()=>{
console.log(this.state.login);
console.log(this.state.password);
var url = "/accounts/login.json"; var url = "/accounts/login.json";
axios.post(url, { axios.post(url, {
login: this.props.login, login: this.props.login,
@ -107,16 +145,15 @@ class InterestpageComponent extends Component {
return return
} }
if (response.status === 200) { if (response.status === 200) {
if (response.data.status === 402) { // if (response.data.status === 402) {
window.location.href = response.data.url; // window.location.href = response.data.url;
} else { // } else {
broadcastChannelPostMessage('refreshPage') // broadcastChannelPostMessage('refreshPage')
this.setState({ // this.setState({
isRender: false // isRender: false
}) // })
window.location.href = "/" window.location.href = "/"
// }
}
} }

Loading…
Cancel
Save