technologyAdd.jsx 9.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235
  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() {
  14. $.ajax({
  15. method: "post",
  16. dataType: "json",
  17. crossDomain: false,
  18. url: globalConfig.context + "/api/user/getContacts",
  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: "post",
  37. dataType: "json",
  38. crossDomain: false,
  39. url: globalConfig.context + "/api/user/getDepartment",
  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. this.getContactsList();
  60. },
  61. showModal() {
  62. this.setState({
  63. visible: true,
  64. });
  65. },
  66. handleOk() {
  67. this.setState({
  68. loading: true
  69. });
  70. if (!this.state.contacts) {
  71. message.warning('请选择一个联系人!');
  72. this.setState({
  73. loading: false
  74. });
  75. return;
  76. };
  77. $.ajax({
  78. method: "POST",
  79. dataType: "json",
  80. crossDomain: false,
  81. url: globalConfig.context + "/api/techproject/applyTechProject",
  82. data: {
  83. contacts: this.state.contacts,
  84. department: this.state.department,
  85. dispatchInfo: this.state.dispatchInfo,
  86. projectName: this.state.projectName,
  87. projectCatagory: this.state.projectCatagory,
  88. techField: this.state.techField,
  89. projectDes: this.state.projectDes,
  90. projectMode: this.state.projectMode,
  91. projectApproval: this.state.projectApproval,
  92. subsidy: this.state.subsidy,
  93. consultant: this.state.consultant,
  94. }
  95. }).done(function (data) {
  96. if (!data.error.length) {
  97. message.success('保存成功!');
  98. this.setState({
  99. visible: false
  100. });
  101. this.props.closeAdd(false);
  102. } else {
  103. message.warning(data.error[0].message);
  104. this.setState({
  105. loading: false
  106. });
  107. }
  108. }.bind(this));
  109. },
  110. handleCancel(e) {
  111. this.setState({
  112. visible: false,
  113. });
  114. this.props.closeAdd(false);
  115. },
  116. spinChange(e) {
  117. this.setState({
  118. loading: e
  119. });
  120. },
  121. projectEstablishmentCheck(e) {
  122. if (e.target.checked == true) {
  123. this.state.projectMode = 1;
  124. } else if (e.target.checked == false) {
  125. this.state.projectMode = 0;
  126. };
  127. },
  128. subsidyCheck(e) {
  129. if (e.target.checked == true) {
  130. this.state.subsidy = 1;
  131. } else if (e.target.checked == false) {
  132. this.state.subsidy = 0;
  133. };
  134. },
  135. render() {
  136. return (
  137. <div className="cognizance-add">
  138. <Modal title="新科技项目申请" visible={this.state.visible}
  139. onOk={this.handleOk} onCancel={this.handleCancel}
  140. width='800px'
  141. footer={[
  142. <Button key="submit" type="primary" loading={this.state.loading} onClick={this.handleOk}>
  143. 确认
  144. </Button>,
  145. <Button key="back" onClick={this.handleCancel}>
  146. 取消
  147. </Button>,
  148. ]}
  149. >
  150. <div className="clearfix" style={{ marginBottom: '10px' }}>
  151. <div className="half-item">
  152. <span className="item-title">选择联系人: </span>
  153. <Select placeholder="请选择联系人" style={{ width: 200 }}
  154. onSelect={(e, n) => { this.state.contacts = e }}>
  155. {this.state.contactsOption}
  156. </Select>
  157. </div>
  158. </div>
  159. <div className="clearfix">
  160. <div className="half-item">
  161. <span className="item-title">选择申报科技部门: </span>
  162. <Select
  163. placeholder="请选择申报部门"
  164. style={{ width: 200 }}
  165. onSelect={(e, n) => { this.state.department = e; }}>
  166. {this.state.departmentOption}
  167. </Select>
  168. </div>
  169. </div>
  170. <div className="clearfix">
  171. <div>
  172. <span className="item-title">派单信息: </span>
  173. </div>
  174. <Input type="textarea" rows={6} onChange={(e) => { this.state.dispatchInfo = e.target.value; }} />
  175. </div>
  176. <div className="clearfix">
  177. <div className="half-item">
  178. <span className="item-title">项目名称: </span>
  179. <Input style={{ width: 200 }} onChange={(e) => { this.state.projectName = e.target.value; }} />
  180. </div>
  181. </div>
  182. <div className="clearfix">
  183. <div className="half-item">
  184. <span className="item-title">项目类型: </span>
  185. <Input style={{ width: 200 }} onChange={(e) => { this.state.projectCatagory = e.target.value; }} />
  186. </div>
  187. </div>
  188. <div className="clearfix">
  189. <div className="half-item">
  190. <span className="item-title">技术领域: </span>
  191. <Input style={{ width: 200 }} onChange={(e) => { this.state.techField = e.target.value; }} />
  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.projectDes = e.target.value; }} />
  199. </div>
  200. <div className="clearfix">
  201. <div className="half-item">
  202. <span className="item-title">是否立项: </span>
  203. <Checkbox onChange={this.projectEstablishmentCheck}></Checkbox>
  204. </div>
  205. <div className="half-item">
  206. <span className="item-title">立项金额: </span>
  207. <Input style={{ width: 200 }} onChange={(e) => { this.state.projectApproval = e.target.value; }} />
  208. </div>
  209. </div>
  210. <div className="clearfix">
  211. <div className="half-item">
  212. <span className="item-title">是否后补助: </span>
  213. <Checkbox onChange={this.subsidyCheck}></Checkbox>
  214. </div>
  215. </div>
  216. <div className="clearfix">
  217. <div className="half-item">
  218. <span className="item-title">选择咨询师: </span>
  219. <Select placeholder="请选择咨询师" style={{ width: 200 }}
  220. onSelect={(e, n) => { this.state.consultant = e }}>
  221. {this.props.authorOption}
  222. </Select>
  223. </div>
  224. </div>
  225. </Modal>
  226. </div>
  227. );
  228. }
  229. });
  230. export default ApplyAdd;