comPatentAdd.jsx 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290
  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 } 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. filterOption={(input, option) => {
  161. this.setState({companyId : option.key});
  162. option.props.value.indexOf(input) >= 0;
  163. }}
  164. onChange={(e)=>{ this.state.companyName = e;}}
  165. showSearch={true} style={{ width: 200 }} >{this.state.companyOption}</Select>
  166. <FormItem
  167. labelCol={{ span: 24 }}
  168. wrapperCol={{ span: 18 }}
  169. label="专利简要描述"
  170. >
  171. {getFieldDecorator('intro', {
  172. initialValue: this.state.intro || null
  173. })(
  174. <Input type="textarea"
  175. placeholder="多行输入"
  176. rows={6} />
  177. )}
  178. </FormItem>
  179. <p>第一发明人</p>
  180. <FormItem
  181. {...formItemLayout}
  182. label="姓名"
  183. >
  184. {getFieldDecorator('firstInventorName', {
  185. rules: [{ required: true, message: 'Please input name!' }]
  186. })(
  187. <Input className="mini-input" />
  188. )}
  189. <Checkbox onChange={this.firstInventorCheck}>告知专利局是否公布</Checkbox>
  190. </FormItem>
  191. <FormItem
  192. {...formItemLayout}
  193. label="身份证"
  194. >
  195. {getFieldDecorator('firstInventorID', {
  196. rules: [{ required: true, message: 'Please input ID!' }]
  197. })(
  198. <Input className="mini-input" />
  199. )}
  200. </FormItem>
  201. <p>第二发明人</p>
  202. <FormItem
  203. {...formItemLayout}
  204. label="姓名"
  205. >
  206. {getFieldDecorator('secondInventorName')(
  207. <Input className="mini-input" />
  208. )}
  209. <Checkbox onChange={this.secondInventorCheck}>告知专利局是否公布</Checkbox>
  210. </FormItem>
  211. <p>第三发明人</p>
  212. <FormItem
  213. {...formItemLayout}
  214. label="姓名"
  215. >
  216. {getFieldDecorator('thirdInventorName')(
  217. <Input className="mini-input" />
  218. )}
  219. <Checkbox onChange={this.thirdInventorCheck}>告知专利局是否公布</Checkbox>
  220. </FormItem>
  221. <FormItem
  222. {...formItemLayout}
  223. label="上传代理委托书"
  224. labelCol={{ span: 24 }}
  225. wrapperCol={{ span: 12 }}
  226. >
  227. {getFieldDecorator('avatar')(
  228. <Avatar urlData={this.avatarUrl} name='patent_prory_statement' oid={this.state.companyName} />
  229. )}
  230. <span>请上传专利代理委托书</span><a onClick={() => { window.open(globalConfig.context + "/techservice/patent/downloadTemplate") }}>模板下载</a>
  231. </FormItem>
  232. <FormItem>
  233. <Button className="set-submit" type="primary" htmlType="submit">保存</Button>
  234. <Button type="ghost" style={{ marginLeft: '20px' }} onClick={this.props.closeModal}>取消</Button>
  235. </FormItem>
  236. </Form >
  237. );
  238. },
  239. }));
  240. const PatentAdd = React.createClass({
  241. getInitialState() {
  242. return {
  243. visible: false,
  244. loading: false
  245. };
  246. },
  247. showModal() {
  248. this.setState({
  249. visible: true,
  250. });
  251. },
  252. handleOk() {
  253. this.setState({
  254. visible: false,
  255. });
  256. },
  257. handleCancel(e) {
  258. this.setState({
  259. visible: false,
  260. });
  261. this.props.closeDesc(false);
  262. },
  263. spinChange(e) {
  264. this.setState({
  265. loading: e
  266. });
  267. },
  268. render() {
  269. return (
  270. <div className="patent-addNew">
  271. <Button className="patent-addNew" type="primary" onClick={this.showModal}>申请新专利<Icon type="plus" /></Button>
  272. <Spin spinning={this.state.loading} className='spin-box'>
  273. <Modal title="新专利申请" visible={this.state.visible}
  274. onOk={this.handleOk} onCancel={this.handleCancel}
  275. width='800px'
  276. footer=''
  277. >
  278. <PatentAddFrom spinState={this.spinChange} closeModal={this.handleCancel} />
  279. </Modal>
  280. </Spin>
  281. </div>
  282. );
  283. },
  284. });
  285. export default PatentAdd;