applyAdd.jsx 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261
  1. import React from 'react';
  2. import { Button, Input, Select, message, Modal, Checkbox, Radio, Spin } from 'antd';
  3. import { companySearch } from '../../../tools.js';
  4. import ajax from 'jquery/src/ajax/xhr.js';
  5. import $ from 'jquery/src/ajax';
  6. const ApplyAdd = React.createClass({
  7. getInitialState() {
  8. return {
  9. visible: false,
  10. loading: false
  11. };
  12. },
  13. getContactsList(theUid) {
  14. $.ajax({
  15. method: "get",
  16. dataType: "json",
  17. crossDomain: false,
  18. url: globalConfig.context + "/api/admin/customer/findAllContacts",
  19. data: { "uid": theUid },
  20. success: function (data) {
  21. let theOption = [];
  22. if (data.error.length || !data.data) {
  23. return;
  24. };
  25. for (let item in data.data) {
  26. let theData = data.data[item];
  27. theOption.push(
  28. <Select.Option value={item} key={item.name}>{theData.name}</Select.Option>
  29. );
  30. };
  31. this.setState({
  32. contactsOption: theOption
  33. });
  34. }.bind(this),
  35. });
  36. },
  37. getDepartmentList(id) {
  38. $.ajax({
  39. method: "get",
  40. dataType: "json",
  41. crossDomain: false,
  42. url: globalConfig.context + "/api/admin/techproject/getDepartment",
  43. data: { "uid": id || this.props.data.uid },
  44. success: function (data) {
  45. let theOption = [];
  46. if (!data.data) {
  47. if (data.error && data.error.length) {
  48. message.warning(data.error[0].message);
  49. };
  50. return;
  51. };
  52. for (let item in data.data) {
  53. let theData = data.data[item];
  54. theOption.push(
  55. <Select.Option value={item} key={item}>{theData}</Select.Option>
  56. );
  57. };
  58. this.setState({
  59. departmentOption: theOption,
  60. });
  61. }.bind(this),
  62. });
  63. },
  64. componentWillReceiveProps(nextProps) {
  65. this.state.visible = nextProps.showAdd
  66. },
  67. showModal() {
  68. this.setState({
  69. visible: true,
  70. });
  71. },
  72. handleOk() {
  73. this.setState({
  74. loading: true
  75. });
  76. if (!this.state.uid) {
  77. message.warning('请选择公司!');
  78. this.setState({
  79. loading: false
  80. });
  81. return;
  82. }
  83. if (!this.state.contacts) {
  84. message.warning('请选择一个联系人!');
  85. this.setState({
  86. loading: false
  87. });
  88. return;
  89. };
  90. if (!this.state.salesman) {
  91. message.warning('请选择一个营销员!');
  92. this.setState({
  93. loading: false
  94. });
  95. return;
  96. };
  97. $.ajax({
  98. method: "POST",
  99. dataType: "json",
  100. crossDomain: false,
  101. url: globalConfig.context + "/api/admin/techproject/applyTechProject",
  102. data: {
  103. uid: this.state.uid,
  104. contacts: this.state.contacts,
  105. department: this.state.department,
  106. dispatchInfo: this.state.dispatchInfo,
  107. projectName: this.state.projectName,
  108. projectCatagory: this.state.projectCatagory,
  109. techField: this.state.techField,
  110. projectDes: this.state.projectDes,
  111. projectMode: this.state.projectMode,
  112. projectApproval: this.state.projectApproval,
  113. subsidy: this.state.subsidy,
  114. consultant: this.state.consultant,
  115. salesman: this.state.salesman
  116. }
  117. }).done(function (data) {
  118. if (!data.error.length) {
  119. message.success('保存成功!');
  120. this.setState({
  121. visible: false
  122. });
  123. this.props.closeAdd(false);
  124. } else {
  125. message.warning(data.error[0].message);
  126. this.setState({
  127. loading: false
  128. });
  129. }
  130. }.bind(this));
  131. },
  132. handleCancel(e) {
  133. this.setState({
  134. visible: false,
  135. });
  136. this.props.closeAdd(false);
  137. },
  138. spinChange(e) {
  139. this.setState({
  140. loading: e
  141. });
  142. },
  143. subsidyCheck(e) {
  144. if (e.target.value == 1) {
  145. this.state.subsidy = 1;
  146. } else if (e.target.value == 2) {
  147. this.state.projectMode = 1;
  148. };
  149. this.setState({
  150. moneyType: e.target.value
  151. });
  152. },
  153. render() {
  154. return (
  155. <div className="cognizance-add">
  156. <Modal maskClosable={false} title="新科技项目申请" visible={this.state.visible}
  157. onOk={this.handleOk} onCancel={this.handleCancel}
  158. width='800px'
  159. footer={[
  160. <Button key="submit" type="primary" loading={this.state.loading} onClick={this.handleOk}>
  161. 确认
  162. </Button>,
  163. <Button key="back" onClick={this.handleCancel}>
  164. 取消
  165. </Button>,
  166. ]} >
  167. <Spin spinning={this.state.loading} className='spin-box'>
  168. <div className="clearfix" style={{ marginBottom: '10px' }}>
  169. <div className="half-item">
  170. <span className="item-title">选择公司: </span>
  171. <Select
  172. placeholder="请选择公司"
  173. style={{ width: 260 }}
  174. showSearch
  175. filterOption={companySearch}
  176. onSelect={(e, n) => { this.state.uid = e; this.getContactsList(e); this.getDepartmentList(e); }}>
  177. {this.props.companyAddOption}
  178. </Select>
  179. </div>
  180. <div className="half-item">
  181. <span className="item-title">选择联系人: </span>
  182. <Select placeholder="请选择联系人" style={{ width: 200 }}
  183. onSelect={(e, n) => { this.state.contacts = e }}>
  184. {this.state.contactsOption}
  185. </Select>
  186. </div>
  187. </div>
  188. <div className="clearfix">
  189. <div className="half-item">
  190. <span className="item-title">申报科技部门: </span>
  191. <Select
  192. placeholder="请填写申报部门"
  193. style={{ width: 260 }}
  194. onChange={(e) => { this.state.department = e; }}>
  195. {this.state.departmentOption}
  196. </Select>
  197. </div>
  198. </div>
  199. <div className="clearfix">
  200. <div>
  201. <span className="item-title">派单信息: </span>
  202. </div>
  203. <Input type="textarea" rows={6} onChange={(e) => { this.state.dispatchInfo = e.target.value; }} />
  204. </div>
  205. <div className="clearfix">
  206. <div className="half-item">
  207. <span className="item-title">项目名称: </span>
  208. <Input style={{ width: 200 }} onChange={(e) => { this.state.projectName = e.target.value; }} />
  209. </div>
  210. </div>
  211. <div className="clearfix">
  212. <div className="half-item">
  213. <span className="item-title">项目类型: </span>
  214. <Input style={{ width: 200 }} onChange={(e) => { this.state.projectCatagory = e.target.value; }} />
  215. </div>
  216. </div>
  217. <div className="clearfix">
  218. <div className="half-item">
  219. <span className="item-title">技术领域: </span>
  220. <Input style={{ width: 200 }} onChange={(e) => { this.state.techField = e.target.value; }} />
  221. </div>
  222. </div>
  223. <div className="clearfix">
  224. <div>
  225. <span className="item-title">项目介绍: </span>
  226. </div>
  227. <Input type="textarea" rows={6} onChange={(e) => { this.state.projectDes = e.target.value; }} />
  228. </div>
  229. <div className="clearfix">
  230. <div className="half-item">
  231. <span className="item-title">立项/后补助: </span>
  232. <Radio.Group onChange={this.subsidyCheck}>
  233. <Radio value={1}>立项</Radio>
  234. <Radio value={2}>后补助</Radio>
  235. </Radio.Group>
  236. </div>
  237. <div className="half-item">
  238. <span className="item-title">金额: </span>
  239. <Input style={{ width: 200 }} onChange={(e) => { this.state.projectApproval = e.target.value; }} />
  240. <span>万元</span>
  241. </div>
  242. <div className="half-item">
  243. <span className="item-title">营销员: </span>
  244. <Select
  245. placeholder="请填写营销员"
  246. style={{ width: 260 }}
  247. onChange={(e) => { this.state.salesman = e; }}>
  248. {this.props.salesmanOption}
  249. </Select>
  250. </div>
  251. </div>
  252. </Spin>
  253. </Modal>
  254. </div>
  255. );
  256. }
  257. });
  258. export default ApplyAdd;