comPatentAdd.jsx 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289
  1. import React from 'react';
  2. import { Icon, Modal, Button, Form, Upload, message, Input, Spin, Checkbox, Select } from 'antd';
  3. import './comprehensive.less';
  4. import ajax from 'jquery/src/ajax/xhr.js'
  5. import $ from 'jquery/src/ajax';
  6. import { getBase64, beforeUpload, companySearch } from '../../../tools.js';
  7. class Avatar extends React.Component {
  8. constructor(props) {
  9. super(props);
  10. this.state = {
  11. imageUrl: ''
  12. }
  13. }
  14. handleChange(info) {
  15. if (!this.props.oid || this.props.oid === "") {
  16. message.warning('请先选择公司!');
  17. return;
  18. };
  19. if (info.file.status === 'done') {
  20. // Get this url from response in real world.
  21. getBase64(info.file.originFileObj, imageUrl => this.setState({ imageUrl }));
  22. this.props.urlData(info.file.response.data);
  23. }
  24. }
  25. render() {
  26. return (
  27. <Upload
  28. className="avatar-uploader"
  29. name="avatar"
  30. showUploadList={false}
  31. action={globalConfig.context + "/api/admin/patent/upload"}
  32. data={{ 'sign': this.props.name, 'uid': this.props.oid }}
  33. beforeUpload={beforeUpload}
  34. onChange={this.handleChange.bind(this)}
  35. >
  36. <Button><Icon type="upload" />上传专利代理委托书</Button>
  37. </Upload>
  38. );
  39. }
  40. };
  41. const PatentAddFrom = Form.create()(React.createClass({
  42. getCompanyList() {
  43. this.setState({
  44. loading: true
  45. });
  46. $.ajax({
  47. method: "get",
  48. dataType: "json",
  49. crossDomain: false,
  50. url: globalConfig.context + "/techservice/patent/getUnitNames",
  51. success: function (data) {
  52. if (data.error.length || !data.data) {
  53. return;
  54. };
  55. let _me = this;
  56. for (var item in data.data) {
  57. _me.state.companyOption.push(
  58. <Select.Option value={item} key={item}>{data.data[item]}</Select.Option>
  59. )
  60. };
  61. }.bind(this),
  62. }).always(function () {
  63. this.setState({
  64. loading: false
  65. });
  66. }.bind(this));
  67. },
  68. getInitialState() {
  69. return {
  70. loading: false,
  71. companyOption: [],
  72. firstCheck: 0,
  73. secondCheck: 0,
  74. thirdCheck: 0
  75. };
  76. },
  77. componentWillMount() {
  78. this.getCompanyList();
  79. },
  80. handleSubmit(e) {
  81. e.preventDefault();
  82. if (!this.state.companyName || this.state.companyName === "") {
  83. message.warning('请先选择公司!');
  84. return;
  85. };
  86. this.props.form.validateFields((err, values) => {
  87. if (!err) {
  88. this.props.spinState(true);
  89. $.ajax({
  90. method: "POST",
  91. dataType: "json",
  92. crossDomain: false,
  93. url: globalConfig.context + "/api/admin/patent/apply",
  94. data: {
  95. 'uid': this.state.companyName,
  96. 'firstInventorIdNumber': values.firstInventorID,
  97. 'firstInventorName': values.firstInventorName,
  98. 'patentDes': values.intro,
  99. 'secondInventorName': values.secondInventorName,
  100. 'thirdInventorName': values.thirdInventorName,
  101. 'firstInventorIsPublish': this.state.firstCheck,
  102. 'secondInventorIsPublish': this.state.secondCheck,
  103. 'thirdInventorIsPublish': this.state.thirdCheck,
  104. 'patentProryStatementUrl': this.state.avatarUrl
  105. }
  106. }).done(function (data) {
  107. if (!data.error.length) {
  108. message.success('保存成功!');
  109. this.props.okClick();
  110. this.props.closeModal();
  111. } else {
  112. message.warning(data.error[0].message);
  113. }
  114. }.bind(this)).always(function () {
  115. this.props.spinState(false);
  116. this.props.form.resetFields();
  117. }.bind(this));
  118. }
  119. });
  120. },
  121. firstInventorCheck(e) {
  122. if (e.target.checked == true) {
  123. this.state.firstCheck = 1;
  124. } else if (e.target.checked == false) {
  125. this.state.firstCheck = 0;
  126. }
  127. },
  128. secondInventorCheck(e) {
  129. if (e.target.checked == true) {
  130. this.state.secondCheck = 1;
  131. } else if (e.target.checked == false) {
  132. this.state.secondCheck = 0;
  133. };
  134. },
  135. thirdInventorCheck(e) {
  136. if (e.target.checked == true) {
  137. this.state.thirdCheck = 1;
  138. } else if (e.target.checked == false) {
  139. this.state.thirdCheck = 0;
  140. };
  141. },
  142. avatarUrl(e) {
  143. this.state.avatarUrl = e;
  144. },
  145. render() {
  146. const FormItem = Form.Item;
  147. const { getFieldDecorator } = this.props.form;
  148. const formItemLayout = {
  149. labelCol: { span: 3 },
  150. wrapperCol: { span: 14 },
  151. };
  152. const _me = this;
  153. return (
  154. <Form horizontal onSubmit={this.handleSubmit} className="person-form">
  155. <Select placeholder="选择公司"
  156. showSearch
  157. filterOption={companySearch}
  158. onChange={(e) => { this.state.companyName = e; }}
  159. showSearch={true} style={{ width: 200 }} >{this.state.companyOption}</Select>
  160. <FormItem
  161. labelCol={{ span: 24 }}
  162. wrapperCol={{ span: 18 }}
  163. label="专利简要描述"
  164. >
  165. {getFieldDecorator('intro', {
  166. initialValue: this.state.intro || null
  167. })(
  168. <Input type="textarea"
  169. placeholder="多行输入"
  170. rows={6} />
  171. )}
  172. </FormItem>
  173. <p>第一发明人</p>
  174. <FormItem
  175. {...formItemLayout}
  176. label="姓名"
  177. >
  178. {getFieldDecorator('firstInventorName', {
  179. rules: [{ required: true, message: 'Please input name!' }]
  180. })(
  181. <Input className="mini-input" />
  182. )}
  183. <Checkbox onChange={this.firstInventorCheck}>告知专利局是否公布</Checkbox>
  184. </FormItem>
  185. <FormItem
  186. {...formItemLayout}
  187. label="身份证"
  188. >
  189. {getFieldDecorator('firstInventorID', {
  190. rules: [{ required: true, message: 'Please input ID!' }]
  191. })(
  192. <Input className="mini-input" />
  193. )}
  194. </FormItem>
  195. <p>第二发明人</p>
  196. <FormItem
  197. {...formItemLayout}
  198. label="姓名"
  199. >
  200. {getFieldDecorator('secondInventorName')(
  201. <Input className="mini-input" />
  202. )}
  203. <Checkbox onChange={this.secondInventorCheck}>告知专利局是否公布</Checkbox>
  204. </FormItem>
  205. <p>第三发明人</p>
  206. <FormItem
  207. {...formItemLayout}
  208. label="姓名"
  209. >
  210. {getFieldDecorator('thirdInventorName')(
  211. <Input className="mini-input" />
  212. )}
  213. <Checkbox onChange={this.thirdInventorCheck}>告知专利局是否公布</Checkbox>
  214. </FormItem>
  215. <FormItem
  216. {...formItemLayout}
  217. label="上传代理委托书"
  218. labelCol={{ span: 24 }}
  219. wrapperCol={{ span: 12 }}
  220. >
  221. {getFieldDecorator('avatar')(
  222. <Avatar urlData={this.avatarUrl} name='patent_prory_statement' oid={this.state.companyName} />
  223. )}
  224. <p>
  225. <a onClick={() => { window.open(globalConfig.context + "/api/admin/patent/downloadTemplateFile?sign=patent_prory_statement") }}>模板下载</a>
  226. </p>
  227. </FormItem>
  228. <FormItem>
  229. <Button className="set-submit" type="primary" htmlType="submit">保存</Button>
  230. <Button type="ghost" style={{ marginLeft: '20px' }} onClick={this.props.closeModal}>取消</Button>
  231. </FormItem>
  232. </Form >
  233. );
  234. },
  235. }));
  236. const PatentAdd = React.createClass({
  237. getInitialState() {
  238. return {
  239. visible: false,
  240. loading: false
  241. };
  242. },
  243. showModal() {
  244. this.setState({
  245. visible: true,
  246. });
  247. },
  248. handleOk() {
  249. this.setState({
  250. visible: false,
  251. });
  252. },
  253. handleCancel(e) {
  254. this.setState({
  255. visible: false,
  256. });
  257. this.props.closeDesc(false);
  258. },
  259. spinChange(e) {
  260. this.setState({
  261. loading: e
  262. });
  263. },
  264. render() {
  265. return (
  266. <div className="patent-addNew">
  267. <Button className="patent-addNew" type="primary" onClick={this.showModal}>申请新专利<Icon type="plus" /></Button>
  268. <Spin spinning={this.state.loading} className='spin-box'>
  269. <Modal title="新专利申请" visible={this.state.visible}
  270. onOk={this.handleOk} onCancel={this.handleCancel}
  271. width='800px'
  272. footer=''
  273. >
  274. <PatentAddFrom
  275. spinState={this.spinChange}
  276. closeModal={this.handleCancel}
  277. okClick={() => { this.props.closeDesc(false, true) }} />
  278. </Modal>
  279. </Spin>
  280. </div>
  281. );
  282. },
  283. });
  284. export default PatentAdd;