123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155 |
- 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 <Block flex>
- {<FilterLayout
- show
- itemList={this.filterForm}
- data={this.state.search}
- onChange={data => {
- data.page = 1;
- this.search(data);
- }} />}
- <ActionLayout
- itemList={this.actionList}
- selectedKeys={this.state.selectedKeys}
- onAction={key => this.onAction(key)}
- />
- <TableLayout
- select
- columns={this.tableSort(this.columns)}
- list={this.state.list}
- pagination={this.state.page}
- loading={this.props.core.loading}
- onChange={(pagination, filters, sorter) => this.tableChange(pagination, filters, sorter)}
- onSelect={(keys, rows) => this.tableSelect(keys, rows)}
- selectedKeys={this.state.selectedKeys}
- />
- </Block>;
- }
- }
|