ProgressPage.vue 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
  1. <template>
  2. <div v-show="visible" class="main">
  3. <div class="center">
  4. <el-progress type="circle" :width="100" :stroke-width="6" color="#0F9900" :percentage="percentage"></el-progress>
  5. <p class="text">{{ text }}</p>
  6. </div>
  7. </div>
  8. </template>
  9. <script>
  10. //-----------------------------------------------------------------------------
  11. import Vue from 'vue';
  12. import Component from 'vue-class-component';
  13. const ruMessage = {
  14. 'start': ' ',
  15. 'finish': ' ',
  16. 'error': ' ',
  17. 'download': 'скачивание',
  18. 'decompress': 'распаковка',
  19. 'convert': 'конвертирование',
  20. 'loading': 'загрузка',
  21. 'parse': 'обработка',
  22. 'upload': 'отправка',
  23. };
  24. export default @Component({
  25. })
  26. class ProgressPage extends Vue {
  27. text = '';
  28. totalSteps = 1;
  29. step = 1;
  30. progress = 0;
  31. visible = false;
  32. show() {
  33. this.$el.style.width = this.$parent.$el.offsetWidth + 'px';
  34. this.$el.style.height = this.$parent.$el.offsetHeight + 'px';
  35. this.text = '';
  36. this.totalSteps = 1;
  37. this.step = 1;
  38. this.progress = 0;
  39. this.visible = true;
  40. }
  41. hide() {
  42. this.visible = false;
  43. }
  44. setState(state) {
  45. if (state.state)
  46. this.text = (ruMessage[state.state] ? ruMessage[state.state] : state.state);
  47. this.step = (state.step ? state.step : this.step);
  48. this.totalSteps = (state.totalSteps > this.totalSteps ? state.totalSteps : this.totalSteps);
  49. this.progress = state.progress || 0;
  50. }
  51. get percentage() {
  52. let circle = document.querySelector('path[class="el-progress-circle__path"]');
  53. if (circle)
  54. circle.style.transition = '';
  55. return Math.round(((this.step - 1)/this.totalSteps + this.progress/(100*this.totalSteps))*100);
  56. }
  57. }
  58. //-----------------------------------------------------------------------------
  59. </script>
  60. <style scoped>
  61. .main {
  62. display: flex;
  63. flex-direction: column;
  64. justify-content: center;
  65. align-items: center;
  66. z-index: 100;
  67. background-color: rgba(0, 0, 0, 0.8);
  68. position: absolute;
  69. }
  70. .center {
  71. display: flex;
  72. flex-direction: column;
  73. justify-content: flex-start;
  74. align-items: center;
  75. color: white;
  76. height: 300px;
  77. }
  78. .text {
  79. color: yellow;
  80. }
  81. </style>
  82. <style>
  83. .el-progress__text {
  84. color: lightgreen !important;
  85. }
  86. </style>