applyAdd.jsx 10 KB

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