comPatentAdd.jsx 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350
  1. import React from 'react';
  2. import { Icon, Modal, Button, Form, Upload, message, Input, Spin, 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/uploadProry"}
  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 + "/api/admin/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. getContactsList(theUid) {
  69. $.ajax({
  70. method: "get",
  71. dataType: "json",
  72. crossDomain: false,
  73. url: globalConfig.context + "/api/admin/getContacts",
  74. data: {
  75. uid: theUid || this.state.uid
  76. },
  77. success: function (data) {
  78. let theOption = [];
  79. if (data.error.length || !data.data) {
  80. return;
  81. };
  82. for (let item in data.data) {
  83. let theData = data.data[item];
  84. theOption.push(
  85. <Select.Option value={item} key={theData}>{theData}</Select.Option>
  86. );
  87. };
  88. this.setState({
  89. contactsOption: theOption
  90. });
  91. }.bind(this),
  92. });
  93. },
  94. getInitialState() {
  95. return {
  96. loading: false,
  97. companyOption: []
  98. // firstCheck: 0,
  99. // secondCheck: 0,
  100. // thirdCheck: 0
  101. };
  102. },
  103. componentWillMount() {
  104. this.getCompanyList();
  105. },
  106. handleSubmit(e) {
  107. e.preventDefault();
  108. this.props.form.validateFields((err, values) => {
  109. if (!err) {
  110. this.props.spinState(true);
  111. $.ajax({
  112. method: "POST",
  113. dataType: "json",
  114. crossDomain: false,
  115. url: globalConfig.context + "/api/admin/patent/apply",
  116. data: {
  117. 'uid': values.companyName,
  118. 'contacts': values.contacts,
  119. 'firstInventorIdNumber': values.firstInventorID,
  120. 'firstInventorName': values.firstInventorName,
  121. 'patentDes': values.intro,
  122. 'secondInventorName': values.secondInventorName,
  123. 'thirdInventorName': values.thirdInventorName,
  124. 'office':values.office,
  125. //'firstInventorIsPublish': this.state.firstCheck,
  126. //'secondInventorIsPublish': this.state.secondCheck,
  127. //'thirdInventorIsPublish': this.state.thirdCheck,
  128. 'patentProryStatementUrl': this.state.avatarUrl
  129. }
  130. }).done(function (data) {
  131. if (data.error && !data.error.length) {
  132. message.success('保存成功!');
  133. this.props.okClick();
  134. this.props.closeModal();
  135. this.props.form.resetFields();
  136. } else {
  137. message.warning(data.error[0].message);
  138. }
  139. }.bind(this)).always(function () {
  140. this.props.spinState(false);
  141. }.bind(this));
  142. }
  143. });
  144. },
  145. // firstInventorCheck(e) {
  146. // if (e.target.checked == true) {
  147. // this.state.firstCheck = 1;
  148. // } else if (e.target.checked == false) {
  149. // this.state.firstCheck = 0;
  150. // }
  151. // },
  152. // secondInventorCheck(e) {
  153. // if (e.target.checked == true) {
  154. // this.state.secondCheck = 1;
  155. // } else if (e.target.checked == false) {
  156. // this.state.secondCheck = 0;
  157. // };
  158. // },
  159. // thirdInventorCheck(e) {
  160. // if (e.target.checked == true) {
  161. // this.state.thirdCheck = 1;
  162. // } else if (e.target.checked == false) {
  163. // this.state.thirdCheck = 0;
  164. // };
  165. // },
  166. avatarUrl(e) {
  167. this.state.avatarUrl = e;
  168. },
  169. render() {
  170. const FormItem = Form.Item;
  171. const { getFieldDecorator } = this.props.form;
  172. const formItemLayout = {
  173. labelCol: { span: 4 },
  174. wrapperCol: { span: 18 },
  175. };
  176. const _me = this;
  177. return (
  178. <Form horizontal onSubmit={this.handleSubmit} className="person-form">
  179. <FormItem
  180. {...formItemLayout}
  181. label="申请公司"
  182. >
  183. {getFieldDecorator('companyName', {
  184. rules: [{ required: true, message: '请选择一个公司!' }],
  185. initialValue: this.state.companyName || null
  186. })(
  187. <Select placeholder="选择公司"
  188. showSearch
  189. filterOption={companySearch}
  190. onChange={(e) => { this.setState({ companyName: e }); this.getContactsList(e); }}
  191. showSearch={true} style={{ width: 260 }} >
  192. {this.state.companyOption}
  193. </Select>
  194. )}
  195. </FormItem>
  196. <FormItem
  197. {...formItemLayout}
  198. label="联系人"
  199. >
  200. {getFieldDecorator('contacts', {
  201. rules: [{ required: true, message: '请选择一个联系人!' }],
  202. initialValue: this.state.contacts || null
  203. })(
  204. <Select placeholder="选择联系人"
  205. style={{ width: 260 }} >
  206. {this.state.contactsOption}
  207. </Select>
  208. )}
  209. </FormItem>
  210. <FormItem
  211. {...formItemLayout}
  212. label="事务所"
  213. >
  214. {getFieldDecorator('office', {
  215. rules: [{ required: true, message: '请填写一个事务所!' }],
  216. initialValue: this.state.office || null
  217. })(
  218. <Input />
  219. )}
  220. </FormItem>
  221. <FormItem
  222. labelCol={{ span: 24 }}
  223. wrapperCol={{ span: 18 }}
  224. label="专利简要描述"
  225. >
  226. {getFieldDecorator('intro', {
  227. initialValue: this.state.intro || null
  228. })(
  229. <Input type="textarea"
  230. placeholder="多行输入"
  231. rows={6} />
  232. )}
  233. </FormItem>
  234. <p>第一发明人</p>
  235. <FormItem
  236. {...formItemLayout}
  237. label="姓名"
  238. >
  239. {getFieldDecorator('firstInventorName', {
  240. rules: [{ required: true, message: '请输入姓名!' }]
  241. })(
  242. <Input className="mini-input" />
  243. )}
  244. </FormItem>
  245. <FormItem
  246. {...formItemLayout}
  247. label="身份证"
  248. >
  249. {getFieldDecorator('firstInventorID', {
  250. rules: [{ required: true, message: '请输入身份证号!' }]
  251. })(
  252. <Input className="mini-input" />
  253. )}
  254. </FormItem>
  255. <p>第二发明人</p>
  256. <FormItem
  257. {...formItemLayout}
  258. label="姓名"
  259. >
  260. {getFieldDecorator('secondInventorName')(
  261. <Input className="mini-input" />
  262. )}
  263. </FormItem>
  264. <p>第三发明人</p>
  265. <FormItem
  266. {...formItemLayout}
  267. label="姓名"
  268. >
  269. {getFieldDecorator('thirdInventorName')(
  270. <Input className="mini-input" />
  271. )}
  272. </FormItem>
  273. <FormItem
  274. {...formItemLayout}
  275. label="上传代理委托书"
  276. labelCol={{ span: 24 }}
  277. wrapperCol={{ span: 12 }}
  278. >
  279. {getFieldDecorator('avatar')(
  280. <Avatar urlData={this.avatarUrl} name='patent_prory_statement' oid={this.state.companyName} />
  281. )}
  282. <p>
  283. <a onClick={() => { window.open(globalConfig.context + "/api/admin/patent/downloadTemplateFile?sign=patent_prory_statement") }}>模板下载</a>
  284. </p>
  285. </FormItem>
  286. <FormItem>
  287. <Button className="set-submit" type="primary" htmlType="submit">保存</Button>
  288. <Button type="ghost" style={{ marginLeft: '20px' }} onClick={this.props.closeModal}>取消</Button>
  289. </FormItem>
  290. </Form >
  291. );
  292. },
  293. }));
  294. const PatentAdd = React.createClass({
  295. getInitialState() {
  296. return {
  297. visible: false,
  298. loading: false
  299. };
  300. },
  301. showModal() {
  302. this.setState({
  303. visible: true,
  304. });
  305. },
  306. handleOk() {
  307. this.setState({
  308. visible: false,
  309. });
  310. },
  311. handleCancel(e) {
  312. this.setState({
  313. visible: false,
  314. });
  315. this.props.closeDesc(false);
  316. },
  317. spinChange(e) {
  318. this.setState({
  319. loading: e
  320. });
  321. },
  322. render() {
  323. return (
  324. <div className="patent-addNew">
  325. <Button className="patent-addNew" type="primary" onClick={this.showModal}>申请新专利<Icon type="plus" /></Button>
  326. <Spin spinning={this.state.loading} className='spin-box'>
  327. <Modal title="新专利申请" visible={this.state.visible}
  328. onOk={this.handleOk} onCancel={this.handleCancel}
  329. width='800px'
  330. footer=''
  331. >
  332. <PatentAddFrom
  333. spinState={this.spinChange}
  334. closeModal={this.handleCancel}
  335. okClick={() => { this.props.closeDesc(false, true) }} />
  336. </Modal>
  337. </Spin>
  338. </div>
  339. );
  340. },
  341. });
  342. export default PatentAdd;
  343. // <Checkbox onChange={this.firstInventorCheck}>告知专利局是否公布</Checkbox>