import React from 'react'; import './index.less'; import { Icon, Radio } from 'antd'; import Page from '@src/containers/Page'; import { asyncSMessage } from '@src/services/AsyncTools'; import { getMap, formatMoney, formatDate } from '@src/services/Tools'; import UserLayout from '../../../layouts/User'; import menu from '../index'; import UserTable from '../../../components/UserTable'; import Modal from '../../../components/Modal'; import More from '../../../components/More'; import IconButton from '../../../components/IconButton'; import { Order } from '../../../stores/order'; import { RecordSource, InvoiceType } from '../../../../Constant'; import { User } from '../../../stores/user'; const RecordSourceMap = getMap(RecordSource, 'value', 'label'); export default class extends Page { constructor(props) { props.size = 15; super(props); } init() { this.columns = [ { title: '订单编号', key: 'id', render: text => { return text; }, }, { title: '服务', key: 'title', render: (text, record) => { const actionList = []; if (record.canInvoice && !record.hasInvoice) { actionList.push({ key: 'invoice', label: '开发票' }); } if (record.canInvoice) { actionList.push({ key: 'detail', label: '订单详情' }); } const onAction = value => { const { key } = value; switch (key) { case 'invoice': this.setState({ showInvoice: true, invoice: { orderId: record.id, money: record.invoiceMoney, invoiceType: InvoiceType[0].value }, }); break; case 'detail': openLink(`/order/${record.id}`); break; default: } }; let content = []; if (record.checkouts.length > 3) { content.push(
{record.checkouts[0].title}
等{record.checkouts.length}个商品
{actionList.length > 0 && }
, ); } else { content = record.checkouts.map((row, index) => { return (
{row.title}
{index === 0 && actionList.length > 0 && ( )} {row.productType === 'data' && ( { openLink(row.data.resource); }} /> )}
); }); } return
{content}
; }, }, { title: '购买时间', key: 'createTime', render: text => { return (
{text.split(' ')[0]}
{text.split(' ')[1]}
); }, }, { title: '付款方式', key: 'payMethod', render: text => { return RecordSourceMap[text]; }, }, { title: '付款金额', key: 'money', render: text => { return ¥{formatMoney(text)}; }, }, ]; } initState() { return { list: [], }; } initData() { Order.list(this.state.search).then(result => { result.list = result.list.map(row => { row.checkouts = row.checkouts || []; User.formatOrder(row); row.createTime = formatDate(row.createTime, 'YYYY-MM-DD HH:mm:ss'); return row; }); this.setState({ list: result.list, total: result.total, page: this.state.search.page }); }); } onChangePage(page) { this.search({ page }); } submitInvoice(invoice) { if (!invoice.title) return; if (invoice.invoiceType === 'enterprise' && !invoice.identity) return; Order.openInvoice(invoice) .then(() => { this.refresh(); this.setState({ showFinish: true, showInvoice: false, invoice: {} }); }) .catch(e => { asyncSMessage(e.message, 'error'); }); } renderView() { const { config } = this.props; return ; } renderTable() { const { list, total, page, showInvoice, showInvoiceFinish, invoice = {} } = this.state; const { info } = this.props.user; return (
this.onChangePage(p)} total={total} current={page} pageSize={this.state.search.size} /> this.submitInvoice(invoice)} onCancel={() => this.setState({ showInvoice: false })} >
发票类型:
普通增值税电子发票
抬头类型:
{InvoiceType.map(row => { return ( { invoice.invoiceType = row.value; this.setState({ invoice }); }} /> {row.label} ); })}
发票抬头:
{ invoice.title = e.target.value; this.setState({ invoice }); }} />
{invoice.invoiceType === 'enterprise' && (
纳税人识别号:
{ invoice.identity = e.target.value; this.setState({ invoice }); }} />
)}
发票内容:
商品明细
发票金额:
¥ {formatMoney(invoice.money)}
this.setState({ showInvoiceFinish: false })} >
我们会在三个工作日内将电子发票发送至您的绑定邮箱:
{info.email}
请注意查收。
我们也会通过站内信的方式通知您
); } }