applyAdd.jsx 8.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224
  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. yearOption: []
  12. };
  13. },
  14. getContactsList(theUid) {
  15. $.ajax({
  16. method: "post",
  17. dataType: "json",
  18. crossDomain: false,
  19. url: globalConfig.context + "/api/admin/getContacts",
  20. data: {
  21. uid: theUid
  22. },
  23. success: function (data) {
  24. let theOption = [];
  25. if (data.error.length || !data.data) {
  26. return;
  27. };
  28. for (let item in data.data) {
  29. let theData = data.data[item];
  30. theOption.push(
  31. <Select.Option value={theData} key={theData}>{theData}</Select.Option>
  32. );
  33. };
  34. this.setState({
  35. contactsOption: theOption
  36. });
  37. }.bind(this),
  38. });
  39. },
  40. componentWillReceiveProps(nextProps) {
  41. this.state.visible = nextProps.showAdd
  42. },
  43. componentWillMount() {
  44. let d = new Date();
  45. let _me = this;
  46. d = d.getFullYear() - 1;
  47. this.state.thisYear = d;
  48. for (let i = d; i < d + 20; i++) {
  49. _me.state.yearOption.push(
  50. <Select.Option value={i.toString()} key={i}>{i}</Select.Option>
  51. )
  52. };
  53. },
  54. showModal() {
  55. this.setState({
  56. visible: true,
  57. });
  58. },
  59. handleOk() {
  60. this.setState({
  61. loading: true
  62. });
  63. if (!this.state.year) {
  64. message.warning('请选择年份!');
  65. this.setState({
  66. loading: false
  67. });
  68. return;
  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/admin/applyCognizance",
  82. data: {
  83. year: this.state.year,
  84. contacts: this.state.contacts,
  85. comment: this.state.comment,
  86. consultant: this.state.consultant,
  87. uid: this.state.uid,
  88. state: this.state.year == this.state.thisYear ? 0 : 7
  89. }
  90. }).done(function (data) {
  91. if (!data.error.length) {
  92. message.success('保存成功!');
  93. this.setState({
  94. visible: false
  95. });
  96. this.props.closeAdd(false);
  97. } else {
  98. message.warning(data.error[0].message);
  99. this.setState({
  100. loading: false
  101. });
  102. }
  103. }.bind(this));
  104. },
  105. handleCancel(e) {
  106. this.setState({
  107. visible: false,
  108. });
  109. this.props.closeAdd(false);
  110. },
  111. spinChange(e) {
  112. this.setState({
  113. loading: e
  114. });
  115. },
  116. render() {
  117. return (
  118. <div className="cognizance-add">
  119. <Modal title="新科技项目申请" visible={this.state.visible}
  120. onOk={this.handleOk} onCancel={this.handleCancel}
  121. width='800px'
  122. footer={[
  123. <Button key="submit" type="primary" loading={this.state.loading} onClick={this.handleOk}>
  124. 确认
  125. </Button>,
  126. <Button key="back" onClick={this.handleCancel}>
  127. 取消
  128. </Button>,
  129. ]}
  130. >
  131. <div className="clearfix" style={{ marginBottom: '10px' }}>
  132. <div className="half-item">
  133. <span className="item-title">选择公司: </span>
  134. <Select
  135. placeholder="请选择公司"
  136. style={{ width: 200 }}
  137. showSearch
  138. filterOption={companySearch}
  139. onSelect={(e, n) => { this.state.uid = e; this.getContactsList(e); }}>
  140. {this.props.companyOption}
  141. </Select>
  142. </div>
  143. <div className="half-item">
  144. <span className="item-title">选择联系人: </span>
  145. <Select placeholder="请选择联系人" style={{ width: 200 }}
  146. onSelect={(e, n) => { this.state.contacts = e }}>
  147. {this.state.contactsOption}
  148. </Select>
  149. </div>
  150. </div>
  151. <div className="clearfix">
  152. <div className="half-item">
  153. <span className="item-title">选择申报科技部门: </span>
  154. <Select placeholder="请选择年份" style={{ width: 200 }}
  155. onSelect={(e, n) => { this.state.year = e }}>
  156. {this.state.yearOption}
  157. </Select>
  158. </div>
  159. </div>
  160. <div className="clearfix">
  161. <div>
  162. <span className="item-title">派单信息: </span>
  163. </div>
  164. <Input type="textarea" rows={6} onChange={(e) => { this.state.comment = e.target.value; }} />
  165. </div>
  166. <div className="clearfix">
  167. <div className="half-item">
  168. <span className="item-title">项目名称: </span>
  169. <Input style={{ width: 200 }} />
  170. </div>
  171. </div>
  172. <div className="clearfix">
  173. <div className="half-item">
  174. <span className="item-title">项目类型: </span>
  175. <Input style={{ width: 200 }} />
  176. </div>
  177. </div>
  178. <div className="clearfix">
  179. <div className="half-item">
  180. <span className="item-title">技术领域: </span>
  181. <Input style={{ width: 200 }} />
  182. </div>
  183. </div>
  184. <div className="clearfix">
  185. <div>
  186. <span className="item-title">项目介绍: </span>
  187. </div>
  188. <Input type="textarea" rows={6} />
  189. </div>
  190. <div className="clearfix">
  191. <div className="half-item">
  192. <span className="item-title">是否立项: </span>
  193. <Checkbox ></Checkbox>
  194. </div>
  195. <div className="half-item">
  196. <span className="item-title">立项金额: </span>
  197. <Input style={{ width: 200 }} />
  198. </div>
  199. </div>
  200. <div className="clearfix">
  201. <div className="half-item">
  202. <span className="item-title">是否后补助: </span>
  203. <Checkbox onChange={this.subsidyCheck}></Checkbox>
  204. </div>
  205. </div>
  206. <div className="clearfix">
  207. <div className="half-item">
  208. <span className="item-title">选择咨询师: </span>
  209. <Select placeholder="请选择咨询师" style={{ width: 200 }}
  210. onSelect={(e, n) => { this.state.consultant = e }}>
  211. {this.props.authorOption}
  212. </Select>
  213. </div>
  214. </div>
  215. </Modal>
  216. </div>
  217. );
  218. }
  219. });
  220. export default ApplyAdd;