Commit 7f97fee0 authored by XieZhiXiong's avatar XieZhiXiong

fix: 修复产品名称不显示的问题

parent a27553dc
@import '../../../global/styles/utils.less';
.productName {
.textOverflow();
}
\ No newline at end of file
import React, { useState, useRef } from 'react';
import { Card, Rate, Button, Space, Modal, message } from 'antd';
import { ClockCircleOutlined, QuestionCircleOutlined } from '@ant-design/icons';
import { Link } from 'umi';
import { StandardTable } from 'god';
import { ColumnType } from 'antd/lib/table/interface';
import { createFormActions } from '@formily/antd';
import moment from 'moment';
import { useStateFilterSearchLinkageEffect } from '@/formSchema/effects/useFilterSearch';
import { FORM_FILTER_PATH } from '@/formSchema/const';
import { useAsyncInitSelect } from '@/formSchema/effects/useAsyncInitSelect';
import { PublicApi } from '@/services/api';
import { isJSONStr } from '@/utils';
import EyePreview from '@/components/EyePreview';
import NiceForm from '@/components/NiceForm';
import { listSearchSchema } from './schema';
import { COMMENT_STATUS_VISIBLE, COMMENT_STATUS_INVISIBLE } from '../constants';
import styles from './index.less';
const { confirm } = Modal;
const formActions = createFormActions();
const CommentManage: React.FC = () => {
const ref = useRef<any>({});
const [selectedRowKeys, setSelectedRowKeys] = useState<Array<number>>([]);
const handleVisibleComment = (status, id) => {
const msg = message.loading({
content: '正在操作,请稍候...',
duration: 0,
});
PublicApi.postMemberPlatformCommentOrderTradeHistoryUpdateStatus({
id,
status,
}).then(res => {
if (res.code === 1000) {
ref.current.reload();
}
}).finally(() => {
msg();
});
};
const columns: ColumnType<any>[] = [
{
title: '订单号',
dataIndex: 'orderNo',
align: 'center',
render: (text, record) => (
<EyePreview
url={`/comment/manage/detail?id=${record.id}`}
>
{text}
</EyePreview>
),
},
{
title: '交易商品/交易时间',
dataIndex: 'product',
align: 'center',
render: (text, record) => {
const product = isJSONStr(text) || {};
return (
<>
<div>{product.productName}</div>
<div
style={{
marginTop: 4,
}}
>
<ClockCircleOutlined />
{` ${record.dealTime}`}
</div>
</>
)
},
},
{
title: '被评价方',
dataIndex: 'subMemberName',
align: 'center',
},
{
title: '评价方',
dataIndex: 'memberName',
align: 'center',
render: (text, record) => <>{text}</>,
},
{
title: '评价星级',
dataIndex: 'star',
align: 'center',
render: text => <Rate value={text} disabled />,
},
{
title: '评价内容',
dataIndex: 'comment',
align: 'center',
ellipsis: true,
},
{
title: '评价时间',
dataIndex: 'createTime',
align: 'center',
},
{
title: '操作',
dataIndex: 'action',
align: 'center',
render: (_, record) => (
<>
<Button
type="link"
onClick={() => handleVisibleComment((record.status === COMMENT_STATUS_VISIBLE || !record.status) ? COMMENT_STATUS_INVISIBLE : COMMENT_STATUS_VISIBLE, record.id)}
>
{(record.status === COMMENT_STATUS_VISIBLE || !record.status) ? '屏蔽' : '已屏蔽'}
</Button>
</>
),
},
];
const fetchListData = (params: any) => {
const { createTimeStart, createTimeEnd, dealTimeStart, dealTimeEnd, ...rest } = params;
return new Promise((resolve, reject) => {
PublicApi.getMemberPlatformCommentOrderTradeHistoryPage({
...rest,
createTimeStart: createTimeStart ? moment(+createTimeStart).format('YYYY-MM-DD HH:mm:ss') : null,
createTimeEnd: createTimeEnd ? moment(+createTimeEnd).format('YYYY-MM-DD HH:mm:ss') : null,
dealTimeStart: dealTimeStart ? moment(+dealTimeStart).format('YYYY-MM-DD HH:mm:ss') : null,
dealTimeEnd: dealTimeEnd ? moment(+dealTimeEnd).format('YYYY-MM-DD HH:mm:ss') : null,
})
.then(res => {
if (res.code === 1000) {
resolve(res.data);
}
reject();
})
.catch(() => {
reject();
});
});
};
// 初始化高级筛选选项
const fetchSelectOptions = async () => {
return {};
};
const handleBatchDelete = () => {
if (!selectedRowKeys.length) {
message.warning('未选择任何评论');
return;
}
confirm({
title: '提示',
icon: <QuestionCircleOutlined />,
content: '确定要删除选中的评论吗?',
okText: '确定',
cancelText: '取消',
onOk() {
return new Promise((resolve, reject) => {
PublicApi.postMemberPlatformCommentOrderTradeHistoryDelete({
ids: selectedRowKeys,
})
.then(res => {
if (res.code === 1000) {
ref.current.reload();
setSelectedRowKeys([]);
resolve();
}
reject();
})
.catch(() => {
reject();
});
});
},
});
};
const controllerBtns = (
<Space>
<Button onClick={handleBatchDelete}>批量删除</Button>
</Space>
);
const rowSelection = {
onChange: (keys: any, rows: {}[]) => {
setSelectedRowKeys(keys);
},
selectedRowKeys: selectedRowKeys,
};
return (
<Card>
<StandardTable
tableProps={{
rowKey: 'id',
}}
columns={columns}
currentRef={ref}
rowSelection={rowSelection}
fetchTableData={(params: any) => fetchListData(params)}
controlRender={
<NiceForm
actions={formActions}
onSubmit={values => ref.current.reload(values)}
expressionScope={{
controllerBtns,
}}
effects={($, actions) => {
useStateFilterSearchLinkageEffect(
$,
actions,
'product',
FORM_FILTER_PATH,
);
useAsyncInitSelect(
['innerStatus', 'outerStatus'],
fetchSelectOptions,
);
}}
schema={listSearchSchema}
/>
}
/>
</Card>
);
};
import React, { useState, useRef } from 'react';
import { Card, Rate, Button, Space, Modal, message, Tooltip } from 'antd';
import { ClockCircleOutlined, QuestionCircleOutlined } from '@ant-design/icons';
import { Link } from 'umi';
import { StandardTable } from 'god';
import { ColumnType } from 'antd/lib/table/interface';
import { createFormActions } from '@formily/antd';
import moment from 'moment';
import { useStateFilterSearchLinkageEffect } from '@/formSchema/effects/useFilterSearch';
import { FORM_FILTER_PATH } from '@/formSchema/const';
import { useAsyncInitSelect } from '@/formSchema/effects/useAsyncInitSelect';
import { PublicApi } from '@/services/api';
import { isJSONStr } from '@/utils';
import EyePreview from '@/components/EyePreview';
import NiceForm from '@/components/NiceForm';
import { listSearchSchema } from './schema';
import { COMMENT_STATUS_VISIBLE, COMMENT_STATUS_INVISIBLE } from '../constants';
import styles from './index.less';
const { confirm } = Modal;
const formActions = createFormActions();
const CommentManage: React.FC = () => {
const ref = useRef<any>({});
const [selectedRowKeys, setSelectedRowKeys] = useState<Array<number>>([]);
const handleVisibleComment = (status, id) => {
const msg = message.loading({
content: '正在操作,请稍候...',
duration: 0,
});
PublicApi.postMemberPlatformCommentOrderTradeHistoryUpdateStatus({
id,
status,
}).then(res => {
if (res.code === 1000) {
ref.current.reload();
}
}).finally(() => {
msg();
});
};
const columns: ColumnType<any>[] = [
{
title: '订单号',
dataIndex: 'orderNo',
align: 'center',
render: (text, record) => (
<EyePreview
url={`/comment/manage/detail?id=${record.id}`}
>
{text}
</EyePreview>
),
},
{
title: '交易商品/交易时间',
dataIndex: 'product',
align: 'center',
render: (text, record) => {
return (
<>
<Tooltip title={text}>
<div className={styles.productName}>{text}</div>
</Tooltip>
<div
style={{
marginTop: 4,
}}
>
<ClockCircleOutlined />
{` ${record.dealTime}`}
</div>
</>
)
},
},
{
title: '被评价方',
dataIndex: 'subMemberName',
align: 'center',
},
{
title: '评价方',
dataIndex: 'memberName',
align: 'center',
render: (text, record) => <>{text}</>,
},
{
title: '评价星级',
dataIndex: 'star',
align: 'center',
render: text => <Rate value={text} disabled />,
},
{
title: '评价内容',
dataIndex: 'comment',
align: 'center',
ellipsis: true,
},
{
title: '评价时间',
dataIndex: 'createTime',
align: 'center',
},
{
title: '操作',
dataIndex: 'action',
align: 'center',
render: (_, record) => (
<>
<Button
type="link"
onClick={() => handleVisibleComment((record.status === COMMENT_STATUS_VISIBLE || !record.status) ? COMMENT_STATUS_INVISIBLE : COMMENT_STATUS_VISIBLE, record.id)}
>
{(record.status === COMMENT_STATUS_VISIBLE || !record.status) ? '屏蔽' : '已屏蔽'}
</Button>
</>
),
},
];
const fetchListData = (params: any) => {
const { createTimeStart, createTimeEnd, dealTimeStart, dealTimeEnd, ...rest } = params;
return new Promise((resolve, reject) => {
PublicApi.getMemberPlatformCommentOrderTradeHistoryPage({
...rest,
createTimeStart: createTimeStart ? moment(+createTimeStart).format('YYYY-MM-DD HH:mm:ss') : null,
createTimeEnd: createTimeEnd ? moment(+createTimeEnd).format('YYYY-MM-DD HH:mm:ss') : null,
dealTimeStart: dealTimeStart ? moment(+dealTimeStart).format('YYYY-MM-DD HH:mm:ss') : null,
dealTimeEnd: dealTimeEnd ? moment(+dealTimeEnd).format('YYYY-MM-DD HH:mm:ss') : null,
})
.then(res => {
if (res.code === 1000) {
resolve(res.data);
}
reject();
})
.catch(() => {
reject();
});
});
};
// 初始化高级筛选选项
const fetchSelectOptions = async () => {
return {};
};
const handleBatchDelete = () => {
if (!selectedRowKeys.length) {
message.warning('未选择任何评论');
return;
}
confirm({
title: '提示',
icon: <QuestionCircleOutlined />,
content: '确定要删除选中的评论吗?',
okText: '确定',
cancelText: '取消',
onOk() {
return new Promise((resolve, reject) => {
PublicApi.postMemberPlatformCommentOrderTradeHistoryDelete({
ids: selectedRowKeys,
})
.then(res => {
if (res.code === 1000) {
ref.current.reload();
setSelectedRowKeys([]);
resolve();
}
reject();
})
.catch(() => {
reject();
});
});
},
});
};
const controllerBtns = (
<Space>
<Button onClick={handleBatchDelete}>批量删除</Button>
</Space>
);
const rowSelection = {
onChange: (keys: any, rows: {}[]) => {
setSelectedRowKeys(keys);
},
selectedRowKeys: selectedRowKeys,
};
return (
<Card>
<StandardTable
tableProps={{
rowKey: 'id',
}}
columns={columns}
currentRef={ref}
rowSelection={rowSelection}
fetchTableData={(params: any) => fetchListData(params)}
controlRender={
<NiceForm
actions={formActions}
onSubmit={values => ref.current.reload(values)}
expressionScope={{
controllerBtns,
}}
effects={($, actions) => {
useStateFilterSearchLinkageEffect(
$,
actions,
'product',
FORM_FILTER_PATH,
);
useAsyncInitSelect(
['innerStatus', 'outerStatus'],
fetchSelectOptions,
);
}}
schema={listSearchSchema}
/>
}
/>
</Card>
);
};
export default CommentManage;
\ No newline at end of file
This source diff could not be displayed because it is too large. You can view the blob instead.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment