ProgressPage.vue 2.2 KB

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