technologyAdd.jsx 7.3 KB

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