You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
221 lines
9.1 KiB
221 lines
9.1 KiB
import React from "react";
|
|
import {Button, Col, Container, Image, Row} from "react-bootstrap";
|
|
import {ActivityStatus, HelpEntity, PageProps} from "../entity";
|
|
import moment from "moment";
|
|
import {JSONResponse, Method, request} from "../interface";
|
|
import {EmptyBodyTransform, HelpRes, HelpTransform, PageDataMessage, SimpleMessage} from "../result";
|
|
import {MyDialog} from "../ui/MyDialog";
|
|
import {changeActivity} from "../public";
|
|
import {Input} from "../ui/InputGroup";
|
|
import {Cookies} from "react-cookie";
|
|
import {time_score} from "../account/PropCookie";
|
|
import {Api, prefix} from "../api";
|
|
|
|
const classList="border-info border d-flex justify-content-center align-items-center"
|
|
|
|
/**
|
|
* 我的帮助
|
|
*/
|
|
export class MyHelp extends React.Component<{
|
|
//刷新用户信息
|
|
refreshFun?:Function;
|
|
cookies?:Cookies;
|
|
},
|
|
|
|
{
|
|
data?:Array<HelpEntity>,
|
|
page?:PageProps ,
|
|
result:JSX.Element|null,
|
|
//活动评价
|
|
activeScore:number,
|
|
historyId:number|null;
|
|
timeScore?:string;
|
|
}>{
|
|
|
|
|
|
constructor(props: Readonly<any>) {
|
|
super(props);
|
|
|
|
this.state= {
|
|
activeScore: 5,
|
|
result:null,
|
|
historyId:null
|
|
}
|
|
}
|
|
|
|
componentDidMount() {
|
|
this.loadMyHelp(1)
|
|
}
|
|
|
|
|
|
score(){
|
|
let that=this
|
|
request(Api.main.activity.score,Method.POST ,{
|
|
score:this.state.activeScore+"",
|
|
historyId:this.state.historyId+""
|
|
},new EmptyBodyTransform(),function (res:JSONResponse<SimpleMessage>) {
|
|
switch (res.customResult) {
|
|
case SimpleMessage.ok:
|
|
that.setState({
|
|
historyId:null,
|
|
result:<h3 className="text-center text-info">活动评价成功</h3>
|
|
})
|
|
that.loadMyHelp(1)
|
|
break
|
|
case SimpleMessage.fail:
|
|
that.setState({
|
|
result:<h3 className="text-center text-danger">活动评价失败,请联系管理员</h3>
|
|
})
|
|
break
|
|
}
|
|
})
|
|
}
|
|
|
|
/**
|
|
* 获取操作布局
|
|
* @param help
|
|
*/
|
|
getAction(help:HelpEntity){
|
|
if(help.activityScore){
|
|
return (<Row>
|
|
<Col className={classList}>已评价</Col>
|
|
<Col className={classList}/>
|
|
<Col className={classList}>{help.activityScore}</Col>
|
|
</Row>)
|
|
}
|
|
else if(help.joinTime&&help.completeTime){
|
|
return (<Row>
|
|
<Col className={classList}>已完成</Col>
|
|
<Col className={classList+" p-3"}>
|
|
<Button className="w-100" onClick={()=>this.setState({historyId:help.historyId})}>评价活动</Button>
|
|
</Col>
|
|
<Col className={classList}/>
|
|
</Row>)
|
|
}else if(help.joinTime){
|
|
return (<Row>
|
|
<Col className={classList}>{help.hasEnd?"已超时":"待完成"}</Col>
|
|
<Col className={classList+" p-3"}>
|
|
{help.hasEnd?null:
|
|
<Button className="w-100" onClick={()=>{
|
|
let that=this
|
|
changeActivity(help.activityId,ActivityStatus.complete, this,function (timeScore:string) {
|
|
that.setState({
|
|
timeScore:timeScore
|
|
})
|
|
that.loadMyHelp(1)
|
|
|
|
})
|
|
}} variant={"info"}>完成</Button>}</Col>
|
|
<Col className={classList}/>
|
|
</Row>)
|
|
}else{
|
|
return (
|
|
<Row>
|
|
<Col className={classList}>{help.hasStart?"待参与":"待活动开始"}</Col>
|
|
<Col className={classList+" p-3"}>
|
|
{help.hasStart?
|
|
<Button className="w-100" onClick={()=> {
|
|
let that=this
|
|
changeActivity(help.activityId,ActivityStatus.join, this,function () {
|
|
that.loadMyHelp(1)
|
|
})
|
|
}} variant={"info"}>参与</Button>:null}
|
|
</Col>
|
|
<Col className={classList}/>
|
|
</Row>
|
|
)
|
|
}
|
|
}
|
|
|
|
loadMyHelp(page:number){
|
|
let that=this
|
|
request(Api.main.activity.myHelp+"?currentPage="+page,Method.GET,{},new HelpTransform(),function (res:HelpRes) {
|
|
switch (res.customResult) {
|
|
case PageDataMessage.ok:
|
|
that.setState({
|
|
data:res.dataList
|
|
})
|
|
break
|
|
case PageDataMessage.fail:
|
|
that.setState({
|
|
result:<h3 className="text-center text-danger">帮助信息加载失败,请联系管理员</h3>
|
|
})
|
|
break
|
|
}
|
|
})
|
|
}
|
|
|
|
render() {
|
|
return (
|
|
<div className="overflow-auto my-help-height w-100">
|
|
{this.state.data?this.state.data.length===0?<h3 className="text-info text-center">没有找到帮助记录</h3>:this.state.data.map((help:HelpEntity,index:number)=>
|
|
<div key={"list"+index} className="mt-3 mb-3 border-info border">
|
|
<Container>
|
|
<Row>
|
|
<Col xs={4}>
|
|
<Image src={prefix.image+help.activityImg} className="activityImage"/>
|
|
</Col>
|
|
<Col>
|
|
<h5>{help.title}</h5>
|
|
<h6>{help.content}</h6>
|
|
</Col>
|
|
</Row>
|
|
<Row>
|
|
{["求助时间","活动开始时间","活动结束时间"].map((text:string,index:number)=>
|
|
<Col className={classList} key={"col"+index}>{text}</Col>
|
|
)}
|
|
</Row>
|
|
<Row>
|
|
{[help.seekHelpTime,help.activityStartTime,help.activityEndTime].map((time:number, index:number)=>
|
|
<Col className="border-info border" key={"col"+index}>{moment(time).format("YYYY-MM-DD HH:mm:ss")}</Col>
|
|
)}
|
|
</Row>
|
|
<Row>
|
|
{["报名时间","参与时间","完成时间"].map((text:string,index:number)=>
|
|
<Col className={classList} key={"col"+index}>{text}</Col>
|
|
)}
|
|
</Row>
|
|
<Row>
|
|
{[help.applyTime,help.joinTime,help.completeTime].map((time,index:number)=>
|
|
<Col className="border-info border" key={"col"+index}>{time?moment(time).format("YYYY-MM-DD HH:mm:ss"):""}</Col>
|
|
)}
|
|
</Row>
|
|
<Row>
|
|
{["参与状态","操作","活动评分"].map((text:string,index:number)=>
|
|
<Col className={classList} key={"col"+index}>{text}</Col>
|
|
)}
|
|
</Row>
|
|
{this.getAction(help)}
|
|
</Container>
|
|
</div>
|
|
):<h3 className="text-center text-info">帮助信息加载中</h3>}
|
|
|
|
<MyDialog content={this.state.result} open={this.state.result!==null} titleId="my_help_dialog" menuName="提示" onClose={()=>{
|
|
this.setState({
|
|
result:null
|
|
})
|
|
if(this.state.timeScore&&this.props.cookies?.get(time_score)!==this.state.timeScore&&this.props.refreshFun) {
|
|
this.props.refreshFun({
|
|
timeScore:this.state.timeScore
|
|
})
|
|
}
|
|
}}/>
|
|
|
|
<MyDialog content={
|
|
<div>
|
|
<Input name="activeScore" type={"number"} value={this.state.activeScore+""} desc="评分" placeholder={"请输入评分(0-10)"} onChange={(value:string)=>{
|
|
if(+value<0||+value>10){
|
|
value="5"
|
|
}
|
|
this.setState({
|
|
activeScore:+value
|
|
})
|
|
}}/>
|
|
|
|
<Button variant={"info"} block={true} className="col-3 ml-auto mr-auto mt-3" onClick={()=>this.score()}>评价</Button>
|
|
</div>} open={this.state.historyId!==null} titleId="score-dialog" menuName="评分" onClose={()=>this.setState({historyId:null})}/>
|
|
|
|
</div>
|
|
)
|
|
}
|
|
}
|
|
|