ProgressPage.vue 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  1. <template>
  2. <div v-show="visible" class="flex column justify-center items-center z-max" style="background-color: rgba(0, 0, 0, 0.8)">
  3. <div class="flex column justify-start items-center" style="height: 250px">
  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-yellow">{{ 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. 'queue': 'очередь',
  30. 'download': 'скачивание',
  31. 'decompress': 'распаковка',
  32. 'convert': 'конвертирование',
  33. 'loading': 'загрузка',
  34. 'parse': 'обработка',
  35. 'upload': 'отправка',
  36. };
  37. export default @Component({
  38. })
  39. class ProgressPage extends Vue {
  40. text = '';
  41. totalSteps = 1;
  42. step = 1;
  43. progress = 0;
  44. visible = false;
  45. show() {
  46. this.$el.style.width = this.$parent.$el.offsetWidth + 'px';
  47. this.$el.style.height = this.$parent.$el.offsetHeight + 'px';
  48. this.text = '';
  49. this.totalSteps = 1;
  50. this.step = 1;
  51. this.progress = 0;
  52. this.visible = true;
  53. }
  54. hide() {
  55. this.visible = false;
  56. this.text = '';
  57. }
  58. setState(state) {
  59. if (state.state) {
  60. if (state.state == 'queue') {
  61. this.text = (state.place ? 'Номер в очереди: ' + state.place : '');
  62. } else {
  63. this.text = (ruMessage[state.state] ? ruMessage[state.state] : state.state);
  64. }
  65. }
  66. this.step = (state.step ? state.step : this.step);
  67. this.totalSteps = (state.totalSteps > this.totalSteps ? state.totalSteps : this.totalSteps);
  68. this.progress = state.progress || 0;
  69. }
  70. get percentage() {
  71. return Math.round(((this.step - 1)/this.totalSteps + this.progress/(100*this.totalSteps))*100);
  72. }
  73. }
  74. //-----------------------------------------------------------------------------
  75. </script>