page.js 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154
  1. import React from 'react';
  2. import './index.less';
  3. import Page from '@src/containers/Page';
  4. import Block from '@src/components/Block';
  5. import FilterLayout from '@src/layouts/FilterLayout';
  6. import ActionLayout from '@src/layouts/ActionLayout';
  7. import TableLayout from '@src/layouts/TableLayout';
  8. import { getMap, formatDate, bindSearch } from '@src/services/Tools';
  9. import { asyncSMessage, asyncDelConfirm } from '@src/services/AsyncTools';
  10. import { SwitchSelect, InvoiceType } from '../../../../Constant';
  11. import { User } from '../../../stores/user';
  12. const SwitchSelectMap = getMap(SwitchSelect, 'value', 'label');
  13. const InvoiceTypeMap = getMap(InvoiceType, 'value', 'label');
  14. export default class extends Page {
  15. init() {
  16. this.exerciseMap = {};
  17. this.filterForm = [{
  18. key: 'userId',
  19. type: 'tree',
  20. allowClear: true,
  21. tree: [],
  22. name: '用户',
  23. placeholder: '用户',
  24. }, {
  25. key: 'isDownload',
  26. type: 'select',
  27. allowClear: true,
  28. name: '下载状态',
  29. select: SwitchSelect,
  30. number: true,
  31. }, {
  32. key: 'isFinish',
  33. type: 'select',
  34. allowClear: true,
  35. name: '开票状态',
  36. select: SwitchSelect,
  37. number: true,
  38. }];
  39. this.actionList = [{
  40. key: 'download',
  41. name: '下载',
  42. }, {
  43. key: 'finish',
  44. name: '批量开票',
  45. }];
  46. this.columns = [{
  47. title: '申请时间',
  48. dataIndex: 'createTime',
  49. render: (text) => {
  50. return formatDate(text);
  51. },
  52. }, {
  53. title: '申请用户',
  54. dataIndex: 'userId',
  55. render: (text, record) => {
  56. return `${record.user.nickname}`;
  57. },
  58. }, {
  59. title: '发票金额',
  60. dataIndex: 'order.invoiceMoney',
  61. }, {
  62. title: '抬头类型',
  63. dataIndex: 'invoiceType',
  64. render: (text) => {
  65. return InvoiceTypeMap[text] || text;
  66. },
  67. }, {
  68. title: '抬头',
  69. dataIndex: 'title',
  70. }, {
  71. title: '纳税人识别号',
  72. dataIndex: 'identity',
  73. }, {
  74. title: '邮箱',
  75. dataIndex: 'user.email',
  76. }, {
  77. title: '开票状态',
  78. dataIndex: 'isFinish',
  79. render: (text) => {
  80. return SwitchSelectMap[text ? 1 : 0];
  81. },
  82. }, {
  83. title: '下载状态',
  84. dataIndex: 'isDownload',
  85. render: (text) => {
  86. return SwitchSelectMap[text ? 1 : 0];
  87. },
  88. }];
  89. bindSearch(this.filterForm, 'userId', this, (search) => {
  90. return User.list(search);
  91. }, (row) => {
  92. return {
  93. title: `${row.nickname}(${row.mobile})`,
  94. value: row.id,
  95. };
  96. }, this.state.search.userId ? Number(this.state.search.userId) : null, null);
  97. }
  98. initData() {
  99. User.listInvoice(this.state.search).then(result => {
  100. this.setTableData(result.list, result.total);
  101. });
  102. }
  103. downloadAction() {
  104. const { selectedKeys } = this.state;
  105. asyncDelConfirm('下载确认', '是否下载选中记录?', () => {
  106. return User.downloadInvoice({ ids: selectedKeys }).then(() => {
  107. asyncSMessage('操作成功!');
  108. this.refresh();
  109. });
  110. });
  111. }
  112. finishAction() {
  113. const { selectedKeys } = this.state;
  114. asyncDelConfirm('开票确认', '是否开票选中记录?', () => {
  115. return User.finishInvoice({ ids: selectedKeys }).then(() => {
  116. asyncSMessage('操作成功!');
  117. this.refresh();
  118. });
  119. });
  120. }
  121. renderView() {
  122. return <Block flex>
  123. {<FilterLayout
  124. show
  125. itemList={this.filterForm}
  126. data={this.state.search}
  127. onChange={data => {
  128. this.search(data);
  129. }} />}
  130. <ActionLayout
  131. itemList={this.actionList}
  132. selectedKeys={this.state.selectedKeys}
  133. onAction={key => this.onAction(key)}
  134. />
  135. <TableLayout
  136. select
  137. columns={this.tableSort(this.columns)}
  138. list={this.state.list}
  139. pagination={this.state.page}
  140. loading={this.props.core.loading}
  141. onChange={(pagination, filters, sorter) => this.tableChange(pagination, filters, sorter)}
  142. onSelect={(keys, rows) => this.tableSelect(keys, rows)}
  143. selectedKeys={this.state.selectedKeys}
  144. />
  145. </Block>;
  146. }
  147. }