comPatentAdd.jsx 9.6 KB

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