comPatentAdd.jsx 9.4 KB

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