|
@@ -1,86 +1,94 @@
|
|
|
-import React, { useState, useEffect} from 'react'
|
|
|
-import { Modal, Form, Table, Spin } from 'antd'
|
|
|
-
|
|
|
-import type { AdminModalType } from './data'
|
|
|
-import { getComplaintDetail } from '@/services/complaint'
|
|
|
-import { filterTimestamp } from '@/filters/index'
|
|
|
-
|
|
|
-const request = (url: string): Promise<any> => {
|
|
|
- return new Promise( (resolve, reject) => {
|
|
|
- const xhr = new XMLHttpRequest()
|
|
|
- xhr.open('GET', url, false)
|
|
|
- xhr.onreadystatechange = function () {
|
|
|
- if (xhr.readyState === 4 && xhr.status === 200) {
|
|
|
- resolve(xhr.response)
|
|
|
- } else {
|
|
|
- reject(new Error('置换帖子的contenturl出错'))
|
|
|
- }
|
|
|
- }
|
|
|
- xhr.send()
|
|
|
- }).catch(e => e)
|
|
|
-}
|
|
|
-
|
|
|
-const sendRequest = async (url: string ) => await request(url)
|
|
|
-
|
|
|
-const layout = {
|
|
|
- labelCol: { span: 5 },
|
|
|
- wrapperCol: { span: 16 },
|
|
|
-};
|
|
|
-
|
|
|
-const AdminModal: React.FC<AdminModalType> = ({visible, complaintData, articleType, closeModal}) => {
|
|
|
- console.log(complaintData, 'complaintData');
|
|
|
-
|
|
|
- const [ postsDetail, setPostsDetail] = useState<Record<string, any>>({})
|
|
|
-
|
|
|
- const [ complaintList, setComplaintList] = useState([])
|
|
|
-
|
|
|
- const [spinning, setSpinning] = useState(false)
|
|
|
-
|
|
|
- // 查询详情
|
|
|
- const GetComplaintDetail = async (): Promise<void> => {
|
|
|
- setSpinning(true)
|
|
|
- const {code, data} = await getComplaintDetail({itemId: complaintData.itemId, articleType})
|
|
|
- setSpinning(false)
|
|
|
- if (code === 0) {
|
|
|
- const { list, article } = data
|
|
|
- // eslint-disable-next-line no-await-in-loop
|
|
|
- if (article) {
|
|
|
- article.content = article.hasOwnProperty('contentUrl') && await sendRequest(article.contentUrl)
|
|
|
- setPostsDetail(article)
|
|
|
- }
|
|
|
- setComplaintList(list)
|
|
|
-
|
|
|
- console.log(data, '查询详情');
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- useEffect( () => {
|
|
|
- GetComplaintDetail()
|
|
|
- }, [])
|
|
|
-
|
|
|
- return (
|
|
|
- <Modal visible={visible} title="查看详情" onCancel={closeModal} width={600}>
|
|
|
- <Spin spinning={spinning}>
|
|
|
- <Form {...layout}>
|
|
|
- <Form.Item label="标题">{postsDetail.label}</Form.Item>
|
|
|
- <Form.Item label="内容">{postsDetail.content}</Form.Item>
|
|
|
- <Form.Item label="分类名称">{postsDetail.categoryLabel}</Form.Item>
|
|
|
- <Form.Item label="所属贴吧板块">{postsDetail.barLabel}</Form.Item>
|
|
|
- <Form.Item label="发布人">{postsDetail.authorName}</Form.Item>
|
|
|
- <Form.Item label="发布时间">{filterTimestamp(postsDetail.createTime)}</Form.Item>
|
|
|
- <Form.Item label="投诉情况">
|
|
|
- <Table dataSource={complaintList} pagination={false}>
|
|
|
- <Table.Column title="投诉人" key="userName" dataIndex="userName"></Table.Column>
|
|
|
- <Table.Column title="投诉原因" key="reason" dataIndex="reason"></Table.Column>
|
|
|
- <Table.Column title="投诉时间" key="createTime" dataIndex="createTime"
|
|
|
- render={text => <span>{filterTimestamp(text)}</span>}
|
|
|
- ></Table.Column>
|
|
|
- </Table>
|
|
|
- </Form.Item>
|
|
|
- </Form>
|
|
|
- </Spin>
|
|
|
- </Modal>
|
|
|
- )
|
|
|
-}
|
|
|
-
|
|
|
-export default AdminModal
|
|
|
+import React, { useState, useEffect } from 'react';
|
|
|
+import { Modal, Form, Table, Spin } from 'antd';
|
|
|
+
|
|
|
+import type { AdminModalType } from './data';
|
|
|
+import { getComplaintDetail } from '@/services/complaint';
|
|
|
+import { filterTimestamp } from '@/filters/index';
|
|
|
+
|
|
|
+const request = (url: string): Promise<any> => {
|
|
|
+ return new Promise((resolve, reject) => {
|
|
|
+ const xhr = new XMLHttpRequest();
|
|
|
+ xhr.open('GET', url, false);
|
|
|
+ xhr.onreadystatechange = function () {
|
|
|
+ if (xhr.readyState === 4 && xhr.status === 200) {
|
|
|
+ resolve(xhr.response);
|
|
|
+ } else {
|
|
|
+ reject(new Error('置换帖子的contenturl出错'));
|
|
|
+ }
|
|
|
+ };
|
|
|
+ xhr.send();
|
|
|
+ }).catch((e) => e);
|
|
|
+};
|
|
|
+
|
|
|
+const sendRequest = async (url: string) => await request(url);
|
|
|
+
|
|
|
+const layout = {
|
|
|
+ labelCol: { span: 5 },
|
|
|
+ wrapperCol: { span: 16 },
|
|
|
+};
|
|
|
+
|
|
|
+const AdminModal: React.FC<AdminModalType> = ({
|
|
|
+ visible,
|
|
|
+ complaintData,
|
|
|
+ articleType,
|
|
|
+ closeModal,
|
|
|
+}) => {
|
|
|
+ console.log(complaintData, 'complaintData');
|
|
|
+
|
|
|
+ const [postsDetail, setPostsDetail] = useState<Record<string, any>>({});
|
|
|
+
|
|
|
+ const [complaintList, setComplaintList] = useState([]);
|
|
|
+
|
|
|
+ const [spinning, setSpinning] = useState(false);
|
|
|
+
|
|
|
+ // 查询详情
|
|
|
+ const GetComplaintDetail = async (): Promise<void> => {
|
|
|
+ setSpinning(true);
|
|
|
+ const { code, data } = await getComplaintDetail({ itemId: complaintData.itemId, articleType });
|
|
|
+ setSpinning(false);
|
|
|
+ if (code === 0) {
|
|
|
+ const { list, article } = data;
|
|
|
+ // eslint-disable-next-line no-await-in-loop
|
|
|
+ if (article) {
|
|
|
+ // article.content = article.hasOwnProperty('contentUrl') && await sendRequest(article.contentUrl).value
|
|
|
+ setPostsDetail(article);
|
|
|
+ }
|
|
|
+ setComplaintList(list);
|
|
|
+
|
|
|
+ console.log(data, '查询详情');
|
|
|
+ }
|
|
|
+ };
|
|
|
+
|
|
|
+ useEffect(() => {
|
|
|
+ GetComplaintDetail();
|
|
|
+ }, []);
|
|
|
+
|
|
|
+ return (
|
|
|
+ <Modal visible={visible} title="查看详情" onCancel={closeModal} width={600}>
|
|
|
+ <Spin spinning={spinning}>
|
|
|
+ <Form {...layout}>
|
|
|
+ <Form.Item label="标题">{postsDetail.label}</Form.Item>
|
|
|
+ <Form.Item label="内容">{postsDetail.content}</Form.Item>
|
|
|
+ <Form.Item label="分类名称">{postsDetail.categoryLabel}</Form.Item>
|
|
|
+ <Form.Item label="所属贴吧板块">{postsDetail.barLabel}</Form.Item>
|
|
|
+ <Form.Item label="发布人">{postsDetail.authorName}</Form.Item>
|
|
|
+ <Form.Item label="发布时间">{filterTimestamp(postsDetail.createTime)}</Form.Item>
|
|
|
+ <Form.Item label="投诉情况">
|
|
|
+ <Table dataSource={complaintList} pagination={false}>
|
|
|
+ <Table.Column title="投诉人" key="userName" dataIndex="userName"></Table.Column>
|
|
|
+ <Table.Column title="投诉原因" key="reason" dataIndex="reason"></Table.Column>
|
|
|
+ <Table.Column
|
|
|
+ title="投诉时间"
|
|
|
+ key="createTime"
|
|
|
+ dataIndex="createTime"
|
|
|
+ render={(text) => <span>{filterTimestamp(text)}</span>}
|
|
|
+ ></Table.Column>
|
|
|
+ </Table>
|
|
|
+ </Form.Item>
|
|
|
+ </Form>
|
|
|
+ </Spin>
|
|
|
+ </Modal>
|
|
|
+ );
|
|
|
+};
|
|
|
+
|
|
|
+export default AdminModal;
|