2024-08-29 17:56:39 +08:00
|
|
|
|
import {
|
|
|
|
|
Table, TableProps, Tooltip, Spin,
|
|
|
|
|
// Modal,
|
|
|
|
|
Input
|
|
|
|
|
} from "antd";
|
2024-08-27 18:29:20 +08:00
|
|
|
|
const { Search } = Input;
|
2024-08-12 14:43:58 +08:00
|
|
|
|
import { useEffect, useState } from "react";
|
|
|
|
|
import useMessage from "antd/es/message/useMessage";
|
|
|
|
|
import { get } from "../../util/AjaxUtils";
|
|
|
|
|
import './myorder.css'
|
|
|
|
|
type IListPage<T> = {
|
|
|
|
|
page: number;
|
|
|
|
|
total: number;
|
|
|
|
|
rows: T[]
|
|
|
|
|
}
|
2024-08-29 17:56:39 +08:00
|
|
|
|
// type DetailDataType = {
|
|
|
|
|
// productType: string;
|
|
|
|
|
// quantity: number;
|
|
|
|
|
// unitPrice: number;
|
|
|
|
|
// notes: string;
|
|
|
|
|
// productDescription: string;
|
|
|
|
|
// }
|
2024-08-12 14:43:58 +08:00
|
|
|
|
type DataType = {
|
|
|
|
|
orderId: string;
|
|
|
|
|
orderNo: string;
|
|
|
|
|
totalAmount: number;
|
2024-08-29 17:56:39 +08:00
|
|
|
|
orderDetails: any;
|
2024-08-12 14:43:58 +08:00
|
|
|
|
orderStatus: string;
|
|
|
|
|
gmtCreate: string;
|
|
|
|
|
}
|
2024-08-27 18:29:20 +08:00
|
|
|
|
type DataTypeDetail = {
|
|
|
|
|
productName: string; //商品名称
|
|
|
|
|
productType: string; //商品类型
|
|
|
|
|
quantity: number; //购买数量
|
|
|
|
|
unitPrice: number; //单价
|
|
|
|
|
productDescription: string; //商品描述
|
|
|
|
|
notes: string; //备注
|
|
|
|
|
}
|
2024-08-12 14:43:58 +08:00
|
|
|
|
export default function MyOrder() {
|
|
|
|
|
const [messageApi, messageContext] = useMessage();
|
|
|
|
|
const [isLoading, setIsLoading] = useState(false)
|
|
|
|
|
const [page, setPage] = useState(1);
|
|
|
|
|
const [total, setTotal] = useState(0);
|
|
|
|
|
const [dataArray, setDataArray] = useState<DataType[]>([]);
|
2024-08-29 17:56:39 +08:00
|
|
|
|
|
|
|
|
|
// const [detailData, setDetailData] = useState<DataTypeDetail[]>([])
|
|
|
|
|
// const [orderId, setorderId] = useState('')
|
|
|
|
|
// const [orderDetailsModal, setOrderDetailsModal] = useState(false) //详情弹窗
|
2024-08-27 18:29:20 +08:00
|
|
|
|
const [keyWords, setKewWords] = useState('')
|
2024-08-30 16:10:27 +08:00
|
|
|
|
const [productName, setProductName] = useState('')
|
2024-08-29 17:56:39 +08:00
|
|
|
|
const [expandedRowKeys, setExpandedRowKeys] = useState<any[]>([]); //展开项
|
2024-08-12 14:43:58 +08:00
|
|
|
|
const getData = () => {
|
2024-08-29 17:56:39 +08:00
|
|
|
|
// setDataArray([])
|
2024-08-12 14:43:58 +08:00
|
|
|
|
get<IListPage<DataType>>({
|
|
|
|
|
messageApi,
|
2024-08-27 18:29:20 +08:00
|
|
|
|
url: '/api/order/listpage/self',
|
2024-08-12 14:43:58 +08:00
|
|
|
|
config: {
|
|
|
|
|
params: {
|
|
|
|
|
page: page,
|
2024-08-27 18:29:20 +08:00
|
|
|
|
rows: 20,
|
|
|
|
|
keywords: keyWords,
|
2024-08-30 16:10:27 +08:00
|
|
|
|
productName: productName
|
2024-08-12 14:43:58 +08:00
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
onBefore() {
|
|
|
|
|
setIsLoading(true);
|
|
|
|
|
},
|
|
|
|
|
onSuccess({ data }) {
|
|
|
|
|
// console.log(data);
|
|
|
|
|
|
|
|
|
|
setPage(data.page);
|
|
|
|
|
setTotal(data.total);
|
|
|
|
|
setDataArray(data.rows);
|
2024-08-29 17:56:39 +08:00
|
|
|
|
|
|
|
|
|
setExpandedRowKeys(data.rows.map(item => item.orderId))
|
2024-08-12 14:43:58 +08:00
|
|
|
|
},
|
|
|
|
|
onFinally() {
|
|
|
|
|
setIsLoading(false);
|
|
|
|
|
}
|
|
|
|
|
})
|
|
|
|
|
}
|
2024-08-29 17:56:39 +08:00
|
|
|
|
// const getOrderDetails = () => {
|
|
|
|
|
// get({
|
|
|
|
|
// messageApi,
|
|
|
|
|
// url: `/api/order-detail/list/order-id/${orderId}`,
|
|
|
|
|
// config: {
|
2024-08-27 18:29:20 +08:00
|
|
|
|
|
2024-08-29 17:56:39 +08:00
|
|
|
|
// },
|
|
|
|
|
// onBefore() {
|
|
|
|
|
// setIsLoading(true);
|
|
|
|
|
// },
|
|
|
|
|
// onSuccess(data: any) {
|
|
|
|
|
// // console.log(data.data);
|
|
|
|
|
// setDetailData(data.data)
|
|
|
|
|
|
|
|
|
|
// },
|
|
|
|
|
// onFinally() {
|
|
|
|
|
// setIsLoading(false);
|
|
|
|
|
// }
|
|
|
|
|
// })
|
|
|
|
|
// }
|
2024-08-27 18:29:20 +08:00
|
|
|
|
|
2024-08-12 14:43:58 +08:00
|
|
|
|
const columns: TableProps<DataType>['columns'] = [
|
2024-08-29 17:56:39 +08:00
|
|
|
|
|
|
|
|
|
{
|
|
|
|
|
title: '序号',
|
|
|
|
|
dataIndex: 'index',
|
|
|
|
|
align: 'center',
|
|
|
|
|
width: 50,
|
|
|
|
|
render: (_text, _record, index) => (page - 1) * 20 + index + 1, // 显示序号,从1开始
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
|
2024-08-12 14:43:58 +08:00
|
|
|
|
{
|
|
|
|
|
title: '订单号',
|
|
|
|
|
dataIndex: 'orderNo',
|
|
|
|
|
align: 'center',
|
|
|
|
|
width: 250,
|
|
|
|
|
fixed: 'left'
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
title: '总金额',
|
|
|
|
|
dataIndex: 'totalAmount',
|
|
|
|
|
align: 'center',
|
|
|
|
|
width: 100,
|
|
|
|
|
fixed: 'left',
|
|
|
|
|
render: (value) => {
|
|
|
|
|
return (value / 100).toFixed(2)
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
title: '订单状态',
|
|
|
|
|
dataIndex: 'orderStatus',
|
|
|
|
|
align: 'center',
|
|
|
|
|
width: 100,
|
|
|
|
|
render: (value) => {
|
|
|
|
|
if (value === 'COMPLETE') {
|
|
|
|
|
return '完成';
|
|
|
|
|
}
|
2024-08-29 17:56:39 +08:00
|
|
|
|
if (value === 'FULL_REFUND') {
|
2024-08-27 18:29:20 +08:00
|
|
|
|
return '全额退款';
|
2024-08-29 17:56:39 +08:00
|
|
|
|
}
|
2024-08-27 18:29:20 +08:00
|
|
|
|
if (value === 'PENDING') {
|
|
|
|
|
return '等待';
|
|
|
|
|
}
|
|
|
|
|
if (value === 'CORRECTION1_REFUND') {
|
|
|
|
|
return '补正1次退款';
|
|
|
|
|
}
|
|
|
|
|
if (value === 'CORRECTION2_REFUND') {
|
|
|
|
|
return '补正2次退款';
|
2024-08-12 14:43:58 +08:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
title: '创建时间',
|
|
|
|
|
dataIndex: 'gmtCreate',
|
|
|
|
|
align: 'center',
|
|
|
|
|
width: 180
|
|
|
|
|
},
|
2024-08-29 17:56:39 +08:00
|
|
|
|
Table.EXPAND_COLUMN,
|
2024-08-27 18:29:20 +08:00
|
|
|
|
// {
|
2024-08-29 17:56:39 +08:00
|
|
|
|
// title: '订单详情',
|
2024-08-27 18:29:20 +08:00
|
|
|
|
// align: 'center',
|
|
|
|
|
// width: 100,
|
2024-08-29 17:56:39 +08:00
|
|
|
|
// render: (_, record) => (
|
|
|
|
|
// // {record.name}
|
|
|
|
|
// <div className='refunBtn' onClick={() => {
|
|
|
|
|
// // console.log(record.orderId); //id
|
|
|
|
|
// // console.log(record.orderNo); //编号
|
|
|
|
|
// // setOrderId(record.orderId)
|
|
|
|
|
// // setOrderDetailsModal(true)
|
|
|
|
|
// // getOrderDetails(record.orderId)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// }}>查看</div>
|
|
|
|
|
// ),
|
2024-08-27 18:29:20 +08:00
|
|
|
|
// },
|
2024-08-29 17:56:39 +08:00
|
|
|
|
|
2024-08-27 18:29:20 +08:00
|
|
|
|
]
|
|
|
|
|
const detailColumns: TableProps<DataTypeDetail>['columns'] = [
|
|
|
|
|
{
|
2024-08-29 17:56:39 +08:00
|
|
|
|
title: <div style={{
|
|
|
|
|
// color: 'rgba(0, 0, 0, 0.45)'
|
|
|
|
|
}}>商品名称</div>,
|
2024-08-27 18:29:20 +08:00
|
|
|
|
dataIndex: 'productName',
|
|
|
|
|
align: 'center',
|
|
|
|
|
// width: 250,
|
|
|
|
|
ellipsis: {
|
|
|
|
|
showTitle: false,
|
|
|
|
|
},
|
2024-08-12 14:43:58 +08:00
|
|
|
|
render: (_value, record) => {
|
2024-08-27 18:29:20 +08:00
|
|
|
|
return <Tooltip placement="top" title={record.productName}>{record.productName}</Tooltip>
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
{
|
2024-08-29 17:56:39 +08:00
|
|
|
|
title: <div >商品类型</div>,
|
2024-08-27 18:29:20 +08:00
|
|
|
|
dataIndex: 'productType',
|
|
|
|
|
align: 'center',
|
|
|
|
|
render: (_value, record) => {
|
|
|
|
|
if (record.productType === 'PROJ') {
|
2024-08-12 14:43:58 +08:00
|
|
|
|
return '项目创建'
|
|
|
|
|
}
|
2024-08-27 18:29:20 +08:00
|
|
|
|
if (record.productType === 'AGENT') {
|
2024-08-12 14:43:58 +08:00
|
|
|
|
return '项目代理'
|
|
|
|
|
}
|
2024-08-27 18:29:20 +08:00
|
|
|
|
if (record.productType === 'FULL_REFUND') {
|
|
|
|
|
return '全额退款'
|
|
|
|
|
}
|
|
|
|
|
if (record.productType === 'CORRECTION1_REFUND') {
|
|
|
|
|
return '补正1次退款'
|
|
|
|
|
}
|
|
|
|
|
if (record.productType === 'CORRECTION2_REFUND') {
|
|
|
|
|
return '补正2次退款'
|
|
|
|
|
}
|
|
|
|
|
return record.productType
|
2024-08-12 14:43:58 +08:00
|
|
|
|
}
|
2024-08-27 18:29:20 +08:00
|
|
|
|
|
2024-08-12 14:43:58 +08:00
|
|
|
|
},
|
|
|
|
|
{
|
2024-08-29 17:56:39 +08:00
|
|
|
|
title: <div >购买数量</div>,
|
2024-08-27 18:29:20 +08:00
|
|
|
|
dataIndex: 'quantity',
|
2024-08-12 14:43:58 +08:00
|
|
|
|
align: 'center',
|
|
|
|
|
width: 100,
|
2024-08-27 18:29:20 +08:00
|
|
|
|
|
2024-08-12 14:43:58 +08:00
|
|
|
|
},
|
|
|
|
|
{
|
2024-08-29 17:56:39 +08:00
|
|
|
|
title: <div >单价</div>,
|
2024-08-27 18:29:20 +08:00
|
|
|
|
dataIndex: 'unitPrice',
|
2024-08-12 14:43:58 +08:00
|
|
|
|
align: 'center',
|
2024-08-27 18:29:20 +08:00
|
|
|
|
render: (value) => {
|
|
|
|
|
return (value / 100).toFixed(2)
|
2024-08-12 14:43:58 +08:00
|
|
|
|
}
|
2024-08-27 18:29:20 +08:00
|
|
|
|
|
2024-08-12 14:43:58 +08:00
|
|
|
|
},
|
2024-08-27 18:29:20 +08:00
|
|
|
|
|
2024-08-12 14:43:58 +08:00
|
|
|
|
{
|
2024-08-29 17:56:39 +08:00
|
|
|
|
title: <div >订单备注</div>,
|
2024-08-12 14:43:58 +08:00
|
|
|
|
dataIndex: 'detail.notes',
|
|
|
|
|
align: 'center',
|
2024-08-27 18:29:20 +08:00
|
|
|
|
// width: 120,
|
2024-08-30 10:07:41 +08:00
|
|
|
|
ellipsis: {
|
|
|
|
|
showTitle: false,
|
|
|
|
|
},
|
2024-08-12 14:43:58 +08:00
|
|
|
|
render: (_value, record) => {
|
2024-08-27 18:29:20 +08:00
|
|
|
|
return <Tooltip placement="top" title={record.notes}>{record.notes}</Tooltip>
|
2024-08-12 14:43:58 +08:00
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
{
|
2024-08-29 17:56:39 +08:00
|
|
|
|
title: <div >商品描述</div>,
|
2024-08-27 18:29:20 +08:00
|
|
|
|
dataIndex: 'productDescription',
|
2024-08-12 14:43:58 +08:00
|
|
|
|
align: 'center',
|
|
|
|
|
width: 200,
|
|
|
|
|
ellipsis: {
|
|
|
|
|
showTitle: false,
|
|
|
|
|
},
|
|
|
|
|
render: (_value, record) => {
|
2024-08-27 18:29:20 +08:00
|
|
|
|
return <Tooltip placement="top" title={record.productDescription}>{record.productDescription}</Tooltip>
|
2024-08-12 14:43:58 +08:00
|
|
|
|
}
|
2024-08-27 18:29:20 +08:00
|
|
|
|
}
|
2024-08-12 14:43:58 +08:00
|
|
|
|
]
|
|
|
|
|
// useEffect(() => {
|
|
|
|
|
// getData();
|
|
|
|
|
// }, []);
|
2024-08-27 18:29:20 +08:00
|
|
|
|
const handleSearch = (value: string) => {
|
|
|
|
|
// console.log(value);
|
|
|
|
|
setKewWords(value)
|
|
|
|
|
}
|
2024-08-30 16:10:27 +08:00
|
|
|
|
|
2024-08-27 18:29:20 +08:00
|
|
|
|
const handleChange = (e: any) => {
|
|
|
|
|
|
|
|
|
|
// console.log(e.target.value);
|
|
|
|
|
if (e.target.value == '') {
|
|
|
|
|
setKewWords('')
|
|
|
|
|
}
|
|
|
|
|
}
|
2024-08-30 16:10:27 +08:00
|
|
|
|
const namehandleSearch = (value: string) => {
|
|
|
|
|
setProductName(value)
|
|
|
|
|
}
|
|
|
|
|
const namehandleChange = (e: any) => {
|
2024-08-29 17:56:39 +08:00
|
|
|
|
|
2024-08-30 16:10:27 +08:00
|
|
|
|
// console.log(e.target.value);
|
|
|
|
|
if (e.target.value == '') {
|
|
|
|
|
// setKewWords('')
|
|
|
|
|
setProductName('')
|
|
|
|
|
}
|
|
|
|
|
}
|
2024-08-12 14:43:58 +08:00
|
|
|
|
useEffect(() => {
|
|
|
|
|
getData();
|
2024-08-30 16:10:27 +08:00
|
|
|
|
}, [page, keyWords, productName]);
|
2024-08-29 17:56:39 +08:00
|
|
|
|
// useEffect(() => {
|
|
|
|
|
// if (orderId) {
|
|
|
|
|
// getOrderDetails()
|
|
|
|
|
// }
|
|
|
|
|
// }, [orderId])
|
2024-08-12 14:43:58 +08:00
|
|
|
|
return (
|
|
|
|
|
<div>
|
|
|
|
|
{messageContext}
|
2024-08-27 18:29:20 +08:00
|
|
|
|
<div style={{
|
|
|
|
|
marginBottom: 10,
|
|
|
|
|
marginTop: 10
|
|
|
|
|
}}>
|
|
|
|
|
<Search placeholder="输入订单号查询订单"
|
|
|
|
|
// value={nowKeyword}
|
|
|
|
|
onSearch={handleSearch}
|
|
|
|
|
onChange={handleChange}
|
|
|
|
|
style={{
|
2024-08-30 16:10:27 +08:00
|
|
|
|
width: '220px',
|
2024-08-29 17:56:39 +08:00
|
|
|
|
|
2024-08-27 18:29:20 +08:00
|
|
|
|
}}
|
2024-08-29 17:56:39 +08:00
|
|
|
|
allowClear
|
2024-08-27 18:29:20 +08:00
|
|
|
|
/>
|
2024-08-30 16:10:27 +08:00
|
|
|
|
<Search placeholder="输入商品名称查询订单"
|
|
|
|
|
// value={nowKeyword}
|
|
|
|
|
onSearch={namehandleSearch}
|
|
|
|
|
onChange={namehandleChange}
|
|
|
|
|
style={{
|
|
|
|
|
width: '220px',
|
|
|
|
|
marginLeft: 10
|
|
|
|
|
}}
|
|
|
|
|
allowClear
|
|
|
|
|
/>
|
2024-08-27 18:29:20 +08:00
|
|
|
|
</div>
|
|
|
|
|
|
2024-08-12 14:43:58 +08:00
|
|
|
|
<Spin tip="加载中..." spinning={isLoading}>
|
|
|
|
|
<Table columns={columns} dataSource={dataArray}
|
|
|
|
|
pagination={
|
|
|
|
|
{
|
|
|
|
|
pageSize: 20,
|
|
|
|
|
total: total,
|
|
|
|
|
onChange: (currentPage) => {
|
|
|
|
|
setPage(currentPage);
|
|
|
|
|
},
|
2024-08-27 18:29:20 +08:00
|
|
|
|
showSizeChanger: false
|
2024-08-12 14:43:58 +08:00
|
|
|
|
}
|
|
|
|
|
}
|
2024-08-29 17:56:39 +08:00
|
|
|
|
expandable={{
|
|
|
|
|
expandedRowRender: (record) => {
|
|
|
|
|
// setorderId(record.orderId)
|
2024-08-30 16:10:27 +08:00
|
|
|
|
return <div style={{ padding: '0px 20px', marginLeft: 60 }}>
|
2024-08-29 17:56:39 +08:00
|
|
|
|
<div style={{
|
|
|
|
|
marginBottom: 10
|
|
|
|
|
}}>订单详情</div>
|
|
|
|
|
<Spin tip="加载中..." spinning={isLoading}>
|
|
|
|
|
<Table columns={detailColumns}
|
|
|
|
|
dataSource={record.orderDetails}
|
|
|
|
|
pagination={false}
|
|
|
|
|
bordered key="orderDetailId" rowKey="orderDetailId"
|
|
|
|
|
style={{ border: '1px solid #efefef' }}
|
|
|
|
|
/>
|
|
|
|
|
</Spin>
|
|
|
|
|
</div>
|
|
|
|
|
},
|
|
|
|
|
defaultExpandAllRows: true,
|
|
|
|
|
// columnTitle:'订单详情'
|
|
|
|
|
expandedRowKeys: expandedRowKeys,
|
|
|
|
|
}}
|
|
|
|
|
bordered
|
|
|
|
|
scroll={{ y: 500 }} key="orderId" rowKey="orderId" />
|
2024-08-12 14:43:58 +08:00
|
|
|
|
</Spin>
|
2024-08-29 17:56:39 +08:00
|
|
|
|
{/* <Modal
|
2024-08-27 18:29:20 +08:00
|
|
|
|
title="订单详情"
|
|
|
|
|
cancelText="取消"
|
|
|
|
|
destroyOnClose={true}
|
|
|
|
|
open={orderDetailsModal}
|
|
|
|
|
// onOk={() => {
|
|
|
|
|
// setOrderDetailsModal(false)
|
|
|
|
|
// }}
|
|
|
|
|
width={1300}
|
|
|
|
|
onCancel={() => {
|
|
|
|
|
setOrderDetailsModal(false)
|
|
|
|
|
}}
|
|
|
|
|
footer={null}
|
|
|
|
|
>
|
|
|
|
|
<Spin tip="加载中..." spinning={isLoading}>
|
|
|
|
|
<Table columns={detailColumns}
|
|
|
|
|
dataSource={detailData}
|
|
|
|
|
// pagination={
|
|
|
|
|
// {
|
|
|
|
|
// pageSize: 20,
|
|
|
|
|
// total: total,
|
|
|
|
|
// onChange: (currentPage) => {
|
|
|
|
|
// setPage(currentPage);
|
|
|
|
|
// },
|
|
|
|
|
// showSizeChanger: false
|
|
|
|
|
// }
|
|
|
|
|
// }
|
|
|
|
|
pagination={false}
|
|
|
|
|
// scroll={{ y: 500 }}
|
2024-08-27 18:38:36 +08:00
|
|
|
|
bordered key="dataTable" rowKey="orderDetailId" />
|
2024-08-27 18:29:20 +08:00
|
|
|
|
</Spin>
|
2024-08-29 17:56:39 +08:00
|
|
|
|
</Modal> */}
|
2024-08-12 14:43:58 +08:00
|
|
|
|
</div>
|
|
|
|
|
)
|
|
|
|
|
}
|