comPatentAdd.jsx 9.9 KB

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