import React, { PureComponent } from 'react'; import moment from 'moment'; import { connect } from 'dva'; import { Button, Card, Col, Divider, Form, Input, Row, Tabs, DatePicker, List } from 'antd'; import PageHeaderWrapper from '@/components/PageHeaderWrapper'; import DictionaryText from '@/components/Dictionary/DictionaryText'; import OrderUpdatePayAmount from './OrderUpdatePayAmount'; import dictionary from '@/utils/dictionary'; import styles from './OrderList.less'; const { RangePicker } = DatePicker; const FormItem = Form.Item; const { TabPane } = Tabs; const OrderContent = orderItem => { const { dispatch, skuName, skuImage, quantity, price, payAmount, createTime, status } = orderItem; const handleUpdatePayAmount = updateOrderItem => { dispatch({ type: 'orderList/changePayAmountVisible', payload: { payAmountVisible: true, payAmount: updateOrderItem.payAmount, orderId: updateOrderItem.orderId, orderItemId: updateOrderItem.id, }, }); }; return (
{skuName}
(名称)
{skuName}
秋季精选
(金额/物件)
{quantity}件
{price / 100} 元/{quantity * (price / 100)} 元
(购买人)
范先生
13302926050
(下单时间)
{moment(createTime).format('YYYY-MM-DD HH:mm')}
 
(订单状态)
{[0, 1, 2].indexOf(status) ? : ''}
(实付金额)
{payAmount / 100}元
handleUpdatePayAmount(orderItem)}>修改价格
); }; const OrderList = props => { const { list, dispatch, loading } = props; const { pagination, dataSource } = list; const paginationProps = { ...pagination, }; return ( (
订单号: {item.orderNo} 支付金额: {item.payAmount / 100} 元
查看详情 备注
{item.orderItems.map(orderItem => { return ; })}
)} /> ); }; // SearchForm const SearchForm = Form.create()(props => { const { form: { getFieldDecorator }, form, handleSearch, } = props; const handleFormReset = () => {}; const onSubmit = e => { e.preventDefault(); form.validateFields((err, fields) => { const buildTime = (fieldValue, key) => { const res = {}; if (fieldValue) { const keySuffix = key.substring(0, 1).toUpperCase() + key.substring(1); // res[`start${keySuffix}`] = fieldValue[0].valueOf(); res[`start${keySuffix}`] = fieldValue[0].format('YYYY-MM-DD HH:mm:ss'); // res[`end${keySuffix}`] = fieldValue[1].valueOf(); res[`end${keySuffix}`] = fieldValue[1].format('YYYY-MM-DD HH:mm:ss'); } return res; }; const timeFields = ['createTime', 'closingTime']; const buildSearchParams = fields2 => { let res = {}; Object.keys(fields).map(objectKey => { const fieldValue = fields2[objectKey]; if (timeFields.indexOf(objectKey) !== -1) { // 处理时间 res = { ...res, ...buildTime(fieldValue, objectKey), }; } else if (fieldValue !== undefined) { res[objectKey] = fieldValue; } return true; }); return res; }; const searchParams = buildSearchParams(fields); if (handleSearch) { handleSearch(searchParams); } }); }; return (
{getFieldDecorator('id')()} {getFieldDecorator('orderNo')()} {getFieldDecorator('createTime')()} {getFieldDecorator('closingTime')()}
); }); @connect(({ orderList, loading }) => ({ orderList, list: orderList.list, loading: loading.models.orderList, })) class BasicList extends PureComponent { componentDidMount() { const { list: { pagination }, } = this.props; this.queryList({ pageNo: pagination.current, pageSize: pagination.pageSize, }); } queryList = params => { const { dispatch } = this.props; // 保存每次操作 searchParams this.searchParams = params; // dispatch dispatch({ type: 'orderList/queryPage', payload: { ...params, }, }); }; handleEditorClick = () => { console.info('edit'); }; handleSearch = fields => { const { list: { pagination }, } = this.props; this.queryList({ ...fields, pageNo: pagination.current, pageSize: pagination.pageSize, }); }; handleTabsChange = key => { const params = { ...this.searchParams, status: key, }; this.queryList(params); }; render() { return (
); } } export default BasicList;