create.jsx 2.9 KB

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