comPatentAdd.jsx 10 KB

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