import { Table, TableProps, Tooltip, Spin, // Modal, Input } from "antd"; const { Search } = Input; import { useEffect, useState } from "react"; import useMessage from "antd/es/message/useMessage"; import { get } from "../../util/AjaxUtils"; import './myorder.css' type IListPage = { page: number; total: number; rows: T[] } // type DetailDataType = { // productType: string; // quantity: number; // unitPrice: number; // notes: string; // productDescription: string; // } type DataType = { orderId: string; orderNo: string; totalAmount: number; orderDetails: any; orderStatus: string; gmtCreate: string; } type DataTypeDetail = { productName: string; //商品名称 productType: string; //商品类型 quantity: number; //购买数量 unitPrice: number; //单价 productDescription: string; //商品描述 notes: string; //备注 } 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([]); // const [detailData, setDetailData] = useState([]) // const [orderId, setorderId] = useState('') // const [orderDetailsModal, setOrderDetailsModal] = useState(false) //详情弹窗 const [keyWords, setKewWords] = useState('') const [expandedRowKeys, setExpandedRowKeys] = useState([]); //展开项 const getData = () => { // setDataArray([]) get>({ messageApi, url: '/api/order/listpage/self', config: { params: { page: page, rows: 20, keywords: keyWords, } }, onBefore() { setIsLoading(true); }, onSuccess({ data }) { // console.log(data); setPage(data.page); setTotal(data.total); setDataArray(data.rows); setExpandedRowKeys(data.rows.map(item => item.orderId)) }, onFinally() { setIsLoading(false); } }) } // const getOrderDetails = () => { // get({ // messageApi, // url: `/api/order-detail/list/order-id/${orderId}`, // config: { // }, // onBefore() { // setIsLoading(true); // }, // onSuccess(data: any) { // // console.log(data.data); // setDetailData(data.data) // }, // onFinally() { // setIsLoading(false); // } // }) // } const columns: TableProps['columns'] = [ { title: '序号', dataIndex: 'index', align: 'center', width: 50, render: (_text, _record, index) => (page - 1) * 20 + index + 1, // 显示序号,从1开始 }, { 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 '完成'; } if (value === 'FULL_REFUND') { return '全额退款'; } if (value === 'PENDING') { return '等待'; } if (value === 'CORRECTION1_REFUND') { return '补正1次退款'; } if (value === 'CORRECTION2_REFUND') { return '补正2次退款'; } } }, { title: '创建时间', dataIndex: 'gmtCreate', align: 'center', width: 180 }, Table.EXPAND_COLUMN, // { // title: '订单详情', // align: 'center', // width: 100, // render: (_, record) => ( // // {record.name} //
{ // // console.log(record.orderId); //id // // console.log(record.orderNo); //编号 // // setOrderId(record.orderId) // // setOrderDetailsModal(true) // // getOrderDetails(record.orderId) // }}>查看
// ), // }, ] const detailColumns: TableProps['columns'] = [ { title:
商品名称
, dataIndex: 'productName', align: 'center', // width: 250, ellipsis: { showTitle: false, }, render: (_value, record) => { return {record.productName} } }, { title:
商品类型
, dataIndex: 'productType', align: 'center', render: (_value, record) => { if (record.productType === 'PROJ') { return '项目创建' } if (record.productType === 'AGENT') { return '项目代理' } if (record.productType === 'FULL_REFUND') { return '全额退款' } if (record.productType === 'CORRECTION1_REFUND') { return '补正1次退款' } if (record.productType === 'CORRECTION2_REFUND') { return '补正2次退款' } return record.productType } }, { title:
购买数量
, dataIndex: 'quantity', align: 'center', width: 100, }, { title:
单价
, dataIndex: 'unitPrice', align: 'center', render: (value) => { return (value / 100).toFixed(2) } }, { title:
订单备注
, dataIndex: 'detail.notes', align: 'center', // width: 120, render: (_value, record) => { return {record.notes} } }, { title:
商品描述
, dataIndex: 'productDescription', align: 'center', width: 200, ellipsis: { showTitle: false, }, render: (_value, record) => { return {record.productDescription} } } ] // useEffect(() => { // getData(); // }, []); const handleSearch = (value: string) => { // console.log(value); setKewWords(value) } const handleChange = (e: any) => { // console.log(e.target.value); if (e.target.value == '') { setKewWords('') } } useEffect(() => { getData(); }, [page, keyWords]); // useEffect(() => { // if (orderId) { // getOrderDetails() // } // }, [orderId]) return (
{messageContext}
{ setPage(currentPage); }, showSizeChanger: false } } expandable={{ expandedRowRender: (record) => { // setorderId(record.orderId) return
订单详情
}, defaultExpandAllRows: true, // columnTitle:'订单详情' expandedRowKeys: expandedRowKeys, }} bordered scroll={{ y: 500 }} key="orderId" rowKey="orderId" /> {/* { // setOrderDetailsModal(false) // }} width={1300} onCancel={() => { setOrderDetailsModal(false) }} footer={null} >
{ // setPage(currentPage); // }, // showSizeChanger: false // } // } pagination={false} // scroll={{ y: 500 }} bordered key="dataTable" rowKey="orderDetailId" /> */} ) }