comPatentAdd.jsx 8.7 KB

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