ProgressPage.vue 2.3 KB

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