page.js 6.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212
  1. import React from 'react';
  2. import './index.less';
  3. import { Icon, Radio } from 'antd';
  4. import Page from '@src/containers/Page';
  5. import { asyncSMessage } from '@src/services/AsyncTools';
  6. import { getMap, formatMoney, formatDate } from '@src/services/Tools';
  7. import UserLayout from '../../../layouts/User';
  8. import menu from '../index';
  9. import UserTable from '../../../components/UserTable';
  10. import Modal from '../../../components/Modal';
  11. import More from '../../../components/More';
  12. import IconButton from '../../../components/IconButton';
  13. import { Order } from '../../../stores/order';
  14. import { RecordSource, ServiceKey } from '../../../../Constant';
  15. const RecordSourceMap = getMap(RecordSource, 'value', 'label');
  16. const ServiceKeyMap = getMap(ServiceKey, 'value', 'label');
  17. function formatTitle(record) {
  18. if (record.productType === 'course-package') {
  19. return (record.coursePackage || {}).title;
  20. }
  21. if (record.productType === 'course') {
  22. return (record.course || {}).title;
  23. }
  24. if (record.productType === 'data') {
  25. return (record.data || {}).title;
  26. }
  27. if (record.productType === 'service') {
  28. return `${ServiceKeyMap[record.service]}`;
  29. }
  30. return '';
  31. }
  32. const columns = [
  33. { title: '订单编号', key: 'id' },
  34. {
  35. title: '服务',
  36. key: 'title',
  37. render: (text, record) => {
  38. const actionList = [];
  39. if (record.canInvoice && !record.hasInvoice) {
  40. actionList.push({ key: 'invoice', label: '开发票' });
  41. }
  42. actionList.push({ key: 'detail', label: '订单详情' });
  43. const onAction = key => {
  44. switch (key) {
  45. case 'invoice':
  46. this.setState({ showInvoice: true, invoice: { orderId: record.id, money: record.invoiceMoney } });
  47. break;
  48. case 'detail':
  49. openLink(`/order/detail/${record.id}`);
  50. break;
  51. default:
  52. }
  53. };
  54. let content = '';
  55. if (record.checkouts.length > 3) {
  56. content = [
  57. <div className="flex-block">
  58. {formatTitle(record.checkouts[0])}
  59. <br />等{record.checkouts.length}个商品
  60. </div>,
  61. ];
  62. } else {
  63. content = record.checkouts
  64. .map(row => {
  65. return formatTitle(row);
  66. })
  67. .join(<br />);
  68. }
  69. return (
  70. <div className="t-2">
  71. <div className="flex-layout m-b-5">
  72. {content}
  73. <More actionList={actionList} onAction={onAction}>
  74. <IconButton type="more" />
  75. </More>
  76. </div>
  77. </div>
  78. );
  79. },
  80. },
  81. {
  82. title: '购买时间',
  83. key: 'createTime',
  84. render: text => {
  85. return formatDate(text, 'YYYY-MM-DD\nHH:mm:ss');
  86. },
  87. },
  88. {
  89. title: '付款方式',
  90. key: 'payMethod',
  91. render: text => {
  92. return RecordSourceMap[text];
  93. },
  94. },
  95. {
  96. title: '付款金额',
  97. key: 'money',
  98. render: text => {
  99. return formatMoney(text);
  100. },
  101. },
  102. ];
  103. export default class extends Page {
  104. constructor(props) {
  105. props.size = 15;
  106. super(props);
  107. }
  108. initState() {
  109. return {
  110. list: [],
  111. };
  112. }
  113. initData() {
  114. Order.list(this.state.search).then(result => {
  115. this.setState({ list: result.list, total: result.total, page: this.state.search.page });
  116. });
  117. }
  118. onChangePage(page) {
  119. this.search({ page });
  120. }
  121. submitInvoice(invoice) {
  122. Order.openInvoice(invoice)
  123. .then(() => {
  124. this.refresh();
  125. this.setState({ showFinish: true, showInvoice: false, invoice: {} });
  126. })
  127. .catch(e => {
  128. asyncSMessage(e.message, 'error');
  129. });
  130. }
  131. renderView() {
  132. const { config } = this.props;
  133. return <UserLayout active={config.key} menu={menu} center={this.renderTable()} />;
  134. }
  135. renderTable() {
  136. const { list, total, page } = this.state;
  137. return (
  138. <div className="table-layout">
  139. <UserTable
  140. size="small"
  141. columns={columns}
  142. data={list}
  143. onChange={p => this.onChangePage(p)}
  144. total={total}
  145. current={page}
  146. />
  147. <Modal title="开发票" width={630} btnType="link" confirmText="申请" onConfirm={() => {}} onCancel={() => {}}>
  148. <div className="input-layout m-b-2 t-2 t-s-16">
  149. <div className="label m-r-5">发票类型:</div>
  150. <div className="input-block">
  151. <Radio />
  152. 普通增值税电子发票
  153. </div>
  154. </div>
  155. <div className="input-layout m-b-2 t-2 t-s-16">
  156. <div className="label m-r-5">抬头类型:</div>
  157. <div className="input-block">
  158. <span className="m-r-2">
  159. <Radio />
  160. 个人
  161. </span>
  162. <span className="m-l-2">
  163. <Radio />
  164. 公司
  165. </span>
  166. </div>
  167. </div>
  168. <div className="input-layout m-b-2 t-2 t-s-16">
  169. <div className="label m-r-5">发票抬头:</div>
  170. <div className="input-block">
  171. <input style={{ width: 330, paddingTop: 3, paddingBottom: 3 }} className="b-c-1 p-l-1 p-r-1 p-l-1" />
  172. </div>
  173. </div>
  174. <div className="input-layout m-b-2 t-2 t-s-16">
  175. <div className="label m-r-5">纳税人识别号:</div>
  176. <div className="input-block">
  177. <input style={{ width: 300, paddingTop: 3, paddingBottom: 3 }} className="b-c-1 p-l-1 p-r-1 p-l-1" />
  178. </div>
  179. </div>
  180. <div className="input-layout m-b-2 t-2 t-s-16">
  181. <div className="label m-r-5">发票内容:</div>
  182. <div className="input-block">
  183. <Radio />
  184. 商品明细
  185. </div>
  186. </div>
  187. <div className="input-layout t-2 t-s-16">
  188. <div className="label m-r-5">发票金额:</div>
  189. <div className="input-block">¥ 210010.0</div>
  190. </div>
  191. </Modal>
  192. <Modal title="申请成功" width={630} confirmText="好的,知道了" btnAlign="center" onConfirm={() => {}}>
  193. <div className="t-2 t-s-18">
  194. <Icon className="t-5 m-r-5" type="check" />
  195. 我们会在三个工作日内将电子发票发送至您的绑定邮箱:
  196. </div>
  197. <div className="t-2 t-s-18">201-30-2103@12321.com</div>
  198. <div className="m-b-2 t-2 t-s-18">请注意查收。</div>
  199. <div className="m-t-2 t-3 t-s-14">我们也会通过站内信的方式通知您</div>
  200. </Modal>
  201. </div>
  202. );
  203. }
  204. }