technologyAdd.jsx 7.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182
  1. import React from 'react';
  2. import { Button, Input, Select, message, Modal, 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. componentWillReceiveProps(nextProps) {
  14. this.state.visible = nextProps.showAdd;
  15. },
  16. showModal() {
  17. this.setState({
  18. visible: true,
  19. });
  20. },
  21. handleOk() {
  22. this.setState({
  23. loading: true
  24. });
  25. if (!this.state.contacts) {
  26. message.warning('请选择一个联系人!');
  27. this.setState({
  28. loading: false
  29. });
  30. return;
  31. };
  32. $.ajax({
  33. method: "POST",
  34. dataType: "json",
  35. crossDomain: false,
  36. url: globalConfig.context + "/api/user/techproject/applyTechProject",
  37. data: {
  38. contacts: this.state.contacts,
  39. department: this.state.department,
  40. dispatchInfo: this.state.dispatchInfo,
  41. projectName: this.state.projectName,
  42. projectCatagory: this.state.projectCatagory,
  43. techField: this.state.techField,
  44. projectDes: this.state.projectDes,
  45. projectMode: this.state.projectMode,
  46. projectApproval: this.state.projectApproval,
  47. subsidy: this.state.subsidy,
  48. consultant: this.state.consultant,
  49. }
  50. }).done(function (data) {
  51. if (!data.error.length) {
  52. message.success('保存成功!');
  53. this.setState({
  54. visible: false
  55. });
  56. this.props.closeAdd(false);
  57. } else {
  58. message.warning(data.error[0].message);
  59. this.setState({
  60. loading: false
  61. });
  62. }
  63. }.bind(this));
  64. },
  65. handleCancel(e) {
  66. this.setState({
  67. visible: false,
  68. });
  69. this.props.closeAdd(false);
  70. },
  71. spinChange(e) {
  72. this.setState({
  73. loading: e
  74. });
  75. },
  76. subsidyCheck(e) {
  77. if (e.target.value == 1) {
  78. this.state.subsidy = 1;
  79. } else if (e.target.value == 2) {
  80. this.state.projectMode = 1;
  81. };
  82. this.setState({
  83. moneyType: e.target.value
  84. });
  85. },
  86. render() {
  87. return (
  88. <div className="cognizance-add">
  89. <Modal maskClosable={false} title="新科技项目申请" visible={this.state.visible}
  90. onOk={this.handleOk} onCancel={this.handleCancel}
  91. width='800px'
  92. footer={[
  93. <Button key="submit" type="primary" loading={this.state.loading} onClick={this.handleOk}>
  94. 确认
  95. </Button>,
  96. <Button key="back" onClick={this.handleCancel}>
  97. 取消
  98. </Button>,
  99. ]}
  100. >
  101. <div className="clearfix" style={{ marginBottom: '10px' }}>
  102. <div className="half-item">
  103. <span className="item-title">选择联系人: </span>
  104. <Select placeholder="请选择联系人" style={{ width: 200 }}
  105. onSelect={(e, n) => { this.state.contacts = e }}>
  106. {this.props.contactsOption}
  107. </Select>
  108. </div>
  109. </div>
  110. <div className="clearfix">
  111. <div className="half-item">
  112. <span className="item-title">申报科技部门: </span>
  113. <Select placeholder="请选择申报部门" style={{ width: 300 }}
  114. notFoundContent="未获取到申报部门列表"
  115. showSearch
  116. filterOption={companySearch}
  117. onSelect={(e, n) => { this.state.department = e }}>
  118. {this.props.departmentOption}
  119. </Select>
  120. </div>
  121. </div>
  122. <div className="clearfix">
  123. <div>
  124. <span className="item-title">派单信息: </span>
  125. </div>
  126. <Input type="textarea" rows={6} onChange={(e) => { this.state.dispatchInfo = e.target.value; }} />
  127. </div>
  128. <div className="clearfix">
  129. <div className="half-item">
  130. <span className="item-title">项目名称: </span>
  131. <Input style={{ width: 200 }} onChange={(e) => { this.state.projectName = e.target.value; }} />
  132. </div>
  133. </div>
  134. <div className="clearfix">
  135. <div className="half-item">
  136. <span className="item-title">项目类型: </span>
  137. <Input style={{ width: 200 }} onChange={(e) => { this.state.projectCatagory = e.target.value; }} />
  138. </div>
  139. </div>
  140. <div className="clearfix">
  141. <div className="half-item">
  142. <span className="item-title">技术领域: </span>
  143. <Input style={{ width: 200 }} onChange={(e) => { this.state.techField = e.target.value; }} />
  144. </div>
  145. </div>
  146. <div className="clearfix">
  147. <div>
  148. <span className="item-title">项目介绍: </span>
  149. </div>
  150. <Input type="textarea" rows={6} onChange={(e) => { this.state.projectDes = e.target.value; }} />
  151. </div>
  152. <div className="clearfix">
  153. <div className="half-item">
  154. <span className="item-title">立项/后补助: </span>
  155. <Radio.Group onChange={this.subsidyCheck}>
  156. <Radio value={1}>立项</Radio>
  157. <Radio value={2}>后补助</Radio>
  158. </Radio.Group>
  159. </div>
  160. <div className="half-item">
  161. <span className="item-title">金额: </span>
  162. <Input style={{ width: 200 }} onChange={(e) => { this.state.projectApproval = e.target.value; }} />
  163. </div>
  164. </div>
  165. <div className="clearfix">
  166. <div className="half-item">
  167. <span className="item-title">选择负责人: </span>
  168. <Select placeholder="请选择负责人" style={{ width: 200 }}
  169. onSelect={(e, n) => { this.state.consultant = e }}>
  170. {this.props.authorOption}
  171. </Select>
  172. </div>
  173. </div>
  174. </Modal>
  175. </div>
  176. );
  177. }
  178. });
  179. export default ApplyAdd;