import React from 'react'; import './index.less'; import Page from '@src/containers/Page'; import Block from '@src/components/Block'; import FilterLayout from '@src/layouts/FilterLayout'; import ActionLayout from '@src/layouts/ActionLayout'; import TableLayout from '@src/layouts/TableLayout'; import { getMap, formatDate, bindSearch } from '@src/services/Tools'; import { asyncSMessage, asyncDelConfirm } from '@src/services/AsyncTools'; import { SwitchSelect, InvoiceType } from '../../../../Constant'; import { User } from '../../../stores/user'; const SwitchSelectMap = getMap(SwitchSelect, 'value', 'label'); const InvoiceTypeMap = getMap(InvoiceType, 'value', 'label'); export default class extends Page { init() { this.exerciseMap = {}; this.filterForm = [{ key: 'userId', type: 'select', allowClear: true, name: '用户', select: [], number: true, placeholder: '请输入', }, { key: 'isDownload', type: 'select', allowClear: true, name: '下载状态', select: SwitchSelect, number: true, }, { key: 'isFinish', type: 'select', allowClear: true, name: '开票状态', select: SwitchSelect, number: true, }]; this.actionList = [{ key: 'download', name: '下载', needSelect: 1, }, { key: 'finish', name: '批量开票', needSelect: 1, }]; this.columns = [{ title: '申请时间', dataIndex: 'createTime', render: (text) => { return formatDate(text, 'YYYY-MM-DD HH:mm:ss'); }, }, { title: '申请用户', dataIndex: 'userId', render: (text, record) => { return `${record.user.nickname}`; }, }, { title: '发票金额', dataIndex: 'order.invoiceMoney', }, { title: '抬头类型', dataIndex: 'invoiceType', render: (text) => { return InvoiceTypeMap[text] || text; }, }, { title: '抬头', dataIndex: 'title', }, { title: '纳税人识别号', dataIndex: 'identity', }, { title: '邮箱', dataIndex: 'user.email', }, { title: '开票状态', dataIndex: 'isFinish', render: (text) => { return SwitchSelectMap[text ? 1 : 0]; }, }, { title: '下载状态', dataIndex: 'isDownload', render: (text) => { return SwitchSelectMap[text ? 1 : 0]; }, }]; bindSearch(this.filterForm, 'userId', this, (search) => { return User.list(search); }, (row) => { return { title: `${row.nickname}(${row.mobile})`, value: row.id, }; }, this.state.search.userId ? Number(this.state.search.userId) : null, null); } initData() { User.listInvoice(this.state.search).then(result => { this.setTableData(result.list, result.total); }); } downloadAction() { const { selectedKeys } = this.state; asyncDelConfirm('下载确认', '是否下载选中记录?', () => { openLink(`/api/user/invoice/download?${selectedKeys.map(row => `ids=${row}`).join('&')}`); }); } finishAction() { const { selectedKeys } = this.state; asyncDelConfirm('开票确认', '是否开票选中记录?', () => { return User.finishInvoice({ ids: selectedKeys }).then(() => { asyncSMessage('操作成功!'); this.refresh(); }); }); } renderView() { return { { data.page = 1; this.search(data); }} />} this.onAction(key)} /> this.tableChange(pagination, filters, sorter)} onSelect={(keys, rows) => this.tableSelect(keys, rows)} selectedKeys={this.state.selectedKeys} /> ; } }