ProgressPage.vue 2.6 KB

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