ProgressPage.vue 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  1. <template>
  2. <div v-show="visible" class="main">
  3. <div class="center">
  4. <el-progress type="circle" :width="100" :stroke-width="5" color="green" :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. 'fninish': '',
  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. this.visible = false;
  41. }
  42. setState(state) {
  43. this.text = (ruMessage[state.state] ? ruMessage[state.state] : state.state);
  44. this.step = (state.step ? state.step : this.step);
  45. this.totalSteps = (state.totalSteps > this.totalSteps ? state.totalSteps : this.totalSteps);
  46. this.progress = (state.progress ? state.progress : this.progress);
  47. }
  48. get percentage() {
  49. return Math.round(((this.step - 1)/this.totalSteps + this.progress/(100*this.totalSteps))*100);
  50. }
  51. }
  52. //-----------------------------------------------------------------------------
  53. </script>
  54. <style scoped>
  55. .main {
  56. display: flex;
  57. flex-direction: column;
  58. justify-content: center;
  59. align-items: center;
  60. z-index: 100;
  61. background-color: rgba(0, 0, 0, 0.8);
  62. position: absolute;
  63. }
  64. .center {
  65. display: flex;
  66. flex-direction: column;
  67. justify-content: flex-start;
  68. align-items: center;
  69. color: white;
  70. height: 300px;
  71. }
  72. .text {
  73. color: yellow;
  74. }
  75. </style>
  76. <style>
  77. .el-progress__text {
  78. color: lightgreen;
  79. }
  80. </style>