import React, { useState, useEffect, useCallback } from 'react'; import PropTypes from 'prop-types'; import getCustomHeader from '@/components/token-header'; import PageHead from '@/components/page-head'; import { ajax } from '@/utils'; import { Table, Dialog, Form, Input, Checkbox, Message, Pagination, } from '@alifd/next'; import styles from './index.module.scss'; const { Column } = Table; let edit = {}; const FormItem = Form.Item; const SEARCHLABEL = {buyerId:'买家ID',storeId:'商铺ID',itemId:'商品ID',orderId:'订单号',skuId:'skuID',gradeValue:'评分分数'}; const Comment = ({ data={} }) => { const [contentData, setContent] = useState(data); const [replyId, setReplyId] = useState(''); const [page, setPage] = useState(1); const [lastQueryRequest, setLastQuery] = useState({}); const [total, setTotal] = useState(data.totalCount); const { commentList } = contentData; const refreshComment = async() => { const commentData = await ajax({ api: 'getReply', method: 'post', data: JSON.stringify({ onlyOnline: false, exceptFunction: false }), type: 'json', contentType: 'application/json', headers: getCustomHeader() }); if (commentData.success) { setContent(commentData.result); } } const tableRender = (value: any, index: number, record: Object) => { if (record.replyCommentList.length) return; return ( { setReplyId(record.commentId); }}> 立即聊天 ); }; const commentTextRender = (value: any, index: number, record: Object) => { return ( <>

{record.commentText}

{ record.replyCommentList.map(item => { return(

回复内容:{item.replyText}

) }) } ) } const ReplyDialog = () => { return ( {setReplyId('')}} >
{ if (!errorData) { const commentData = await ajax({ api: 'replyComment', method: 'post', data: JSON.stringify({...successData, originalCommentId: replyId}), type: 'json', contentType: 'application/json', headers: getCustomHeader() }); if (commentData.success) { refreshComment(); setReplyId(''); } else { Message.error(commentData.message); } } else { console.log(errorData); } }}> 回复
) } const MoreFilter = ({}) => { return (
{ Object.keys(SEARCHLABEL).map(item => { let content; switch(item) { case 'enableCount': content = ({SEARCHLABEL[item]}) break; default: content = (); break; } return ( {content} ) }) } { if (!errorData) { const commentData = await ajax({ api: 'getReply', method: 'post', data: JSON.stringify({ ...successData, enableCount: true }), type: 'json', contentType: 'application/json', headers: getCustomHeader() }); if (commentData.success) { setContent(commentData.result); setPage(1); const {totalCount} = commentData.result; const {buyerId, storeId, itemId, orderId, skuId, gradeValue, enableCount} = commentData.result.lastQueryRequest; setLastQuery({buyerId, storeId, itemId, orderId, skuId, gradeValue, enableCount}); setTotal(totalCount); } } else { console.log(errorData); } }}> 查询
) } return (
{!!commentList.length && ( { const commentData = await ajax({ api: 'getReply', method: 'post', data: JSON.stringify({ ...lastQueryRequest, currentPageNum: page, pageSize: 20 }), type: 'json', contentType: 'application/json', headers: getCustomHeader() }); if (commentData.success) { setContent(commentData.result); setPage(page); } }} />)}
); }; export default Comment;