technologyAdd.jsx 9.2 KB

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