1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798 |
- import React from 'react';
- import './index.less';
- import Page from '@src/containers/Page';
- import { getMap, formatMoney, formatDate } from '@src/services/Tools';
- import UserLayout from '../../../layouts/User';
- import menu from '../index';
- import UserTable from '../../../components/UserTable';
- import { Order } from '../../../stores/order';
- import { RecordSource, ServiceKey } from '../../../../Constant';
- const RecordSourceMap = getMap(RecordSource, 'value', 'label');
- const ServiceKeyMap = getMap(ServiceKey, 'value', 'label');
- const columns = [
- { title: '订单编号', key: 'orderId' },
- {
- title: '服务',
- key: 'title',
- render: (text, record) => {
- if (record.productType === 'course-package') {
- return (record.coursePackage || {}).title;
- }
- if (record.productType === 'course') {
- return (record.course || {}).title;
- }
- if (record.productType === 'data') {
- return (record.data || {}).title;
- }
- if (record.productType === 'service') {
- return `${ServiceKeyMap[text]}`;
- }
- return '';
- },
- },
- {
- title: '购买时间',
- key: 'createTime',
- render: (text) => {
- return formatDate(text, 'YYYY-MM-DD\nHH:mm:ss');
- },
- },
- {
- title: '付款方式',
- key: 'source',
- render: (text) => {
- return RecordSourceMap[text];
- },
- },
- {
- title: '付款金额',
- key: 'money',
- render: (text) => {
- return formatMoney(text);
- },
- },
- ];
- export default class extends Page {
- constructor(props) {
- props.size = 15;
- super(props);
- }
- initState() {
- return {};
- }
- initData() {
- Order.list(this.state.search)
- .then(result => {
- this.setState({ list: result.list, total: result.total, page: this.state.search.page });
- });
- }
- onChangePage(page) {
- this.search({ page });
- }
- renderView() {
- const { config } = this.props;
- return <UserLayout active={config.key} menu={menu} center={this.renderTable()} />;
- }
- renderTable() {
- const { list, total, page } = this.state;
- return (
- <div className="table-layout">
- <UserTable
- size="small"
- columns={columns}
- data={list}
- onChange={p => this.onChangePage(p)}
- total={total}
- current={page}
- />
- </div>
- );
- }
- }
|