create.jsx 3.1 KB

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