Merge remote-tracking branch 'origin/master'

dev_forum
杨树明 5 years ago
commit ecbdfe7898

@ -110,13 +110,15 @@ class Cropper extends Component {
render() {
const { width, height, previewId, imageSrc } = this.props;
return (
<div>
{/* This rule is very important, please do not ignore this! */}
<style>{`
.wrapper {
width: ${ (width+'px') || '500px'};
height: ${ (height+'px') || '500px'};
width: ${ width ? (width+'px') : '500px'};
height: ${ height ? (height+'px') : '500px'};
border: 1px solid #eee;
}
img {
max-width: 100%;
@ -129,8 +131,11 @@ class Cropper extends Component {
}
`}</style>
<div className="wrapper">
{/* http://localhost:3007/images/footNavLogo.png 图片转了后不对 */}
<img id={this.props.imageId || "__image"} src={`${imageSrc || "/images/testPicture.jpg"}`}></img>
{/* http://localhost:3007/images/footNavLogo.png 图片转了后不对
|| "/images/testPicture.jpg"
|| "/images/shixun0.jpg"
*/}
<img id={this.props.imageId || "__image"} src={`${imageSrc }`}></img>
</div>
{/* background: 'aquamarine',
'border-radius': '128px'

@ -1350,15 +1350,22 @@ class Listofworks extends Component {
},{responseType: 'blob'}).then((response) => {
console.log("1342");
console.log(response);
var blob = new Blob([response.data])
if (response.status == 200) {
var blob = new Blob([response.data])
var downloadElement = document.createElement('a');
var href = window.URL.createObjectURL(blob); //创建下载的链接
downloadElement.href = href;
downloadElement.download = '实习报告.pdf'; //下载后文件名
document.body.appendChild(downloadElement);
downloadElement.click(); //点击下载
document.body.removeChild(downloadElement); //下载完成移除元素
let filename = response.headers.get('Content-Disposition');
if (filename) {
filename = filename.match(/\"(.*)\"/)[1]; //提取文件名
downloadElement.href = href;
downloadElement.download = filename; //下载后文件名
document.body.appendChild(downloadElement);
downloadElement.click(); //点击下载
document.body.removeChild(downloadElement); //下载完成移除元素
}
window.URL.revokeObjectURL(href); //释放掉blob对象
}
}).catch((error) => {
console.log(error)
});
@ -1377,15 +1384,21 @@ class Listofworks extends Component {
},{responseType: 'blob'}).then((response) => {
console.log("1306");
console.log(response);
if (response.status == 200) {
var blob = new Blob([response.data])
var downloadElement = document.createElement('a');
var href = window.URL.createObjectURL(blob); //创建下载的链接
downloadElement.href = href;
downloadElement.download = '课堂学生成绩.xlsx'; //下载后文件名
document.body.appendChild(downloadElement);
downloadElement.click(); //点击下载
document.body.removeChild(downloadElement); //下载完成移除元素
let filename = response.headers.get('Content-Disposition');
if (filename) {
filename = filename.match(/\"(.*)\"/)[1]; //提取文件名
downloadElement.href = href;
downloadElement.download = filename; //下载后文件名
document.body.appendChild(downloadElement);
downloadElement.click(); //点击下载
document.body.removeChild(downloadElement); //下载完成移除元素
}
window.URL.revokeObjectURL(href); //释放掉blob对象
}
}).catch((error) => {
console.log(error)
});

@ -1607,7 +1607,7 @@ class Trainingjobsetting extends Component {
showmodel:false
})
}
// 导出实习报告批量
// 导出实习报告批量
internshipreport = () => {
console.log("internshipreport");
var homeworkid = this.props.match.params.homeworkid;
@ -1616,14 +1616,26 @@ class Trainingjobsetting extends Component {
params: {
homework_common_id: homeworkid,
}
}).then((response) => {
console.log("1593");
},{responseType: 'blob'}).then((response) => {
console.log("326");
console.log(response);
var blob = new Blob([response.data])
var downloadElement = document.createElement('a');
var href = window.URL.createObjectURL(blob); //创建下载的链接
let filename = response.headers.get('Content-Disposition');
if (filename) {
filename = filename.match(/\"(.*)\"/)[1]; //提取文件名
downloadElement.href = href;
downloadElement.download = filename; //下载后文件名
document.body.appendChild(downloadElement);
downloadElement.click(); //点击下载
document.body.removeChild(downloadElement); //下载完成移除元素
}
window.URL.revokeObjectURL(href); //释放掉blob对象
}).catch((error) => {
console.log(error)
});
}
// 课堂学生成绩的导出下载
@ -1631,9 +1643,22 @@ class Trainingjobsetting extends Component {
console.log("Classstudentachievement");
const course_id = this.props.match.params.coursesId;
let url = "/courses/" + course_id + "/export_member_scores_excel.xlsx";
axios.get(url).then((response) => {
console.log("1607");
axios.get((url),{responseType: 'blob'}).then((response) => {
console.log("339");
console.log(response);
var blob = new Blob([response.data])
var downloadElement = document.createElement('a');
var href = window.URL.createObjectURL(blob); //创建下载的链接
let filename = response.headers.get('Content-Disposition');
if (filename) {
filename = filename.match(/\"(.*)\"/)[1]; //提取文件名
downloadElement.href = href;
downloadElement.download = filename; //下载后文件名
document.body.appendChild(downloadElement);
downloadElement.click(); //点击下载
document.body.removeChild(downloadElement); //下载完成移除元素
}
window.URL.revokeObjectURL(href); //释放掉blob对象
}).catch((error) => {
console.log(error)

@ -327,9 +327,22 @@ class Workquestionandanswer extends Component {
params: {
homework_common_id: homeworkid,
}
}).then((response) => {
},{responseType: 'blob'}).then((response) => {
console.log("326");
console.log(response);
var blob = new Blob([response.data])
var downloadElement = document.createElement('a');
var href = window.URL.createObjectURL(blob); //创建下载的链接
let filename = response.headers.get('Content-Disposition');
if (filename) {
filename = filename.match(/\"(.*)\"/)[1]; //提取文件名
downloadElement.href = href;
downloadElement.download = filename; //下载后文件名
document.body.appendChild(downloadElement);
downloadElement.click(); //点击下载
document.body.removeChild(downloadElement); //下载完成移除元素
}
window.URL.revokeObjectURL(href); //释放掉blob对象
}).catch((error) => {
console.log(error)
@ -341,9 +354,22 @@ class Workquestionandanswer extends Component {
console.log("Classstudentachievement");
const course_id = this.props.match.params.coursesId;
let url = "/courses/" + course_id + "/export_member_scores_excel.xlsx";
axios.get(url).then((response) => {
axios.get((url),{responseType: 'blob'}).then((response) => {
console.log("339");
console.log(response);
var blob = new Blob([response.data])
var downloadElement = document.createElement('a');
var href = window.URL.createObjectURL(blob); //创建下载的链接
let filename = response.headers.get('Content-Disposition');
if (filename) {
filename = filename.match(/\"(.*)\"/)[1]; //提取文件名
downloadElement.href = href;
downloadElement.download = filename; //下载后文件名
document.body.appendChild(downloadElement);
downloadElement.click(); //点击下载
document.body.removeChild(downloadElement); //下载完成移除元素
}
window.URL.revokeObjectURL(href); //释放掉blob对象
}).catch((error) => {
console.log(error)

@ -75,9 +75,11 @@ export function TPMIndexHOC(WrappedComponent) {
// header里面需要有user
initCommonState(user) {
// 更新头像后,需要改变参数,不然会被图片缓存影响到
const newUser = Object.assign({}, {...user}, { image_url: `${user.image_url}?t=${new Date().getTime()}`});
this.setState({
user,
current_user: user
user: newUser,
current_user: newUser
})
}
showShixun = () => {
@ -230,7 +232,7 @@ export function TPMIndexHOC(WrappedComponent) {
/**
课堂权限相关方法暂时写这里了 ----------------------------------------END
*/
fetchUser() {
fetchUser = () => {
let url = `/users/get_user_info.json`
let courseId;
let query = this.props.location.pathname;
@ -289,7 +291,8 @@ export function TPMIndexHOC(WrappedComponent) {
isStudent: this.isStudent,
isAdminOrStudent: this.isAdminOrStudent,
isNotMember: this.isNotMember,
isUserid:this.state.coursedata&&this.state.coursedata.userid
isUserid:this.state.coursedata&&this.state.coursedata.userid,
fetchUser: this.fetchUser
}
return (
<div>

@ -51,11 +51,11 @@ class AccountPage extends Component {
}
getBasicInfo=(login)=>{
let url=`/users/accounts/${login}.json`;
let url=`/users/accounts/${login || this.props.current_user.login}.json`;
axios.get(url).then((result)=>{
if(result.data){
this.setState({
basicInfo:result.data
basicInfo: Object.assign({}, {...result.data}, { avatar_url: `${result.data.avatar_url}?t=${new Date().getTime()}`})
})
if(result.data && result.data.base_info_completed == false){
this.props.history.push(`/account/basic/edit`);

@ -2,14 +2,16 @@ import React, { Component } from 'react';
import { SnackbarHOC, getImageUrl } from 'educoder';
import ChangeHeaderPicModal from './ChangeHeaderPicModal'
class AccountNav extends Component {
class AccountImg extends Component {
editImg = () => {
this.refs['picModal'].setVisible(true)
}
render() {
const picUrl = getImageUrl("images/"+this.props.src)
return (
<div className="headphoto mt14">
<ChangeHeaderPicModal {...this.props} ref="picModal"></ChangeHeaderPicModal>
<ChangeHeaderPicModal
{...this.props} ref="picModal" imageSrc={picUrl} userLogin={this.props.current_user ? this.props.current_user.login : '' }></ChangeHeaderPicModal>
<style>{`
/*
.headphoto {
@ -47,11 +49,11 @@ class AccountNav extends Component {
display: block;
}
`}</style>
<img alt="头像" id="user_avatar_show" nhname="avatar_image" src={`${getImageUrl("images/"+this.props.src)}`}></img>
<img alt="头像" id="user_avatar_show" nhname="avatar_image" src={`${picUrl}`}></img>
<p className="headphoto-black" onClick={this.editImg} >修改头像</p>
</div>
);
}
}
export default AccountNav;
export default AccountImg;

@ -22,7 +22,7 @@ class AccountNav extends Component {
return (
<div className="accountNav fl">
<div className="accountInfo">
<AccountImg src={basicInfo && basicInfo.avatar_url}></AccountImg>
<AccountImg src={basicInfo && basicInfo.avatar_url} {...this.props}></AccountImg>
<span className="name">{basicInfo && basicInfo.name}</span>
<span className="role">{basicInfo && basicInfo.technical_title}</span>
</div>

@ -28,6 +28,10 @@ class ChangeHeaderPicModal extends Component{
file = files[0];
if (/^image\/\w+/.test(file.type)) {
if (file.size > 2 * 1024 * 1024) {
this.props.showNotification && this.props.showNotification("仅支持文件大小小于2M的文件")
return;
}
uploadedImageType = file.type;
uploadedImageName = file.name;
@ -41,7 +45,6 @@ class ChangeHeaderPicModal extends Component{
// cropper = new Cropper(image, options);
inputImage.value = null;
} else {
this.props.showNotification && this.props.showNotification("请选择一个图片格式的文件")
// window.alert('Please choose an image file.');
}
@ -72,14 +75,16 @@ class ChangeHeaderPicModal extends Component{
var dataUrl = canvas.toDataURL("image/jpeg");
console.log(dataUrl)
const url = `/users/accounts/${this.props.userLogin || 'kosasa'}/avatar.json`
const url = `/users/accounts/${this.props.userLogin}/avatar.json`
axios.put(url, {
image: dataUrl
})
.then((response) => {
// {"status":0,"message":"success","avatar_url":"avatars/User/15739"}
if (response.data.status == 0) {
// this.props.getBasicInfo()
this.props.fetchUser()
// 头像更新后会触发AccountPage的DidUpdate然后会调用getBasicInfo
this.props.showNotification && this.props.showNotification("修改头像成功")
this.setVisible(false)
}
@ -111,6 +116,7 @@ class ChangeHeaderPicModal extends Component{
text-align: center;
width: 120px;
height: 120px;
border: 1px solid #eee;
}
.previewWrap {
flex-direction: column;
@ -121,10 +127,14 @@ class ChangeHeaderPicModal extends Component{
}
.changeHeaderModal .tip {
color: #9B9B9B;
margin-top: 4px;
}
.changeHeaderModal .cropperWrap .tip {
display: inline-block;
}
.previewWrap .tip {
text-align: center;
margin-top: 2px;
margin-top: 4px;
}
#uploadBtn {
color: #4CACFF;
@ -134,8 +144,9 @@ class ChangeHeaderPicModal extends Component{
}
`}</style>
<div className="df">
<div>
<div className="cropperWrap">
<Cropper
imageSrc={''}
ref="cropper"
imageId={imageId}
previewId="changeHeader_imagePreview"

Loading…
Cancel
Save