applyAdd.jsx 10 KB

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