ProgressPage.vue 2.6 KB

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