ProgressPage.vue 2.9 KB

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