Guest User

Untitled

a guest
Feb 10th, 2020
153
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 7.53 KB | None | 0 0
  1. /* eslint-disable react/destructuring-assignment */
  2. import GridContent from '@/components/PageHeaderWrapper/GridContent';
  3. import { formItemLayout, tailFormItemLayout } from '@/utils/form';
  4. import rules from '@/utils/rules';
  5. import { getRecordValue } from '@/utils/utils';
  6. import { Button, Card, Col, DatePicker, Divider, Form, Input, Radio, Row, Select, Spin, Typography } from 'antd';
  7. import _ from 'lodash';
  8. import React from 'react';
  9.  
  10. const { Text } = Typography;
  11.  
  12.  
  13. interface TroCapHangThang_Props {
  14. model: { edit, record },
  15. cond: object,
  16. loading: boolean,
  17. dispatch: Function,
  18. form: { validateFieldsAndScroll, getFieldDecorator },
  19. }
  20.  
  21. class TroCapHangThang extends React.Component<TroCapHangThang_Props> {
  22. public componentDidMount() {
  23. }
  24.  
  25. public handleSubmit = e => {
  26. const { form, model: { edit, record }, cond } = this.props;
  27. e.preventDefault();
  28. form.validateFieldsAndScroll((err, values) => {
  29. if (err) { return; }
  30. if (edit) {
  31. this.props.dispatch({
  32. type: `trocaphangthang/upd`,
  33. payload: {
  34. ...values,
  35. _id: record._id,
  36. },
  37. });
  38. } else {
  39. this.props.dispatch({
  40. type: `trocaphangthang/add`,
  41. payload: {
  42. ...cond,
  43. ...values,
  44. },
  45. });
  46. }
  47. });
  48. };
  49.  
  50. public render() {
  51. const { model, form: { getFieldDecorator }, cond, loading } = this.props;
  52. return (
  53. <div className="box">
  54. <Card
  55. bordered={true}
  56. title={
  57. <div className="cardTitle">{!model.edit ? `Thêm mới` : `Chỉnh sửa`}</div>
  58. }
  59. >
  60.  
  61. <Row>
  62.  
  63. <Form layout='inline' onSubmit={this.handleSubmit}>
  64. <Col span={24}>
  65.  
  66. <Form.Item label="Giá Sản Phẩm">
  67. {getFieldDecorator('gia', {
  68. initialValue: getRecordValue(model, cond, 'gia', 0),
  69.  
  70. rules: [...rules.number(1000000000), ...rules.required],
  71. })(<Input />)}
  72. </Form.Item>
  73. <Form.Item label="Họ tên" style={{ marginRight: 50 }}>
  74. {getFieldDecorator('hoTen', {
  75. // initialValue: getRecordValue(model, cond, 'hoTen', ''),
  76. rules: [...rules.required],
  77. })(<Input style={{ width: 300 }}
  78. />)}
  79. </Form.Item>
  80.  
  81. {/* <Form.Item label="Năm sinh" style={{ marginRight: 50 }}>
  82. {getFieldDecorator('namSinh', {
  83. // initialValue: getRecordValue(model, cond, 'namSinh', ''),
  84. rules: [...rules.required],
  85. })(
  86. <DatePicker format={'DD/MM/YYYY'} />
  87. )}
  88. </Form.Item> */}
  89.  
  90. {/* <Form.Item label="Giới tính" style={{ marginRight: 50 }}>
  91. {getFieldDecorator('gioiTinh', {
  92. initialValue: getRecordValue(model, cond, 'gioiTinh', ''),
  93. rules: [...rules.required],
  94. })(
  95. <Radio.Group>
  96. <Radio value="0">Nam</Radio>
  97. <Radio value="1">Nữ</Radio>
  98. </Radio.Group>,
  99. )}
  100. </Form.Item> */}
  101. </Col>
  102.  
  103. {/* <Col span={24}>
  104. <Form.Item label="Số CMND" style={{ marginRight: 50 }}>
  105. {getFieldDecorator('cmnd', {
  106. initialValue: getRecordValue(model, cond, 'cmnd', ''),
  107. rules: [...rules.required],
  108. })(<Input style={{ width: 200 }} />)}
  109. </Form.Item>
  110. <Form.Item label="Ngày cấp" style={{ marginRight: 50 }}>
  111. {getFieldDecorator('ngapCap', {
  112. initialValue: getRecordValue(model, cond, 'ngapCap', ''),
  113. rules: [...rules.required],
  114. })(
  115. <DatePicker format={'DD/MM/YYYY'} />
  116. )}
  117. </Form.Item>
  118.  
  119. <Form.Item label="Nơi cấp" style={{ marginRight: 50 }}>
  120. {getFieldDecorator('noiCap', {
  121. // initialValue: getRecordValue(model, cond, 'noiCap', ''),
  122. rules: [...rules.required],
  123. })(<Input style={{ width: 300 }} />)}
  124. </Form.Item>
  125. </Col>
  126. <Col span={24}>
  127. <Form.Item label="Nguyên quán" >
  128. {getFieldDecorator('nguyenQuan', {
  129. initialValue: getRecordValue(model, cond, 'nguyenQuan', ''),
  130. rules: [...rules.required],
  131. })(<Input style={{ width: '800px' }} />)}
  132. </Form.Item>
  133. </Col>
  134. <Col span={24}>
  135. <Form.Item label="Hiện đăng ký hộ khẩu thường trú tại">
  136. {getFieldDecorator('hoKhauThuongTru', {
  137. initialValue: getRecordValue(model, cond, 'hoKhauThuongTru', ''),
  138. rules: [...rules.required],
  139. })(<Input style={{ width: '800px' }} />)}
  140. </Form.Item>
  141. </Col>
  142. */}
  143. {/* <Divider type='horizontal' /> */}
  144.  
  145. {/* <Col span={24}>
  146. <b>I. Phần khai của người có công đang hưởng một hoặc nhiều chế độ hàng tháng</b>
  147. </Col>
  148. <Text>1. Hiện đang hưởng chế độ đối với</Text> */}
  149. {/* <Col span={24}>
  150. <Form.Item label="Hiện đăng ký hộ khẩu thường trú tại">
  151. {getFieldDecorator('dataIndex', {
  152. initialValue: getRecordValue(model, cond, 'dataIndex', ''),
  153. rules: [...rules.required],
  154. })(<Input style={{ width: '800px' }} />)}
  155. </Form.Item>
  156. </Col> */}
  157. {/* <Col span={24}>
  158. <Form.Item label="1.1" >
  159. {getFieldDecorator('1', {
  160. initialValue: getRecordValue(model, cond, '1', ''),
  161. rules: [...rules.required],
  162. })(<Input />)}
  163. </Form.Item>
  164.  
  165. <Form.Item label="Số sổ lĩnh trợ cấp" >
  166. {getFieldDecorator('soSo', {
  167. initialValue: getRecordValue(model, cond, 'soSo', ''),
  168. rules: [...rules.required],
  169. })(<Input style={{ width: '200px' }} />)}
  170. </Form.Item>
  171.  
  172. <Form.Item label="Số tiền/tháng" >
  173. {getFieldDecorator('soTien', {
  174. initialValue: getRecordValue(model, cond, 'soTien', ''),
  175. rules: [...rules.required],
  176. })(<Input style={{ width: '200px' }} />)}
  177. </Form.Item>
  178. </Col> */}
  179.  
  180.  
  181. <Spin spinning={loading}>
  182. <Form.Item >
  183. <Button.Group>
  184. <Button type="primary" icon="plus" htmlType="submit">
  185. {model.edit ? 'Cập nhật' : 'Thêm mới'}
  186. </Button>
  187. </Button.Group>
  188. </Form.Item>
  189. </Spin>
  190. </Form>
  191.  
  192. </Row>
  193.  
  194. </Card >
  195. </div >
  196. );
  197. }
  198. }
  199.  
  200. const WrappedForm = Form.create({ name: 'TroCapHangThang' })(TroCapHangThang);
  201.  
  202. export default WrappedForm;
Advertisement
Add Comment
Please, Sign In to add comment