comPatentAdd.jsx 9.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239
  1. import React from 'react';
  2. import { Icon, Modal, Button, Form, message, Input, Spin, Checkbox, Select, Row, Col } from 'antd';
  3. import './comprehensive.less';
  4. import { companySearch } from '../../../tools.js';
  5. import ajax from 'jquery/src/ajax/xhr.js'
  6. import $ from 'jquery/src/ajax';
  7. const PatentAddFrom = Form.create()(React.createClass({
  8. getContactsList(theUid) {
  9. $.ajax({
  10. method: "post",
  11. dataType: "json",
  12. crossDomain: false,
  13. url: globalConfig.context + "/api/admin/getContacts",
  14. data: {
  15. uid: theUid
  16. },
  17. success: function (data) {
  18. let theOption = [];
  19. if (data.error.length || !data.data) {
  20. return;
  21. };
  22. for (let item in data.data) {
  23. let theData = data.data[item];
  24. theOption.push(
  25. <Select.Option value={item} key={theData}>{theData}</Select.Option>
  26. );
  27. };
  28. this.setState({
  29. contactsOption: theOption
  30. });
  31. }.bind(this),
  32. });
  33. },
  34. getInitialState() {
  35. return {
  36. loading: false,
  37. companyOption: [],
  38. firstCheck: 0,
  39. secondCheck: 0,
  40. thirdCheck: 0,
  41. accelerated: 0,
  42. acceleratedDate: 0,
  43. visible: "visible"
  44. };
  45. },
  46. handleSubmit(e) {
  47. e.preventDefault();
  48. if (!this.state.companyName || this.state.companyName === "") {
  49. message.warning('请先选择公司!');
  50. return;
  51. };
  52. this.props.form.validateFields((err, values) => {
  53. if (!err) {
  54. this.props.spinState(true);
  55. $.ajax({
  56. method: "POST",
  57. dataType: "json",
  58. crossDomain: false,
  59. url: globalConfig.context + "/techservice/patent/manageApplyPatent",
  60. data: {
  61. 'uid': this.state.companyName,
  62. 'firstInventorIdNumber': values.firstInventorID,
  63. 'firstInventorName': values.firstInventorName,
  64. 'patentDes': values.intro,
  65. 'secondInventorName': values.secondInventorName,
  66. 'thirdInventorName': values.thirdInventorName,
  67. 'firstInventorIsPublish': this.state.firstCheck,
  68. 'secondInventorIsPublish': this.state.secondCheck,
  69. 'thirdInventorIsPublish': this.state.thirdCheck,
  70. 'patentProryStatementUrl': this.state.avatarUrl
  71. }
  72. }).done(function (data) {
  73. if (!data.error.length) {
  74. message.success('保存成功!');
  75. } else {
  76. message.warning(data.error[0].message);
  77. }
  78. }.bind(this)).always(function () {
  79. this.props.spinState(false);
  80. this.props.okClick();
  81. this.props.form.resetFields();
  82. }.bind(this));
  83. }
  84. });
  85. },
  86. acceleratedCheck(e) {
  87. if (e.target.checked == true) {
  88. this.state.accelerated = 1;
  89. this.setState({ visible: "show" });
  90. } else if (e.target.checked == false) {
  91. this.state.accelerated = 0;
  92. this.setState({ visible: "visible" });
  93. }
  94. },
  95. acceleratedSelect(value) {
  96. this.state.acceleratedDate = value;
  97. },
  98. render() {
  99. const FormItem = Form.Item;
  100. const { getFieldDecorator } = this.props.form;
  101. const formItemLayout = {
  102. labelCol: { span: 3 },
  103. wrapperCol: { span: 14 },
  104. };
  105. const _me = this;
  106. return (
  107. <Form horizontal onSubmit={this.handleSubmit} className="person-form">
  108. <FormItem
  109. wrapperCol={{ span: 24 }}
  110. >
  111. <Row>
  112. <Col span={12}>
  113. <span>选择公司: </span>
  114. <Select
  115. placeholder="请选择公司"
  116. notFoundContent="未找到公司"
  117. style={{ width: 200 }}
  118. showSearch
  119. filterOption={companySearch}
  120. value={this.state.uid}
  121. onSelect={(e, n) => { this.setState({ uid: e }); this.getContactsList(e); }}>
  122. {this.props.companyOption}
  123. </Select>
  124. </Col>
  125. <Col span={12}>
  126. <span>选择联系人: </span>
  127. <Select placeholder="请选择联系人" style={{ width: 200 }}
  128. notFoundContent="未获取到联系人列表"
  129. value={this.state.contacts}
  130. onSelect={(e, n) => { this.setState({ contacts: e }); }}>
  131. {this.state.contactsOption}
  132. </Select>
  133. </Col>
  134. </Row>
  135. </FormItem>
  136. <FormItem
  137. labelCol={{ span: 24 }}
  138. wrapperCol={{ span: 18 }}
  139. label="派单信息"
  140. >
  141. {getFieldDecorator('intro', {
  142. initialValue: this.state.intro || null
  143. })(
  144. <Input type="textarea"
  145. placeholder="多行输入"
  146. rows={6} />
  147. )}
  148. </FormItem>
  149. <FormItem
  150. labelCol={{ span: 0 }}
  151. wrapperCol={{ span: 18 }}
  152. >
  153. <span>是否加急:</span>
  154. <Checkbox onChange={this.acceleratedCheck}></Checkbox>
  155. <Select className={this.state.visible} placeholder="请选择加急时间" style={{ width: 120 }} onChange={this.acceleratedSelect}>
  156. <Select.Option value="3">3天</Select.Option>
  157. <Select.Option value="5">5天</Select.Option>
  158. <Select.Option value="10">10天</Select.Option>
  159. <Select.Option value="20">20天</Select.Option>
  160. </Select>
  161. </FormItem>
  162. <FormItem
  163. {...formItemLayout}
  164. label="选择咨询师"
  165. >
  166. <Select placeholder="请选择咨询师" style={{ width: 200 }}
  167. value={this.state.consultant}
  168. onSelect={(e, n) => { this.setState({ consultant: e }); }}>
  169. {this.props.authorOption}
  170. </Select>
  171. </FormItem>
  172. <FormItem
  173. {...formItemLayout}
  174. label="外包公司"
  175. >
  176. {getFieldDecorator('intro', {
  177. initialValue: this.state.intro || null
  178. })(
  179. <Input placeholder="输入外包公司" />
  180. )}
  181. </FormItem>
  182. <FormItem>
  183. <Button className="set-submit" type="primary" htmlType="submit">确认</Button>
  184. <Button type="ghost" style={{ marginLeft: '20px' }} onClick={this.props.closeModal}>取消</Button>
  185. </FormItem>
  186. </Form >
  187. );
  188. },
  189. }));
  190. const PatentAdd = React.createClass({
  191. getInitialState() {
  192. return {
  193. visible: false,
  194. loading: false
  195. };
  196. },
  197. showModal() {
  198. this.setState({
  199. visible: true,
  200. });
  201. },
  202. handleCancel(e) {
  203. this.setState({
  204. visible: false,
  205. });
  206. this.props.closeAdd(false);
  207. },
  208. spinChange(e) {
  209. this.setState({
  210. loading: e
  211. });
  212. },
  213. render() {
  214. return (
  215. <div className="patent-addNew">
  216. <Button className="patent-addNew" type="primary" onClick={this.showModal}>申请新软著<Icon type="plus" /></Button>
  217. <Spin spinning={this.state.loading} className='spin-box'>
  218. <Modal title="申请新软著"
  219. visible={this.state.visible}
  220. onCancel={this.handleCancel}
  221. width='800px'
  222. footer=''
  223. >
  224. <PatentAddFrom
  225. spinState={this.spinChange}
  226. okClick={() => { this.props.closeAdd(false, true) }}
  227. companyOption={this.props.companyOption}
  228. authorOption={this.props.authorOption} />
  229. </Modal>
  230. </Spin>
  231. </div>
  232. );
  233. },
  234. });
  235. export default PatentAdd;