create.jsx 2.8 KB

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