applyAdd.jsx 9.0 KB

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