create.jsx 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128
  1. import React from 'react';
  2. import { Icon, message, Button, Checkbox } from 'antd';
  3. import './create.less';
  4. import ajax from 'jquery/src/ajax/xhr.js'
  5. import $ from 'jquery/src/ajax';
  6. import Steps from './steps';
  7. import SpinContainer from "../../SpinContainer";
  8. const CreateEvaluate = React.createClass({
  9. getInitialState() {
  10. return {
  11. title: '',
  12. id: '',
  13. checked: false,
  14. loading: false,
  15. announce: ''
  16. };
  17. },
  18. theLoad(){
  19. this.setState({
  20. loading: true
  21. })
  22. $.ajax({
  23. url: globalConfig.context + '/open/html/get/evaluation_announcement'
  24. }).done(function (res) {
  25. if (res) {
  26. this.setState({
  27. loading: true,
  28. announce: res
  29. })
  30. }
  31. }.bind(this)).always(function () {
  32. this.setState({
  33. loading: false
  34. })
  35. }.bind(this));
  36. },
  37. returnList() {
  38. if (this.props.handlekey) {
  39. this.props.handlekey('evaluate');
  40. }
  41. },
  42. announce() {
  43. return {
  44. __html: this.state.announce
  45. }
  46. },
  47. agree() {
  48. $.ajax({
  49. url: globalConfig.context + '/api/user/evaluate/create'
  50. }).done(function (res) {
  51. if (res && res.data) {
  52. this.setState({
  53. loading: true,
  54. id: res.data
  55. })
  56. }
  57. }.bind(this)).always(function () {
  58. this.setState({
  59. loading: false
  60. })
  61. }.bind(this));
  62. },
  63. onChanged(e) {
  64. this.setState({
  65. checked: e.target.checked
  66. });
  67. },
  68. titleChanged(title) {
  69. this.setState({
  70. title: title
  71. });
  72. },
  73. componentWillMount() {
  74. if (this.props.data.id) {
  75. this.state.id = this.props.data.id;
  76. } else {
  77. this.state.id='';
  78. this.state.title='';
  79. this.theLoad();
  80. }
  81. },
  82. componentWillReceiveProps(nextProps) {
  83. if (!this.props.visible && nextProps.visible) {
  84. if (nextProps.data.id) {
  85. this.state.id = nextProps.data.id;
  86. } else {
  87. this.setState({id:'',title:''});
  88. this.theLoad();
  89. };
  90. };
  91. },
  92. renderBody() {
  93. if (this.state.id) {
  94. return <Steps id={this.state.id} title={this.titleChanged} visible={this.props.visible} />
  95. } else {
  96. return <div>
  97. <div className="announce-head">
  98. 本系统使用说明
  99. <p>使用本系统之前,请您务必仔细阅读并透彻理解本声明。当您使用本系统,将视为您认可本声明内容。</p>
  100. </div>
  101. <div className="announce-body" dangerouslySetInnerHTML={this.announce()} />
  102. <div className="announce-foot">
  103. <Checkbox checked={this.state.checked} onChange={this.onChanged}>我同意以上声明</Checkbox>
  104. <Button type="primary" onClick={this.agree} disabled={!this.state.checked}>继续</Button>
  105. </div>
  106. </div>
  107. }
  108. },
  109. render() {
  110. return (
  111. <SpinContainer spinning={this.state.loading}>
  112. <div className="content-container">
  113. <div className="content-title">
  114. 科技评估 {this.state.title ? '- ' + this.state.title : ''}
  115. </div>
  116. <div className="content-body">
  117. {this.renderBody()}
  118. </div>
  119. </div>
  120. </SpinContainer>
  121. )
  122. },
  123. });
  124. export default CreateEvaluate;