comPatentAdd.jsx 8.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216
  1. import React from 'react';
  2. import { Icon, Modal, Button, Form, message, Input, Spin, 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() {
  9. $.ajax({
  10. method: "get",
  11. dataType: "json",
  12. crossDomain: false,
  13. url: globalConfig.context + "/api/user/cognizance/getContacts",
  14. success: function (data) {
  15. let theOption = [];
  16. if (data.error.length || !data.data) {
  17. return;
  18. };
  19. for (let item in data.data) {
  20. let theData = data.data[item];
  21. theOption.push(
  22. <Select.Option value={item} key={theData}>{theData}</Select.Option>
  23. );
  24. };
  25. this.setState({
  26. contactsOption: theOption
  27. });
  28. }.bind(this),
  29. });
  30. },
  31. getInitialState() {
  32. return {
  33. loading: false,
  34. companyOption: [],
  35. accelerated: 0,
  36. visible: "visible"
  37. };
  38. },
  39. handleSubmit(e) {
  40. e.preventDefault();
  41. this.props.form.validateFields((err, values) => {
  42. if (!err) {
  43. this.props.spinState(true);
  44. $.ajax({
  45. method: "POST",
  46. dataType: "json",
  47. crossDomain: false,
  48. url: globalConfig.context + "/api/user/copyright/apply",
  49. data: {
  50. //"uid": values.uid, // 公司用户id,size 0-36, required
  51. "contact": values.contact, // 联系人, 1,2,3
  52. "copyrightInfo": values.copyrightInfo, // 软著简介,size 0-255
  53. "copyrightName": values.copyrightName, // 软著名称, size 0-60
  54. //"outsource": values.outsource, // 外包公司, size 0-60
  55. "comment": values.workIssue, // 派单信息, size 0-128
  56. "inUrgent": values.inUrgent, // 加急天数,
  57. //"comment": values.comment, // 备注 size 0-128
  58. //"principal": values.principal // 负责人id
  59. }
  60. }).done(function (data) {
  61. if (!data.error.length) {
  62. message.success('保存成功!');
  63. this.props.okClick();
  64. this.props.closeModal();
  65. this.props.form.resetFields();
  66. } else {
  67. message.warning(data.error[0].message);
  68. }
  69. }.bind(this)).always(function () {
  70. this.props.spinState(false);
  71. }.bind(this));
  72. }
  73. });
  74. },
  75. componentWillMount() {
  76. this.getContactsList();
  77. },
  78. componentWillReceiveProps(nextProps) {
  79. if (!this.props.visible && nextProps.visible) {
  80. this.state.visible = "visible";
  81. this.props.form.resetFields();
  82. };
  83. },
  84. render() {
  85. const FormItem = Form.Item;
  86. const { getFieldDecorator } = this.props.form;
  87. const formItemLayout = {
  88. labelCol: { span: 4 },
  89. wrapperCol: { span: 14 },
  90. };
  91. const _me = this;
  92. return (
  93. <Form horizontal onSubmit={this.handleSubmit} id="CopyrightDesc-form">
  94. <Row>
  95. <Col span={12}>
  96. <FormItem
  97. {...formItemLayout}
  98. label="软著名称"
  99. >
  100. {getFieldDecorator('copyrightName')(
  101. <Input placeholder="请输入软著名称" />
  102. )}
  103. </FormItem>
  104. </Col>
  105. <Col span={12}>
  106. <span>选择联系人: </span>
  107. {getFieldDecorator('contact')(
  108. <Select placeholder="请选择联系人" style={{ width: 200 }}
  109. notFoundContent="未获取到联系人列表"
  110. onSelect={(e, n) => { this.setState({ contact: e }); }}>
  111. {this.state.contactsOption}
  112. </Select>
  113. )}
  114. </Col>
  115. </Row>
  116. <FormItem
  117. labelCol={{ span: 24 }}
  118. wrapperCol={{ span: 18 }}
  119. label="软著简介"
  120. >
  121. {getFieldDecorator('copyrightInfo')(
  122. <Input type="textarea"
  123. placeholder="多行输入"
  124. rows={6} />
  125. )}
  126. </FormItem>
  127. <FormItem
  128. labelCol={{ span: 24 }}
  129. wrapperCol={{ span: 18 }}
  130. label="备注"
  131. >
  132. {getFieldDecorator('workIssue')(
  133. <Input type="textarea"
  134. placeholder="多行输入"
  135. rows={6} />
  136. )}
  137. </FormItem>
  138. <FormItem
  139. {...formItemLayout}
  140. label="是否加急"
  141. >
  142. {getFieldDecorator('inUrgent', {
  143. initialValue: '0'
  144. })(
  145. <Select
  146. placeholder="请选择加急时间"
  147. style={{ width: 200 }}>
  148. <Select.Option value="0">不加急(45个工作日)</Select.Option>
  149. <Select.Option value="3">3个工作日</Select.Option>
  150. <Select.Option value="5">5个工作日</Select.Option>
  151. <Select.Option value="10">6-10个工作日</Select.Option>
  152. <Select.Option value="15">11-15个工作日</Select.Option>
  153. <Select.Option value="20">16-20个工作日</Select.Option>
  154. <Select.Option value="25">21-25个工作日</Select.Option>
  155. <Select.Option value="30">26-30个工作日</Select.Option>
  156. <Select.Option value="35">31-35个工作日</Select.Option>
  157. </Select>
  158. )}
  159. </FormItem>
  160. <FormItem>
  161. <Button className="set-submit" type="primary" htmlType="submit">确认</Button>
  162. <Button type="ghost" style={{ marginLeft: '20px' }} onClick={this.props.closeModal}>取消</Button>
  163. </FormItem>
  164. </Form >
  165. );
  166. },
  167. }));
  168. const PatentAdd = React.createClass({
  169. getInitialState() {
  170. return {
  171. visible: false,
  172. loading: false
  173. };
  174. },
  175. showModal() {
  176. this.setState({
  177. visible: true,
  178. });
  179. },
  180. handleCancel(e) {
  181. this.setState({
  182. visible: false,
  183. });
  184. this.props.closeAdd(false);
  185. },
  186. spinChange(e) {
  187. this.setState({
  188. loading: e
  189. });
  190. },
  191. render() {
  192. return (
  193. <div className="patent-addNew">
  194. <Button className="patent-addNew" type="primary" onClick={this.showModal}>申请新软著<Icon type="plus" /></Button>
  195. <Modal maskClosable={false} title="申请新软著"
  196. visible={this.state.visible}
  197. onCancel={this.handleCancel}
  198. width='800px'
  199. footer='' >
  200. <Spin spinning={this.state.loading} className='spin-box'>
  201. <PatentAddFrom
  202. spinState={this.spinChange}
  203. visible={this.state.visible}
  204. closeModal={this.handleCancel}
  205. okClick={() => { this.props.closeAdd(false, true) }} />
  206. </Spin>
  207. </Modal>
  208. </div>
  209. );
  210. },
  211. });
  212. export default PatentAdd;