comPatentAdd.jsx 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285
  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 + "/techservice/patent/patentFile"}
  32. data={{ 'sign': this.props.name, 'oid': 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 + "/techservice/patent/manageApplyPatent",
  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. } else {
  110. message.warning(data.error[0].message);
  111. }
  112. }.bind(this)).always(function () {
  113. this.props.spinState(false);
  114. this.props.clickOk();
  115. this.props.form.resetFields();
  116. }.bind(this));
  117. }
  118. });
  119. },
  120. firstInventorCheck(e) {
  121. if (e.target.checked == true) {
  122. this.state.firstCheck = 1;
  123. } else if (e.target.checked == false) {
  124. this.state.firstCheck = 0;
  125. }
  126. },
  127. secondInventorCheck(e) {
  128. if (e.target.checked == true) {
  129. this.state.secondCheck = 1;
  130. } else if (e.target.checked == false) {
  131. this.state.secondCheck = 0;
  132. };
  133. },
  134. thirdInventorCheck(e) {
  135. if (e.target.checked == true) {
  136. this.state.thirdCheck = 1;
  137. } else if (e.target.checked == false) {
  138. this.state.thirdCheck = 0;
  139. };
  140. },
  141. avatarUrl(e) {
  142. this.state.avatarUrl = e;
  143. },
  144. render() {
  145. const FormItem = Form.Item;
  146. const { getFieldDecorator } = this.props.form;
  147. const formItemLayout = {
  148. labelCol: { span: 3 },
  149. wrapperCol: { span: 14 },
  150. };
  151. const _me = this;
  152. return (
  153. <Form horizontal onSubmit={this.handleSubmit} className="person-form">
  154. <Select placeholder="选择公司"
  155. showSearch
  156. filterOption={companySearch}
  157. onChange={(e) => { this.state.companyName = e; }}
  158. showSearch={true} style={{ width: 200 }} >{this.state.companyOption}</Select>
  159. <FormItem
  160. labelCol={{ span: 24 }}
  161. wrapperCol={{ span: 18 }}
  162. label="专利简要描述"
  163. >
  164. {getFieldDecorator('intro', {
  165. initialValue: this.state.intro || null
  166. })(
  167. <Input type="textarea"
  168. placeholder="多行输入"
  169. rows={6} />
  170. )}
  171. </FormItem>
  172. <p>第一发明人</p>
  173. <FormItem
  174. {...formItemLayout}
  175. label="姓名"
  176. >
  177. {getFieldDecorator('firstInventorName', {
  178. rules: [{ required: true, message: 'Please input name!' }]
  179. })(
  180. <Input className="mini-input" />
  181. )}
  182. <Checkbox onChange={this.firstInventorCheck}>告知专利局是否公布</Checkbox>
  183. </FormItem>
  184. <FormItem
  185. {...formItemLayout}
  186. label="身份证"
  187. >
  188. {getFieldDecorator('firstInventorID', {
  189. rules: [{ required: true, message: 'Please input ID!' }]
  190. })(
  191. <Input className="mini-input" />
  192. )}
  193. </FormItem>
  194. <p>第二发明人</p>
  195. <FormItem
  196. {...formItemLayout}
  197. label="姓名"
  198. >
  199. {getFieldDecorator('secondInventorName')(
  200. <Input className="mini-input" />
  201. )}
  202. <Checkbox onChange={this.secondInventorCheck}>告知专利局是否公布</Checkbox>
  203. </FormItem>
  204. <p>第三发明人</p>
  205. <FormItem
  206. {...formItemLayout}
  207. label="姓名"
  208. >
  209. {getFieldDecorator('thirdInventorName')(
  210. <Input className="mini-input" />
  211. )}
  212. <Checkbox onChange={this.thirdInventorCheck}>告知专利局是否公布</Checkbox>
  213. </FormItem>
  214. <FormItem
  215. {...formItemLayout}
  216. label="上传代理委托书"
  217. labelCol={{ span: 24 }}
  218. wrapperCol={{ span: 12 }}
  219. >
  220. {getFieldDecorator('avatar')(
  221. <Avatar urlData={this.avatarUrl} name='patent_prory_statement' oid={this.state.companyName} />
  222. )}
  223. <p>
  224. <a onClick={() => { window.open(globalConfig.context + "/open/downloadTemplateFile?sign=patent_prory_statement") }}>模板下载</a>
  225. </p>
  226. </FormItem>
  227. <FormItem>
  228. <Button className="set-submit" type="primary" htmlType="submit">保存</Button>
  229. <Button type="ghost" style={{ marginLeft: '20px' }} onClick={this.props.closeModal}>取消</Button>
  230. </FormItem>
  231. </Form >
  232. );
  233. },
  234. }));
  235. const PatentAdd = React.createClass({
  236. getInitialState() {
  237. return {
  238. visible: false,
  239. loading: false
  240. };
  241. },
  242. showModal() {
  243. this.setState({
  244. visible: true,
  245. });
  246. },
  247. handleOk() {
  248. this.setState({
  249. visible: false,
  250. });
  251. },
  252. handleCancel(e) {
  253. this.setState({
  254. visible: false,
  255. });
  256. this.props.closeDesc(false);
  257. },
  258. spinChange(e) {
  259. this.setState({
  260. loading: e
  261. });
  262. },
  263. render() {
  264. return (
  265. <div className="patent-addNew">
  266. <Button className="patent-addNew" type="primary" onClick={this.showModal}>申请新专利<Icon type="plus" /></Button>
  267. <Spin spinning={this.state.loading} className='spin-box'>
  268. <Modal title="新专利申请" visible={this.state.visible}
  269. onOk={this.handleOk} onCancel={this.handleCancel}
  270. width='800px'
  271. footer=''
  272. >
  273. <PatentAddFrom spinState={this.spinChange} closeModal={this.handleCancel} clickOk={this.handleOk} />
  274. </Modal>
  275. </Spin>
  276. </div>
  277. );
  278. },
  279. });
  280. export default PatentAdd;