technologyAdd.jsx 7.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184
  1. import React from 'react';
  2. import { Button, Input, Select, message, Modal, Radio, Spin } 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. <Spin spinning={this.state.loading} className='spin-box'>
  102. <div className="clearfix" style={{ marginBottom: '10px' }}>
  103. <div className="half-item">
  104. <span className="item-title">选择联系人: </span>
  105. <Select placeholder="请选择联系人" style={{ width: 200 }}
  106. onSelect={(e, n) => { this.state.contacts = e }}>
  107. {this.props.contactsOption}
  108. </Select>
  109. </div>
  110. </div>
  111. <div className="clearfix">
  112. <div className="half-item">
  113. <span className="item-title">申报科技部门: </span>
  114. <Select placeholder="请选择申报部门" style={{ width: 300 }}
  115. notFoundContent="未获取到申报部门列表"
  116. showSearch
  117. filterOption={companySearch}
  118. onSelect={(e, n) => { this.state.department = e }}>
  119. {this.props.departmentOption}
  120. </Select>
  121. </div>
  122. </div>
  123. <div className="clearfix">
  124. <div>
  125. <span className="item-title">派单信息: </span>
  126. </div>
  127. <Input type="textarea" rows={6} onChange={(e) => { this.state.dispatchInfo = e.target.value; }} />
  128. </div>
  129. <div className="clearfix">
  130. <div className="half-item">
  131. <span className="item-title">项目名称: </span>
  132. <Input style={{ width: 200 }} onChange={(e) => { this.state.projectName = e.target.value; }} />
  133. </div>
  134. </div>
  135. <div className="clearfix">
  136. <div className="half-item">
  137. <span className="item-title">项目类型: </span>
  138. <Input style={{ width: 200 }} onChange={(e) => { this.state.projectCatagory = e.target.value; }} />
  139. </div>
  140. </div>
  141. <div className="clearfix">
  142. <div className="half-item">
  143. <span className="item-title">技术领域: </span>
  144. <Input style={{ width: 200 }} onChange={(e) => { this.state.techField = e.target.value; }} />
  145. </div>
  146. </div>
  147. <div className="clearfix">
  148. <div>
  149. <span className="item-title">项目介绍: </span>
  150. </div>
  151. <Input type="textarea" rows={6} onChange={(e) => { this.state.projectDes = e.target.value; }} />
  152. </div>
  153. <div className="clearfix">
  154. <div className="half-item">
  155. <span className="item-title">立项/后补助: </span>
  156. <Radio.Group onChange={this.subsidyCheck}>
  157. <Radio value={1}>立项</Radio>
  158. <Radio value={2}>后补助</Radio>
  159. </Radio.Group>
  160. </div>
  161. <div className="half-item">
  162. <span className="item-title">金额: </span>
  163. <Input style={{ width: 200 }} onChange={(e) => { this.state.projectApproval = e.target.value; }} />
  164. </div>
  165. </div>
  166. <div className="clearfix">
  167. <div className="half-item">
  168. <span className="item-title">选择负责人: </span>
  169. <Select placeholder="请选择负责人" style={{ width: 200 }}
  170. onSelect={(e, n) => { this.state.consultant = e }}>
  171. {this.props.authorOption}
  172. </Select>
  173. </div>
  174. </div>
  175. </Spin>
  176. </Modal>
  177. </div>
  178. );
  179. }
  180. });
  181. export default ApplyAdd;