clientInputPatent.jsx 9.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257
  1. import React from 'react';
  2. import { Icon, Modal, Button, Form, message, Input, Spin, Select, DatePicker } from 'antd';
  3. import './comprehensive.less';
  4. import { patentGetList, patentTypeList } from '../../../dataDic.js';
  5. import { companySearch } from '../../../tools.js';
  6. import ajax from 'jquery/src/ajax/xhr.js'
  7. import $ from 'jquery/src/ajax';
  8. const PatentAddFrom = Form.create()(React.createClass({
  9. getInitialState() {
  10. return {
  11. loading: false,
  12. patentGetOption: [],
  13. patentTypeOption: [],
  14. companyOption: []
  15. };
  16. },
  17. getCompanyList() {
  18. this.setState({
  19. loading: true
  20. });
  21. $.ajax({
  22. method: "get",
  23. dataType: "json",
  24. crossDomain: false,
  25. url: globalConfig.context + "/api/user/patent/getUnitNames",
  26. success: function (data) {
  27. if (data.error.length || !data.data) {
  28. return;
  29. };
  30. let _me = this;
  31. for (var item in data.data) {
  32. _me.state.companyOption.push(
  33. <Select.Option value={item} key={item}>{data.data[item]}</Select.Option>
  34. )
  35. };
  36. }.bind(this),
  37. }).always(function () {
  38. this.setState({
  39. loading: false
  40. });
  41. }.bind(this));
  42. },
  43. componentWillMount() {
  44. let _me = this;
  45. patentGetList.map(function (item) {
  46. _me.state.patentGetOption.push(
  47. <Select.Option value={item.value} key={item.key}>{item.key}</Select.Option>
  48. )
  49. });
  50. patentTypeList.map(function (item) {
  51. _me.state.patentTypeOption.push(
  52. <Select.Option value={item.value} key={item.key}>{item.key}</Select.Option>
  53. )
  54. });
  55. this.getCompanyList();
  56. },
  57. handleSubmit(e) {
  58. e.preventDefault();
  59. this.props.form.validateFields((err, values) => {
  60. if (!err) {
  61. this.props.spinState(true);
  62. $.ajax({
  63. method: "POST",
  64. dataType: "json",
  65. crossDomain: false,
  66. url: globalConfig.context + "/api/user/patent/managerInputPatent",
  67. data: {
  68. "uid": this.state.companyId,
  69. "patentNumber": values.patentNumber,
  70. "patentName": values.patentName,
  71. "patentCatagory": this.state.patentCatagory,
  72. "obtailWay": this.state.obtailWay,
  73. "sortNumber": values.sortNumber,
  74. "authorizationNumber": values.authorizationNumber,
  75. "authorizationDate": this.state.authorizationDate
  76. }
  77. }).done(function (data) {
  78. if (data.error && data.error.length) {
  79. message.warning(data.error[0].message);
  80. } else {
  81. message.success('保存成功!');
  82. this.props.clickOk();
  83. this.props.form.resetFields();
  84. };
  85. }.bind(this)).always(function () {
  86. this.props.spinState(false);
  87. }.bind(this));
  88. }
  89. });
  90. },
  91. checkIdcardnum(rule, value, callback) {
  92. if (!/(^\d{15}$)|(^\d{17}(\d|X)$)/.test(value)) {
  93. callback('请输入正确的身份证号!');
  94. } else {
  95. callback();
  96. }
  97. },
  98. render() {
  99. const FormItem = Form.Item;
  100. const { getFieldDecorator } = this.props.form;
  101. const formItemLayout = {
  102. labelCol: { span: 3 },
  103. wrapperCol: { span: 12 },
  104. };
  105. const _me = this;
  106. return (
  107. <Form horizontal onSubmit={this.handleSubmit} className="person-form">
  108. <FormItem
  109. {...formItemLayout}
  110. label="选择公司"
  111. >
  112. {getFieldDecorator('companyId', {
  113. rules: [{ required: true, message: '请选择,公司不能为空!' }]
  114. })(
  115. <Select placeholder="请选择公司"
  116. showSearch
  117. filterOption={companySearch}
  118. style={{ width: 200 }}
  119. onChange={(e) => { this.state.companyId = e; }}>
  120. {this.state.companyOption}
  121. </Select>
  122. )}
  123. </FormItem>
  124. <FormItem
  125. {...formItemLayout}
  126. label="专利编号"
  127. >
  128. {getFieldDecorator('patentNumber', {
  129. rules: [{ required: true, message: '请输入,专利编号不能为空!' }]
  130. })(
  131. <Input placeholder="请输入专利编号" />
  132. )}
  133. </FormItem>
  134. <FormItem
  135. {...formItemLayout}
  136. label="专利名称"
  137. >
  138. {getFieldDecorator('patentName', {
  139. rules: [{ required: true, message: '请输入,专利名称不能为空!' }]
  140. })(
  141. <Input placeholder="请输入专利名称" />
  142. )}
  143. </FormItem>
  144. <FormItem
  145. {...formItemLayout}
  146. label="排序号"
  147. >
  148. {getFieldDecorator('sortNumber', {
  149. rules: [{ required: true, message: '请输入,排序号不能为空!' }]
  150. })(
  151. <Input placeholder="请输入排序号" />
  152. )}
  153. </FormItem>
  154. <FormItem
  155. {...formItemLayout}
  156. label="专利类型"
  157. >
  158. {getFieldDecorator('patentCatagory', {
  159. rules: [{ required: true, message: '请选择,专利类型不能为空!' }]
  160. })(
  161. <Select placeholder="请选择专利类型" style={{ width: 200 }}
  162. onChange={(e) => { this.state.patentCatagory = e; }}>
  163. {this.state.patentTypeOption}
  164. </Select>
  165. )}
  166. </FormItem>
  167. <FormItem
  168. {...formItemLayout}
  169. label="获得方式"
  170. >
  171. {getFieldDecorator('obtailWay', {
  172. rules: [{ required: true, message: '请选择,获得方式不能为空!' }]
  173. })(
  174. <Select placeholder="请选择获得方式" style={{ width: 200 }}
  175. onChange={(e) => { this.state.obtailWay = e; }}>
  176. {this.state.patentGetOption}
  177. </Select>
  178. )}
  179. </FormItem>
  180. <FormItem
  181. {...formItemLayout}
  182. label="授权号"
  183. >
  184. {getFieldDecorator('authorizationNumber', {
  185. rules: [{ required: true, message: '请输入,授权号不能为空!' }]
  186. })(
  187. <Input placeholder="请输入授权号" />
  188. )}
  189. </FormItem>
  190. <FormItem
  191. {...formItemLayout}
  192. label="授权日期"
  193. >
  194. {getFieldDecorator('authorizationDate', {
  195. rules: [{ required: true, message: '请选择,授权日期不能为空!' }]
  196. })(
  197. <DatePicker style={{ width: 200 }}
  198. onChange={(data, dataString) => { this.state.authorizationDate = dataString }} />
  199. )}
  200. </FormItem>
  201. <FormItem>
  202. <Button className="set-submit" type="primary" htmlType="submit">保存</Button>
  203. <Button type="ghost" style={{ marginLeft: '20px' }} onClick={this.props.closeModal}>取消</Button>
  204. </FormItem>
  205. </Form >
  206. );
  207. },
  208. }));
  209. const PatentAdd = React.createClass({
  210. getInitialState() {
  211. return {
  212. visible: false,
  213. loading: false
  214. };
  215. },
  216. showModal() {
  217. this.setState({
  218. visible: true,
  219. });
  220. },
  221. handleOk() {
  222. this.setState({
  223. visible: false,
  224. });
  225. this.props.closeDesc(false, true);
  226. },
  227. handleCancel(e) {
  228. this.setState({
  229. visible: false,
  230. });
  231. this.props.closeDesc(false);
  232. },
  233. spinChange(e) {
  234. this.setState({
  235. loading: e
  236. });
  237. },
  238. render() {
  239. return (
  240. <div className="patent-addNew">
  241. <Button className="patent-addNew" type="primary" onClick={this.showModal}>新专利添加<Icon type="plus" /></Button>
  242. <Modal maskClosable={false} title="新专利添加" visible={this.state.visible}
  243. onOk={this.handleOk} onCancel={this.handleCancel}
  244. width='720px'
  245. footer='' >
  246. <Spin spinning={this.state.loading} className='spin-box'>
  247. <PatentAddFrom spinState={this.spinChange} closeModal={this.handleCancel} clickOk={this.handleOk} />
  248. </Spin>
  249. </Modal>
  250. </div>
  251. );
  252. },
  253. });
  254. export default PatentAdd;