ProgressPage.vue 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100
  1. <template>
  2. <div v-show="visible" class="column justify-center items-center z-max" style="background-color: rgba(0, 0, 0, 0.8)">
  3. <div class="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. <div>
  18. <span class="text-yellow">{{ text }}</span>
  19. <q-icon :style="iconStyle" color="yellow" name="la la-slash" size="20px"/>
  20. </div>
  21. </div>
  22. </div>
  23. </template>
  24. <script>
  25. //-----------------------------------------------------------------------------
  26. import Vue from 'vue';
  27. import Component from 'vue-class-component';
  28. import * as utils from '../../../share/utils';
  29. const ruMessage = {
  30. 'start': ' ',
  31. 'finish': ' ',
  32. 'error': ' ',
  33. 'queue': 'очередь',
  34. 'download': 'скачивание',
  35. 'decompress': 'распаковка',
  36. 'convert': 'конвертирование',
  37. 'loading': 'загрузка',
  38. 'parse': 'обработка',
  39. 'upload': 'отправка',
  40. };
  41. export default @Component({
  42. })
  43. class ProgressPage extends Vue {
  44. text = '';
  45. totalSteps = 1;
  46. step = 1;
  47. progress = 0;
  48. visible = false;
  49. iconStyle = '';
  50. show() {
  51. this.text = '';
  52. this.totalSteps = 1;
  53. this.step = 1;
  54. this.progress = 0;
  55. this.iconAngle = 0;
  56. this.ani = false;
  57. this.visible = true;
  58. }
  59. hide() {
  60. this.visible = false;
  61. this.text = '';
  62. this.iconAngle = 0;
  63. }
  64. setState(state) {
  65. if (state.state) {
  66. if (state.state == 'queue') {
  67. this.text = (state.place ? 'Номер в очереди: ' + state.place : '');
  68. } else {
  69. this.text = (ruMessage[state.state] ? ruMessage[state.state] : state.state);
  70. }
  71. }
  72. this.step = (state.step ? state.step : this.step);
  73. this.totalSteps = (state.totalSteps > this.totalSteps ? state.totalSteps : this.totalSteps);
  74. this.progress = state.progress || 0;
  75. if (!this.ani) {
  76. (async() => {
  77. this.ani = true;
  78. this.iconAngle += 30;
  79. this.iconStyle = `transform: rotate(${this.iconAngle}deg); transition: 150ms linear`;
  80. await utils.sleep(150);
  81. this.ani = false;
  82. })();
  83. }
  84. }
  85. get percentage() {
  86. return Math.round(((this.step - 1)/this.totalSteps + this.progress/(100*this.totalSteps))*100);
  87. }
  88. }
  89. //-----------------------------------------------------------------------------
  90. </script>