@ -1,9 +1,12 @@
import '../../katex.css' ;
import React , { Component } from "react" ;
import React , { Component } from "react" ;
import { getImageUrl , markdownToHTML , WordsBtn , getUrl } from 'educoder' ;
import { getImageUrl , markdownToHTML , WordsBtn , getUrl } from 'educoder' ;
import { Tooltip } from 'antd'
import { Tooltip } from 'antd' ;
import TPMMDEditor from '../../../tpm/challengesnew/TPMMDEditor'
import TPMMDEditor from '../../../tpm/challengesnew/TPMMDEditor' ;
import axios from 'axios'
import axios from 'axios' ;
import moment from 'moment'
import moment from 'moment' ;
import showdown from 'showdown' ;
import showdownKatex from 'showdown-katex' ;
const _origin = ''
const _origin = ''
/ * *
/ * *
https : //www.showdoc.cc/127895880302646?page_id=1962215317836957
https : //www.showdoc.cc/127895880302646?page_id=1962215317836957
@ -14,7 +17,7 @@ const REFUSE = 4
class CCommentItem extends Component {
class CCommentItem extends Component {
constructor ( props ) {
constructor ( props ) {
super ( props ) ;
super ( props ) ;
this . state = {
this . state = {
show _reply : false ,
show _reply : false ,
show _appeal : false ,
show _appeal : false ,
@ -46,7 +49,7 @@ class CCommentItem extends Component{
let { item , commentIndex } = this . props ;
let { item , commentIndex } = this . props ;
const url = ` /student_works/ ${ studentWorkId } /cancel_appeal.json `
const url = ` /student_works/ ${ studentWorkId } /cancel_appeal.json `
axios . post ( url , {
axios . post ( url , {
score _id : item . id
score _id : item . id
} )
} )
. then ( ( response ) => {
. then ( ( response ) => {
@ -57,7 +60,7 @@ class CCommentItem extends Component{
} )
} )
. catch ( function ( error ) {
. catch ( function ( error ) {
console . log ( error ) ;
console . log ( error ) ;
} ) ;
} ) ;
}
}
} )
} )
}
}
@ -77,7 +80,7 @@ class CCommentItem extends Component{
comment : this . state . secondReplyContent
comment : this . state . secondReplyContent
} ) . then ( ( result ) => {
} ) . then ( ( result ) => {
if ( result . data . status == 0 ) {
if ( result . data . status == 0 ) {
this . props . replySuccess ( )
this . props . replySuccess ( )
this . cancelReply ( )
this . cancelReply ( )
}
}
} ) . catch ( ( error ) => {
} ) . catch ( ( error ) => {
@ -92,7 +95,7 @@ class CCommentItem extends Component{
if ( result . data . status == 0 ) {
if ( result . data . status == 0 ) {
this . props . replySuccess ( )
this . props . replySuccess ( )
this . cancelAppeal ( )
this . cancelAppeal ( )
}
}
} ) . catch ( ( error ) => {
} ) . catch ( ( error ) => {
console . log ( error )
console . log ( error )
@ -118,14 +121,14 @@ class CCommentItem extends Component{
} )
} )
. catch ( function ( error ) {
. catch ( function ( error ) {
console . log ( error ) ;
console . log ( error ) ;
} ) ;
} ) ;
}
}
} )
} )
}
}
on _deal _appeal _score = ( mode , item ) => {
on _deal _appeal _score = ( mode , item ) => {
this . props . confirm ( {
this . props . confirm ( {
// content: `确认要删除所选的${len}个帖子吗?`,
// content: `确认要删除所选的${len}个帖子吗?`,
content :
content :
< div >
< div >
< div > { mode == ACCEPT ? '此匿评成绩将被废弃,评阅人的作品将被违规扣分' : '此匿评成绩将被认为合理' } < / d i v >
< div > { mode == ACCEPT ? '此匿评成绩将被废弃,评阅人的作品将被违规扣分' : '此匿评成绩将被认为合理' } < / d i v >
< div > 是否确认 { mode == ACCEPT ? '接受申诉' : '拒绝申诉' } < / d i v >
< div > 是否确认 { mode == ACCEPT ? '接受申诉' : '拒绝申诉' } < / d i v >
@ -146,13 +149,39 @@ class CCommentItem extends Component{
} )
} )
. catch ( function ( error ) {
. catch ( function ( error ) {
console . log ( error ) ;
console . log ( error ) ;
} ) ;
} ) ;
}
}
} )
} )
}
}
parseCommentContent = ( oldContent ) => {
parseCommentContent = ( oldContent ) => {
return markdownToHTML ( oldContent ) ;
return markdownToHTML ( oldContent ) ;
}
}
exportMdtoHtml = ( md ) => {
let newmd = md ;
newmd = newmd . replace ( /TOC/g , '' ) ;
newmd = newmd . replace ( /\[|]/g , '' ) ;
newmd = newmd . replace ( /`/g , '' ) ;
newmd = newmd . replace ( /`/g , '' ) ;
newmd = newmd . replace ( /"/g , '' ) ;
newmd = newmd . replace ( /"/g , '' ) ;
newmd = newmd . replace ( /"/g , '' ) ;
const converter = new showdown . Converter ( {
extensions : [
showdownKatex ( {
// maybe you want katex to throwOnError
throwOnError : true ,
// disable displayMode
displayMode : false ,
// change errorColor to blue
errorColor : '#1500ff' ,
} ) ,
] ,
} ) ;
return converter . makeHtml ( newmd ) ;
}
renderChildenComments = ( parent ) => {
renderChildenComments = ( parent ) => {
if ( parent . journals . length == 0 ) {
if ( parent . journals . length == 0 ) {
return '' ;
return '' ;
@ -172,19 +201,19 @@ class CCommentItem extends Component{
// is_appeal_info true 是匿评人匿评信息,需要统一使用头像去掉链接
// is_appeal_info true 是匿评人匿评信息,需要统一使用头像去掉链接
return parent . journals . map ( item => {
return parent . journals . map ( item => {
// <div>{item.content} {item.user_info.user_name}</div>
// <div>{item.content} {item.user_info.user_name}</div>
// src={getImageUrl(`images/${item.image_url}`)}
// src={getImageUrl(`images/${item.image_url}`)}
const imgSrc = ( ! item . user _info . user _image _url || item . user _info . user _image _url === '--' ) ? ` edu_user/anony.png ` : item . user _info . user _image _url ;
const imgSrc = ( ! item . user _info . user _image _url || item . user _info . user _image _url === '--' ) ? ` edu_user/anony.png ` : item . user _info . user _image _url ;
return (
return (
< div className = "comment_item_cont appraise df clearfix" key = { item . id } >
< div className = "comment_item_cont appraise df clearfix" key = { item . id } >
< div className = "J_Comment_Face fl" >
< div className = "J_Comment_Face fl" >
{ item . is _appeal _info == true ?
{ item . is _appeal _info == true ?
< a href = { ` javascript:void(0) ` } target = "_blank" >
< a href = { ` javascript:void(0) ` } target = "_blank" >
< img alt = "用户头像" height = "50"
< img alt = "用户头像" height = "50"
src = { ` ${ getUrl ( ) } /images/edu_user/anony.png ` } width = "50" / >
src = { ` ${ getUrl ( ) } /images/edu_user/anony.png ` } width = "50" / >
< / a >
< / a >
: < a href = { ` ${ _origin } /users/ ${ item . user _info . user _login } ` } target = "_blank" >
: < a href = { ` ${ _origin } /users/ ${ item . user _info . user _login } ` } target = "_blank" >
< img alt = "用户头像" height = "50"
< img alt = "用户头像" height = "50"
src = { ` ${ getImageUrl ( ` images/ ` + imgSrc ) } ` }
src = { ` ${ getImageUrl ( ` images/ ` + imgSrc ) } ` }
width = "50" / >
width = "50" / >
< / a > }
< / a > }
@ -204,21 +233,21 @@ class CCommentItem extends Component{
< / a > }
< / a > }
< span className = "t_area fl" > { moment ( item . time ) . format ( 'YYYY-MM-DD HH:mm' ) } < / s p a n >
< span className = "t_area fl" > { moment ( item . time ) . format ( 'YYYY-MM-DD HH:mm' ) } < / s p a n >
{ item . is _appeal _info && ( item . appeal _status == 1 ?
{ item . is _appeal _info && ( item . appeal _status == 1 ?
< span className = { "edu-filter-btn edu-filter-btn-4CACFF ml15 fl typestyle " } > 申诉中 < / s p a n > :
< span className = { "edu-filter-btn edu-filter-btn-4CACFF ml15 fl typestyle " } > 申诉中 < / s p a n > :
item . appeal _status == 2 ?
item . appeal _status == 2 ?
< span className = { "edu-filter-btn edu-filter-btn-EDEDED ml15 fl typestyle color666666 " } > 申诉已撤销 < / s p a n > :
< span className = { "edu-filter-btn edu-filter-btn-EDEDED ml15 fl typestyle color666666 " } > 申诉已撤销 < / s p a n > :
item . appeal _status == 3 ?
item . appeal _status == 3 ?
< span className = { "edu-filter-btn edu-filter-btn-4CACFF ml15 fl typestyle " } > 申诉成功 < / s p a n > :
< span className = { "edu-filter-btn edu-filter-btn-4CACFF ml15 fl typestyle " } > 申诉成功 < / s p a n > :
item . appeal _status == 4 ?
item . appeal _status == 4 ?
< span className = { "edu-filter-btn edu-filter-btn-EDEDED ml15 fl typestyle color666666 " } > 申诉被拒绝 < / s p a n > :
< span className = { "edu-filter-btn edu-filter-btn-EDEDED ml15 fl typestyle color666666 " } > 申诉被拒绝 < / s p a n > :
item . appeal _status == 5 ?
item . appeal _status == 5 ?
< span className = { "edu-filter-btn edu-filter-btn-EDEDED ml15 fl typestyle color666666 " } > 申诉失败 < / s p a n > : ' ' )
< span className = { "edu-filter-btn edu-filter-btn-EDEDED ml15 fl typestyle color666666 " } > 申诉失败 < / s p a n > : ' ' )
}
}
{ /* fr */ }
{ /* fr */ }
{ / * { i t e m . i s _ i n v a l i d ? < s p a n c l a s s N a m e = " v a l i d a t e _ a r e a f r " > 失 效 < / s p a n > :
{ / * { i t e m . i s _ i n v a l i d ? < s p a n c l a s s N a m e = " v a l i d a t e _ a r e a f r " > 失 效 < / s p a n > :
< React . Fragment > * / }
< React . Fragment > * / }
{ ! item . is _appeal _info && item . can _delete == true && < Tooltip title = "删除" >
{ ! item . is _appeal _info && item . can _delete == true && < Tooltip title = "删除" >
< i className = "iconfont icon-shanchu mr5 fr font-14" onClick = { ( ) => this . onDeleteSecondReply ( item ) }
< i className = "iconfont icon-shanchu mr5 fr font-14" onClick = { ( ) => this . onDeleteSecondReply ( item ) }
@ -233,19 +262,19 @@ class CCommentItem extends Component{
< / R e a c t . F r a g m e n t > }
< / R e a c t . F r a g m e n t > }
{ item . appeal _status == 1 && this . props . is _author == true && this . props . isStudent ( ) === true &&
{ item . appeal _status == 1 && this . props . is _author == true && this . props . isStudent ( ) === true &&
< WordsBtn style = "blue" className = "fr mr5" onClick = { ( ) => this . cancelMyAppeal ( ) } > 撤销申诉 < / W o r d s B t n > }
< WordsBtn style = "blue" className = "fr mr5" onClick = { ( ) => this . cancelMyAppeal ( ) } > 撤销申诉 < / W o r d s B t n > }
< / d i v >
< / d i v >
< / d i v >
< / d i v >
< div className = "comment_content clearfix" id = { ` reply_content_ ${ item . id } ` } >
< div className = "comment_content clearfix" id = { ` reply_content_ ${ item . id } ` } >
< div className = "color-grey-3" id = { ` reply_content_ ${ item . id } ` } >
< div className = "color-grey-3" id = { ` reply_content_ ${ item . id } ` } >
< div className = { " break_word_comments markdown-body"}
< div className = { " markdown-body"}
dangerouslySetInnerHTML = { { _ _html : this . parseCommentContent ( item . content ) } } > < / d i v >
dangerouslySetInnerHTML = { { _ _html : this . exportMdtoHtml ( item . content ) } } > < / d i v >
< div className = "cl" > < / d i v >
< div className = "cl" > < / d i v >
< / d i v >
< / d i v >
< / d i v >
< / d i v >
< / d i v >
< / d i v >
< / d i v >
< / d i v >
< / d i v >
< / d i v >
@ -256,7 +285,7 @@ class CCommentItem extends Component{
render ( ) {
render ( ) {
let { item , commentIndex , homework _status , is _author } = this . props ;
let { item , commentIndex , homework _status , is _author } = this . props ;
let { show _reply , show _appeal } = this . state ;
let { show _reply , show _appeal } = this . state ;
const _content = item . content ? this . parseCommentContent ( item . content ) : ''
const _content = item . content ? this . exportMdtoHtml ( item . content ) : ''
const isAnonymous = homework _status && homework _status . indexOf ( '匿评中' ) != - 1
const isAnonymous = homework _status && homework _status . indexOf ( '匿评中' ) != - 1
const isAppealing = homework _status && homework _status . indexOf ( '申诉中' ) != - 1
const isAppealing = homework _status && homework _status . indexOf ( '申诉中' ) != - 1
const attachments = item . attachments ;
const attachments = item . attachments ;
@ -266,13 +295,13 @@ class CCommentItem extends Component{
< div className = "ccomment comment_item_cont df clearfix" key = { item . id } >
< div className = "ccomment comment_item_cont df clearfix" key = { item . id } >
< div className = "J_Comment_Face fl" >
< div className = "J_Comment_Face fl" >
{ item . image _url == '--' ?
{ item . image _url == '--' ?
< a href = { ` javascript:void(0) ` } >
< a href = { ` javascript:void(0) ` } >
< img alt = "用户头像" height = "50"
< img alt = "用户头像" height = "50"
src = { ` ${ getUrl ( ) } /images/edu_user/anony.png ` } width = "50" / >
src = { ` ${ getUrl ( ) } /images/edu_user/anony.png ` } width = "50" / >
< / a >
< / a >
: < a href = { ` ${ _origin } /users/ ${ item . user _login } ` } target = "_blank" >
: < a href = { ` ${ _origin } /users/ ${ item . user _login } ` } target = "_blank" >
< img alt = "用户头像" height = "50"
< img alt = "用户头像" height = "50"
src = { ` ${ getUrl ( ) } /images/ ${ item . image _url } ` }
src = { ` ${ getUrl ( ) } /images/ ${ item . image _url } ` }
width = "50" / >
width = "50" / >
< / a > }
< / a > }
@ -285,7 +314,7 @@ class CCommentItem extends Component{
< div className = "t_content fl" >
< div className = "t_content fl" >
< div className = "J_Comment_Reply" >
< div className = "J_Comment_Reply" >
< div className = "comment_orig_content" style = { { margin : "0px" } } >
< div className = "comment_orig_content" style = { { margin : "0px" } } >
< div className = "J_Comment_Info clearfix mt3" >
< div className = "J_Comment_Info clearfix mt3" >
< div className = "t_info fl" >
< div className = "t_info fl" >
@ -303,8 +332,8 @@ class CCommentItem extends Component{
< span className = "t_area fl" > { item . time } < / s p a n >
< span className = "t_area fl" > { item . time } < / s p a n >
{ /* 分数 */ }
{ /* 分数 */ }
{ item . score !== null && < span className = "score_area fl" > { item . score } 分 < / s p a n > }
{ item . score !== null && < span className = "score_area fl" > { item . score } 分 < / s p a n > }
{ /* item.is_invalid && */ }
{ /* item.is_invalid && */ }
{ / * { i t e m . d e l e t e & & i s A d m i n & & < T o o l t i p t i t l e = { " 删 除 " } >
{ / * { i t e m . d e l e t e & & i s A d m i n & & < T o o l t i p t i t l e = { " 删 除 " } >
< i className = "iconfont icon-shanchu mr5 fr" style = { { marginLeft : '6px' } }
< i className = "iconfont icon-shanchu mr5 fr" style = { { marginLeft : '6px' } }
@ -312,29 +341,29 @@ class CCommentItem extends Component{
< / i >
< / i >
< /Tooltip>} */ }
< /Tooltip>} */ }
{ /* fr */ }
{ /* fr */ }
{ /* <WordsBtn style="blue" className="fr">回复</WordsBtn> */ }
{ /* <WordsBtn style="blue" className="fr">回复</WordsBtn> */ }
{ item . is _invalid ? < span className = "validate_area fr" > 失效 < / s p a n > :
{ item . is _invalid ? < span className = "validate_area fr" > 失效 < / s p a n > :
< React . Fragment >
< React . Fragment >
< WordsBtn style = "blue" className = "fr" onClick = { this . state . show _reply ? this . cancelReply : this . showReply } > 回复 < / W o r d s B t n >
< WordsBtn style = "blue" className = "fr" onClick = { this . state . show _reply ? this . cancelReply : this . showReply } > 回复 < / W o r d s B t n >
{ ( isAppealing || isAnonymous ) && item . can _appeal && item . appeal _status == 0 &&
{ ( isAppealing || isAnonymous ) && item . can _appeal && item . appeal _status == 0 &&
< WordsBtn style = "blue" className = "fr mr20" onClick = { this . state . show _appeal ? this . cancelAppeal : this . showAppeal } > 申诉 < / W o r d s B t n > }
< WordsBtn style = "blue" className = "fr mr20" onClick = { this . state . show _appeal ? this . cancelAppeal : this . showAppeal } > 申诉 < / W o r d s B t n > }
< / R e a c t . F r a g m e n t >
< / R e a c t . F r a g m e n t >
}
}
{ item . delete && isAdmin
{ item . delete && isAdmin
&& < WordsBtn style = "blue" className = "fr mr12"
&& < WordsBtn style = "blue" className = "fr mr12"
onClick = { ( ) => this . props . onDelete ( item ) } > 删除 < / W o r d s B t n > }
onClick = { ( ) => this . props . onDelete ( item ) } > 删除 < / W o r d s B t n > }
< / d i v >
< / d i v >
< / d i v >
< / d i v >
{ ! ! _content && _content !== 'null' && < div className = "comment_content clearfix mt8" id = { ` reply_content_ ${ item . id } ` } >
{ ! ! _content && _content !== 'null' && < div className = "comment_content clearfix mt8" id = { ` reply_content_ ${ item . id } ` } >
< div className = "color-grey-3" id = { ` reply_content_ ${ item . id } ` } >
< div className = "color-grey-3" id = { ` reply_content_ ${ item . id } ` } >
< div className = { " break_word_comments markdown-body"} dangerouslySetInnerHTML = { { _ _html : _content } } > < / d i v >
< div className = { " markdown-body"} dangerouslySetInnerHTML = { { _ _html : _content } } > < / d i v >
< div className = "cl" > < / d i v >
< div className = "cl" > < / d i v >
< / d i v >
< / d i v >
< / d i v > }
< / d i v > }
@ -367,7 +396,7 @@ class CCommentItem extends Component{
< div className = "childrenCommentsView" style = { { background : '#fff' } } >
< div className = "childrenCommentsView" style = { { background : '#fff' } } >
{ /* {(item && item.journals && item.journals.length) ? <div className="trangle"></div>: ''} */ }
{ /* {(item && item.journals && item.journals.length) ? <div className="trangle"></div>: ''} */ }
{ this . renderChildenComments ( item ) }
{ this . renderChildenComments ( item ) }
{ / * { i t e m . i s A l l C h i l d r e n L o a d e d ! = t r u e & & i t e m . j o u r n a l s & & t h i s . p r o p s . i s C h i l d C o m m e n t P a g i n a t i o n = = t r u e & & i t e m . j o u r n a l s . l e n g t h > = 5 ?
{ / * { i t e m . i s A l l C h i l d r e n L o a d e d ! = t r u e & & i t e m . j o u r n a l s & & t h i s . p r o p s . i s C h i l d C o m m e n t P a g i n a t i o n = = t r u e & & i t e m . j o u r n a l s . l e n g t h > = 5 ?
< Tooltip title = { "点击查看更多回复" } disableFocusListener = { true } >
< Tooltip title = { "点击查看更多回复" } disableFocusListener = { true } >
< div className = "loadMoreChildComments" onClick = { ( ) => { this . props . loadMoreChildComments && this . props . loadMoreChildComments ( item ) } } >
< div className = "loadMoreChildComments" onClick = { ( ) => { this . props . loadMoreChildComments && this . props . loadMoreChildComments ( item ) } } >
< i className = "iconfont icon-xiajiantou" > < / i >
< i className = "iconfont icon-xiajiantou" > < / i >
@ -379,9 +408,9 @@ class CCommentItem extends Component{
< p className = "" >
< p className = "" >
{ /* 第二排右侧按钮区域 */ }
{ /* 第二排右侧按钮区域 */ }
{ /* ${this.state.show_reply ? '回复' : '申诉'} */ }
{ /* ${this.state.show_reply ? '回复' : '申诉'} */ }
{ ( show _reply || show _appeal ) &&
{ ( show _reply || show _appeal ) &&
< React . Fragment >
< React . Fragment >
< TPMMDEditor mdID = { ` ${ commentIndex } ` } watch = { false }
< TPMMDEditor mdID = { ` ${ commentIndex } ` } watch = { false }
height = { 130 } onChange = { ( val ) => this . setState ( { secondReplyContent : val } ) }
height = { 130 } onChange = { ( val ) => this . setState ( { secondReplyContent : val } ) }
placeholder = { ` 请输入内容 ` } noStorage = { true }
placeholder = { ` 请输入内容 ` } noStorage = { true }
> < / T P M M D E d i t o r >
> < / T P M M D E d i t o r >
@ -389,15 +418,15 @@ class CCommentItem extends Component{
< a className = "task-btn task-btn-orange fr" style = { { height : '26px' , lineHeight : '26px' , width : '60px' } }
< a className = "task-btn task-btn-orange fr" style = { { height : '26px' , lineHeight : '26px' , width : '60px' } }
onClick = { this . onSubmit }
onClick = { this . onSubmit }
> { this . state . show _reply ? '回复' : '申诉' } < / a >
> { this . state . show _reply ? '回复' : '申诉' } < / a >
< a onClick = { this . onCancel } className = "defalutCancelbtn fr"
< a onClick = { this . onCancel } className = "defalutCancelbtn fr"
style = { { height : '26px' , width : '60px' , fontSize : '14px' , lineHeight : '26px' , marginRight : '10px' } } > 取消 < / a >
style = { { height : '26px' , width : '60px' , fontSize : '14px' , lineHeight : '26px' , marginRight : '10px' } } > 取消 < / a >
< / d i v >
< / d i v >
< / R e a c t . F r a g m e n t >
< / R e a c t . F r a g m e n t >
}
}
< / p >
< / p >
< / d i v >
< / d i v >
< / d i v >
< / d i v >
< / d i v >
< / d i v >