index.js 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131
  1. import React, { PureComponent } from 'react';
  2. import { connect } from 'dva';
  3. import { routerRedux } from 'dva/router';
  4. import { Spin, Card, Form, Switch, Radio, Button, Input } from 'antd';
  5. import PageHeaderLayout from '../../layouts/PageHeaderLayout';
  6. import { getLocalUser } from '../../utils/helper';
  7. @connect(state => ({ merchant: state.merchant }))
  8. @Form.create()
  9. export default class MerchantInfo extends PureComponent {
  10. handlePageCancel = () => {
  11. this.props.dispatch(routerRedux.push('/'));
  12. }
  13. handlePageSubmit = (e) => {
  14. e.preventDefault();
  15. const { form, dispatch } = this.props;
  16. const { getFieldsValue, validateFields } = form;
  17. validateFields((errors) => {
  18. if (errors) return;
  19. const data = { ...getFieldsValue() };
  20. const { merchantId } = getLocalUser();
  21. data.id = merchantId;
  22. dispatch({
  23. type: 'merchant/update',
  24. payload: data,
  25. callback: () => {
  26. dispatch(routerRedux.push('/'));
  27. },
  28. });
  29. });
  30. }
  31. render() {
  32. const { form, merchant } = this.props;
  33. const { item, loading } = merchant;
  34. const { getFieldDecorator } = form;
  35. const formItemLayout = {
  36. labelCol: {
  37. xs: { span: 24 },
  38. sm: { span: 7 },
  39. },
  40. wrapperCol: {
  41. xs: { span: 24 },
  42. sm: { span: 12 },
  43. md: { span: 10 },
  44. },
  45. };
  46. const submitFormLayout = {
  47. wrapperCol: {
  48. xs: { span: 24, offset: 0 },
  49. sm: { span: 10, offset: 7 },
  50. },
  51. };
  52. return (
  53. <PageHeaderLayout>
  54. <Spin spinning={loading}>
  55. <Card>
  56. <Form layout="horizontal" onSubmit={this.handlePageSubmit}>
  57. {/*
  58. <Form.Item label="厂商编号" hasFeedback {...formItemLayout}>
  59. {getFieldDecorator('code',{
  60. rules: [{ required: true, type: 'string', message: '编号为必填写!' }],
  61. initialValue: item.code,
  62. })(<Input />)}
  63. </Form.Item>
  64. <Form.Item label="厂商名称" hasFeedback {...formItemLayout}>
  65. {getFieldDecorator('name',{
  66. rules: [{ required: true, type: 'string', message: '名称为必填项!' }],
  67. initialValue: item.name,
  68. })(<Input />)}
  69. </Form.Item>
  70. <Form.Item label="厂商类型" {...formItemLayout}>
  71. {getFieldDecorator('domain',{
  72. initialValue: item.domain || Codes.CODE_PJ,
  73. })(
  74. <Radio.Group>
  75. {Object.keys(domains).map(key =>
  76. <Radio value={Number(key)} key={`domain-${key}`}>{domains[Number(key)]}</Radio>
  77. )}
  78. </Radio.Group>
  79. )}
  80. </Form.Item>
  81. */}
  82. <Form.Item label="开户银行" hasFeedback {...formItemLayout}>
  83. {getFieldDecorator('depositBank', {
  84. rules: [{ required: true, type: 'string', message: '开户银行为必填项!' }],
  85. initialValue: item.depositBank,
  86. })(<Input />)}
  87. </Form.Item>
  88. <Form.Item label="银行账户" hasFeedback {...formItemLayout}>
  89. {getFieldDecorator('bankAccount', {
  90. rules: [{ required: true, type: 'string', message: '银行账户为必填项!' }],
  91. initialValue: item.bankAccount,
  92. })(<Input />)}
  93. </Form.Item>
  94. <Form.Item label="营业执照编号" hasFeedback {...formItemLayout}>
  95. {getFieldDecorator('licenseId', {
  96. initialValue: item.licenseId,
  97. })(<Input />)}
  98. </Form.Item>
  99. <Form.Item label="纳税人识别号" hasFeedback {...formItemLayout}>
  100. {getFieldDecorator('taxNumber', {
  101. initialValue: item.taxNumber,
  102. })(<Input />)}
  103. </Form.Item>
  104. <Form.Item label="发票类型" {...formItemLayout}>
  105. {getFieldDecorator('receiptType', {
  106. initialValue: item.receiptType || 'SPECIAL',
  107. })(
  108. <Radio.Group>
  109. <Radio value="COMMON" key="receipt-com">普通发票</Radio>
  110. <Radio value="SPECIAL" key="receipt-spl">增值税发票</Radio>
  111. </Radio.Group>
  112. )}
  113. </Form.Item>
  114. <Form.Item {...submitFormLayout} style={{ marginTop: 32 }}>
  115. <Button onClick={this.handlePageCancel}>取消</Button>
  116. <Button type="primary" style={{ marginLeft: 35 }} htmlType="submit">提交</Button>
  117. </Form.Item>
  118. </Form>
  119. </Card>
  120. </Spin>
  121. </PageHeaderLayout>
  122. );
  123. }
  124. }