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 ?