import { Col, Image, Spin, Tooltip } from 'antd'; import React, { useEffect, useState } from 'react'; import { connect } from 'umi'; import styles from './index.less'; import { timeToString } from '@/utils/common'; import { DislikeOutlined, LeftOutlined, LikeOutlined, RightOutlined, } from '@ant-design/icons'; import { recurrent, severity, bug_categories } from '@/pages/edit/components/Step2/const'; const BugItemDetail = (props) => { const { bugItemDetail, dispatch, reportCommonInfo, commonId, getReportReview, } = props; const [detail, setDetail] = useState({}); const [operator, setOperator] = useState(-1); const handleChangeImgToLeft = () => { let newDetail = { ...detail }; newDetail.left--; newDetail.right--; newDetail['imgArr'] = newDetail['originArr'].slice(newDetail['left'], newDetail['right']); setDetail(newDetail); }; const handleChangeImgToRight = () => { let newDetail = { ...detail }; newDetail.left++; newDetail.right++; newDetail['imgArr'] = newDetail['originArr'].slice(newDetail['left'], newDetail['right']); setDetail(newDetail); }; const handleOperateIcon = (type) => { if (operator === -1) { //这里的操作是点赞点踩操作 setOperator(type); if (type) { //type===1表示点赞 dispatch({ type: 'editReport/goodForReport', payload: { id: detail.id,//被点赞的报告的id report_id: reportCommonInfo.id, user_id: commonId.userId, action: 'like', }, }).then(() => { getReportReview(); }); } else { dispatch({ type: 'editReport/badForReport', payload: { id: detail.id,//被点赞的报告的id report_id: reportCommonInfo.id, user_id: commonId.userId, action: 'dislike', }, }).then(() => { getReportReview(); }); } } else { //这里的操作是取消点赞点踩操作 setOperator(-1); if (type) { //type===1表示点赞 dispatch({ type: 'editReport/cancelGoodForReport', payload: { id: detail.id,//被点赞的报告的id report_id: reportCommonInfo.id, }, }).then(_ => { getReportReview(); }); } else { dispatch({ type: 'editReport/cancelBadForReport', payload: { id: detail.id,//被点赞的报告的id report_id: reportCommonInfo.id, }, }).then(_ => { getReportReview(); }); } } }; useEffect(() => { if (JSON.stringify(bugItemDetail) !== '{}') { let { detail } = bugItemDetail; detail['originArr'] = detail.img_url ? detail.img_url.split(',') : []; if (detail['originArr'].length >= 3) { //通过更改左右的标记值来更改显示的图片 detail['left'] = 0; detail['right'] = 3; detail['imgArr'] = detail['originArr'].slice(detail['left'], detail['right']); } else if (detail['originArr'].length > 0 && detail['originArr'].length < 3) { detail['imgArr'] = detail['originArr']; detail['left'] = 0; detail['right'] = detail['originArr'].length; } setDetail(detail); } }, [bugItemDetail]); return ( detail && detail.id ?
Bug标识: {detail && detail.id || ''}
Bug题目: {detail && detail.title || ''}
Bug描述: {detail && detail.description+detail.description+detail.description}
创建时间:{timeToString(detail.create_time_millis)}
页面路径:{detail.bug_page}
漏洞分类:{detail.bug_category}
严重等级:{severity[detail.severity - 1]}
复现程度:{recurrent[detail.recurrent - 1]}
{ detail && detail.img_url ? (
Bug截图:
{detail.left > 0 ? :
} {detail.imgArr.map(img => { return ; })} {detail.right < (detail.originArr.length - 1) ? :
}
) : null }
Bug评价: {operator !== 0 ? handleOperateIcon(1)} /> : null} {operator !== 1 ? handleOperateIcon(0)} /> : null}
: ); }; export default connect(({ allBugs, editReport }) => ({ bugItemDetail: allBugs.bugItemDetail, reportCommonInfo: editReport.reportCommonInfo, commonId: editReport.commonId, }))(BugItemDetail);