progressSelect.jsx 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  1. import React, { Component } from "react";
  2. import {
  3. message,
  4. Button,
  5. } from "antd";
  6. import $ from "jquery/src/ajax";
  7. import ReactDOM from 'react-dom';
  8. import ProgressDetail from './progressDetail';
  9. import './progress.less';
  10. import Print from './progress/index'
  11. class MyComponent extends Component {
  12. constructor(props) {
  13. super(props);
  14. this.state = {
  15. data: {},
  16. options: {
  17. noPrint: '.no-print',
  18. type: 'window',
  19. },
  20. }
  21. this.onSelect = this.onSelect.bind(this);
  22. }
  23. onSelect() {
  24. this.setState({
  25. loading: true,
  26. })
  27. $.ajax({
  28. method: 'get',
  29. dataType: 'json',
  30. crossDomain: false,
  31. url: globalConfig.context + '/api/admin/taskDetails/logDetails',
  32. data: {
  33. id: this.props.id,
  34. },
  35. success: function (data) {
  36. if (data.error && data.error.length) {
  37. message.warning(data.error[0].message)
  38. } else {
  39. let obj = data.data
  40. this.setState({
  41. data: obj,
  42. }, () => {
  43. Print(this.printTemp)
  44. })
  45. }
  46. }.bind(this),
  47. }).always(
  48. function () {
  49. this.setState({
  50. loading: false,
  51. })
  52. }.bind(this)
  53. )
  54. }
  55. render() {
  56. return (
  57. <div>
  58. <Button type="primary"
  59. onClick={this.onSelect}
  60. >查看</Button>
  61. <div
  62. style={{ display: 'none' }}
  63. >
  64. <div
  65. ref={ref => {
  66. this.printTemp = ref;
  67. }}
  68. >
  69. <ProgressDetail data={this.state.data} />
  70. </div>
  71. </div>
  72. </div>
  73. );
  74. }
  75. }
  76. export default MyComponent;